From 80267c2e3f3ad15f1b37dc24b5beb5a09f120f1d Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Thu, 14 Dec 2017 14:45:01 -0500 Subject: [PATCH 01/21] refresh gapics with json-transport updates --- composer.json | 3 +- .../BigtableInstanceAdminGapicClient.php | 1127 +++++++++++------ .../Gapic/BigtableTableAdminGapicClient.php | 908 +++++++++---- ...bigtable_instance_admin_client_config.json | 45 + ...table_instance_admin_descriptor_config.php | 34 + ...able_instance_admin_rest_client_config.php | 191 +++ .../bigtable_table_admin_client_config.json | 35 + ...bigtable_table_admin_descriptor_config.php | 32 + ...igtable_table_admin_rest_client_config.php | 132 ++ src/Bigtable/V2/Gapic/BigtableGapicClient.php | 415 +++--- .../resources/bigtable_descriptor_config.php | 23 + .../resources/bigtable_rest_client_config.php | 67 + .../V2beta1/Gapic/DlpServiceGapicClient.php | 418 +++--- .../dlp_service_descriptor_config.php | 20 + .../dlp_service_rest_client_config.php | 55 + .../Gapic/ErrorGroupServiceGapicClient.php | 196 +-- .../Gapic/ErrorStatsServiceGapicClient.php | 260 ++-- .../Gapic/ReportErrorsServiceGapicClient.php | 172 +-- .../error_group_service_descriptor_config.php | 8 + ...error_group_service_rest_client_config.php | 28 + .../error_stats_service_descriptor_config.php | 28 + ...error_stats_service_rest_client_config.php | 35 + ...eport_errors_service_descriptor_config.php | 8 + ...port_errors_service_rest_client_config.php | 18 + .../V1beta1/Gapic/FirestoreGapicClient.php | 574 +++------ .../resources/firestore_descriptor_config.php | 48 + .../firestore_rest_client_config.php | 122 ++ .../Gapic/LanguageServiceGapicClient.php | 296 ++--- .../language_service_descriptor_config.php | 8 + .../language_service_rest_client_config.php | 38 + .../V2/Gapic/ConfigServiceV2GapicClient.php | 449 ++----- .../V2/Gapic/LoggingServiceV2GapicClient.php | 323 ++--- .../V2/Gapic/MetricsServiceV2GapicClient.php | 302 ++--- .../config_service_v2_descriptor_config.php | 28 + .../config_service_v2_rest_client_config.php | 102 ++ .../logging_service_v2_descriptor_config.php | 38 + .../logging_service_v2_rest_client_config.php | 40 + .../metrics_service_v2_descriptor_config.php | 18 + .../metrics_service_v2_rest_client_config.php | 55 + .../V3/Gapic/GroupServiceGapicClient.php | 349 ++--- .../V3/Gapic/MetricServiceGapicClient.php | 416 ++---- .../Gapic/UptimeCheckServiceGapicClient.php | 672 ++++++++++ .../V3/UptimeCheckServiceClient.php | 42 + .../group_service_descriptor_config.php | 28 + .../group_service_rest_client_config.php | 65 + .../metric_service_descriptor_config.php | 38 + .../metric_service_rest_client_config.php | 82 ++ .../uptime_check_service_client_config.json | 56 + ...uptime_check_service_descriptor_config.php | 28 + ...ptime_check_service_rest_client_config.php | 60 + src/PubSub/V1/Gapic/PublisherGapicClient.php | 453 ++----- src/PubSub/V1/Gapic/SubscriberGapicClient.php | 694 +++------- .../resources/publisher_descriptor_config.php | 28 + .../publisher_rest_client_config.php | 105 ++ .../subscriber_descriptor_config.php | 34 + .../subscriber_rest_client_config.php | 175 +++ .../V1/Gapic/DatabaseAdminGapicClient.php | 456 ++----- .../database_admin_descriptor_config.php | 30 + .../database_admin_rest_client_config.php | 94 ++ .../V1/Gapic/InstanceAdminGapicClient.php | 495 +++----- .../instance_admin_descriptor_config.php | 40 + .../instance_admin_rest_client_config.php | 104 ++ src/Spanner/V1/Gapic/SpannerGapicClient.php | 490 ++----- .../resources/spanner_descriptor_config.php | 28 + .../resources/spanner_rest_client_config.php | 115 ++ src/Speech/V1/Gapic/SpeechGapicClient.php | 272 ++-- .../V1/resources/speech_descriptor_config.php | 19 + .../resources/speech_rest_client_config.php | 18 + .../V1beta1/Gapic/SpeechGapicClient.php | 272 ++-- .../resources/speech_descriptor_config.php | 19 + .../resources/speech_rest_client_config.php | 18 + .../VideoIntelligenceServiceGapicClient.php | 209 ++- ...intelligence_service_descriptor_config.php | 14 + ...ntelligence_service_rest_client_config.php | 13 + .../VideoIntelligenceServiceGapicClient.php | 210 ++- ...intelligence_service_descriptor_config.php | 14 + ...ntelligence_service_rest_client_config.php | 13 + .../VideoIntelligenceServiceGapicClient.php | 210 ++- ...intelligence_service_descriptor_config.php | 14 + ...ntelligence_service_rest_client_config.php | 13 + .../V1/Gapic/ImageAnnotatorGapicClient.php | 158 +-- .../image_annotator_descriptor_config.php | 8 + .../image_annotator_rest_client_config.php | 13 + 83 files changed, 7236 insertions(+), 6147 deletions(-) create mode 100644 src/Bigtable/Admin/V2/resources/bigtable_instance_admin_descriptor_config.php create mode 100644 src/Bigtable/Admin/V2/resources/bigtable_instance_admin_rest_client_config.php create mode 100644 src/Bigtable/Admin/V2/resources/bigtable_table_admin_descriptor_config.php create mode 100644 src/Bigtable/Admin/V2/resources/bigtable_table_admin_rest_client_config.php create mode 100644 src/Bigtable/V2/resources/bigtable_descriptor_config.php create mode 100644 src/Bigtable/V2/resources/bigtable_rest_client_config.php create mode 100644 src/Dlp/V2beta1/resources/dlp_service_descriptor_config.php create mode 100644 src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php create mode 100644 src/ErrorReporting/V1beta1/resources/error_group_service_descriptor_config.php create mode 100644 src/ErrorReporting/V1beta1/resources/error_group_service_rest_client_config.php create mode 100644 src/ErrorReporting/V1beta1/resources/error_stats_service_descriptor_config.php create mode 100644 src/ErrorReporting/V1beta1/resources/error_stats_service_rest_client_config.php create mode 100644 src/ErrorReporting/V1beta1/resources/report_errors_service_descriptor_config.php create mode 100644 src/ErrorReporting/V1beta1/resources/report_errors_service_rest_client_config.php create mode 100644 src/Firestore/V1beta1/resources/firestore_descriptor_config.php create mode 100644 src/Firestore/V1beta1/resources/firestore_rest_client_config.php create mode 100644 src/Language/V1beta2/resources/language_service_descriptor_config.php create mode 100644 src/Language/V1beta2/resources/language_service_rest_client_config.php create mode 100644 src/Logging/V2/resources/config_service_v2_descriptor_config.php create mode 100644 src/Logging/V2/resources/config_service_v2_rest_client_config.php create mode 100644 src/Logging/V2/resources/logging_service_v2_descriptor_config.php create mode 100644 src/Logging/V2/resources/logging_service_v2_rest_client_config.php create mode 100644 src/Logging/V2/resources/metrics_service_v2_descriptor_config.php create mode 100644 src/Logging/V2/resources/metrics_service_v2_rest_client_config.php create mode 100644 src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php create mode 100644 src/Monitoring/V3/UptimeCheckServiceClient.php create mode 100644 src/Monitoring/V3/resources/group_service_descriptor_config.php create mode 100644 src/Monitoring/V3/resources/group_service_rest_client_config.php create mode 100644 src/Monitoring/V3/resources/metric_service_descriptor_config.php create mode 100644 src/Monitoring/V3/resources/metric_service_rest_client_config.php create mode 100644 src/Monitoring/V3/resources/uptime_check_service_client_config.json create mode 100644 src/Monitoring/V3/resources/uptime_check_service_descriptor_config.php create mode 100644 src/Monitoring/V3/resources/uptime_check_service_rest_client_config.php create mode 100644 src/PubSub/V1/resources/publisher_descriptor_config.php create mode 100644 src/PubSub/V1/resources/publisher_rest_client_config.php create mode 100644 src/PubSub/V1/resources/subscriber_descriptor_config.php create mode 100644 src/PubSub/V1/resources/subscriber_rest_client_config.php create mode 100644 src/Spanner/Admin/Database/V1/resources/database_admin_descriptor_config.php create mode 100644 src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php create mode 100644 src/Spanner/Admin/Instance/V1/resources/instance_admin_descriptor_config.php create mode 100644 src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php create mode 100644 src/Spanner/V1/resources/spanner_descriptor_config.php create mode 100644 src/Spanner/V1/resources/spanner_rest_client_config.php create mode 100644 src/Speech/V1/resources/speech_descriptor_config.php create mode 100644 src/Speech/V1/resources/speech_rest_client_config.php create mode 100644 src/Speech/V1beta1/resources/speech_descriptor_config.php create mode 100644 src/Speech/V1beta1/resources/speech_rest_client_config.php create mode 100644 src/VideoIntelligence/V1/resources/video_intelligence_service_descriptor_config.php create mode 100644 src/VideoIntelligence/V1/resources/video_intelligence_service_rest_client_config.php create mode 100644 src/VideoIntelligence/V1beta1/resources/video_intelligence_service_descriptor_config.php create mode 100644 src/VideoIntelligence/V1beta1/resources/video_intelligence_service_rest_client_config.php create mode 100644 src/VideoIntelligence/V1beta2/resources/video_intelligence_service_descriptor_config.php create mode 100644 src/VideoIntelligence/V1beta2/resources/video_intelligence_service_rest_client_config.php create mode 100644 src/Vision/V1/resources/image_annotator_descriptor_config.php create mode 100644 src/Vision/V1/resources/image_annotator_rest_client_config.php diff --git a/composer.json b/composer.json index e1ea9b58d6bf..75805922421b 100644 --- a/composer.json +++ b/composer.json @@ -43,14 +43,13 @@ "require": { "php": ">=5.5", "rize/uri-template": "~0.3", - "google/auth": "~0.9|^1.0", "guzzlehttp/guzzle": "^5.3|^6.0", "guzzlehttp/psr7": "^1.2", "monolog/monolog": "~1", "psr/http-message": "1.0.*", "ramsey/uuid": "~3", "google/proto-client": "^0.30.0", - "google/gax": "^0.29" + "google/gax": "dev-json-transport" }, "require-dev": { "phpunit/phpunit": "^4.8|^5.0", diff --git a/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php b/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php index 0dcdcd949985..ebdb523aa03d 100644 --- a/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php +++ b/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php @@ -30,29 +30,43 @@ namespace Google\Cloud\Bigtable\Admin\V2\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\OperationResponse; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; -use Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminGrpcClient; +use Google\Cloud\Bigtable\Admin\V2\AppProfile; use Google\Cloud\Bigtable\Admin\V2\Cluster; +use Google\Cloud\Bigtable\Admin\V2\CreateAppProfileRequest; use Google\Cloud\Bigtable\Admin\V2\CreateClusterRequest; use Google\Cloud\Bigtable\Admin\V2\CreateInstanceRequest; +use Google\Cloud\Bigtable\Admin\V2\DeleteAppProfileRequest; use Google\Cloud\Bigtable\Admin\V2\DeleteClusterRequest; use Google\Cloud\Bigtable\Admin\V2\DeleteInstanceRequest; +use Google\Cloud\Bigtable\Admin\V2\GetAppProfileRequest; use Google\Cloud\Bigtable\Admin\V2\GetClusterRequest; use Google\Cloud\Bigtable\Admin\V2\GetInstanceRequest; use Google\Cloud\Bigtable\Admin\V2\Instance; use Google\Cloud\Bigtable\Admin\V2\Instance_State as State; use Google\Cloud\Bigtable\Admin\V2\Instance_Type as Type; +use Google\Cloud\Bigtable\Admin\V2\ListAppProfilesRequest; +use Google\Cloud\Bigtable\Admin\V2\ListAppProfilesResponse; use Google\Cloud\Bigtable\Admin\V2\ListClustersRequest; +use Google\Cloud\Bigtable\Admin\V2\ListClustersResponse; use Google\Cloud\Bigtable\Admin\V2\ListInstancesRequest; -use Google\Cloud\Bigtable\Admin\V2\StorageType; -use Google\Cloud\Version; +use Google\Cloud\Bigtable\Admin\V2\ListInstancesResponse; +use Google\Cloud\Bigtable\Admin\V2\PartialUpdateInstanceRequest; +use Google\Cloud\Bigtable\Admin\V2\UpdateAppProfileRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\LongRunning\Operation; +use Google\Protobuf\FieldMask; +use Google\Protobuf\GPBEmpty; /** * Service Description: Service for creating, configuring, and deleting Cloud Bigtable Instances and @@ -113,6 +127,13 @@ */ class BigtableInstanceAdminGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.bigtable.admin.v2.BigtableInstanceAdmin'; + /** * The default address of the service. */ @@ -135,22 +156,35 @@ class BigtableInstanceAdminGapicClient private static $projectNameTemplate; private static $instanceNameTemplate; + private static $appProfileNameTemplate; private static $clusterNameTemplate; private static $locationNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $bigtableInstanceAdminStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/bigtable.admin', + 'https://www.googleapis.com/auth/bigtable.admin.cluster', + 'https://www.googleapis.com/auth/bigtable.admin.instance', + 'https://www.googleapis.com/auth/bigtable.admin.table', + 'https://www.googleapis.com/auth/cloud-bigtable.admin', + 'https://www.googleapis.com/auth/cloud-bigtable.admin.cluster', + 'https://www.googleapis.com/auth/cloud-bigtable.admin.table', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ], + 'clientConfigPath' => __DIR__.'/../resources/bigtable_instance_admin_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/bigtable_instance_admin_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/bigtable_instance_admin_descriptor_config.php', + ]; + private $operationsClient; private static function getProjectNameTemplate() { - if (self::$projectNameTemplate == null) { + if (null == self::$projectNameTemplate) { self::$projectNameTemplate = new PathTemplate('projects/{project}'); } @@ -159,16 +193,25 @@ private static function getProjectNameTemplate() private static function getInstanceNameTemplate() { - if (self::$instanceNameTemplate == null) { + if (null == self::$instanceNameTemplate) { self::$instanceNameTemplate = new PathTemplate('projects/{project}/instances/{instance}'); } return self::$instanceNameTemplate; } + private static function getAppProfileNameTemplate() + { + if (null == self::$appProfileNameTemplate) { + self::$appProfileNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/appProfiles/{app_profile}'); + } + + return self::$appProfileNameTemplate; + } + private static function getClusterNameTemplate() { - if (self::$clusterNameTemplate == null) { + if (null == self::$clusterNameTemplate) { self::$clusterNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/clusters/{cluster}'); } @@ -177,7 +220,7 @@ private static function getClusterNameTemplate() private static function getLocationNameTemplate() { - if (self::$locationNameTemplate == null) { + if (null == self::$locationNameTemplate) { self::$locationNameTemplate = new PathTemplate('projects/{project}/locations/{location}'); } @@ -186,10 +229,11 @@ private static function getLocationNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'project' => self::getProjectNameTemplate(), 'instance' => self::getInstanceNameTemplate(), + 'appProfile' => self::getAppProfileNameTemplate(), 'cluster' => self::getClusterNameTemplate(), 'location' => self::getLocationNameTemplate(), ]; @@ -198,38 +242,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getLongRunningDescriptors() - { - return [ - 'createInstance' => [ - 'operationReturnType' => '\Google\Cloud\Bigtable\Admin\V2\Instance', - 'metadataReturnType' => '\Google\Cloud\Bigtable\Admin\V2\CreateInstanceMetadata', - ], - 'createCluster' => [ - 'operationReturnType' => '\Google\Cloud\Bigtable\Admin\V2\Cluster', - 'metadataReturnType' => '\Google\Cloud\Bigtable\Admin\V2\CreateClusterMetadata', - ], - 'updateCluster' => [ - 'operationReturnType' => '\Google\Cloud\Bigtable\Admin\V2\Cluster', - 'metadataReturnType' => '\Google\Cloud\Bigtable\Admin\V2\UpdateClusterMetadata', - ], - ]; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a project resource. @@ -264,6 +276,26 @@ public static function instanceName($project, $instance) ]); } + /** + * Formats a string containing the fully-qualified path to represent + * a app_profile resource. + * + * @param string $project + * @param string $instance + * @param string $appProfile + * + * @return string The formatted app_profile resource. + * @experimental + */ + public static function appProfileName($project, $instance, $appProfile) + { + return self::getAppProfileNameTemplate()->render([ + 'project' => $project, + 'instance' => $instance, + 'app_profile' => $appProfile, + ]); + } + /** * Formats a string containing the fully-qualified path to represent * a cluster resource. @@ -308,6 +340,7 @@ public static function locationName($project, $location) * Template: Pattern * - project: projects/{project} * - instance: projects/{project}/instances/{instance} + * - appProfile: projects/{project}/instances/{instance}/appProfiles/{app_profile} * - cluster: projects/{project}/instances/{instance}/clusters/{cluster} * - location: projects/{project}/locations/{location}. * @@ -372,12 +405,9 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $lroDescriptors = self::getLongRunningDescriptors(); - if (!is_null($methodName) && array_key_exists($methodName, $lroDescriptors)) { - $options = $lroDescriptors[$methodName]; - } else { - $options = []; - } + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); @@ -394,16 +424,19 @@ public function resumeOperation($operationName, $methodName = null) * Default 'bigtableadmin.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -422,91 +455,31 @@ public function resumeOperation($operationName, $methodName = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/bigtable.admin', - 'https://www.googleapis.com/auth/bigtable.admin.cluster', - 'https://www.googleapis.com/auth/bigtable.admin.instance', - 'https://www.googleapis.com/auth/bigtable.admin.table', - 'https://www.googleapis.com/auth/cloud-bigtable.admin', - 'https://www.googleapis.com/auth/cloud-bigtable.admin.cluster', - 'https://www.googleapis.com/auth/cloud-bigtable.admin.table', - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/bigtable_instance_admin_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - if (array_key_exists('operationsClient', $options)) { - $this->operationsClient = $options['operationsClient']; - } else { - $operationsClientOptions = $options; - unset($operationsClientOptions['retryingOverride']); - unset($operationsClientOptions['clientConfigPath']); - $this->operationsClient = new OperationsClient($operationsClientOptions); - } - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'createInstance' => $defaultDescriptors, - 'getInstance' => $defaultDescriptors, - 'listInstances' => $defaultDescriptors, - 'updateInstance' => $defaultDescriptors, - 'deleteInstance' => $defaultDescriptors, - 'createCluster' => $defaultDescriptors, - 'getCluster' => $defaultDescriptors, - 'listClusters' => $defaultDescriptors, - 'updateCluster' => $defaultDescriptors, - 'deleteCluster' => $defaultDescriptors, - ]; - $longRunningDescriptors = self::getLongRunningDescriptors(); - foreach ($longRunningDescriptors as $method => $longRunningDescriptor) { - $this->descriptors[$method]['longRunningDescriptor'] = $longRunningDescriptor + ['operationsClient' => $this->operationsClient]; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.bigtable.admin.v2.BigtableInstanceAdmin', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createBigtableInstanceAdminStubFunction = function ($hostname, $opts, $channel) { - return new BigtableInstanceAdminGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createBigtableInstanceAdminStubFunction', $options)) { - $createBigtableInstanceAdminStubFunction = $options['createBigtableInstanceAdminStubFunction']; - } - $this->bigtableInstanceAdminStub = $this->grpcCredentialsHelper->createStub($createBigtableInstanceAdminStubFunction); + $options += self::$clientDefaults; + $this->setClientOptions($options); + $this->pluckArray([ + 'serviceName', + 'clientConfigPath', + 'restClientConfigPath', + 'descriptorsConfigPath', + ], $options); + $this->operationsClient = new OperationsClient($options); } /** @@ -586,24 +559,17 @@ public function createInstance($parent, $instanceId, $instance, $clusters, $opti $request->setInstance($instance); $request->setClusters($clusters); - $defaultCallSettings = $this->defaultCallSettings['createInstance']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableInstanceAdminStub, - 'CreateInstance', - $mergedSettings, - $this->descriptors['createInstance'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startOperationsCall( + new Call( + self::SERVICE_NAME.'/CreateInstance', + Operation::class, + $request + ), + $this->configureCallSettings('createInstance', $optionalArgs), + $this->descriptors['createInstance']['longRunning'] + [ + 'operationsClient' => $this->getOperationsClient(), + ] + )->wait(); } /** @@ -642,24 +608,14 @@ public function getInstance($name, $optionalArgs = []) $request = new GetInstanceRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['getInstance']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableInstanceAdminStub, - 'GetInstance', - $mergedSettings, - $this->descriptors['getInstance'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetInstance', + Instance::class, + $request + ), + $this->configureCallSettings('getInstance', $optionalArgs) + )->wait(); } /** @@ -703,24 +659,14 @@ public function listInstances($parent, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listInstances']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableInstanceAdminStub, - 'ListInstances', - $mergedSettings, - $this->descriptors['listInstances'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/ListInstances', + ListInstancesResponse::class, + $request + ), + $this->configureCallSettings('listInstances', $optionalArgs) + )->wait(); } /** @@ -733,22 +679,34 @@ public function listInstances($parent, $optionalArgs = []) * $formattedName = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $displayName = ''; * $type = Type::TYPE_UNSPECIFIED; - * $response = $bigtableInstanceAdminClient->updateInstance($formattedName, $displayName, $type); + * $labels = []; + * $response = $bigtableInstanceAdminClient->updateInstance($formattedName, $displayName, $type, $labels); * } finally { * $bigtableInstanceAdminClient->close(); * } * ``` * - * @param string $name (`OutputOnly`) - * The unique name of the instance. Values are of the form - * `projects//instances/[a-z][a-z0-9\\-]+[a-z0-9]`. - * @param string $displayName The descriptive name for this instance as it appears in UIs. - * Can be changed at any time, but should be kept globally unique - * to avoid confusion. - * @param int $type The type of the instance. Defaults to `PRODUCTION`. - * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\Instance_Type} - * @param array $optionalArgs { - * Optional. + * @param string $name (`OutputOnly`) + * The unique name of the instance. Values are of the form + * `projects//instances/[a-z][a-z0-9\\-]+[a-z0-9]`. + * @param string $displayName The descriptive name for this instance as it appears in UIs. + * Can be changed at any time, but should be kept globally unique + * to avoid confusion. + * @param int $type The type of the instance. Defaults to `PRODUCTION`. + * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\Instance_Type} + * @param array $labels Labels are a flexible and lightweight mechanism for organizing cloud + * resources into groups that reflect a customer's organizational needs and + * deployment strategies. They can be used to filter resources and aggregate + * metrics. + * + * * Label keys must be between 1 and 63 characters long and must conform to + * the regular expression: `[\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62}`. + * * Label values must be between 0 and 63 characters long and must conform to + * the regular expression: `[\p{Ll}\p{Lo}\p{N}_-]{0,63}`. + * * No more than 64 labels can be associated with a given resource. + * * Keys and values must both be under 128 bytes. + * @param array $optionalArgs { + * Optional. * * @type int $state * (`OutputOnly`) @@ -766,34 +724,74 @@ public function listInstances($parent, $optionalArgs = []) * @throws \Google\ApiCore\ApiException if the remote call fails * @experimental */ - public function updateInstance($name, $displayName, $type, $optionalArgs = []) + public function updateInstance($name, $displayName, $type, $labels, $optionalArgs = []) { $request = new Instance(); $request->setName($name); $request->setDisplayName($displayName); $request->setType($type); + $request->setLabels($labels); if (isset($optionalArgs['state'])) { $request->setState($optionalArgs['state']); } - $defaultCallSettings = $this->defaultCallSettings['updateInstance']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableInstanceAdminStub, - 'UpdateInstance', - $mergedSettings, - $this->descriptors['updateInstance'] - ); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/UpdateInstance', + Instance::class, + $request + ), + $this->configureCallSettings('updateInstance', $optionalArgs) + )->wait(); + } - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + /** + * Partially updates an instance within a project. + * + * Sample code: + * ``` + * try { + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); + * $instance = new Instance(); + * $updateMask = new FieldMask(); + * $response = $bigtableInstanceAdminClient->partialUpdateInstance($instance, $updateMask); + * } finally { + * $bigtableInstanceAdminClient->close(); + * } + * ``` + * + * @param Instance $instance The Instance which will (partially) replace the current value. + * @param FieldMask $updateMask The subset of Instance fields which should be replaced. + * Must be explicitly set. + * @param array $optionalArgs { + * Optional. + * + * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\LongRunning\Operation + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function partialUpdateInstance($instance, $updateMask, $optionalArgs = []) + { + $request = new PartialUpdateInstanceRequest(); + $request->setInstance($instance); + $request->setUpdateMask($updateMask); + + return $this->startCall( + new Call( + self::SERVICE_NAME.'/PartialUpdateInstance', + Operation::class, + $request + ), + $this->configureCallSettings('partialUpdateInstance', $optionalArgs) + )->wait(); } /** @@ -830,24 +828,14 @@ public function deleteInstance($name, $optionalArgs = []) $request = new DeleteInstanceRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['deleteInstance']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableInstanceAdminStub, - 'DeleteInstance', - $mergedSettings, - $this->descriptors['deleteInstance'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteInstance', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteInstance', $optionalArgs) + )->wait(); } /** @@ -921,24 +909,17 @@ public function createCluster($parent, $clusterId, $cluster, $optionalArgs = []) $request->setClusterId($clusterId); $request->setCluster($cluster); - $defaultCallSettings = $this->defaultCallSettings['createCluster']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableInstanceAdminStub, - 'CreateCluster', - $mergedSettings, - $this->descriptors['createCluster'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startOperationsCall( + new Call( + self::SERVICE_NAME.'/CreateCluster', + Operation::class, + $request + ), + $this->configureCallSettings('createCluster', $optionalArgs), + $this->descriptors['createCluster']['longRunning'] + [ + 'operationsClient' => $this->getOperationsClient(), + ] + )->wait(); } /** @@ -977,24 +958,14 @@ public function getCluster($name, $optionalArgs = []) $request = new GetClusterRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['getCluster']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableInstanceAdminStub, - 'GetCluster', - $mergedSettings, - $this->descriptors['getCluster'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetCluster', + Cluster::class, + $request + ), + $this->configureCallSettings('getCluster', $optionalArgs) + )->wait(); } /** @@ -1040,24 +1011,14 @@ public function listClusters($parent, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listClusters']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableInstanceAdminStub, - 'ListClusters', - $mergedSettings, - $this->descriptors['listClusters'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/ListClusters', + ListClustersResponse::class, + $request + ), + $this->configureCallSettings('listClusters', $optionalArgs) + )->wait(); } /** @@ -1070,8 +1031,7 @@ public function listClusters($parent, $optionalArgs = []) * $formattedName = $bigtableInstanceAdminClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); * $location = ''; * $serveNodes = 0; - * $defaultStorageType = StorageType::STORAGE_TYPE_UNSPECIFIED; - * $operationResponse = $bigtableInstanceAdminClient->updateCluster($formattedName, $location, $serveNodes, $defaultStorageType); + * $operationResponse = $bigtableInstanceAdminClient->updateCluster($formattedName, $location, $serveNodes); * $operationResponse->pollUntilComplete(); * if ($operationResponse->operationSucceeded()) { * $result = $operationResponse->getResult(); @@ -1082,7 +1042,7 @@ public function listClusters($parent, $optionalArgs = []) * } * * // OR start the operation, keep the operation name, and resume later - * $operationResponse = $bigtableInstanceAdminClient->updateCluster($formattedName, $location, $serveNodes, $defaultStorageType); + * $operationResponse = $bigtableInstanceAdminClient->updateCluster($formattedName, $location, $serveNodes); * $operationName = $operationResponse->getName(); * // ... do other work * $newOperationResponse = $bigtableInstanceAdminClient->resumeOperation($operationName, 'updateCluster'); @@ -1102,27 +1062,28 @@ public function listClusters($parent, $optionalArgs = []) * } * ``` * - * @param string $name (`OutputOnly`) - * The unique name of the cluster. Values are of the form - * `projects//instances//clusters/[a-z][-a-z0-9]*`. - * @param string $location (`CreationOnly`) - * The location where this cluster's nodes and storage reside. For best - * performance, clients should be located as close as possible to this cluster. - * Currently only zones are supported, so values should be of the form - * `projects//locations/`. - * @param int $serveNodes The number of nodes allocated to this cluster. More nodes enable higher - * throughput and more consistent performance. - * @param int $defaultStorageType (`CreationOnly`) - * The type of storage used by this cluster to serve its - * parent instance's tables, unless explicitly overridden. - * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\StorageType} - * @param array $optionalArgs { - * Optional. + * @param string $name (`OutputOnly`) + * The unique name of the cluster. Values are of the form + * `projects//instances//clusters/[a-z][-a-z0-9]*`. + * @param string $location (`CreationOnly`) + * The location where this cluster's nodes and storage reside. For best + * performance, clients should be located as close as possible to this + * cluster. Currently only zones are supported, so values should be of the + * form `projects//locations/`. + * @param int $serveNodes The number of nodes allocated to this cluster. More nodes enable higher + * throughput and more consistent performance. + * @param array $optionalArgs { + * Optional. * * @type int $state * (`OutputOnly`) * The current state of the cluster. * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\Cluster_State} + * @type int $defaultStorageType + * (`CreationOnly`) + * The type of storage used by this cluster to serve its + * parent instance's tables, unless explicitly overridden. + * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\StorageType} * @type \Google\ApiCore\RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array @@ -1135,35 +1096,30 @@ public function listClusters($parent, $optionalArgs = []) * @throws \Google\ApiCore\ApiException if the remote call fails * @experimental */ - public function updateCluster($name, $location, $serveNodes, $defaultStorageType, $optionalArgs = []) + public function updateCluster($name, $location, $serveNodes, $optionalArgs = []) { $request = new Cluster(); $request->setName($name); $request->setLocation($location); $request->setServeNodes($serveNodes); - $request->setDefaultStorageType($defaultStorageType); if (isset($optionalArgs['state'])) { $request->setState($optionalArgs['state']); } - - $defaultCallSettings = $this->defaultCallSettings['updateCluster']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); + if (isset($optionalArgs['defaultStorageType'])) { + $request->setDefaultStorageType($optionalArgs['defaultStorageType']); } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableInstanceAdminStub, - 'UpdateCluster', - $mergedSettings, - $this->descriptors['updateCluster'] - ); - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startOperationsCall( + new Call( + self::SERVICE_NAME.'/UpdateCluster', + Operation::class, + $request + ), + $this->configureCallSettings('updateCluster', $optionalArgs), + $this->descriptors['updateCluster']['longRunning'] + [ + 'operationsClient' => $this->getOperationsClient(), + ] + )->wait(); } /** @@ -1200,39 +1156,498 @@ public function deleteCluster($name, $optionalArgs = []) $request = new DeleteClusterRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['deleteCluster']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteCluster', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteCluster', $optionalArgs) + )->wait(); + } + + /** + * This is a private alpha release of Cloud Bigtable replication. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * Creates an app profile within an instance. + * + * Sample code: + * ``` + * try { + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); + * $formattedParent = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * $appProfileId = ''; + * $appProfile = new AppProfile(); + * $response = $bigtableInstanceAdminClient->createAppProfile($formattedParent, $appProfileId, $appProfile); + * } finally { + * $bigtableInstanceAdminClient->close(); + * } + * ``` + * + * @param string $parent The unique name of the instance in which to create the new app profile. + * Values are of the form + * `projects//instances/`. + * @param string $appProfileId The ID to be used when referring to the new app profile within its + * instance, e.g., just `myprofile` rather than + * `projects/myproject/instances/myinstance/appProfiles/myprofile`. + * @param AppProfile $appProfile The app profile to be created. + * Fields marked `OutputOnly` will be ignored. + * @param array $optionalArgs { + * Optional. + * + * @type bool $ignoreWarnings + * If true, ignore safety checks when creating the app profile. + * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Bigtable\Admin\V2\AppProfile + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function createAppProfile($parent, $appProfileId, $appProfile, $optionalArgs = []) + { + $request = new CreateAppProfileRequest(); + $request->setParent($parent); + $request->setAppProfileId($appProfileId); + $request->setAppProfile($appProfile); + if (isset($optionalArgs['ignoreWarnings'])) { + $request->setIgnoreWarnings($optionalArgs['ignoreWarnings']); + } + + return $this->startCall( + new Call( + self::SERVICE_NAME.'/CreateAppProfile', + AppProfile::class, + $request + ), + $this->configureCallSettings('createAppProfile', $optionalArgs) + )->wait(); + } + + /** + * This is a private alpha release of Cloud Bigtable replication. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * Gets information about an app profile. + * + * Sample code: + * ``` + * try { + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); + * $formattedName = $bigtableInstanceAdminClient->appProfileName('[PROJECT]', '[INSTANCE]', '[APP_PROFILE]'); + * $response = $bigtableInstanceAdminClient->getAppProfile($formattedName); + * } finally { + * $bigtableInstanceAdminClient->close(); + * } + * ``` + * + * @param string $name The unique name of the requested app profile. Values are of the form + * `projects//instances//appProfiles/`. + * @param array $optionalArgs { + * Optional. + * + * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Bigtable\Admin\V2\AppProfile + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function getAppProfile($name, $optionalArgs = []) + { + $request = new GetAppProfileRequest(); + $request->setName($name); + + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetAppProfile', + AppProfile::class, + $request + ), + $this->configureCallSettings('getAppProfile', $optionalArgs) + )->wait(); + } + + /** + * This is a private alpha release of Cloud Bigtable replication. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * Lists information about app profiles in an instance. + * + * Sample code: + * ``` + * try { + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); + * $formattedParent = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * // Iterate through all elements + * $pagedResponse = $bigtableInstanceAdminClient->listAppProfiles($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * + * // OR iterate over pages of elements + * $pagedResponse = $bigtableInstanceAdminClient->listAppProfiles($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * } finally { + * $bigtableInstanceAdminClient->close(); + * } + * ``` + * + * @param string $parent The unique name of the instance for which a list of app profiles is + * requested. Values are of the form + * `projects//instances/`. + * @param array $optionalArgs { + * Optional. + * + * @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 \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function listAppProfiles($parent, $optionalArgs = []) + { + $request = new ListAppProfilesRequest(); + $request->setParent($parent); + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableInstanceAdminStub, - 'DeleteCluster', - $mergedSettings, - $this->descriptors['deleteCluster'] + + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListAppProfiles', + ListAppProfilesResponse::class, + $request + ), + $this->configureCallSettings('listAppProfiles', $optionalArgs), + $this->descriptors['listAppProfiles']['pageStreaming'] ); + } + + /** + * This is a private alpha release of Cloud Bigtable replication. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * Updates an app profile within an instance. + * + * Sample code: + * ``` + * try { + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); + * $appProfile = new AppProfile(); + * $updateMask = new FieldMask(); + * $response = $bigtableInstanceAdminClient->updateAppProfile($appProfile, $updateMask); + * } finally { + * $bigtableInstanceAdminClient->close(); + * } + * ``` + * + * @param AppProfile $appProfile The app profile which will (partially) replace the current value. + * @param FieldMask $updateMask The subset of app profile fields which should be replaced. + * If unset, all fields will be replaced. + * @param array $optionalArgs { + * Optional. + * + * @type bool $ignoreWarnings + * If true, ignore safety checks when updating the app profile. + * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\LongRunning\Operation + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function updateAppProfile($appProfile, $updateMask, $optionalArgs = []) + { + $request = new UpdateAppProfileRequest(); + $request->setAppProfile($appProfile); + $request->setUpdateMask($updateMask); + if (isset($optionalArgs['ignoreWarnings'])) { + $request->setIgnoreWarnings($optionalArgs['ignoreWarnings']); + } - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/UpdateAppProfile', + Operation::class, + $request + ), + $this->configureCallSettings('updateAppProfile', $optionalArgs) + )->wait(); } /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. + * This is a private alpha release of Cloud Bigtable replication. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * Deletes an app profile from an instance. + * + * Sample code: + * ``` + * try { + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); + * $formattedName = $bigtableInstanceAdminClient->appProfileName('[PROJECT]', '[INSTANCE]', '[APP_PROFILE]'); + * $ignoreWarnings = false; + * $bigtableInstanceAdminClient->deleteAppProfile($formattedName, $ignoreWarnings); + * } finally { + * $bigtableInstanceAdminClient->close(); + * } + * ``` + * + * @param string $name The unique name of the app profile to be deleted. Values are of the form + * `projects//instances//appProfiles/`. + * @param bool $ignoreWarnings If true, ignore safety checks when deleting the app profile. + * @param array $optionalArgs { + * Optional. + * + * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } * + * @throws \Google\ApiCore\ApiException if the remote call fails * @experimental */ - public function close() + public function deleteAppProfile($name, $ignoreWarnings, $optionalArgs = []) { - $this->bigtableInstanceAdminStub->close(); + $request = new DeleteAppProfileRequest(); + $request->setName($name); + $request->setIgnoreWarnings($ignoreWarnings); + + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteAppProfile', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteAppProfile', $optionalArgs) + )->wait(); } - private function createCredentialsCallback() + /** + * This is a private alpha release of Cloud Bigtable instance level + * permissions. This feature is not currently available to most Cloud Bigtable + * customers. This feature might be changed in backward-incompatible ways and + * is not recommended for production use. It is not subject to any SLA or + * deprecation policy. + * + * Gets the access control policy for an instance resource. Returns an empty + * policy if an instance exists but does not have a policy set. + * + * Sample code: + * ``` + * try { + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); + * $formattedResource = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * $response = $bigtableInstanceAdminClient->getIamPolicy($formattedResource); + * } finally { + * $bigtableInstanceAdminClient->close(); + * } + * ``` + * + * @param string $resource REQUIRED: The resource for which the policy is being requested. + * `resource` is usually specified as a path. For example, a Project + * resource is specified as `projects/{project}`. + * @param array $optionalArgs { + * Optional. + * + * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Iam\V1\Policy + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function getIamPolicy($resource, $optionalArgs = []) + { + $request = new GetIamPolicyRequest(); + $request->setResource($resource); + + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetIamPolicy', + Policy::class, + $request + ), + $this->configureCallSettings('getIamPolicy', $optionalArgs) + )->wait(); + } + + /** + * This is a private alpha release of Cloud Bigtable instance level + * permissions. This feature is not currently available to most Cloud Bigtable + * customers. This feature might be changed in backward-incompatible ways and + * is not recommended for production use. It is not subject to any SLA or + * deprecation policy. + * + * Sets the access control policy on an instance resource. Replaces any + * existing policy. + * + * Sample code: + * ``` + * try { + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); + * $formattedResource = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * $policy = new Policy(); + * $response = $bigtableInstanceAdminClient->setIamPolicy($formattedResource, $policy); + * } finally { + * $bigtableInstanceAdminClient->close(); + * } + * ``` + * + * @param string $resource REQUIRED: The resource for which the policy is being specified. + * `resource` is usually specified as a path. For example, a Project + * resource is specified as `projects/{project}`. + * @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 \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Iam\V1\Policy + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function setIamPolicy($resource, $policy, $optionalArgs = []) + { + $request = new SetIamPolicyRequest(); + $request->setResource($resource); + $request->setPolicy($policy); + + return $this->startCall( + new Call( + self::SERVICE_NAME.'/SetIamPolicy', + Policy::class, + $request + ), + $this->configureCallSettings('setIamPolicy', $optionalArgs) + )->wait(); + } + + /** + * This is a private alpha release of Cloud Bigtable instance level + * permissions. This feature is not currently available to most Cloud Bigtable + * customers. This feature might be changed in backward-incompatible ways and + * is not recommended for production use. It is not subject to any SLA or + * deprecation policy. + * + * Returns permissions that the caller has on the specified instance resource. + * + * Sample code: + * ``` + * try { + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); + * $formattedResource = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * $permissions = []; + * $response = $bigtableInstanceAdminClient->testIamPermissions($formattedResource, $permissions); + * } finally { + * $bigtableInstanceAdminClient->close(); + * } + * ``` + * + * @param string $resource REQUIRED: The resource for which the policy detail is being requested. + * `resource` is usually specified as a path. For example, a Project + * resource is specified as `projects/{project}`. + * @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 \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Iam\V1\TestIamPermissionsResponse + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function testIamPermissions($resource, $permissions, $optionalArgs = []) + { + $request = new TestIamPermissionsRequest(); + $request->setResource($resource); + $request->setPermissions($permissions); + + return $this->startCall( + new Call( + self::SERVICE_NAME.'/TestIamPermissions', + TestIamPermissionsResponse::class, + $request + ), + $this->configureCallSettings('testIamPermissions', $optionalArgs) + )->wait(); + } + + /** + * Initiates an orderly shutdown in which preexisting calls continue but new + * calls are immediately cancelled. + * + * @experimental + */ + public function close() { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php b/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php index 2576ef31f582..b67c238e04bc 100644 --- a/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php +++ b/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php @@ -30,25 +30,38 @@ namespace Google\Cloud\Bigtable\Admin\V2\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; -use Google\ApiCore\PageStreamingDescriptor; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; -use Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminGrpcClient; +use Google\Cloud\Bigtable\Admin\V2\CheckConsistencyRequest; +use Google\Cloud\Bigtable\Admin\V2\CheckConsistencyResponse; +use Google\Cloud\Bigtable\Admin\V2\CreateTableFromSnapshotRequest; use Google\Cloud\Bigtable\Admin\V2\CreateTableRequest; use Google\Cloud\Bigtable\Admin\V2\CreateTableRequest_Split as Split; +use Google\Cloud\Bigtable\Admin\V2\DeleteSnapshotRequest; use Google\Cloud\Bigtable\Admin\V2\DeleteTableRequest; use Google\Cloud\Bigtable\Admin\V2\DropRowRangeRequest; +use Google\Cloud\Bigtable\Admin\V2\GenerateConsistencyTokenRequest; +use Google\Cloud\Bigtable\Admin\V2\GenerateConsistencyTokenResponse; +use Google\Cloud\Bigtable\Admin\V2\GetSnapshotRequest; use Google\Cloud\Bigtable\Admin\V2\GetTableRequest; +use Google\Cloud\Bigtable\Admin\V2\ListSnapshotsRequest; +use Google\Cloud\Bigtable\Admin\V2\ListSnapshotsResponse; use Google\Cloud\Bigtable\Admin\V2\ListTablesRequest; +use Google\Cloud\Bigtable\Admin\V2\ListTablesResponse; use Google\Cloud\Bigtable\Admin\V2\ModifyColumnFamiliesRequest; use Google\Cloud\Bigtable\Admin\V2\ModifyColumnFamiliesRequest_Modification as Modification; +use Google\Cloud\Bigtable\Admin\V2\Snapshot; +use Google\Cloud\Bigtable\Admin\V2\SnapshotTableRequest; use Google\Cloud\Bigtable\Admin\V2\Table; use Google\Cloud\Bigtable\Admin\V2\Table_View as View; -use Google\Cloud\Version; +use Google\LongRunning\Operation; +use Google\Protobuf\Duration; +use Google\Protobuf\GPBEmpty; /** * Service Description: Service for creating, configuring, and deleting Cloud Bigtable tables. @@ -85,6 +98,13 @@ */ class BigtableTableAdminGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.bigtable.admin.v2.BigtableTableAdmin'; + /** * The default address of the service. */ @@ -106,29 +126,62 @@ class BigtableTableAdminGapicClient const CODEGEN_VERSION = '0.0.5'; private static $instanceNameTemplate; + private static $clusterNameTemplate; + private static $snapshotNameTemplate; private static $tableNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/bigtable.admin', + 'https://www.googleapis.com/auth/bigtable.admin.cluster', + 'https://www.googleapis.com/auth/bigtable.admin.instance', + 'https://www.googleapis.com/auth/bigtable.admin.table', + 'https://www.googleapis.com/auth/cloud-bigtable.admin', + 'https://www.googleapis.com/auth/cloud-bigtable.admin.cluster', + 'https://www.googleapis.com/auth/cloud-bigtable.admin.table', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ], + 'clientConfigPath' => __DIR__.'/../resources/bigtable_table_admin_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/bigtable_table_admin_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/bigtable_table_admin_descriptor_config.php', + ]; - protected $grpcCredentialsHelper; - protected $bigtableTableAdminStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private $operationsClient; private static function getInstanceNameTemplate() { - if (self::$instanceNameTemplate == null) { + if (null == self::$instanceNameTemplate) { self::$instanceNameTemplate = new PathTemplate('projects/{project}/instances/{instance}'); } return self::$instanceNameTemplate; } + private static function getClusterNameTemplate() + { + if (null == self::$clusterNameTemplate) { + self::$clusterNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/clusters/{cluster}'); + } + + return self::$clusterNameTemplate; + } + + private static function getSnapshotNameTemplate() + { + if (null == self::$snapshotNameTemplate) { + self::$snapshotNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot}'); + } + + return self::$snapshotNameTemplate; + } + private static function getTableNameTemplate() { - if (self::$tableNameTemplate == null) { + if (null == self::$tableNameTemplate) { self::$tableNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/tables/{table}'); } @@ -137,9 +190,11 @@ private static function getTableNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'instance' => self::getInstanceNameTemplate(), + 'cluster' => self::getClusterNameTemplate(), + 'snapshot' => self::getSnapshotNameTemplate(), 'table' => self::getTableNameTemplate(), ]; } @@ -147,52 +202,63 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getPageStreamingDescriptors() + /** + * Formats a string containing the fully-qualified path to represent + * a instance resource. + * + * @param string $project + * @param string $instance + * + * @return string The formatted instance resource. + * @experimental + */ + public static function instanceName($project, $instance) { - $listTablesPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getTables', - ]); - - $pageStreamingDescriptors = [ - 'listTables' => $listTablesPageStreamingDescriptor, - ]; - - return $pageStreamingDescriptors; + return self::getInstanceNameTemplate()->render([ + 'project' => $project, + 'instance' => $instance, + ]); } - private static function getGapicVersion() + /** + * Formats a string containing the fully-qualified path to represent + * a cluster resource. + * + * @param string $project + * @param string $instance + * @param string $cluster + * + * @return string The formatted cluster resource. + * @experimental + */ + public static function clusterName($project, $instance, $cluster) { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; + return self::getClusterNameTemplate()->render([ + 'project' => $project, + 'instance' => $instance, + 'cluster' => $cluster, + ]); } /** * Formats a string containing the fully-qualified path to represent - * a instance resource. + * a snapshot resource. * * @param string $project * @param string $instance + * @param string $cluster + * @param string $snapshot * - * @return string The formatted instance resource. + * @return string The formatted snapshot resource. * @experimental */ - public static function instanceName($project, $instance) + public static function snapshotName($project, $instance, $cluster, $snapshot) { - return self::getInstanceNameTemplate()->render([ + return self::getSnapshotNameTemplate()->render([ 'project' => $project, 'instance' => $instance, + 'cluster' => $cluster, + 'snapshot' => $snapshot, ]); } @@ -221,6 +287,8 @@ public static function tableName($project, $instance, $table) * The following name formats are supported: * Template: Pattern * - instance: projects/{project}/instances/{instance} + * - cluster: projects/{project}/instances/{instance}/clusters/{cluster} + * - snapshot: projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot} * - table: projects/{project}/instances/{instance}/tables/{table}. * * The optional $template argument can be supplied to specify a particular pattern, and must @@ -258,6 +326,41 @@ public static function parseName($formattedName, $template = null) throw new ValidationException("Input did not match any known format. Input: $formattedName"); } + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return \Google\ApiCore\LongRunning\OperationsClient + * @experimental + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started + * by a long running API method. If $methodName is not provided, or does + * not match a long running API method, then the operation can still be + * resumed, but the OperationResponse object will not deserialize the + * final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return \Google\ApiCore\OperationResponse + * @experimental + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + + return $operation; + } + /** * Constructor. * @@ -268,16 +371,19 @@ public static function parseName($formattedName, $template = null) * Default 'bigtableadmin.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -296,78 +402,31 @@ public static function parseName($formattedName, $template = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/bigtable.admin', - 'https://www.googleapis.com/auth/bigtable.admin.cluster', - 'https://www.googleapis.com/auth/bigtable.admin.instance', - 'https://www.googleapis.com/auth/bigtable.admin.table', - 'https://www.googleapis.com/auth/cloud-bigtable.admin', - 'https://www.googleapis.com/auth/cloud-bigtable.admin.cluster', - 'https://www.googleapis.com/auth/cloud-bigtable.admin.table', - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/bigtable_table_admin_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'createTable' => $defaultDescriptors, - 'listTables' => $defaultDescriptors, - 'getTable' => $defaultDescriptors, - 'deleteTable' => $defaultDescriptors, - 'modifyColumnFamilies' => $defaultDescriptors, - 'dropRowRange' => $defaultDescriptors, - ]; - $pageStreamingDescriptors = self::getPageStreamingDescriptors(); - foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { - $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.bigtable.admin.v2.BigtableTableAdmin', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createBigtableTableAdminStubFunction = function ($hostname, $opts, $channel) { - return new BigtableTableAdminGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createBigtableTableAdminStubFunction', $options)) { - $createBigtableTableAdminStubFunction = $options['createBigtableTableAdminStubFunction']; - } - $this->bigtableTableAdminStub = $this->grpcCredentialsHelper->createStub($createBigtableTableAdminStubFunction); + $options += self::$clientDefaults; + $this->setClientOptions($options); + $this->pluckArray([ + 'serviceName', + 'clientConfigPath', + 'restClientConfigPath', + 'descriptorsConfigPath', + ], $options); + $this->operationsClient = new OperationsClient($options); } /** @@ -435,24 +494,104 @@ public function createTable($parent, $tableId, $table, $optionalArgs = []) $request->setInitialSplits($optionalArgs['initialSplits']); } - $defaultCallSettings = $this->defaultCallSettings['createTable']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableTableAdminStub, - 'CreateTable', - $mergedSettings, - $this->descriptors['createTable'] - ); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/CreateTable', + Table::class, + $request + ), + $this->configureCallSettings('createTable', $optionalArgs) + )->wait(); + } - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + /** + * This is a private alpha release of Cloud Bigtable snapshots. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * Creates a new table from the specified snapshot. The target table must + * not exist. The snapshot and the table must be in the same instance. + * + * Sample code: + * ``` + * try { + * $bigtableTableAdminClient = new BigtableTableAdminClient(); + * $formattedParent = $bigtableTableAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * $tableId = ''; + * $sourceSnapshot = ''; + * $operationResponse = $bigtableTableAdminClient->createTableFromSnapshot($formattedParent, $tableId, $sourceSnapshot); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * + * // OR start the operation, keep the operation name, and resume later + * $operationResponse = $bigtableTableAdminClient->createTableFromSnapshot($formattedParent, $tableId, $sourceSnapshot); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $bigtableTableAdminClient->resumeOperation($operationName, 'createTableFromSnapshot'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $bigtableTableAdminClient->close(); + * } + * ``` + * + * @param string $parent The unique name of the instance in which to create the table. + * Values are of the form `projects//instances/`. + * @param string $tableId The name by which the new table should be referred to within the parent + * instance, e.g., `foobar` rather than `/tables/foobar`. + * @param string $sourceSnapshot The unique name of the snapshot from which to restore the table. The + * snapshot and the table must be in the same instance. + * Values are of the form + * `projects//instances//clusters//snapshots/`. + * @param array $optionalArgs { + * Optional. + * + * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\OperationResponse + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function createTableFromSnapshot($parent, $tableId, $sourceSnapshot, $optionalArgs = []) + { + $request = new CreateTableFromSnapshotRequest(); + $request->setParent($parent); + $request->setTableId($tableId); + $request->setSourceSnapshot($sourceSnapshot); + + return $this->startOperationsCall( + new Call( + self::SERVICE_NAME.'/CreateTableFromSnapshot', + Operation::class, + $request + ), + $this->configureCallSettings('createTableFromSnapshot', $optionalArgs), + $this->descriptors['createTableFromSnapshot']['longRunning'] + [ + 'operationsClient' => $this->getOperationsClient(), + ] + )->wait(); } /** @@ -518,24 +657,15 @@ public function listTables($parent, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listTables']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableTableAdminStub, - 'ListTables', - $mergedSettings, - $this->descriptors['listTables'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListTables', + ListTablesResponse::class, + $request + ), + $this->configureCallSettings('listTables', $optionalArgs), + $this->descriptors['listTables']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -582,24 +712,14 @@ public function getTable($name, $optionalArgs = []) $request->setView($optionalArgs['view']); } - $defaultCallSettings = $this->defaultCallSettings['getTable']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableTableAdminStub, - 'GetTable', - $mergedSettings, - $this->descriptors['getTable'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetTable', + Table::class, + $request + ), + $this->configureCallSettings('getTable', $optionalArgs) + )->wait(); } /** @@ -637,24 +757,14 @@ public function deleteTable($name, $optionalArgs = []) $request = new DeleteTableRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['deleteTable']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableTableAdminStub, - 'DeleteTable', - $mergedSettings, - $this->descriptors['deleteTable'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteTable', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteTable', $optionalArgs) + )->wait(); } /** @@ -703,24 +813,14 @@ public function modifyColumnFamilies($name, $modifications, $optionalArgs = []) $request->setName($name); $request->setModifications($modifications); - $defaultCallSettings = $this->defaultCallSettings['modifyColumnFamilies']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableTableAdminStub, - 'ModifyColumnFamilies', - $mergedSettings, - $this->descriptors['modifyColumnFamilies'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/ModifyColumnFamilies', + Table::class, + $request + ), + $this->configureCallSettings('modifyColumnFamilies', $optionalArgs) + )->wait(); } /** @@ -771,24 +871,385 @@ public function dropRowRange($name, $optionalArgs = []) $request->setDeleteAllDataFromTable($optionalArgs['deleteAllDataFromTable']); } - $defaultCallSettings = $this->defaultCallSettings['dropRowRange']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DropRowRange', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('dropRowRange', $optionalArgs) + )->wait(); + } + + /** + * This is a private alpha release of Cloud Bigtable replication. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * Generates a consistency token for a Table, which can be used in + * CheckConsistency to check whether mutations to the table that finished + * before this call started have been replicated. The tokens will be available + * for 90 days. + * + * Sample code: + * ``` + * try { + * $bigtableTableAdminClient = new BigtableTableAdminClient(); + * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); + * $response = $bigtableTableAdminClient->generateConsistencyToken($formattedName); + * } finally { + * $bigtableTableAdminClient->close(); + * } + * ``` + * + * @param string $name The unique name of the Table for which to create a consistency token. + * Values are of the form + * `projects//instances//tables/`. + * @param array $optionalArgs { + * Optional. + * + * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Bigtable\Admin\V2\GenerateConsistencyTokenResponse + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function generateConsistencyToken($name, $optionalArgs = []) + { + $request = new GenerateConsistencyTokenRequest(); + $request->setName($name); + + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GenerateConsistencyToken', + GenerateConsistencyTokenResponse::class, + $request + ), + $this->configureCallSettings('generateConsistencyToken', $optionalArgs) + )->wait(); + } + + /** + * This is a private alpha release of Cloud Bigtable replication. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * Checks replication consistency based on a consistency token, that is, if + * replication has caught up based on the conditions specified in the token + * and the check request. + * + * Sample code: + * ``` + * try { + * $bigtableTableAdminClient = new BigtableTableAdminClient(); + * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); + * $consistencyToken = ''; + * $response = $bigtableTableAdminClient->checkConsistency($formattedName, $consistencyToken); + * } finally { + * $bigtableTableAdminClient->close(); + * } + * ``` + * + * @param string $name The unique name of the Table for which to check replication consistency. + * Values are of the form + * `projects//instances//tables/
`. + * @param string $consistencyToken The token created using GenerateConsistencyToken for the Table. + * @param array $optionalArgs { + * Optional. + * + * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Bigtable\Admin\V2\CheckConsistencyResponse + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function checkConsistency($name, $consistencyToken, $optionalArgs = []) + { + $request = new CheckConsistencyRequest(); + $request->setName($name); + $request->setConsistencyToken($consistencyToken); + + return $this->startCall( + new Call( + self::SERVICE_NAME.'/CheckConsistency', + CheckConsistencyResponse::class, + $request + ), + $this->configureCallSettings('checkConsistency', $optionalArgs) + )->wait(); + } + + /** + * This is a private alpha release of Cloud Bigtable snapshots. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * Creates a new snapshot in the specified cluster from the specified + * source table. The cluster and the table must be in the same instance. + * + * Sample code: + * ``` + * try { + * $bigtableTableAdminClient = new BigtableTableAdminClient(); + * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); + * $cluster = ''; + * $snapshotId = ''; + * $description = ''; + * $response = $bigtableTableAdminClient->snapshotTable($formattedName, $cluster, $snapshotId, $description); + * } finally { + * $bigtableTableAdminClient->close(); + * } + * ``` + * + * @param string $name The unique name of the table to have the snapshot taken. + * Values are of the form + * `projects//instances//tables/
`. + * @param string $cluster The name of the cluster where the snapshot will be created in. + * Values are of the form + * `projects//instances//clusters/`. + * @param string $snapshotId The ID by which the new snapshot should be referred to within the parent + * cluster, e.g., `mysnapshot` of the form: `[_a-zA-Z0-9][-_.a-zA-Z0-9]*` + * rather than + * `projects//instances//clusters//snapshots/mysnapshot`. + * @param string $description Description of the snapshot. + * @param array $optionalArgs { + * Optional. + * + * @type Duration $ttl + * The amount of time that the new snapshot can stay active after it is + * created. Once 'ttl' expires, the snapshot will get deleted. The maximum + * amount of time a snapshot can stay active is 7 days. If 'ttl' is not + * specified, the default value of 24 hours will be used. + * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\LongRunning\Operation + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function snapshotTable($name, $cluster, $snapshotId, $description, $optionalArgs = []) + { + $request = new SnapshotTableRequest(); + $request->setName($name); + $request->setCluster($cluster); + $request->setSnapshotId($snapshotId); + $request->setDescription($description); + if (isset($optionalArgs['ttl'])) { + $request->setTtl($optionalArgs['ttl']); + } + + return $this->startCall( + new Call( + self::SERVICE_NAME.'/SnapshotTable', + Operation::class, + $request + ), + $this->configureCallSettings('snapshotTable', $optionalArgs) + )->wait(); + } + + /** + * This is a private alpha release of Cloud Bigtable snapshots. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * Gets metadata information about the specified snapshot. + * + * Sample code: + * ``` + * try { + * $bigtableTableAdminClient = new BigtableTableAdminClient(); + * $formattedName = $bigtableTableAdminClient->snapshotName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[SNAPSHOT]'); + * $response = $bigtableTableAdminClient->getSnapshot($formattedName); + * } finally { + * $bigtableTableAdminClient->close(); + * } + * ``` + * + * @param string $name The unique name of the requested snapshot. + * Values are of the form + * `projects//instances//clusters//snapshots/`. + * @param array $optionalArgs { + * Optional. + * + * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Bigtable\Admin\V2\Snapshot + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function getSnapshot($name, $optionalArgs = []) + { + $request = new GetSnapshotRequest(); + $request->setName($name); + + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetSnapshot', + Snapshot::class, + $request + ), + $this->configureCallSettings('getSnapshot', $optionalArgs) + )->wait(); + } + + /** + * This is a private alpha release of Cloud Bigtable snapshots. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * Lists all snapshots associated with the specified cluster. + * + * Sample code: + * ``` + * try { + * $bigtableTableAdminClient = new BigtableTableAdminClient(); + * $formattedParent = $bigtableTableAdminClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); + * // Iterate through all elements + * $pagedResponse = $bigtableTableAdminClient->listSnapshots($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * + * // OR iterate over pages of elements + * $pagedResponse = $bigtableTableAdminClient->listSnapshots($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * } finally { + * $bigtableTableAdminClient->close(); + * } + * ``` + * + * @param string $parent The unique name of the cluster for which snapshots should be listed. + * Values are of the form + * `projects//instances//clusters/`. + * Use ` = '-'` to list snapshots for all clusters in an instance, + * e.g., `projects//instances//clusters/-`. + * @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 \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function listSnapshots($parent, $optionalArgs = []) + { + $request = new ListSnapshotsRequest(); + $request->setParent($parent); + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableTableAdminStub, - 'DropRowRange', - $mergedSettings, - $this->descriptors['dropRowRange'] + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListSnapshots', + ListSnapshotsResponse::class, + $request + ), + $this->configureCallSettings('listSnapshots', $optionalArgs), + $this->descriptors['listSnapshots']['pageStreaming'] ); + } + + /** + * This is a private alpha release of Cloud Bigtable snapshots. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * Permanently deletes the specified snapshot. + * + * Sample code: + * ``` + * try { + * $bigtableTableAdminClient = new BigtableTableAdminClient(); + * $formattedName = $bigtableTableAdminClient->snapshotName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[SNAPSHOT]'); + * $bigtableTableAdminClient->deleteSnapshot($formattedName); + * } finally { + * $bigtableTableAdminClient->close(); + * } + * ``` + * + * @param string $name The unique name of the snapshot to be deleted. + * Values are of the form + * `projects//instances//clusters//snapshots/`. + * @param array $optionalArgs { + * Optional. + * + * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function deleteSnapshot($name, $optionalArgs = []) + { + $request = new DeleteSnapshotRequest(); + $request->setName($name); - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteSnapshot', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteSnapshot', $optionalArgs) + )->wait(); } /** @@ -799,11 +1260,6 @@ public function dropRowRange($name, $optionalArgs = []) */ public function close() { - $this->bigtableTableAdminStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_client_config.json b/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_client_config.json index ee9e46f78be5..ce9bec119b73 100644 --- a/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_client_config.json +++ b/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_client_config.json @@ -42,6 +42,11 @@ "retry_codes_name": "idempotent", "retry_params_name": "default" }, + "PartialUpdateInstance": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, "DeleteInstance": { "timeout_millis": 60000, "retry_codes_name": "idempotent", @@ -71,6 +76,46 @@ "timeout_millis": 60000, "retry_codes_name": "idempotent", "retry_params_name": "default" + }, + "CreateAppProfile": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetAppProfile": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListAppProfiles": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateAppProfile": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteAppProfile": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" } } } diff --git a/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_descriptor_config.php b/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_descriptor_config.php new file mode 100644 index 000000000000..3d39322f1abd --- /dev/null +++ b/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_descriptor_config.php @@ -0,0 +1,34 @@ + [ + 'google.bigtable.admin.v2.BigtableInstanceAdmin' => [ + 'createInstance' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Bigtable\Admin\V2\Instance', + 'metadataReturnType' => '\Google\Cloud\Bigtable\Admin\V2\CreateInstanceMetadata', + ], + ], + 'createCluster' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Bigtable\Admin\V2\Cluster', + 'metadataReturnType' => '\Google\Cloud\Bigtable\Admin\V2\CreateClusterMetadata', + ], + ], + 'updateCluster' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Bigtable\Admin\V2\Cluster', + 'metadataReturnType' => '\Google\Cloud\Bigtable\Admin\V2\UpdateClusterMetadata', + ], + ], + 'listAppProfiles' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getAppProfiles', + ], + ], + ], + ], +]; diff --git a/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_rest_client_config.php b/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_rest_client_config.php new file mode 100644 index 000000000000..cdded2a41d12 --- /dev/null +++ b/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_rest_client_config.php @@ -0,0 +1,191 @@ + [ + 'google.bigtable.admin.v2.BigtableInstanceAdmin' => [ + 'CreateInstance' => [ + 'method' => 'post', + 'uri' => '/v2/{parent=projects/*}/instances', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'GetInstance' => [ + 'method' => 'get', + 'uri' => '/v2/{name=projects/*/instances/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'ListInstances' => [ + 'method' => 'get', + 'uri' => '/v2/{parent=projects/*}/instances', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'UpdateInstance' => [ + 'method' => 'put', + 'uri' => '/v2/{name=projects/*/instances/*}', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'PartialUpdateInstance' => [ + 'method' => 'patch', + 'uri' => '/v2/{instance.name=projects/*/instances/*}', + 'body' => 'instance', + 'placeholders' => [ + 'instance.name' => [ + 'getInstance', + 'getName', + ], + ], + ], + 'DeleteInstance' => [ + 'method' => 'delete', + 'uri' => '/v2/{name=projects/*/instances/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'CreateCluster' => [ + 'method' => 'post', + 'uri' => '/v2/{parent=projects/*/instances/*}/clusters', + 'body' => 'cluster', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'GetCluster' => [ + 'method' => 'get', + 'uri' => '/v2/{name=projects/*/instances/*/clusters/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'ListClusters' => [ + 'method' => 'get', + 'uri' => '/v2/{parent=projects/*/instances/*}/clusters', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'UpdateCluster' => [ + 'method' => 'put', + 'uri' => '/v2/{name=projects/*/instances/*/clusters/*}', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'DeleteCluster' => [ + 'method' => 'delete', + 'uri' => '/v2/{name=projects/*/instances/*/clusters/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'CreateAppProfile' => [ + 'method' => 'post', + 'uri' => '/v2/{parent=projects/*/instances/*}/appProfiles', + 'body' => 'app_profile', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'GetAppProfile' => [ + 'method' => 'get', + 'uri' => '/v2/{name=projects/*/instances/*/appProfiles/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'ListAppProfiles' => [ + 'method' => 'get', + 'uri' => '/v2/{parent=projects/*/instances/*}/appProfiles', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'UpdateAppProfile' => [ + 'method' => 'patch', + 'uri' => '/v2/{app_profile.name=projects/*/instances/*/appProfiles/*}', + 'body' => 'app_profile', + 'placeholders' => [ + 'app_profile.name' => [ + 'getApp_profile', + 'getName', + ], + ], + ], + 'DeleteAppProfile' => [ + 'method' => 'delete', + 'uri' => '/v2/{name=projects/*/instances/*/appProfiles/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'GetIamPolicy' => [ + 'method' => 'post', + 'uri' => '/v2/{resource=projects/*/instances/*}:getIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getResource', + ], + ], + ], + 'SetIamPolicy' => [ + 'method' => 'post', + 'uri' => '/v2/{resource=projects/*/instances/*}:setIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getResource', + ], + ], + ], + 'TestIamPermissions' => [ + 'method' => 'post', + 'uri' => '/v2/{resource=projects/*/instances/*}:testIamPermissions', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getResource', + ], + ], + ], + ], + ], +]; diff --git a/src/Bigtable/Admin/V2/resources/bigtable_table_admin_client_config.json b/src/Bigtable/Admin/V2/resources/bigtable_table_admin_client_config.json index ef22010c1bf4..d1cb8a083d14 100644 --- a/src/Bigtable/Admin/V2/resources/bigtable_table_admin_client_config.json +++ b/src/Bigtable/Admin/V2/resources/bigtable_table_admin_client_config.json @@ -25,6 +25,11 @@ "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, + "CreateTableFromSnapshot": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "ListTables": { "timeout_millis": 60000, "retry_codes_name": "idempotent", @@ -49,6 +54,36 @@ "timeout_millis": 60000, "retry_codes_name": "non_idempotent", "retry_params_name": "default" + }, + "GenerateConsistencyToken": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CheckConsistency": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SnapshotTable": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetSnapshot": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListSnapshots": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteSnapshot": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" } } } diff --git a/src/Bigtable/Admin/V2/resources/bigtable_table_admin_descriptor_config.php b/src/Bigtable/Admin/V2/resources/bigtable_table_admin_descriptor_config.php new file mode 100644 index 000000000000..b8ede8384cef --- /dev/null +++ b/src/Bigtable/Admin/V2/resources/bigtable_table_admin_descriptor_config.php @@ -0,0 +1,32 @@ + [ + 'google.bigtable.admin.v2.BigtableTableAdmin' => [ + 'createTableFromSnapshot' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Bigtable\Admin\V2\Table', + 'metadataReturnType' => '\Google\Cloud\Bigtable\Admin\V2\CreateTableFromSnapshotMetadata', + ], + ], + 'listTables' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getTables', + ], + ], + 'listSnapshots' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getSnapshots', + ], + ], + ], + ], +]; diff --git a/src/Bigtable/Admin/V2/resources/bigtable_table_admin_rest_client_config.php b/src/Bigtable/Admin/V2/resources/bigtable_table_admin_rest_client_config.php new file mode 100644 index 000000000000..ee59e3caff02 --- /dev/null +++ b/src/Bigtable/Admin/V2/resources/bigtable_table_admin_rest_client_config.php @@ -0,0 +1,132 @@ + [ + 'google.bigtable.admin.v2.BigtableTableAdmin' => [ + 'CreateTable' => [ + 'method' => 'post', + 'uri' => '/v2/{parent=projects/*/instances/*}/tables', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'CreateTableFromSnapshot' => [ + 'method' => 'post', + 'uri' => '/v2/{parent=projects/*/instances/*}/tables:createFromSnapshot', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'ListTables' => [ + 'method' => 'get', + 'uri' => '/v2/{parent=projects/*/instances/*}/tables', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'GetTable' => [ + 'method' => 'get', + 'uri' => '/v2/{name=projects/*/instances/*/tables/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'DeleteTable' => [ + 'method' => 'delete', + 'uri' => '/v2/{name=projects/*/instances/*/tables/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'ModifyColumnFamilies' => [ + 'method' => 'post', + 'uri' => '/v2/{name=projects/*/instances/*/tables/*}:modifyColumnFamilies', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'DropRowRange' => [ + 'method' => 'post', + 'uri' => '/v2/{name=projects/*/instances/*/tables/*}:dropRowRange', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'GenerateConsistencyToken' => [ + 'method' => 'post', + 'uri' => '/v2/{name=projects/*/instances/*/tables/*}:generateConsistencyToken', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'CheckConsistency' => [ + 'method' => 'post', + 'uri' => '/v2/{name=projects/*/instances/*/tables/*}:checkConsistency', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'SnapshotTable' => [ + 'method' => 'post', + 'uri' => '/v2/{name=projects/*/instances/*/tables/*}:snapshot', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'GetSnapshot' => [ + 'method' => 'get', + 'uri' => '/v2/{name=projects/*/instances/*/clusters/*/snapshots/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'ListSnapshots' => [ + 'method' => 'get', + 'uri' => '/v2/{parent=projects/*/instances/*/clusters/*}/snapshots', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'DeleteSnapshot' => [ + 'method' => 'delete', + 'uri' => '/v2/{name=projects/*/instances/*/clusters/*/snapshots/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + ], + ], +]; diff --git a/src/Bigtable/V2/Gapic/BigtableGapicClient.php b/src/Bigtable/V2/Gapic/BigtableGapicClient.php index 08eae96b0060..1c912c5451e6 100644 --- a/src/Bigtable/V2/Gapic/BigtableGapicClient.php +++ b/src/Bigtable/V2/Gapic/BigtableGapicClient.php @@ -30,25 +30,26 @@ namespace Google\Cloud\Bigtable\V2\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; -use Google\Cloud\Bigtable\V2\BigtableGrpcClient; use Google\Cloud\Bigtable\V2\CheckAndMutateRowRequest; +use Google\Cloud\Bigtable\V2\CheckAndMutateRowResponse; use Google\Cloud\Bigtable\V2\MutateRowRequest; +use Google\Cloud\Bigtable\V2\MutateRowResponse; use Google\Cloud\Bigtable\V2\MutateRowsRequest; use Google\Cloud\Bigtable\V2\MutateRowsRequest_Entry as Entry; use Google\Cloud\Bigtable\V2\Mutation; use Google\Cloud\Bigtable\V2\ReadModifyWriteRowRequest; +use Google\Cloud\Bigtable\V2\ReadModifyWriteRowResponse; use Google\Cloud\Bigtable\V2\ReadModifyWriteRule; use Google\Cloud\Bigtable\V2\ReadRowsRequest; +use Google\Cloud\Bigtable\V2\ReadRowsResponse; use Google\Cloud\Bigtable\V2\RowFilter; use Google\Cloud\Bigtable\V2\RowSet; use Google\Cloud\Bigtable\V2\SampleRowKeysRequest; -use Google\Cloud\Version; /** * Service Description: Service for reading from and writing to existing Bigtable tables. @@ -83,6 +84,13 @@ */ class BigtableGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.bigtable.v2.Bigtable'; + /** * The default address of the service. */ @@ -105,18 +113,26 @@ class BigtableGapicClient private static $tableNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $bigtableStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/bigtable.data', + 'https://www.googleapis.com/auth/bigtable.data.readonly', + 'https://www.googleapis.com/auth/cloud-bigtable.data', + 'https://www.googleapis.com/auth/cloud-bigtable.data.readonly', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ], + 'clientConfigPath' => __DIR__.'/../resources/bigtable_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/bigtable_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/bigtable_descriptor_config.php', + ]; private static function getTableNameTemplate() { - if (self::$tableNameTemplate == null) { + if (null == self::$tableNameTemplate) { self::$tableNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/tables/{table}'); } @@ -125,7 +141,7 @@ private static function getTableNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'table' => self::getTableNameTemplate(), ]; @@ -134,35 +150,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getGrpcStreamingDescriptors() - { - return [ - 'readRows' => [ - 'grpcStreamingType' => 'ServerStreaming', - ], - 'sampleRowKeys' => [ - 'grpcStreamingType' => 'ServerStreaming', - ], - 'mutateRows' => [ - 'grpcStreamingType' => 'ServerStreaming', - ], - ]; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a table resource. @@ -234,20 +221,23 @@ public static function parseName($formattedName, $template = null) * Default 'bigtable.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. - * Defaults to the scopes for the Google Cloud Bigtable API. + * Defaults to the scopes for the Cloud Bigtable API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. * Specify this setting to specify the retry behavior of all methods on the client. @@ -262,75 +252,23 @@ public static function parseName($formattedName, $template = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/bigtable.data', - 'https://www.googleapis.com/auth/bigtable.data.readonly', - 'https://www.googleapis.com/auth/cloud-bigtable.data', - 'https://www.googleapis.com/auth/cloud-bigtable.data.readonly', - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/bigtable_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'readRows' => $defaultDescriptors, - 'sampleRowKeys' => $defaultDescriptors, - 'mutateRow' => $defaultDescriptors, - 'mutateRows' => $defaultDescriptors, - 'checkAndMutateRow' => $defaultDescriptors, - 'readModifyWriteRow' => $defaultDescriptors, - ]; - $grpcStreamingDescriptors = self::getGrpcStreamingDescriptors(); - foreach ($grpcStreamingDescriptors as $method => $grpcStreamingDescriptor) { - $this->descriptors[$method]['grpcStreamingDescriptor'] = $grpcStreamingDescriptor; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.bigtable.v2.Bigtable', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createBigtableStubFunction = function ($hostname, $opts, $channel) { - return new BigtableGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createBigtableStubFunction', $options)) { - $createBigtableStubFunction = $options['createBigtableStubFunction']; - } - $this->bigtableStub = $this->grpcCredentialsHelper->createStub($createBigtableStubFunction); + $this->setClientOptions($options + self::$clientDefaults); } /** @@ -361,6 +299,14 @@ public function __construct($options = []) * @param array $optionalArgs { * Optional. * + * @type string $appProfileId + * This is a private alpha release of Cloud Bigtable replication. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * This value specifies routing for replication. If not specified, the + * "default" application profile will be used. * @type RowSet $rows * The row keys and/or ranges to read. If not specified, reads from all rows. * @type RowFilter $filter @@ -382,6 +328,9 @@ public function readRows($tableName, $optionalArgs = []) { $request = new ReadRowsRequest(); $request->setTableName($tableName); + if (isset($optionalArgs['appProfileId'])) { + $request->setAppProfileId($optionalArgs['appProfileId']); + } if (isset($optionalArgs['rows'])) { $request->setRows($optionalArgs['rows']); } @@ -392,31 +341,15 @@ public function readRows($tableName, $optionalArgs = []) $request->setRowsLimit($optionalArgs['rowsLimit']); } - if (array_key_exists('timeoutMillis', $optionalArgs)) { - $optionalArgs['retrySettings'] = [ - 'retriesEnabled' => false, - 'noRetriesRpcTimeoutMillis' => $optionalArgs['timeoutMillis'], - ]; - } - - $defaultCallSettings = $this->defaultCallSettings['readRows']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableStub, - 'ReadRows', - $mergedSettings, - $this->descriptors['readRows'] + return $this->transport->startServerStreamingCall( + new Call( + self::SERVICE_NAME.'/ReadRows', + \Google\ApiCore\ServerStream::class, + $request + ), + $this->configureCallSettings('readRows', $optionalArgs), + $this->descriptors['readRows']['grpcStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -446,6 +379,14 @@ public function readRows($tableName, $optionalArgs = []) * @param array $optionalArgs { * Optional. * + * @type string $appProfileId + * This is a private alpha release of Cloud Bigtable replication. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * This value specifies routing for replication. If not specified, the + * "default" application profile will be used. * @type int $timeoutMillis * Timeout to use for this call. * } @@ -459,32 +400,19 @@ public function sampleRowKeys($tableName, $optionalArgs = []) { $request = new SampleRowKeysRequest(); $request->setTableName($tableName); - - if (array_key_exists('timeoutMillis', $optionalArgs)) { - $optionalArgs['retrySettings'] = [ - 'retriesEnabled' => false, - 'noRetriesRpcTimeoutMillis' => $optionalArgs['timeoutMillis'], - ]; + if (isset($optionalArgs['appProfileId'])) { + $request->setAppProfileId($optionalArgs['appProfileId']); } - $defaultCallSettings = $this->defaultCallSettings['sampleRowKeys']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableStub, - 'SampleRowKeys', - $mergedSettings, - $this->descriptors['sampleRowKeys'] + return $this->transport->startServerStreamingCall( + new Call( + self::SERVICE_NAME.'/SampleRowKeys', + \Google\ApiCore\ServerStream::class, + $request + ), + $this->configureCallSettings('sampleRowKeys', $optionalArgs), + $this->descriptors['sampleRowKeys']['grpcStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -514,6 +442,14 @@ public function sampleRowKeys($tableName, $optionalArgs = []) * @param array $optionalArgs { * Optional. * + * @type string $appProfileId + * This is a private alpha release of Cloud Bigtable replication. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * This value specifies routing for replication. If not specified, the + * "default" application profile will be used. * @type \Google\ApiCore\RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array @@ -532,25 +468,18 @@ public function mutateRow($tableName, $rowKey, $mutations, $optionalArgs = []) $request->setTableName($tableName); $request->setRowKey($rowKey); $request->setMutations($mutations); - - $defaultCallSettings = $this->defaultCallSettings['mutateRow']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); + if (isset($optionalArgs['appProfileId'])) { + $request->setAppProfileId($optionalArgs['appProfileId']); } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableStub, - 'MutateRow', - $mergedSettings, - $this->descriptors['mutateRow'] - ); - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/MutateRow', + MutateRowResponse::class, + $request + ), + $this->configureCallSettings('mutateRow', $optionalArgs) + )->wait(); } /** @@ -583,6 +512,14 @@ public function mutateRow($tableName, $rowKey, $mutations, $optionalArgs = []) * @param array $optionalArgs { * Optional. * + * @type string $appProfileId + * This is a private alpha release of Cloud Bigtable replication. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * This value specifies routing for replication. If not specified, the + * "default" application profile will be used. * @type int $timeoutMillis * Timeout to use for this call. * } @@ -597,32 +534,19 @@ public function mutateRows($tableName, $entries, $optionalArgs = []) $request = new MutateRowsRequest(); $request->setTableName($tableName); $request->setEntries($entries); - - if (array_key_exists('timeoutMillis', $optionalArgs)) { - $optionalArgs['retrySettings'] = [ - 'retriesEnabled' => false, - 'noRetriesRpcTimeoutMillis' => $optionalArgs['timeoutMillis'], - ]; + if (isset($optionalArgs['appProfileId'])) { + $request->setAppProfileId($optionalArgs['appProfileId']); } - $defaultCallSettings = $this->defaultCallSettings['mutateRows']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableStub, - 'MutateRows', - $mergedSettings, - $this->descriptors['mutateRows'] + return $this->transport->startServerStreamingCall( + new Call( + self::SERVICE_NAME.'/MutateRows', + \Google\ApiCore\ServerStream::class, + $request + ), + $this->configureCallSettings('mutateRows', $optionalArgs), + $this->descriptors['mutateRows']['grpcStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -648,6 +572,14 @@ public function mutateRows($tableName, $entries, $optionalArgs = []) * @param array $optionalArgs { * Optional. * + * @type string $appProfileId + * This is a private alpha release of Cloud Bigtable replication. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * This value specifies routing for replication. If not specified, the + * "default" application profile will be used. * @type RowFilter $predicateFilter * The filter to be applied to the contents of the specified row. Depending * on whether or not any results are yielded, either `true_mutations` or @@ -682,6 +614,9 @@ public function checkAndMutateRow($tableName, $rowKey, $optionalArgs = []) $request = new CheckAndMutateRowRequest(); $request->setTableName($tableName); $request->setRowKey($rowKey); + if (isset($optionalArgs['appProfileId'])) { + $request->setAppProfileId($optionalArgs['appProfileId']); + } if (isset($optionalArgs['predicateFilter'])) { $request->setPredicateFilter($optionalArgs['predicateFilter']); } @@ -692,32 +627,22 @@ public function checkAndMutateRow($tableName, $rowKey, $optionalArgs = []) $request->setFalseMutations($optionalArgs['falseMutations']); } - $defaultCallSettings = $this->defaultCallSettings['checkAndMutateRow']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableStub, - 'CheckAndMutateRow', - $mergedSettings, - $this->descriptors['checkAndMutateRow'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/CheckAndMutateRow', + CheckAndMutateRowResponse::class, + $request + ), + $this->configureCallSettings('checkAndMutateRow', $optionalArgs) + )->wait(); } /** - * Modifies a row atomically. The method reads the latest existing timestamp - * and value from the specified columns and writes a new entry based on - * pre-defined read/modify/write rules. The new value for the timestamp is the - * greater of the existing timestamp or the current server time. The method - * returns the new contents of all modified cells. + * Modifies a row atomically on the server. The method reads the latest + * existing timestamp and value from the specified columns and writes a new + * entry based on pre-defined read/modify/write rules. The new value for the + * timestamp is the greater of the existing timestamp or the current server + * time. The method returns the new contents of all modified cells. * * Sample code: * ``` @@ -743,6 +668,14 @@ public function checkAndMutateRow($tableName, $rowKey, $optionalArgs = []) * @param array $optionalArgs { * Optional. * + * @type string $appProfileId + * This is a private alpha release of Cloud Bigtable replication. This feature + * is not currently available to most Cloud Bigtable customers. This feature + * might be changed in backward-incompatible ways and is not recommended for + * production use. It is not subject to any SLA or deprecation policy. + * + * This value specifies routing for replication. If not specified, the + * "default" application profile will be used. * @type \Google\ApiCore\RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array @@ -761,25 +694,18 @@ public function readModifyWriteRow($tableName, $rowKey, $rules, $optionalArgs = $request->setTableName($tableName); $request->setRowKey($rowKey); $request->setRules($rules); - - $defaultCallSettings = $this->defaultCallSettings['readModifyWriteRow']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); + if (isset($optionalArgs['appProfileId'])) { + $request->setAppProfileId($optionalArgs['appProfileId']); } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->bigtableStub, - 'ReadModifyWriteRow', - $mergedSettings, - $this->descriptors['readModifyWriteRow'] - ); - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/ReadModifyWriteRow', + ReadModifyWriteRowResponse::class, + $request + ), + $this->configureCallSettings('readModifyWriteRow', $optionalArgs) + )->wait(); } /** @@ -790,11 +716,6 @@ public function readModifyWriteRow($tableName, $rowKey, $rules, $optionalArgs = */ public function close() { - $this->bigtableStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Bigtable/V2/resources/bigtable_descriptor_config.php b/src/Bigtable/V2/resources/bigtable_descriptor_config.php new file mode 100644 index 000000000000..4ec79d17970b --- /dev/null +++ b/src/Bigtable/V2/resources/bigtable_descriptor_config.php @@ -0,0 +1,23 @@ + [ + 'google.bigtable.v2.Bigtable' => [ + 'readRows' => [ + 'grpcStreaming' => [ + 'grpcStreamingType' => 'ServerStreaming', + ], + ], + 'sampleRowKeys' => [ + 'grpcStreaming' => [ + 'grpcStreamingType' => 'ServerStreaming', + ], + ], + 'mutateRows' => [ + 'grpcStreaming' => [ + 'grpcStreamingType' => 'ServerStreaming', + ], + ], + ], + ], +]; diff --git a/src/Bigtable/V2/resources/bigtable_rest_client_config.php b/src/Bigtable/V2/resources/bigtable_rest_client_config.php new file mode 100644 index 000000000000..90df75ea73e4 --- /dev/null +++ b/src/Bigtable/V2/resources/bigtable_rest_client_config.php @@ -0,0 +1,67 @@ + [ + 'google.bigtable.v2.Bigtable' => [ + 'ReadRows' => [ + 'method' => 'post', + 'uri' => '/v2/{table_name=projects/*/instances/*/tables/*}:readRows', + 'body' => '*', + 'placeholders' => [ + 'table_name' => [ + 'getTable_name', + ], + ], + ], + 'SampleRowKeys' => [ + 'method' => 'get', + 'uri' => '/v2/{table_name=projects/*/instances/*/tables/*}:sampleRowKeys', + 'placeholders' => [ + 'table_name' => [ + 'getTable_name', + ], + ], + ], + 'MutateRow' => [ + 'method' => 'post', + 'uri' => '/v2/{table_name=projects/*/instances/*/tables/*}:mutateRow', + 'body' => '*', + 'placeholders' => [ + 'table_name' => [ + 'getTable_name', + ], + ], + ], + 'MutateRows' => [ + 'method' => 'post', + 'uri' => '/v2/{table_name=projects/*/instances/*/tables/*}:mutateRows', + 'body' => '*', + 'placeholders' => [ + 'table_name' => [ + 'getTable_name', + ], + ], + ], + 'CheckAndMutateRow' => [ + 'method' => 'post', + 'uri' => '/v2/{table_name=projects/*/instances/*/tables/*}:checkAndMutateRow', + 'body' => '*', + 'placeholders' => [ + 'table_name' => [ + 'getTable_name', + ], + ], + ], + 'ReadModifyWriteRow' => [ + 'method' => 'post', + 'uri' => '/v2/{table_name=projects/*/instances/*/tables/*}:readModifyWriteRow', + 'body' => '*', + 'placeholders' => [ + 'table_name' => [ + 'getTable_name', + ], + ], + ], + ], + ], +]; diff --git a/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php b/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php index d804cdefef19..526dbb24ff06 100644 --- a/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php +++ b/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php @@ -20,17 +20,22 @@ * This file was generated from the file * https://github.com/google/googleapis/blob/master/google/privacy/dlp/v2beta1/dlp.proto * and updates to that file get reflected here through a refresh process. + * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * + * @experimental */ namespace Google\Cloud\Dlp\V2beta1\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\OperationResponse; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; use Google\Cloud\Dlp\V2beta1\AnalyzeDataSourceRiskRequest; use Google\Cloud\Dlp\V2beta1\BigQueryTable; @@ -38,20 +43,25 @@ use Google\Cloud\Dlp\V2beta1\CreateInspectOperationRequest; use Google\Cloud\Dlp\V2beta1\DeidentifyConfig; use Google\Cloud\Dlp\V2beta1\DeidentifyContentRequest; -use Google\Cloud\Dlp\V2beta1\DlpServiceGrpcClient; +use Google\Cloud\Dlp\V2beta1\DeidentifyContentResponse; use Google\Cloud\Dlp\V2beta1\InspectConfig; use Google\Cloud\Dlp\V2beta1\InspectContentRequest; +use Google\Cloud\Dlp\V2beta1\InspectContentResponse; use Google\Cloud\Dlp\V2beta1\ListInfoTypesRequest; +use Google\Cloud\Dlp\V2beta1\ListInfoTypesResponse; use Google\Cloud\Dlp\V2beta1\ListInspectFindingsRequest; +use Google\Cloud\Dlp\V2beta1\ListInspectFindingsResponse; use Google\Cloud\Dlp\V2beta1\ListRootCategoriesRequest; +use Google\Cloud\Dlp\V2beta1\ListRootCategoriesResponse; use Google\Cloud\Dlp\V2beta1\OperationConfig; use Google\Cloud\Dlp\V2beta1\OutputStorageConfig; use Google\Cloud\Dlp\V2beta1\PrivacyMetric; use Google\Cloud\Dlp\V2beta1\RedactContentRequest; use Google\Cloud\Dlp\V2beta1\RedactContentRequest_ImageRedactionConfig as ImageRedactionConfig; use Google\Cloud\Dlp\V2beta1\RedactContentRequest_ReplaceConfig as ReplaceConfig; +use Google\Cloud\Dlp\V2beta1\RedactContentResponse; use Google\Cloud\Dlp\V2beta1\StorageConfig; -use Google\Cloud\Version; +use Google\LongRunning\Operation; /** * Service Description: The DLP API is a service that allows clients @@ -61,6 +71,10 @@ * The service also includes methods for sensitive data redaction and * scheduling of data scans on Google Cloud Platform based data sets. * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * * This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * @@ -89,9 +103,18 @@ * 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. + * + * @experimental */ class DlpServiceGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.privacy.dlp.v2beta1.DlpService'; + /** * The default address of the service. */ @@ -114,19 +137,23 @@ class DlpServiceGapicClient private static $resultNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $dlpServiceStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/dlp_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/dlp_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/dlp_service_descriptor_config.php', + ]; + private $operationsClient; private static function getResultNameTemplate() { - if (self::$resultNameTemplate == null) { + if (null == self::$resultNameTemplate) { self::$resultNameTemplate = new PathTemplate('inspect/results/{result}'); } @@ -135,7 +162,7 @@ private static function getResultNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'result' => self::getResultNameTemplate(), ]; @@ -144,34 +171,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getLongRunningDescriptors() - { - return [ - 'analyzeDataSourceRisk' => [ - 'operationReturnType' => '\Google\Cloud\Dlp\V2beta1\RiskAnalysisOperationResult', - 'metadataReturnType' => '\Google\Cloud\Dlp\V2beta1\RiskAnalysisOperationMetadata', - ], - 'createInspectOperation' => [ - 'operationReturnType' => '\Google\Cloud\Dlp\V2beta1\InspectOperationResult', - 'metadataReturnType' => '\Google\Cloud\Dlp\V2beta1\InspectOperationMetadata', - ], - ]; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a result resource. @@ -255,12 +254,9 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $lroDescriptors = self::getLongRunningDescriptors(); - if (!is_null($methodName) && array_key_exists($methodName, $lroDescriptors)) { - $options = $lroDescriptors[$methodName]; - } else { - $options = []; - } + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); @@ -277,16 +273,19 @@ public function resumeOperation($operationName, $methodName = null) * Default 'dlp.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -305,81 +304,31 @@ public function resumeOperation($operationName, $methodName = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/dlp_service_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - if (array_key_exists('operationsClient', $options)) { - $this->operationsClient = $options['operationsClient']; - } else { - $operationsClientOptions = $options; - unset($operationsClientOptions['retryingOverride']); - unset($operationsClientOptions['clientConfigPath']); - $this->operationsClient = new OperationsClient($operationsClientOptions); - } - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'inspectContent' => $defaultDescriptors, - 'redactContent' => $defaultDescriptors, - 'deidentifyContent' => $defaultDescriptors, - 'analyzeDataSourceRisk' => $defaultDescriptors, - 'createInspectOperation' => $defaultDescriptors, - 'listInspectFindings' => $defaultDescriptors, - 'listInfoTypes' => $defaultDescriptors, - 'listRootCategories' => $defaultDescriptors, - ]; - $longRunningDescriptors = self::getLongRunningDescriptors(); - foreach ($longRunningDescriptors as $method => $longRunningDescriptor) { - $this->descriptors[$method]['longRunningDescriptor'] = $longRunningDescriptor + ['operationsClient' => $this->operationsClient]; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.privacy.dlp.v2beta1.DlpService', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createDlpServiceStubFunction = function ($hostname, $opts, $channel) { - return new DlpServiceGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createDlpServiceStubFunction', $options)) { - $createDlpServiceStubFunction = $options['createDlpServiceStubFunction']; - } - $this->dlpServiceStub = $this->grpcCredentialsHelper->createStub($createDlpServiceStubFunction); + $options += self::$clientDefaults; + $this->setClientOptions($options); + $this->pluckArray([ + 'serviceName', + 'clientConfigPath', + 'restClientConfigPath', + 'descriptorsConfigPath', + ], $options); + $this->operationsClient = new OperationsClient($options); } /** @@ -433,24 +382,14 @@ public function inspectContent($inspectConfig, $items, $optionalArgs = []) $request->setInspectConfig($inspectConfig); $request->setItems($items); - $defaultCallSettings = $this->defaultCallSettings['inspectContent']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->dlpServiceStub, - 'InspectContent', - $mergedSettings, - $this->descriptors['inspectContent'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/InspectContent', + InspectContentResponse::class, + $request + ), + $this->configureCallSettings('inspectContent', $optionalArgs) + )->wait(); } /** @@ -513,24 +452,14 @@ public function redactContent($inspectConfig, $items, $optionalArgs = []) $request->setImageRedactionConfigs($optionalArgs['imageRedactionConfigs']); } - $defaultCallSettings = $this->defaultCallSettings['redactContent']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->dlpServiceStub, - 'RedactContent', - $mergedSettings, - $this->descriptors['redactContent'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/RedactContent', + RedactContentResponse::class, + $request + ), + $this->configureCallSettings('redactContent', $optionalArgs) + )->wait(); } /** @@ -576,24 +505,14 @@ public function deidentifyContent($deidentifyConfig, $inspectConfig, $items, $op $request->setInspectConfig($inspectConfig); $request->setItems($items); - $defaultCallSettings = $this->defaultCallSettings['deidentifyContent']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->dlpServiceStub, - 'DeidentifyContent', - $mergedSettings, - $this->descriptors['deidentifyContent'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeidentifyContent', + DeidentifyContentResponse::class, + $request + ), + $this->configureCallSettings('deidentifyContent', $optionalArgs) + )->wait(); } /** @@ -660,24 +579,17 @@ public function analyzeDataSourceRisk($privacyMetric, $sourceTable, $optionalArg $request->setPrivacyMetric($privacyMetric); $request->setSourceTable($sourceTable); - $defaultCallSettings = $this->defaultCallSettings['analyzeDataSourceRisk']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->dlpServiceStub, - 'AnalyzeDataSourceRisk', - $mergedSettings, - $this->descriptors['analyzeDataSourceRisk'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startOperationsCall( + new Call( + self::SERVICE_NAME.'/AnalyzeDataSourceRisk', + Operation::class, + $request + ), + $this->configureCallSettings('analyzeDataSourceRisk', $optionalArgs), + $this->descriptors['analyzeDataSourceRisk']['longRunning'] + [ + 'operationsClient' => $this->getOperationsClient(), + ] + )->wait(); } /** @@ -763,24 +675,17 @@ public function createInspectOperation($inspectConfig, $storageConfig, $outputCo $request->setOperationConfig($optionalArgs['operationConfig']); } - $defaultCallSettings = $this->defaultCallSettings['createInspectOperation']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->dlpServiceStub, - 'CreateInspectOperation', - $mergedSettings, - $this->descriptors['createInspectOperation'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startOperationsCall( + new Call( + self::SERVICE_NAME.'/CreateInspectOperation', + Operation::class, + $request + ), + $this->configureCallSettings('createInspectOperation', $optionalArgs), + $this->descriptors['createInspectOperation']['longRunning'] + [ + 'operationsClient' => $this->getOperationsClient(), + ] + )->wait(); } /** @@ -846,24 +751,14 @@ public function listInspectFindings($name, $optionalArgs = []) $request->setFilter($optionalArgs['filter']); } - $defaultCallSettings = $this->defaultCallSettings['listInspectFindings']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->dlpServiceStub, - 'ListInspectFindings', - $mergedSettings, - $this->descriptors['listInspectFindings'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/ListInspectFindings', + ListInspectFindingsResponse::class, + $request + ), + $this->configureCallSettings('listInspectFindings', $optionalArgs) + )->wait(); } /** @@ -906,24 +801,14 @@ public function listInfoTypes($category, $languageCode, $optionalArgs = []) $request->setCategory($category); $request->setLanguageCode($languageCode); - $defaultCallSettings = $this->defaultCallSettings['listInfoTypes']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->dlpServiceStub, - 'ListInfoTypes', - $mergedSettings, - $this->descriptors['listInfoTypes'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/ListInfoTypes', + ListInfoTypesResponse::class, + $request + ), + $this->configureCallSettings('listInfoTypes', $optionalArgs) + )->wait(); } /** @@ -963,24 +848,14 @@ public function listRootCategories($languageCode, $optionalArgs = []) $request = new ListRootCategoriesRequest(); $request->setLanguageCode($languageCode); - $defaultCallSettings = $this->defaultCallSettings['listRootCategories']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->dlpServiceStub, - 'ListRootCategories', - $mergedSettings, - $this->descriptors['listRootCategories'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/ListRootCategories', + ListRootCategoriesResponse::class, + $request + ), + $this->configureCallSettings('listRootCategories', $optionalArgs) + )->wait(); } /** @@ -991,11 +866,6 @@ public function listRootCategories($languageCode, $optionalArgs = []) */ public function close() { - $this->dlpServiceStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Dlp/V2beta1/resources/dlp_service_descriptor_config.php b/src/Dlp/V2beta1/resources/dlp_service_descriptor_config.php new file mode 100644 index 000000000000..2c9faf25cc96 --- /dev/null +++ b/src/Dlp/V2beta1/resources/dlp_service_descriptor_config.php @@ -0,0 +1,20 @@ + [ + 'google.privacy.dlp.v2beta1.DlpService' => [ + 'analyzeDataSourceRisk' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Dlp\V2beta1\RiskAnalysisOperationResult', + 'metadataReturnType' => '\Google\Cloud\Dlp\V2beta1\RiskAnalysisOperationMetadata', + ], + ], + 'createInspectOperation' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Dlp\V2beta1\InspectOperationResult', + 'metadataReturnType' => '\Google\Cloud\Dlp\V2beta1\InspectOperationMetadata', + ], + ], + ], + ], +]; diff --git a/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php b/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php new file mode 100644 index 000000000000..c52ccfeede6a --- /dev/null +++ b/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php @@ -0,0 +1,55 @@ + [ + 'google.privacy.dlp.v2beta1.DlpService' => [ + 'InspectContent' => [ + 'method' => 'post', + 'uri' => '/v2beta1/content:inspect', + 'body' => '*', + ], + 'RedactContent' => [ + 'method' => 'post', + 'uri' => '/v2beta1/content:redact', + 'body' => '*', + ], + 'DeidentifyContent' => [ + 'method' => 'post', + 'uri' => '/v2beta1/content:deidentify', + 'body' => '*', + ], + 'AnalyzeDataSourceRisk' => [ + 'method' => 'post', + 'uri' => '/v2beta1/dataSource:analyze', + 'body' => '*', + ], + 'CreateInspectOperation' => [ + 'method' => 'post', + 'uri' => '/v2beta1/inspect/operations', + 'body' => '*', + ], + 'ListInspectFindings' => [ + 'method' => 'get', + 'uri' => '/v2beta1/{name=inspect/results/*}/findings', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'ListInfoTypes' => [ + 'method' => 'get', + 'uri' => '/v2beta1/rootCategories/{category=*}/infoTypes', + 'placeholders' => [ + 'category' => [ + 'getCategory', + ], + ], + ], + 'ListRootCategories' => [ + 'method' => 'get', + 'uri' => '/v2beta1/rootCategories', + ], + ], + ], +]; diff --git a/src/ErrorReporting/V1beta1/Gapic/ErrorGroupServiceGapicClient.php b/src/ErrorReporting/V1beta1/Gapic/ErrorGroupServiceGapicClient.php index 448251e1d935..fae9e14ea7ae 100644 --- a/src/ErrorReporting/V1beta1/Gapic/ErrorGroupServiceGapicClient.php +++ b/src/ErrorReporting/V1beta1/Gapic/ErrorGroupServiceGapicClient.php @@ -21,26 +21,31 @@ * https://github.com/google/googleapis/blob/master/google/devtools/clouderrorreporting/v1beta1/error_group_service.proto * and updates to that file get reflected here through a refresh process. * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * * @experimental */ namespace Google\Cloud\ErrorReporting\V1beta1\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; use Google\Cloud\ErrorReporting\V1beta1\ErrorGroup; -use Google\Cloud\ErrorReporting\V1beta1\ErrorGroupServiceGrpcClient; use Google\Cloud\ErrorReporting\V1beta1\GetGroupRequest; use Google\Cloud\ErrorReporting\V1beta1\UpdateGroupRequest; -use Google\Cloud\Version; /** * Service Description: Service for retrieving and updating individual error groups. * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * * This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * @@ -58,9 +63,18 @@ * 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. + * + * @experimental */ class ErrorGroupServiceGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.devtools.clouderrorreporting.v1beta1.ErrorGroupService'; + /** * The default address of the service. */ @@ -83,18 +97,21 @@ class ErrorGroupServiceGapicClient private static $groupNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $errorGroupServiceStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/error_group_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/error_group_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/error_group_service_descriptor_config.php', + ]; private static function getGroupNameTemplate() { - if (self::$groupNameTemplate == null) { + if (null == self::$groupNameTemplate) { self::$groupNameTemplate = new PathTemplate('projects/{project}/groups/{group}'); } @@ -103,7 +120,7 @@ private static function getGroupNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'group' => self::getGroupNameTemplate(), ]; @@ -112,20 +129,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a group resource. @@ -195,16 +198,19 @@ public static function parseName($formattedName, $template = null) * Default 'clouderrorreporting.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -223,62 +229,23 @@ public static function parseName($formattedName, $template = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/error_group_service_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'getGroup' => $defaultDescriptors, - 'updateGroup' => $defaultDescriptors, - ]; - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.devtools.clouderrorreporting.v1beta1.ErrorGroupService', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createErrorGroupServiceStubFunction = function ($hostname, $opts, $channel) { - return new ErrorGroupServiceGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createErrorGroupServiceStubFunction', $options)) { - $createErrorGroupServiceStubFunction = $options['createErrorGroupServiceStubFunction']; - } - $this->errorGroupServiceStub = $this->grpcCredentialsHelper->createStub($createErrorGroupServiceStubFunction); + $this->setClientOptions($options + self::$clientDefaults); } /** @@ -323,24 +290,14 @@ public function getGroup($groupName, $optionalArgs = []) $request = new GetGroupRequest(); $request->setGroupName($groupName); - $defaultCallSettings = $this->defaultCallSettings['getGroup']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->errorGroupServiceStub, - 'GetGroup', - $mergedSettings, - $this->descriptors['getGroup'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetGroup', + ErrorGroup::class, + $request + ), + $this->configureCallSettings('getGroup', $optionalArgs) + )->wait(); } /** @@ -379,24 +336,14 @@ public function updateGroup($group, $optionalArgs = []) $request = new UpdateGroupRequest(); $request->setGroup($group); - $defaultCallSettings = $this->defaultCallSettings['updateGroup']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->errorGroupServiceStub, - 'UpdateGroup', - $mergedSettings, - $this->descriptors['updateGroup'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/UpdateGroup', + ErrorGroup::class, + $request + ), + $this->configureCallSettings('updateGroup', $optionalArgs) + )->wait(); } /** @@ -407,11 +354,6 @@ public function updateGroup($group, $optionalArgs = []) */ public function close() { - $this->errorGroupServiceStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php b/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php index 961d9e52e83a..0dcdd0920ac8 100644 --- a/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php +++ b/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php @@ -20,24 +20,29 @@ * This file was generated from the file * https://github.com/google/googleapis/blob/master/google/devtools/clouderrorreporting/v1beta1/error_stats_service.proto * and updates to that file get reflected here through a refresh process. + * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * + * @experimental */ namespace Google\Cloud\ErrorReporting\V1beta1\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; -use Google\ApiCore\PageStreamingDescriptor; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; use Google\Cloud\ErrorReporting\V1beta1\DeleteEventsRequest; -use Google\Cloud\ErrorReporting\V1beta1\ErrorStatsServiceGrpcClient; +use Google\Cloud\ErrorReporting\V1beta1\DeleteEventsResponse; use Google\Cloud\ErrorReporting\V1beta1\ListEventsRequest; +use Google\Cloud\ErrorReporting\V1beta1\ListEventsResponse; use Google\Cloud\ErrorReporting\V1beta1\ListGroupStatsRequest; +use Google\Cloud\ErrorReporting\V1beta1\ListGroupStatsResponse; use Google\Cloud\ErrorReporting\V1beta1\QueryTimeRange; use Google\Cloud\ErrorReporting\V1beta1\ServiceContextFilter; -use Google\Cloud\Version; use Google\Protobuf\Duration; use Google\Protobuf\Timestamp; @@ -45,6 +50,10 @@ * Service Description: An API for retrieving and managing error statistics as well as data for * individual events. * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * * This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * @@ -75,9 +84,18 @@ * 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. + * + * @experimental */ class ErrorStatsServiceGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.devtools.clouderrorreporting.v1beta1.ErrorStatsService'; + /** * The default address of the service. */ @@ -100,18 +118,21 @@ class ErrorStatsServiceGapicClient private static $projectNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $errorStatsServiceStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/error_stats_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/error_stats_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/error_stats_service_descriptor_config.php', + ]; private static function getProjectNameTemplate() { - if (self::$projectNameTemplate == null) { + if (null == self::$projectNameTemplate) { self::$projectNameTemplate = new PathTemplate('projects/{project}'); } @@ -120,7 +141,7 @@ private static function getProjectNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'project' => self::getProjectNameTemplate(), ]; @@ -129,49 +150,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getPageStreamingDescriptors() - { - $listGroupStatsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getErrorGroupStats', - ]); - $listEventsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getErrorEvents', - ]); - - $pageStreamingDescriptors = [ - 'listGroupStats' => $listGroupStatsPageStreamingDescriptor, - 'listEvents' => $listEventsPageStreamingDescriptor, - ]; - - return $pageStreamingDescriptors; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a project resource. @@ -239,16 +217,19 @@ public static function parseName($formattedName, $template = null) * Default 'clouderrorreporting.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -267,67 +248,23 @@ public static function parseName($formattedName, $template = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/error_stats_service_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'listGroupStats' => $defaultDescriptors, - 'listEvents' => $defaultDescriptors, - 'deleteEvents' => $defaultDescriptors, - ]; - $pageStreamingDescriptors = self::getPageStreamingDescriptors(); - foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { - $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.devtools.clouderrorreporting.v1beta1.ErrorStatsService', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createErrorStatsServiceStubFunction = function ($hostname, $opts, $channel) { - return new ErrorStatsServiceGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createErrorStatsServiceStubFunction', $options)) { - $createErrorStatsServiceStubFunction = $options['createErrorStatsServiceStubFunction']; - } - $this->errorStatsServiceStub = $this->grpcCredentialsHelper->createStub($createErrorStatsServiceStubFunction); + $this->setClientOptions($options + self::$clientDefaults); } /** @@ -444,24 +381,15 @@ public function listGroupStats($projectName, $timeRange, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listGroupStats']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->errorStatsServiceStub, - 'ListGroupStats', - $mergedSettings, - $this->descriptors['listGroupStats'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListGroupStats', + ListGroupStatsResponse::class, + $request + ), + $this->configureCallSettings('listGroupStats', $optionalArgs), + $this->descriptors['listGroupStats']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -547,24 +475,15 @@ public function listEvents($projectName, $groupId, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listEvents']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->errorStatsServiceStub, - 'ListEvents', - $mergedSettings, - $this->descriptors['listEvents'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListEvents', + ListEventsResponse::class, + $request + ), + $this->configureCallSettings('listEvents', $optionalArgs), + $this->descriptors['listEvents']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -606,24 +525,14 @@ public function deleteEvents($projectName, $optionalArgs = []) $request = new DeleteEventsRequest(); $request->setProjectName($projectName); - $defaultCallSettings = $this->defaultCallSettings['deleteEvents']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->errorStatsServiceStub, - 'DeleteEvents', - $mergedSettings, - $this->descriptors['deleteEvents'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteEvents', + DeleteEventsResponse::class, + $request + ), + $this->configureCallSettings('deleteEvents', $optionalArgs) + )->wait(); } /** @@ -634,11 +543,6 @@ public function deleteEvents($projectName, $optionalArgs = []) */ public function close() { - $this->errorStatsServiceStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php b/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php index 65c5e6897794..989fff9d3863 100644 --- a/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php +++ b/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php @@ -20,24 +20,32 @@ * This file was generated from the file * https://github.com/google/googleapis/blob/master/google/devtools/clouderrorreporting/v1beta1/report_errors_service.proto * and updates to that file get reflected here through a refresh process. + * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * + * @experimental */ namespace Google\Cloud\ErrorReporting\V1beta1\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; use Google\Cloud\ErrorReporting\V1beta1\ReportErrorEventRequest; -use Google\Cloud\ErrorReporting\V1beta1\ReportErrorsServiceGrpcClient; +use Google\Cloud\ErrorReporting\V1beta1\ReportErrorEventResponse; use Google\Cloud\ErrorReporting\V1beta1\ReportedErrorEvent; -use Google\Cloud\Version; /** * Service Description: An API for reporting error events. * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * * This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * @@ -56,9 +64,18 @@ * 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. + * + * @experimental */ class ReportErrorsServiceGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.devtools.clouderrorreporting.v1beta1.ReportErrorsService'; + /** * The default address of the service. */ @@ -81,18 +98,21 @@ class ReportErrorsServiceGapicClient private static $projectNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $reportErrorsServiceStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/report_errors_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/report_errors_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/report_errors_service_descriptor_config.php', + ]; private static function getProjectNameTemplate() { - if (self::$projectNameTemplate == null) { + if (null == self::$projectNameTemplate) { self::$projectNameTemplate = new PathTemplate('projects/{project}'); } @@ -101,7 +121,7 @@ private static function getProjectNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'project' => self::getProjectNameTemplate(), ]; @@ -110,20 +130,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a project resource. @@ -191,16 +197,19 @@ public static function parseName($formattedName, $template = null) * Default 'clouderrorreporting.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -219,61 +228,23 @@ public static function parseName($formattedName, $template = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/report_errors_service_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'reportErrorEvent' => $defaultDescriptors, - ]; - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.devtools.clouderrorreporting.v1beta1.ReportErrorsService', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createReportErrorsServiceStubFunction = function ($hostname, $opts, $channel) { - return new ReportErrorsServiceGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createReportErrorsServiceStubFunction', $options)) { - $createReportErrorsServiceStubFunction = $options['createReportErrorsServiceStubFunction']; - } - $this->reportErrorsServiceStub = $this->grpcCredentialsHelper->createStub($createReportErrorsServiceStubFunction); + $this->setClientOptions($options + self::$clientDefaults); } /** @@ -324,24 +295,14 @@ public function reportErrorEvent($projectName, $event, $optionalArgs = []) $request->setProjectName($projectName); $request->setEvent($event); - $defaultCallSettings = $this->defaultCallSettings['reportErrorEvent']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->reportErrorsServiceStub, - 'ReportErrorEvent', - $mergedSettings, - $this->descriptors['reportErrorEvent'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/ReportErrorEvent', + ReportErrorEventResponse::class, + $request + ), + $this->configureCallSettings('reportErrorEvent', $optionalArgs) + )->wait(); } /** @@ -352,11 +313,6 @@ public function reportErrorEvent($projectName, $event, $optionalArgs = []) */ public function close() { - $this->reportErrorsServiceStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/ErrorReporting/V1beta1/resources/error_group_service_descriptor_config.php b/src/ErrorReporting/V1beta1/resources/error_group_service_descriptor_config.php new file mode 100644 index 000000000000..3a89cb7b4ca8 --- /dev/null +++ b/src/ErrorReporting/V1beta1/resources/error_group_service_descriptor_config.php @@ -0,0 +1,8 @@ + [ + 'google.devtools.clouderrorreporting.v1beta1.ErrorGroupService' => [ + ], + ], +]; diff --git a/src/ErrorReporting/V1beta1/resources/error_group_service_rest_client_config.php b/src/ErrorReporting/V1beta1/resources/error_group_service_rest_client_config.php new file mode 100644 index 000000000000..099e7a8b836f --- /dev/null +++ b/src/ErrorReporting/V1beta1/resources/error_group_service_rest_client_config.php @@ -0,0 +1,28 @@ + [ + 'google.devtools.clouderrorreporting.v1beta1.ErrorGroupService' => [ + 'GetGroup' => [ + 'method' => 'get', + 'uri' => '/v1beta1/{group_name=projects/*/groups/*}', + 'placeholders' => [ + 'group_name' => [ + 'getGroup_name', + ], + ], + ], + 'UpdateGroup' => [ + 'method' => 'put', + 'uri' => '/v1beta1/{group.name=projects/*/groups/*}', + 'body' => 'group', + 'placeholders' => [ + 'group.name' => [ + 'getGroup', + 'getName', + ], + ], + ], + ], + ], +]; diff --git a/src/ErrorReporting/V1beta1/resources/error_stats_service_descriptor_config.php b/src/ErrorReporting/V1beta1/resources/error_stats_service_descriptor_config.php new file mode 100644 index 000000000000..14f1b47a87bf --- /dev/null +++ b/src/ErrorReporting/V1beta1/resources/error_stats_service_descriptor_config.php @@ -0,0 +1,28 @@ + [ + 'google.devtools.clouderrorreporting.v1beta1.ErrorStatsService' => [ + 'listGroupStats' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getErrorGroupStats', + ], + ], + 'listEvents' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getErrorEvents', + ], + ], + ], + ], +]; diff --git a/src/ErrorReporting/V1beta1/resources/error_stats_service_rest_client_config.php b/src/ErrorReporting/V1beta1/resources/error_stats_service_rest_client_config.php new file mode 100644 index 000000000000..4d422839f6c9 --- /dev/null +++ b/src/ErrorReporting/V1beta1/resources/error_stats_service_rest_client_config.php @@ -0,0 +1,35 @@ + [ + 'google.devtools.clouderrorreporting.v1beta1.ErrorStatsService' => [ + 'ListGroupStats' => [ + 'method' => 'get', + 'uri' => '/v1beta1/{project_name=projects/*}/groupStats', + 'placeholders' => [ + 'project_name' => [ + 'getProject_name', + ], + ], + ], + 'ListEvents' => [ + 'method' => 'get', + 'uri' => '/v1beta1/{project_name=projects/*}/events', + 'placeholders' => [ + 'project_name' => [ + 'getProject_name', + ], + ], + ], + 'DeleteEvents' => [ + 'method' => 'delete', + 'uri' => '/v1beta1/{project_name=projects/*}/events', + 'placeholders' => [ + 'project_name' => [ + 'getProject_name', + ], + ], + ], + ], + ], +]; diff --git a/src/ErrorReporting/V1beta1/resources/report_errors_service_descriptor_config.php b/src/ErrorReporting/V1beta1/resources/report_errors_service_descriptor_config.php new file mode 100644 index 000000000000..f24982788ee1 --- /dev/null +++ b/src/ErrorReporting/V1beta1/resources/report_errors_service_descriptor_config.php @@ -0,0 +1,8 @@ + [ + 'google.devtools.clouderrorreporting.v1beta1.ReportErrorsService' => [ + ], + ], +]; diff --git a/src/ErrorReporting/V1beta1/resources/report_errors_service_rest_client_config.php b/src/ErrorReporting/V1beta1/resources/report_errors_service_rest_client_config.php new file mode 100644 index 000000000000..75b3cb2155bd --- /dev/null +++ b/src/ErrorReporting/V1beta1/resources/report_errors_service_rest_client_config.php @@ -0,0 +1,18 @@ + [ + 'google.devtools.clouderrorreporting.v1beta1.ReportErrorsService' => [ + 'ReportErrorEvent' => [ + 'method' => 'post', + 'uri' => '/v1beta1/{project_name=projects/*}/events:report', + 'body' => 'event', + 'placeholders' => [ + 'project_name' => [ + 'getProject_name', + ], + ], + ], + ], + ], +]; diff --git a/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php b/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php index 8b88f6eac373..72ad8705c5b1 100644 --- a/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php +++ b/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php @@ -30,25 +30,27 @@ namespace Google\Cloud\Firestore\V1beta1\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; -use Google\ApiCore\PageStreamingDescriptor; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; use Google\Cloud\Firestore\V1beta1\BatchGetDocumentsRequest; use Google\Cloud\Firestore\V1beta1\BeginTransactionRequest; +use Google\Cloud\Firestore\V1beta1\BeginTransactionResponse; use Google\Cloud\Firestore\V1beta1\CommitRequest; +use Google\Cloud\Firestore\V1beta1\CommitResponse; use Google\Cloud\Firestore\V1beta1\CreateDocumentRequest; use Google\Cloud\Firestore\V1beta1\DeleteDocumentRequest; use Google\Cloud\Firestore\V1beta1\Document; use Google\Cloud\Firestore\V1beta1\DocumentMask; -use Google\Cloud\Firestore\V1beta1\FirestoreGrpcClient; use Google\Cloud\Firestore\V1beta1\GetDocumentRequest; use Google\Cloud\Firestore\V1beta1\ListCollectionIdsRequest; +use Google\Cloud\Firestore\V1beta1\ListCollectionIdsResponse; use Google\Cloud\Firestore\V1beta1\ListDocumentsRequest; +use Google\Cloud\Firestore\V1beta1\ListDocumentsResponse; use Google\Cloud\Firestore\V1beta1\ListenRequest; +use Google\Cloud\Firestore\V1beta1\ListenResponse; use Google\Cloud\Firestore\V1beta1\Precondition; use Google\Cloud\Firestore\V1beta1\RollbackRequest; use Google\Cloud\Firestore\V1beta1\RunQueryRequest; @@ -58,7 +60,8 @@ use Google\Cloud\Firestore\V1beta1\UpdateDocumentRequest; use Google\Cloud\Firestore\V1beta1\Write; use Google\Cloud\Firestore\V1beta1\WriteRequest; -use Google\Cloud\Version; +use Google\Cloud\Firestore\V1beta1\WriteResponse; +use Google\Protobuf\GPBEmpty; use Google\Protobuf\Timestamp; /** @@ -105,6 +108,13 @@ */ class FirestoreGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.firestore.v1beta1.Firestore'; + /** * The default address of the service. */ @@ -130,18 +140,22 @@ class FirestoreGapicClient private static $documentPathNameTemplate; private static $anyPathNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $firestoreStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/datastore', + ], + 'clientConfigPath' => __DIR__.'/../resources/firestore_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/firestore_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/firestore_descriptor_config.php', + ]; private static function getDatabaseRootNameTemplate() { - if (self::$databaseRootNameTemplate == null) { + if (null == self::$databaseRootNameTemplate) { self::$databaseRootNameTemplate = new PathTemplate('projects/{project}/databases/{database}'); } @@ -150,7 +164,7 @@ private static function getDatabaseRootNameTemplate() private static function getDocumentRootNameTemplate() { - if (self::$documentRootNameTemplate == null) { + if (null == self::$documentRootNameTemplate) { self::$documentRootNameTemplate = new PathTemplate('projects/{project}/databases/{database}/documents'); } @@ -159,7 +173,7 @@ private static function getDocumentRootNameTemplate() private static function getDocumentPathNameTemplate() { - if (self::$documentPathNameTemplate == null) { + if (null == self::$documentPathNameTemplate) { self::$documentPathNameTemplate = new PathTemplate('projects/{project}/databases/{database}/documents/{document_path=**}'); } @@ -168,7 +182,7 @@ private static function getDocumentPathNameTemplate() private static function getAnyPathNameTemplate() { - if (self::$anyPathNameTemplate == null) { + if (null == self::$anyPathNameTemplate) { self::$anyPathNameTemplate = new PathTemplate('projects/{project}/databases/{database}/documents/{document}/{any_path=**}'); } @@ -177,7 +191,7 @@ private static function getAnyPathNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'databaseRoot' => self::getDatabaseRootNameTemplate(), 'documentRoot' => self::getDocumentRootNameTemplate(), @@ -189,67 +203,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getPageStreamingDescriptors() - { - $listDocumentsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getDocuments', - ]); - $listCollectionIdsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getCollectionIds', - ]); - - $pageStreamingDescriptors = [ - 'listDocuments' => $listDocumentsPageStreamingDescriptor, - 'listCollectionIds' => $listCollectionIdsPageStreamingDescriptor, - ]; - - return $pageStreamingDescriptors; - } - - private static function getGrpcStreamingDescriptors() - { - return [ - 'batchGetDocuments' => [ - 'grpcStreamingType' => 'ServerStreaming', - ], - 'runQuery' => [ - 'grpcStreamingType' => 'ServerStreaming', - ], - 'write' => [ - 'grpcStreamingType' => 'BidiStreaming', - ], - 'listen' => [ - 'grpcStreamingType' => 'BidiStreaming', - ], - ]; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a database_root resource. @@ -382,16 +335,19 @@ public static function parseName($formattedName, $template = null) * Default 'firestore.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -410,82 +366,23 @@ public static function parseName($formattedName, $template = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/datastore', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/firestore_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'getDocument' => $defaultDescriptors, - 'listDocuments' => $defaultDescriptors, - 'createDocument' => $defaultDescriptors, - 'updateDocument' => $defaultDescriptors, - 'deleteDocument' => $defaultDescriptors, - 'batchGetDocuments' => $defaultDescriptors, - 'beginTransaction' => $defaultDescriptors, - 'commit' => $defaultDescriptors, - 'rollback' => $defaultDescriptors, - 'runQuery' => $defaultDescriptors, - 'write' => $defaultDescriptors, - 'listen' => $defaultDescriptors, - 'listCollectionIds' => $defaultDescriptors, - ]; - $pageStreamingDescriptors = self::getPageStreamingDescriptors(); - foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { - $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; - } - $grpcStreamingDescriptors = self::getGrpcStreamingDescriptors(); - foreach ($grpcStreamingDescriptors as $method => $grpcStreamingDescriptor) { - $this->descriptors[$method]['grpcStreamingDescriptor'] = $grpcStreamingDescriptor; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.firestore.v1beta1.Firestore', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createFirestoreStubFunction = function ($hostname, $opts, $channel) { - return new FirestoreGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createFirestoreStubFunction', $options)) { - $createFirestoreStubFunction = $options['createFirestoreStubFunction']; - } - $this->firestoreStub = $this->grpcCredentialsHelper->createStub($createFirestoreStubFunction); + $this->setClientOptions($options + self::$clientDefaults); } /** @@ -543,24 +440,14 @@ public function getDocument($name, $optionalArgs = []) $request->setReadTime($optionalArgs['readTime']); } - $defaultCallSettings = $this->defaultCallSettings['getDocument']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->firestoreStub, - 'GetDocument', - $mergedSettings, - $this->descriptors['getDocument'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetDocument', + Document::class, + $request + ), + $this->configureCallSettings('getDocument', $optionalArgs) + )->wait(); } /** @@ -669,24 +556,15 @@ public function listDocuments($parent, $collectionId, $optionalArgs = []) $request->setShowMissing($optionalArgs['showMissing']); } - $defaultCallSettings = $this->defaultCallSettings['listDocuments']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->firestoreStub, - 'ListDocuments', - $mergedSettings, - $this->descriptors['listDocuments'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListDocuments', + ListDocumentsResponse::class, + $request + ), + $this->configureCallSettings('listDocuments', $optionalArgs), + $this->descriptors['listDocuments']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -745,24 +623,14 @@ public function createDocument($parent, $collectionId, $documentId, $document, $ $request->setMask($optionalArgs['mask']); } - $defaultCallSettings = $this->defaultCallSettings['createDocument']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->firestoreStub, - 'CreateDocument', - $mergedSettings, - $this->descriptors['createDocument'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/CreateDocument', + Document::class, + $request + ), + $this->configureCallSettings('createDocument', $optionalArgs) + )->wait(); } /** @@ -824,24 +692,14 @@ public function updateDocument($document, $updateMask, $optionalArgs = []) $request->setCurrentDocument($optionalArgs['currentDocument']); } - $defaultCallSettings = $this->defaultCallSettings['updateDocument']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->firestoreStub, - 'UpdateDocument', - $mergedSettings, - $this->descriptors['updateDocument'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/UpdateDocument', + Document::class, + $request + ), + $this->configureCallSettings('updateDocument', $optionalArgs) + )->wait(); } /** @@ -884,24 +742,14 @@ public function deleteDocument($name, $optionalArgs = []) $request->setCurrentDocument($optionalArgs['currentDocument']); } - $defaultCallSettings = $this->defaultCallSettings['deleteDocument']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->firestoreStub, - 'DeleteDocument', - $mergedSettings, - $this->descriptors['deleteDocument'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteDocument', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteDocument', $optionalArgs) + )->wait(); } /** @@ -977,31 +825,15 @@ public function batchGetDocuments($database, $documents, $optionalArgs = []) $request->setReadTime($optionalArgs['readTime']); } - if (array_key_exists('timeoutMillis', $optionalArgs)) { - $optionalArgs['retrySettings'] = [ - 'retriesEnabled' => false, - 'noRetriesRpcTimeoutMillis' => $optionalArgs['timeoutMillis'], - ]; - } - - $defaultCallSettings = $this->defaultCallSettings['batchGetDocuments']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->firestoreStub, - 'BatchGetDocuments', - $mergedSettings, - $this->descriptors['batchGetDocuments'] + return $this->transport->startServerStreamingCall( + new Call( + self::SERVICE_NAME.'/BatchGetDocuments', + \Google\ApiCore\ServerStream::class, + $request + ), + $this->configureCallSettings('batchGetDocuments', $optionalArgs), + $this->descriptors['batchGetDocuments']['grpcStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -1046,24 +878,14 @@ public function beginTransaction($database, $optionalArgs = []) $request->setOptions($optionalArgs['options']); } - $defaultCallSettings = $this->defaultCallSettings['beginTransaction']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->firestoreStub, - 'BeginTransaction', - $mergedSettings, - $this->descriptors['beginTransaction'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/BeginTransaction', + BeginTransactionResponse::class, + $request + ), + $this->configureCallSettings('beginTransaction', $optionalArgs) + )->wait(); } /** @@ -1112,24 +934,14 @@ public function commit($database, $writes, $optionalArgs = []) $request->setTransaction($optionalArgs['transaction']); } - $defaultCallSettings = $this->defaultCallSettings['commit']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->firestoreStub, - 'Commit', - $mergedSettings, - $this->descriptors['commit'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/Commit', + CommitResponse::class, + $request + ), + $this->configureCallSettings('commit', $optionalArgs) + )->wait(); } /** @@ -1169,24 +981,14 @@ public function rollback($database, $transaction, $optionalArgs = []) $request->setDatabase($database); $request->setTransaction($transaction); - $defaultCallSettings = $this->defaultCallSettings['rollback']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->firestoreStub, - 'Rollback', - $mergedSettings, - $this->descriptors['rollback'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/Rollback', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('rollback', $optionalArgs) + )->wait(); } /** @@ -1254,31 +1056,15 @@ public function runQuery($parent, $optionalArgs = []) $request->setReadTime($optionalArgs['readTime']); } - if (array_key_exists('timeoutMillis', $optionalArgs)) { - $optionalArgs['retrySettings'] = [ - 'retriesEnabled' => false, - 'noRetriesRpcTimeoutMillis' => $optionalArgs['timeoutMillis'], - ]; - } - - $defaultCallSettings = $this->defaultCallSettings['runQuery']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->firestoreStub, - 'RunQuery', - $mergedSettings, - $this->descriptors['runQuery'] + return $this->transport->startServerStreamingCall( + new Call( + self::SERVICE_NAME.'/RunQuery', + \Google\ApiCore\ServerStream::class, + $request + ), + $this->configureCallSettings('runQuery', $optionalArgs), + $this->descriptors['runQuery']['grpcStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -1336,31 +1122,14 @@ public function runQuery($parent, $optionalArgs = []) */ public function write($optionalArgs = []) { - if (array_key_exists('timeoutMillis', $optionalArgs)) { - $optionalArgs['retrySettings'] = [ - 'retriesEnabled' => false, - 'noRetriesRpcTimeoutMillis' => $optionalArgs['timeoutMillis'], - ]; - } - - $defaultCallSettings = $this->defaultCallSettings['write']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->firestoreStub, - 'Write', - $mergedSettings, - $this->descriptors['write'] + return $this->transport->startBidiStreamingCall( + new Call( + self::SERVICE_NAME.'/Write', + WriteResponse::class + ), + $this->configureCallSettings('write', $optionalArgs), + $this->descriptors['write']['grpcStreaming'] ); - - return $callable( - null, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -1418,31 +1187,14 @@ public function write($optionalArgs = []) */ public function listen($optionalArgs = []) { - if (array_key_exists('timeoutMillis', $optionalArgs)) { - $optionalArgs['retrySettings'] = [ - 'retriesEnabled' => false, - 'noRetriesRpcTimeoutMillis' => $optionalArgs['timeoutMillis'], - ]; - } - - $defaultCallSettings = $this->defaultCallSettings['listen']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->firestoreStub, - 'Listen', - $mergedSettings, - $this->descriptors['listen'] + return $this->transport->startBidiStreamingCall( + new Call( + self::SERVICE_NAME.'/Listen', + ListenResponse::class + ), + $this->configureCallSettings('listen', $optionalArgs), + $this->descriptors['listen']['grpcStreaming'] ); - - return $callable( - null, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -1510,24 +1262,15 @@ public function listCollectionIds($parent, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listCollectionIds']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->firestoreStub, - 'ListCollectionIds', - $mergedSettings, - $this->descriptors['listCollectionIds'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListCollectionIds', + ListCollectionIdsResponse::class, + $request + ), + $this->configureCallSettings('listCollectionIds', $optionalArgs), + $this->descriptors['listCollectionIds']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -1538,11 +1281,6 @@ public function listCollectionIds($parent, $optionalArgs = []) */ public function close() { - $this->firestoreStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Firestore/V1beta1/resources/firestore_descriptor_config.php b/src/Firestore/V1beta1/resources/firestore_descriptor_config.php new file mode 100644 index 000000000000..c92d6bacdc23 --- /dev/null +++ b/src/Firestore/V1beta1/resources/firestore_descriptor_config.php @@ -0,0 +1,48 @@ + [ + 'google.firestore.v1beta1.Firestore' => [ + 'listDocuments' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getDocuments', + ], + ], + 'listCollectionIds' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getCollectionIds', + ], + ], + 'batchGetDocuments' => [ + 'grpcStreaming' => [ + 'grpcStreamingType' => 'ServerStreaming', + ], + ], + 'runQuery' => [ + 'grpcStreaming' => [ + 'grpcStreamingType' => 'ServerStreaming', + ], + ], + 'write' => [ + 'grpcStreaming' => [ + 'grpcStreamingType' => 'BidiStreaming', + ], + ], + 'listen' => [ + 'grpcStreaming' => [ + 'grpcStreamingType' => 'BidiStreaming', + ], + ], + ], + ], +]; diff --git a/src/Firestore/V1beta1/resources/firestore_rest_client_config.php b/src/Firestore/V1beta1/resources/firestore_rest_client_config.php new file mode 100644 index 000000000000..52d9d22eb13f --- /dev/null +++ b/src/Firestore/V1beta1/resources/firestore_rest_client_config.php @@ -0,0 +1,122 @@ + [ + 'google.firestore.v1beta1.Firestore' => [ + 'GetDocument' => [ + 'method' => 'get', + 'uri' => '/v1beta1/{name=projects/*/databases/*/documents/*/**}', + 'placeholders' => [ + 'name' => [ + 'getName', + ] + ] + ], + 'ListDocuments' => [ + 'method' => 'get', + 'uri' => '/v1beta1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ] + 'collection_id' => [ + 'getCollection_id', + ] + ] + ], + 'CreateDocument' => [ + 'method' => 'post', + 'uri' => '/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}', + 'body' => 'document', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ] + 'collection_id' => [ + 'getCollection_id', + ] + ] + ], + 'UpdateDocument' => [ + 'method' => 'patch', + 'uri' => '/v1beta1/{document.name=projects/*/databases/*/documents/*/**}', + 'body' => 'document', + 'placeholders' => [ + 'document.name' => [ + 'getDocument', + 'getName', + ] + ] + ], + 'DeleteDocument' => [ + 'method' => 'delete', + 'uri' => '/v1beta1/{name=projects/*/databases/*/documents/*/**}', + 'placeholders' => [ + 'name' => [ + 'getName', + ] + ] + ], + 'BatchGetDocuments' => [ + 'method' => 'post', + 'uri' => '/v1beta1/{database=projects/*/databases/*}/documents:batchGet', + 'body' => '*', + 'placeholders' => [ + 'database' => [ + 'getDatabase', + ] + ] + ], + 'BeginTransaction' => [ + 'method' => 'post', + 'uri' => '/v1beta1/{database=projects/*/databases/*}/documents:beginTransaction', + 'body' => '*', + 'placeholders' => [ + 'database' => [ + 'getDatabase', + ] + ] + ], + 'Commit' => [ + 'method' => 'post', + 'uri' => '/v1beta1/{database=projects/*/databases/*}/documents:commit', + 'body' => '*', + 'placeholders' => [ + 'database' => [ + 'getDatabase', + ] + ] + ], + 'Rollback' => [ + 'method' => 'post', + 'uri' => '/v1beta1/{database=projects/*/databases/*}/documents:rollback', + 'body' => '*', + 'placeholders' => [ + 'database' => [ + 'getDatabase', + ] + ] + ], + 'RunQuery' => [ + 'method' => 'post', + 'uri' => '/v1beta1/{parent=projects/*/databases/*/documents}:runQuery', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ] + ] + ], + 'ListCollectionIds' => [ + 'method' => 'post', + 'uri' => '/v1beta1/{parent=projects/*/databases/*/documents}:listCollectionIds', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ] + ] + ], + ] + ] +]; \ No newline at end of file diff --git a/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php b/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php index 4e520cc8737b..dea725026916 100644 --- a/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php +++ b/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php @@ -30,21 +30,24 @@ namespace Google\Cloud\Language\V1beta2\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\Cloud\Language\V1beta2\AnalyzeEntitiesRequest; +use Google\Cloud\Language\V1beta2\AnalyzeEntitiesResponse; use Google\Cloud\Language\V1beta2\AnalyzeEntitySentimentRequest; +use Google\Cloud\Language\V1beta2\AnalyzeEntitySentimentResponse; use Google\Cloud\Language\V1beta2\AnalyzeSentimentRequest; +use Google\Cloud\Language\V1beta2\AnalyzeSentimentResponse; use Google\Cloud\Language\V1beta2\AnalyzeSyntaxRequest; +use Google\Cloud\Language\V1beta2\AnalyzeSyntaxResponse; use Google\Cloud\Language\V1beta2\AnnotateTextRequest; use Google\Cloud\Language\V1beta2\AnnotateTextRequest_Features as Features; +use Google\Cloud\Language\V1beta2\AnnotateTextResponse; use Google\Cloud\Language\V1beta2\ClassifyTextRequest; +use Google\Cloud\Language\V1beta2\ClassifyTextResponse; use Google\Cloud\Language\V1beta2\Document; use Google\Cloud\Language\V1beta2\EncodingType; -use Google\Cloud\Language\V1beta2\LanguageServiceGrpcClient; -use Google\Cloud\Version; /** * Service Description: Provides text analysis operations such as sentiment analysis and entity @@ -71,6 +74,13 @@ */ class LanguageServiceGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.cloud.language.v1beta2.LanguageService'; + /** * The default address of the service. */ @@ -91,28 +101,17 @@ class LanguageServiceGapicClient */ const CODEGEN_VERSION = '0.0.5'; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $languageServiceStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/language_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/language_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/language_service_descriptor_config.php', + ]; /** * Constructor. @@ -124,16 +123,19 @@ private static function getGapicVersion() * Default 'language.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -152,66 +154,23 @@ private static function getGapicVersion() * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/language_service_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'analyzeSentiment' => $defaultDescriptors, - 'analyzeEntities' => $defaultDescriptors, - 'analyzeEntitySentiment' => $defaultDescriptors, - 'analyzeSyntax' => $defaultDescriptors, - 'classifyText' => $defaultDescriptors, - 'annotateText' => $defaultDescriptors, - ]; - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.cloud.language.v1beta2.LanguageService', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createLanguageServiceStubFunction = function ($hostname, $opts, $channel) { - return new LanguageServiceGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createLanguageServiceStubFunction', $options)) { - $createLanguageServiceStubFunction = $options['createLanguageServiceStubFunction']; - } - $this->languageServiceStub = $this->grpcCredentialsHelper->createStub($createLanguageServiceStubFunction); + $this->setClientOptions($options + self::$clientDefaults); } /** @@ -256,24 +215,14 @@ public function analyzeSentiment($document, $optionalArgs = []) $request->setEncodingType($optionalArgs['encodingType']); } - $defaultCallSettings = $this->defaultCallSettings['analyzeSentiment']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->languageServiceStub, - 'AnalyzeSentiment', - $mergedSettings, - $this->descriptors['analyzeSentiment'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/AnalyzeSentiment', + AnalyzeSentimentResponse::class, + $request + ), + $this->configureCallSettings('analyzeSentiment', $optionalArgs) + )->wait(); } /** @@ -319,24 +268,14 @@ public function analyzeEntities($document, $optionalArgs = []) $request->setEncodingType($optionalArgs['encodingType']); } - $defaultCallSettings = $this->defaultCallSettings['analyzeEntities']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->languageServiceStub, - 'AnalyzeEntities', - $mergedSettings, - $this->descriptors['analyzeEntities'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/AnalyzeEntities', + AnalyzeEntitiesResponse::class, + $request + ), + $this->configureCallSettings('analyzeEntities', $optionalArgs) + )->wait(); } /** @@ -381,24 +320,14 @@ public function analyzeEntitySentiment($document, $optionalArgs = []) $request->setEncodingType($optionalArgs['encodingType']); } - $defaultCallSettings = $this->defaultCallSettings['analyzeEntitySentiment']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->languageServiceStub, - 'AnalyzeEntitySentiment', - $mergedSettings, - $this->descriptors['analyzeEntitySentiment'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/AnalyzeEntitySentiment', + AnalyzeEntitySentimentResponse::class, + $request + ), + $this->configureCallSettings('analyzeEntitySentiment', $optionalArgs) + )->wait(); } /** @@ -444,24 +373,14 @@ public function analyzeSyntax($document, $optionalArgs = []) $request->setEncodingType($optionalArgs['encodingType']); } - $defaultCallSettings = $this->defaultCallSettings['analyzeSyntax']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->languageServiceStub, - 'AnalyzeSyntax', - $mergedSettings, - $this->descriptors['analyzeSyntax'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/AnalyzeSyntax', + AnalyzeSyntaxResponse::class, + $request + ), + $this->configureCallSettings('analyzeSyntax', $optionalArgs) + )->wait(); } /** @@ -499,24 +418,14 @@ public function classifyText($document, $optionalArgs = []) $request = new ClassifyTextRequest(); $request->setDocument($document); - $defaultCallSettings = $this->defaultCallSettings['classifyText']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->languageServiceStub, - 'ClassifyText', - $mergedSettings, - $this->descriptors['classifyText'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/ClassifyText', + ClassifyTextResponse::class, + $request + ), + $this->configureCallSettings('classifyText', $optionalArgs) + )->wait(); } /** @@ -564,24 +473,14 @@ public function annotateText($document, $features, $optionalArgs = []) $request->setEncodingType($optionalArgs['encodingType']); } - $defaultCallSettings = $this->defaultCallSettings['annotateText']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->languageServiceStub, - 'AnnotateText', - $mergedSettings, - $this->descriptors['annotateText'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/AnnotateText', + AnnotateTextResponse::class, + $request + ), + $this->configureCallSettings('annotateText', $optionalArgs) + )->wait(); } /** @@ -592,11 +491,6 @@ public function annotateText($document, $features, $optionalArgs = []) */ public function close() { - $this->languageServiceStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Language/V1beta2/resources/language_service_descriptor_config.php b/src/Language/V1beta2/resources/language_service_descriptor_config.php new file mode 100644 index 000000000000..5d15f3bdec6f --- /dev/null +++ b/src/Language/V1beta2/resources/language_service_descriptor_config.php @@ -0,0 +1,8 @@ + [ + 'google.cloud.language.v1beta2.LanguageService' => [ + ], + ], +]; diff --git a/src/Language/V1beta2/resources/language_service_rest_client_config.php b/src/Language/V1beta2/resources/language_service_rest_client_config.php new file mode 100644 index 000000000000..dae64d232292 --- /dev/null +++ b/src/Language/V1beta2/resources/language_service_rest_client_config.php @@ -0,0 +1,38 @@ + [ + 'google.cloud.language.v1beta2.LanguageService' => [ + 'AnalyzeSentiment' => [ + 'method' => 'post', + 'uri' => '/v1beta2/documents:analyzeSentiment', + 'body' => '*', + ], + 'AnalyzeEntities' => [ + 'method' => 'post', + 'uri' => '/v1beta2/documents:analyzeEntities', + 'body' => '*', + ], + 'AnalyzeEntitySentiment' => [ + 'method' => 'post', + 'uri' => '/v1beta2/documents:analyzeEntitySentiment', + 'body' => '*', + ], + 'AnalyzeSyntax' => [ + 'method' => 'post', + 'uri' => '/v1beta2/documents:analyzeSyntax', + 'body' => '*', + ], + 'ClassifyText' => [ + 'method' => 'post', + 'uri' => '/v1beta2/documents:classifyText', + 'body' => '*', + ], + 'AnnotateText' => [ + 'method' => 'post', + 'uri' => '/v1beta2/documents:annotateText', + 'body' => '*', + ], + ], + ], +]; diff --git a/src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php b/src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php index 3932cbbeb4a8..e9ae29ff57c7 100644 --- a/src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php +++ b/src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php @@ -30,14 +30,11 @@ namespace Google\Cloud\Logging\V2\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; -use Google\ApiCore\PageStreamingDescriptor; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; -use Google\Cloud\Logging\V2\ConfigServiceV2GrpcClient; use Google\Cloud\Logging\V2\CreateExclusionRequest; use Google\Cloud\Logging\V2\CreateSinkRequest; use Google\Cloud\Logging\V2\DeleteExclusionRequest; @@ -45,13 +42,15 @@ use Google\Cloud\Logging\V2\GetExclusionRequest; use Google\Cloud\Logging\V2\GetSinkRequest; use Google\Cloud\Logging\V2\ListExclusionsRequest; +use Google\Cloud\Logging\V2\ListExclusionsResponse; use Google\Cloud\Logging\V2\ListSinksRequest; +use Google\Cloud\Logging\V2\ListSinksResponse; use Google\Cloud\Logging\V2\LogExclusion; use Google\Cloud\Logging\V2\LogSink; use Google\Cloud\Logging\V2\UpdateExclusionRequest; use Google\Cloud\Logging\V2\UpdateSinkRequest; -use Google\Cloud\Version; use Google\Protobuf\FieldMask; +use Google\Protobuf\GPBEmpty; /** * Service Description: Service for configuring sinks used to export log entries outside of @@ -95,6 +94,13 @@ */ class ConfigServiceV2GapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.logging.v2.ConfigServiceV2'; + /** * The default address of the service. */ @@ -119,18 +125,25 @@ class ConfigServiceV2GapicClient private static $sinkNameTemplate; private static $exclusionNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $configServiceV2Stub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/logging.admin', + 'https://www.googleapis.com/auth/logging.read', + 'https://www.googleapis.com/auth/logging.write', + ], + 'clientConfigPath' => __DIR__.'/../resources/config_service_v2_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/config_service_v2_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/config_service_v2_descriptor_config.php', + ]; private static function getProjectNameTemplate() { - if (self::$projectNameTemplate == null) { + if (null == self::$projectNameTemplate) { self::$projectNameTemplate = new PathTemplate('projects/{project}'); } @@ -139,7 +152,7 @@ private static function getProjectNameTemplate() private static function getSinkNameTemplate() { - if (self::$sinkNameTemplate == null) { + if (null == self::$sinkNameTemplate) { self::$sinkNameTemplate = new PathTemplate('projects/{project}/sinks/{sink}'); } @@ -148,7 +161,7 @@ private static function getSinkNameTemplate() private static function getExclusionNameTemplate() { - if (self::$exclusionNameTemplate == null) { + if (null == self::$exclusionNameTemplate) { self::$exclusionNameTemplate = new PathTemplate('projects/{project}/exclusions/{exclusion}'); } @@ -157,7 +170,7 @@ private static function getExclusionNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'project' => self::getProjectNameTemplate(), 'sink' => self::getSinkNameTemplate(), @@ -168,49 +181,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getPageStreamingDescriptors() - { - $listSinksPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getSinks', - ]); - $listExclusionsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getExclusions', - ]); - - $pageStreamingDescriptors = [ - 'listSinks' => $listSinksPageStreamingDescriptor, - 'listExclusions' => $listExclusionsPageStreamingDescriptor, - ]; - - return $pageStreamingDescriptors; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a project resource. @@ -316,16 +286,19 @@ public static function parseName($formattedName, $template = null) * Default 'logging.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -344,78 +317,23 @@ public static function parseName($formattedName, $template = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - 'https://www.googleapis.com/auth/logging.admin', - 'https://www.googleapis.com/auth/logging.read', - 'https://www.googleapis.com/auth/logging.write', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/config_service_v2_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'listSinks' => $defaultDescriptors, - 'getSink' => $defaultDescriptors, - 'createSink' => $defaultDescriptors, - 'updateSink' => $defaultDescriptors, - 'deleteSink' => $defaultDescriptors, - 'listExclusions' => $defaultDescriptors, - 'getExclusion' => $defaultDescriptors, - 'createExclusion' => $defaultDescriptors, - 'updateExclusion' => $defaultDescriptors, - 'deleteExclusion' => $defaultDescriptors, - ]; - $pageStreamingDescriptors = self::getPageStreamingDescriptors(); - foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { - $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.logging.v2.ConfigServiceV2', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createConfigServiceV2StubFunction = function ($hostname, $opts, $channel) { - return new ConfigServiceV2GrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createConfigServiceV2StubFunction', $options)) { - $createConfigServiceV2StubFunction = $options['createConfigServiceV2StubFunction']; - } - $this->configServiceV2Stub = $this->grpcCredentialsHelper->createStub($createConfigServiceV2StubFunction); + $this->setClientOptions($options + self::$clientDefaults); } /** @@ -485,24 +403,15 @@ public function listSinks($parent, $optionalArgs = []) $request->setPageSize($optionalArgs['pageSize']); } - $defaultCallSettings = $this->defaultCallSettings['listSinks']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->configServiceV2Stub, - 'ListSinks', - $mergedSettings, - $this->descriptors['listSinks'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListSinks', + ListSinksResponse::class, + $request + ), + $this->configureCallSettings('listSinks', $optionalArgs), + $this->descriptors['listSinks']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -547,24 +456,14 @@ public function getSink($sinkName, $optionalArgs = []) $request = new GetSinkRequest(); $request->setSinkName($sinkName); - $defaultCallSettings = $this->defaultCallSettings['getSink']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->configServiceV2Stub, - 'GetSink', - $mergedSettings, - $this->descriptors['getSink'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetSink', + LogSink::class, + $request + ), + $this->configureCallSettings('getSink', $optionalArgs) + )->wait(); } /** @@ -631,24 +530,14 @@ public function createSink($parent, $sink, $optionalArgs = []) $request->setUniqueWriterIdentity($optionalArgs['uniqueWriterIdentity']); } - $defaultCallSettings = $this->defaultCallSettings['createSink']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->configServiceV2Stub, - 'CreateSink', - $mergedSettings, - $this->descriptors['createSink'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/CreateSink', + LogSink::class, + $request + ), + $this->configureCallSettings('createSink', $optionalArgs) + )->wait(); } /** @@ -735,24 +624,14 @@ public function updateSink($sinkName, $sink, $optionalArgs = []) $request->setUpdateMask($optionalArgs['updateMask']); } - $defaultCallSettings = $this->defaultCallSettings['updateSink']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->configServiceV2Stub, - 'UpdateSink', - $mergedSettings, - $this->descriptors['updateSink'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/UpdateSink', + LogSink::class, + $request + ), + $this->configureCallSettings('updateSink', $optionalArgs) + )->wait(); } /** @@ -797,24 +676,14 @@ public function deleteSink($sinkName, $optionalArgs = []) $request = new DeleteSinkRequest(); $request->setSinkName($sinkName); - $defaultCallSettings = $this->defaultCallSettings['deleteSink']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->configServiceV2Stub, - 'DeleteSink', - $mergedSettings, - $this->descriptors['deleteSink'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteSink', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteSink', $optionalArgs) + )->wait(); } /** @@ -884,24 +753,15 @@ public function listExclusions($parent, $optionalArgs = []) $request->setPageSize($optionalArgs['pageSize']); } - $defaultCallSettings = $this->defaultCallSettings['listExclusions']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->configServiceV2Stub, - 'ListExclusions', - $mergedSettings, - $this->descriptors['listExclusions'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListExclusions', + ListExclusionsResponse::class, + $request + ), + $this->configureCallSettings('listExclusions', $optionalArgs), + $this->descriptors['listExclusions']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -946,24 +806,14 @@ public function getExclusion($name, $optionalArgs = []) $request = new GetExclusionRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['getExclusion']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->configServiceV2Stub, - 'GetExclusion', - $mergedSettings, - $this->descriptors['getExclusion'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetExclusion', + LogExclusion::class, + $request + ), + $this->configureCallSettings('getExclusion', $optionalArgs) + )->wait(); } /** @@ -1014,24 +864,14 @@ public function createExclusion($parent, $exclusion, $optionalArgs = []) $request->setParent($parent); $request->setExclusion($exclusion); - $defaultCallSettings = $this->defaultCallSettings['createExclusion']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->configServiceV2Stub, - 'CreateExclusion', - $mergedSettings, - $this->descriptors['createExclusion'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/CreateExclusion', + LogExclusion::class, + $request + ), + $this->configureCallSettings('createExclusion', $optionalArgs) + )->wait(); } /** @@ -1089,24 +929,14 @@ public function updateExclusion($name, $exclusion, $updateMask, $optionalArgs = $request->setExclusion($exclusion); $request->setUpdateMask($updateMask); - $defaultCallSettings = $this->defaultCallSettings['updateExclusion']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->configServiceV2Stub, - 'UpdateExclusion', - $mergedSettings, - $this->descriptors['updateExclusion'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/UpdateExclusion', + LogExclusion::class, + $request + ), + $this->configureCallSettings('updateExclusion', $optionalArgs) + )->wait(); } /** @@ -1149,24 +979,14 @@ public function deleteExclusion($name, $optionalArgs = []) $request = new DeleteExclusionRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['deleteExclusion']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->configServiceV2Stub, - 'DeleteExclusion', - $mergedSettings, - $this->descriptors['deleteExclusion'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteExclusion', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteExclusion', $optionalArgs) + )->wait(); } /** @@ -1177,11 +997,6 @@ public function deleteExclusion($name, $optionalArgs = []) */ public function close() { - $this->configServiceV2Stub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php b/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php index 9918d505c396..9bbd91edc112 100644 --- a/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php +++ b/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php @@ -30,22 +30,23 @@ namespace Google\Cloud\Logging\V2\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; -use Google\ApiCore\PageStreamingDescriptor; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; use Google\Api\MonitoredResource; use Google\Cloud\Logging\V2\DeleteLogRequest; use Google\Cloud\Logging\V2\ListLogEntriesRequest; +use Google\Cloud\Logging\V2\ListLogEntriesResponse; use Google\Cloud\Logging\V2\ListLogsRequest; +use Google\Cloud\Logging\V2\ListLogsResponse; use Google\Cloud\Logging\V2\ListMonitoredResourceDescriptorsRequest; +use Google\Cloud\Logging\V2\ListMonitoredResourceDescriptorsResponse; use Google\Cloud\Logging\V2\LogEntry; -use Google\Cloud\Logging\V2\LoggingServiceV2GrpcClient; use Google\Cloud\Logging\V2\WriteLogEntriesRequest; -use Google\Cloud\Version; +use Google\Cloud\Logging\V2\WriteLogEntriesResponse; +use Google\Protobuf\GPBEmpty; /** * Service Description: Service for ingesting and querying logs. @@ -76,6 +77,13 @@ */ class LoggingServiceV2GapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.logging.v2.LoggingServiceV2'; + /** * The default address of the service. */ @@ -99,18 +107,25 @@ class LoggingServiceV2GapicClient private static $projectNameTemplate; private static $logNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $loggingServiceV2Stub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/logging.admin', + 'https://www.googleapis.com/auth/logging.read', + 'https://www.googleapis.com/auth/logging.write', + ], + 'clientConfigPath' => __DIR__.'/../resources/logging_service_v2_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/logging_service_v2_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/logging_service_v2_descriptor_config.php', + ]; private static function getProjectNameTemplate() { - if (self::$projectNameTemplate == null) { + if (null == self::$projectNameTemplate) { self::$projectNameTemplate = new PathTemplate('projects/{project}'); } @@ -119,7 +134,7 @@ private static function getProjectNameTemplate() private static function getLogNameTemplate() { - if (self::$logNameTemplate == null) { + if (null == self::$logNameTemplate) { self::$logNameTemplate = new PathTemplate('projects/{project}/logs/{log}'); } @@ -128,7 +143,7 @@ private static function getLogNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'project' => self::getProjectNameTemplate(), 'log' => self::getLogNameTemplate(), @@ -138,59 +153,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getPageStreamingDescriptors() - { - $listLogEntriesPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getEntries', - ]); - $listMonitoredResourceDescriptorsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getResourceDescriptors', - ]); - $listLogsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getLogNames', - ]); - - $pageStreamingDescriptors = [ - 'listLogEntries' => $listLogEntriesPageStreamingDescriptor, - 'listMonitoredResourceDescriptors' => $listMonitoredResourceDescriptorsPageStreamingDescriptor, - 'listLogs' => $listLogsPageStreamingDescriptor, - ]; - - return $pageStreamingDescriptors; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a project resource. @@ -277,16 +239,19 @@ public static function parseName($formattedName, $template = null) * Default 'logging.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -305,73 +270,23 @@ public static function parseName($formattedName, $template = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - 'https://www.googleapis.com/auth/logging.admin', - 'https://www.googleapis.com/auth/logging.read', - 'https://www.googleapis.com/auth/logging.write', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/logging_service_v2_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'deleteLog' => $defaultDescriptors, - 'writeLogEntries' => $defaultDescriptors, - 'listLogEntries' => $defaultDescriptors, - 'listMonitoredResourceDescriptors' => $defaultDescriptors, - 'listLogs' => $defaultDescriptors, - ]; - $pageStreamingDescriptors = self::getPageStreamingDescriptors(); - foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { - $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.logging.v2.LoggingServiceV2', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createLoggingServiceV2StubFunction = function ($hostname, $opts, $channel) { - return new LoggingServiceV2GrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createLoggingServiceV2StubFunction', $options)) { - $createLoggingServiceV2StubFunction = $options['createLoggingServiceV2StubFunction']; - } - $this->loggingServiceV2Stub = $this->grpcCredentialsHelper->createStub($createLoggingServiceV2StubFunction); + $this->setClientOptions($options + self::$clientDefaults); } /** @@ -421,24 +336,14 @@ public function deleteLog($logName, $optionalArgs = []) $request = new DeleteLogRequest(); $request->setLogName($logName); - $defaultCallSettings = $this->defaultCallSettings['deleteLog']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->loggingServiceV2Stub, - 'DeleteLog', - $mergedSettings, - $this->descriptors['deleteLog'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteLog', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteLog', $optionalArgs) + )->wait(); } /** @@ -548,24 +453,14 @@ public function writeLogEntries($entries, $optionalArgs = []) $request->setPartialSuccess($optionalArgs['partialSuccess']); } - $defaultCallSettings = $this->defaultCallSettings['writeLogEntries']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->loggingServiceV2Stub, - 'WriteLogEntries', - $mergedSettings, - $this->descriptors['writeLogEntries'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/WriteLogEntries', + WriteLogEntriesResponse::class, + $request + ), + $this->configureCallSettings('writeLogEntries', $optionalArgs) + )->wait(); } /** @@ -670,24 +565,15 @@ public function listLogEntries($resourceNames, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listLogEntries']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->loggingServiceV2Stub, - 'ListLogEntries', - $mergedSettings, - $this->descriptors['listLogEntries'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListLogEntries', + ListLogEntriesResponse::class, + $request + ), + $this->configureCallSettings('listLogEntries', $optionalArgs), + $this->descriptors['listLogEntries']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -751,24 +637,15 @@ public function listMonitoredResourceDescriptors($optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listMonitoredResourceDescriptors']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->loggingServiceV2Stub, - 'ListMonitoredResourceDescriptors', - $mergedSettings, - $this->descriptors['listMonitoredResourceDescriptors'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListMonitoredResourceDescriptors', + ListMonitoredResourceDescriptorsResponse::class, + $request + ), + $this->configureCallSettings('listMonitoredResourceDescriptors', $optionalArgs), + $this->descriptors['listMonitoredResourceDescriptors']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -839,24 +716,15 @@ public function listLogs($parent, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listLogs']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->loggingServiceV2Stub, - 'ListLogs', - $mergedSettings, - $this->descriptors['listLogs'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListLogs', + ListLogsResponse::class, + $request + ), + $this->configureCallSettings('listLogs', $optionalArgs), + $this->descriptors['listLogs']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -867,11 +735,6 @@ public function listLogs($parent, $optionalArgs = []) */ public function close() { - $this->loggingServiceV2Stub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php b/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php index 74f6edade881..8f774f277030 100644 --- a/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php +++ b/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php @@ -30,21 +30,19 @@ namespace Google\Cloud\Logging\V2\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; -use Google\ApiCore\PageStreamingDescriptor; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; use Google\Cloud\Logging\V2\CreateLogMetricRequest; use Google\Cloud\Logging\V2\DeleteLogMetricRequest; use Google\Cloud\Logging\V2\GetLogMetricRequest; use Google\Cloud\Logging\V2\ListLogMetricsRequest; +use Google\Cloud\Logging\V2\ListLogMetricsResponse; use Google\Cloud\Logging\V2\LogMetric; -use Google\Cloud\Logging\V2\MetricsServiceV2GrpcClient; use Google\Cloud\Logging\V2\UpdateLogMetricRequest; -use Google\Cloud\Version; +use Google\Protobuf\GPBEmpty; /** * Service Description: Service for configuring logs-based metrics. @@ -87,6 +85,13 @@ */ class MetricsServiceV2GapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.logging.v2.MetricsServiceV2'; + /** * The default address of the service. */ @@ -110,18 +115,25 @@ class MetricsServiceV2GapicClient private static $projectNameTemplate; private static $metricNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $metricsServiceV2Stub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/logging.admin', + 'https://www.googleapis.com/auth/logging.read', + 'https://www.googleapis.com/auth/logging.write', + ], + 'clientConfigPath' => __DIR__.'/../resources/metrics_service_v2_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/metrics_service_v2_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/metrics_service_v2_descriptor_config.php', + ]; private static function getProjectNameTemplate() { - if (self::$projectNameTemplate == null) { + if (null == self::$projectNameTemplate) { self::$projectNameTemplate = new PathTemplate('projects/{project}'); } @@ -130,7 +142,7 @@ private static function getProjectNameTemplate() private static function getMetricNameTemplate() { - if (self::$metricNameTemplate == null) { + if (null == self::$metricNameTemplate) { self::$metricNameTemplate = new PathTemplate('projects/{project}/metrics/{metric}'); } @@ -139,7 +151,7 @@ private static function getMetricNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'project' => self::getProjectNameTemplate(), 'metric' => self::getMetricNameTemplate(), @@ -149,39 +161,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getPageStreamingDescriptors() - { - $listLogMetricsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getMetrics', - ]); - - $pageStreamingDescriptors = [ - 'listLogMetrics' => $listLogMetricsPageStreamingDescriptor, - ]; - - return $pageStreamingDescriptors; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a project resource. @@ -268,16 +247,19 @@ public static function parseName($formattedName, $template = null) * Default 'logging.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -296,73 +278,23 @@ public static function parseName($formattedName, $template = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - 'https://www.googleapis.com/auth/logging.admin', - 'https://www.googleapis.com/auth/logging.read', - 'https://www.googleapis.com/auth/logging.write', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/metrics_service_v2_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'listLogMetrics' => $defaultDescriptors, - 'getLogMetric' => $defaultDescriptors, - 'createLogMetric' => $defaultDescriptors, - 'updateLogMetric' => $defaultDescriptors, - 'deleteLogMetric' => $defaultDescriptors, - ]; - $pageStreamingDescriptors = self::getPageStreamingDescriptors(); - foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { - $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.logging.v2.MetricsServiceV2', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createMetricsServiceV2StubFunction = function ($hostname, $opts, $channel) { - return new MetricsServiceV2GrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createMetricsServiceV2StubFunction', $options)) { - $createMetricsServiceV2StubFunction = $options['createMetricsServiceV2StubFunction']; - } - $this->metricsServiceV2Stub = $this->grpcCredentialsHelper->createStub($createMetricsServiceV2StubFunction); + $this->setClientOptions($options + self::$clientDefaults); } /** @@ -429,24 +361,15 @@ public function listLogMetrics($parent, $optionalArgs = []) $request->setPageSize($optionalArgs['pageSize']); } - $defaultCallSettings = $this->defaultCallSettings['listLogMetrics']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->metricsServiceV2Stub, - 'ListLogMetrics', - $mergedSettings, - $this->descriptors['listLogMetrics'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListLogMetrics', + ListLogMetricsResponse::class, + $request + ), + $this->configureCallSettings('listLogMetrics', $optionalArgs), + $this->descriptors['listLogMetrics']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -486,24 +409,14 @@ public function getLogMetric($metricName, $optionalArgs = []) $request = new GetLogMetricRequest(); $request->setMetricName($metricName); - $defaultCallSettings = $this->defaultCallSettings['getLogMetric']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->metricsServiceV2Stub, - 'GetLogMetric', - $mergedSettings, - $this->descriptors['getLogMetric'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetLogMetric', + LogMetric::class, + $request + ), + $this->configureCallSettings('getLogMetric', $optionalArgs) + )->wait(); } /** @@ -549,24 +462,14 @@ public function createLogMetric($parent, $metric, $optionalArgs = []) $request->setParent($parent); $request->setMetric($metric); - $defaultCallSettings = $this->defaultCallSettings['createLogMetric']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->metricsServiceV2Stub, - 'CreateLogMetric', - $mergedSettings, - $this->descriptors['createLogMetric'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/CreateLogMetric', + LogMetric::class, + $request + ), + $this->configureCallSettings('createLogMetric', $optionalArgs) + )->wait(); } /** @@ -613,24 +516,14 @@ public function updateLogMetric($metricName, $metric, $optionalArgs = []) $request->setMetricName($metricName); $request->setMetric($metric); - $defaultCallSettings = $this->defaultCallSettings['updateLogMetric']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->metricsServiceV2Stub, - 'UpdateLogMetric', - $mergedSettings, - $this->descriptors['updateLogMetric'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/UpdateLogMetric', + LogMetric::class, + $request + ), + $this->configureCallSettings('updateLogMetric', $optionalArgs) + )->wait(); } /** @@ -668,24 +561,14 @@ public function deleteLogMetric($metricName, $optionalArgs = []) $request = new DeleteLogMetricRequest(); $request->setMetricName($metricName); - $defaultCallSettings = $this->defaultCallSettings['deleteLogMetric']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->metricsServiceV2Stub, - 'DeleteLogMetric', - $mergedSettings, - $this->descriptors['deleteLogMetric'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteLogMetric', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteLogMetric', $optionalArgs) + )->wait(); } /** @@ -696,11 +579,6 @@ public function deleteLogMetric($metricName, $optionalArgs = []) */ public function close() { - $this->metricsServiceV2Stub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Logging/V2/resources/config_service_v2_descriptor_config.php b/src/Logging/V2/resources/config_service_v2_descriptor_config.php new file mode 100644 index 000000000000..023d3d375933 --- /dev/null +++ b/src/Logging/V2/resources/config_service_v2_descriptor_config.php @@ -0,0 +1,28 @@ + [ + 'google.logging.v2.ConfigServiceV2' => [ + 'listSinks' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getSinks', + ], + ], + 'listExclusions' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getExclusions', + ], + ], + ], + ], +]; diff --git a/src/Logging/V2/resources/config_service_v2_rest_client_config.php b/src/Logging/V2/resources/config_service_v2_rest_client_config.php new file mode 100644 index 000000000000..939fc6eb9239 --- /dev/null +++ b/src/Logging/V2/resources/config_service_v2_rest_client_config.php @@ -0,0 +1,102 @@ + [ + 'google.logging.v2.ConfigServiceV2' => [ + 'ListSinks' => [ + 'method' => 'get', + 'uri' => '/v2/{parent=*/*}/sinks', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'GetSink' => [ + 'method' => 'get', + 'uri' => '/v2/{sink_name=*/*/sinks/*}', + 'placeholders' => [ + 'sink_name' => [ + 'getSink_name', + ], + ], + ], + 'CreateSink' => [ + 'method' => 'post', + 'uri' => '/v2/{parent=*/*}/sinks', + 'body' => 'sink', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'UpdateSink' => [ + 'method' => 'put', + 'uri' => '/v2/{sink_name=*/*/sinks/*}', + 'body' => 'sink', + 'placeholders' => [ + 'sink_name' => [ + 'getSink_name', + ], + ], + ], + 'DeleteSink' => [ + 'method' => 'delete', + 'uri' => '/v2/{sink_name=*/*/sinks/*}', + 'placeholders' => [ + 'sink_name' => [ + 'getSink_name', + ], + ], + ], + 'ListExclusions' => [ + 'method' => 'get', + 'uri' => '/v2/{parent=*/*}/exclusions', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'GetExclusion' => [ + 'method' => 'get', + 'uri' => '/v2/{name=*/*/exclusions/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'CreateExclusion' => [ + 'method' => 'post', + 'uri' => '/v2/{parent=*/*}/exclusions', + 'body' => 'exclusion', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'UpdateExclusion' => [ + 'method' => 'patch', + 'uri' => '/v2/{name=*/*/exclusions/*}', + 'body' => 'exclusion', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'DeleteExclusion' => [ + 'method' => 'delete', + 'uri' => '/v2/{name=*/*/exclusions/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + ], + ], +]; diff --git a/src/Logging/V2/resources/logging_service_v2_descriptor_config.php b/src/Logging/V2/resources/logging_service_v2_descriptor_config.php new file mode 100644 index 000000000000..d41fd44b6b66 --- /dev/null +++ b/src/Logging/V2/resources/logging_service_v2_descriptor_config.php @@ -0,0 +1,38 @@ + [ + 'google.logging.v2.LoggingServiceV2' => [ + 'listLogEntries' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getEntries', + ], + ], + 'listMonitoredResourceDescriptors' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getResourceDescriptors', + ], + ], + 'listLogs' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getLogNames', + ], + ], + ], + ], +]; diff --git a/src/Logging/V2/resources/logging_service_v2_rest_client_config.php b/src/Logging/V2/resources/logging_service_v2_rest_client_config.php new file mode 100644 index 000000000000..3ee5436b0276 --- /dev/null +++ b/src/Logging/V2/resources/logging_service_v2_rest_client_config.php @@ -0,0 +1,40 @@ + [ + 'google.logging.v2.LoggingServiceV2' => [ + 'DeleteLog' => [ + 'method' => 'delete', + 'uri' => '/v2beta1/{log_name=projects/*/logs/*}', + 'placeholders' => [ + 'log_name' => [ + 'getLog_name', + ], + ], + ], + 'WriteLogEntries' => [ + 'method' => 'post', + 'uri' => '/v2/entries:write', + 'body' => '*', + ], + 'ListLogEntries' => [ + 'method' => 'post', + 'uri' => '/v2/entries:list', + 'body' => '*', + ], + 'ListMonitoredResourceDescriptors' => [ + 'method' => 'get', + 'uri' => '/v2/monitoredResourceDescriptors', + ], + 'ListLogs' => [ + 'method' => 'get', + 'uri' => '/v2/{parent=*/*}/logs', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + ], + ], +]; diff --git a/src/Logging/V2/resources/metrics_service_v2_descriptor_config.php b/src/Logging/V2/resources/metrics_service_v2_descriptor_config.php new file mode 100644 index 000000000000..d9f6efe0909b --- /dev/null +++ b/src/Logging/V2/resources/metrics_service_v2_descriptor_config.php @@ -0,0 +1,18 @@ + [ + 'google.logging.v2.MetricsServiceV2' => [ + 'listLogMetrics' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getMetrics', + ], + ], + ], + ], +]; diff --git a/src/Logging/V2/resources/metrics_service_v2_rest_client_config.php b/src/Logging/V2/resources/metrics_service_v2_rest_client_config.php new file mode 100644 index 000000000000..785e270847b2 --- /dev/null +++ b/src/Logging/V2/resources/metrics_service_v2_rest_client_config.php @@ -0,0 +1,55 @@ + [ + 'google.logging.v2.MetricsServiceV2' => [ + 'ListLogMetrics' => [ + 'method' => 'get', + 'uri' => '/v2/{parent=projects/*}/metrics', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'GetLogMetric' => [ + 'method' => 'get', + 'uri' => '/v2/{metric_name=projects/*/metrics/*}', + 'placeholders' => [ + 'metric_name' => [ + 'getMetric_name', + ], + ], + ], + 'CreateLogMetric' => [ + 'method' => 'post', + 'uri' => '/v2/{parent=projects/*}/metrics', + 'body' => 'metric', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'UpdateLogMetric' => [ + 'method' => 'put', + 'uri' => '/v2/{metric_name=projects/*/metrics/*}', + 'body' => 'metric', + 'placeholders' => [ + 'metric_name' => [ + 'getMetric_name', + ], + ], + ], + 'DeleteLogMetric' => [ + 'method' => 'delete', + 'uri' => '/v2/{metric_name=projects/*/metrics/*}', + 'placeholders' => [ + 'metric_name' => [ + 'getMetric_name', + ], + ], + ], + ], + ], +]; diff --git a/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php b/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php index aaf8361d9083..93d1197a18f8 100644 --- a/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php +++ b/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php @@ -20,27 +20,32 @@ * This file was generated from the file * https://github.com/google/googleapis/blob/master/google/monitoring/v3/group_service.proto * and updates to that file get reflected here through a refresh process. + * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * + * @experimental */ namespace Google\Cloud\Monitoring\V3\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; -use Google\ApiCore\PageStreamingDescriptor; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; use Google\Cloud\Monitoring\V3\CreateGroupRequest; use Google\Cloud\Monitoring\V3\DeleteGroupRequest; use Google\Cloud\Monitoring\V3\GetGroupRequest; use Google\Cloud\Monitoring\V3\Group; -use Google\Cloud\Monitoring\V3\GroupServiceGrpcClient; use Google\Cloud\Monitoring\V3\ListGroupMembersRequest; +use Google\Cloud\Monitoring\V3\ListGroupMembersResponse; use Google\Cloud\Monitoring\V3\ListGroupsRequest; +use Google\Cloud\Monitoring\V3\ListGroupsResponse; use Google\Cloud\Monitoring\V3\TimeInterval; use Google\Cloud\Monitoring\V3\UpdateGroupRequest; -use Google\Cloud\Version; +use Google\Protobuf\GPBEmpty; /** * Service Description: The Group API lets you inspect and manage your @@ -56,6 +61,10 @@ * updated automatically as monitored resources are added and removed * from the infrastructure. * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * * This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * @@ -85,9 +94,18 @@ * 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. + * + * @experimental */ class GroupServiceGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.monitoring.v3.GroupService'; + /** * The default address of the service. */ @@ -111,18 +129,24 @@ class GroupServiceGapicClient private static $projectNameTemplate; private static $groupNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $groupServiceStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + 'https://www.googleapis.com/auth/monitoring.write', + ], + 'clientConfigPath' => __DIR__.'/../resources/group_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/group_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/group_service_descriptor_config.php', + ]; private static function getProjectNameTemplate() { - if (self::$projectNameTemplate == null) { + if (null == self::$projectNameTemplate) { self::$projectNameTemplate = new PathTemplate('projects/{project}'); } @@ -131,7 +155,7 @@ private static function getProjectNameTemplate() private static function getGroupNameTemplate() { - if (self::$groupNameTemplate == null) { + if (null == self::$groupNameTemplate) { self::$groupNameTemplate = new PathTemplate('projects/{project}/groups/{group}'); } @@ -140,7 +164,7 @@ private static function getGroupNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'project' => self::getProjectNameTemplate(), 'group' => self::getGroupNameTemplate(), @@ -150,49 +174,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getPageStreamingDescriptors() - { - $listGroupsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getGroup', - ]); - $listGroupMembersPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getMembers', - ]); - - $pageStreamingDescriptors = [ - 'listGroups' => $listGroupsPageStreamingDescriptor, - 'listGroupMembers' => $listGroupMembersPageStreamingDescriptor, - ]; - - return $pageStreamingDescriptors; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a project resource. @@ -279,16 +260,19 @@ public static function parseName($formattedName, $template = null) * Default 'monitoring.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -307,73 +291,23 @@ public static function parseName($formattedName, $template = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/monitoring', - 'https://www.googleapis.com/auth/monitoring.read', - 'https://www.googleapis.com/auth/monitoring.write', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/group_service_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'listGroups' => $defaultDescriptors, - 'getGroup' => $defaultDescriptors, - 'createGroup' => $defaultDescriptors, - 'updateGroup' => $defaultDescriptors, - 'deleteGroup' => $defaultDescriptors, - 'listGroupMembers' => $defaultDescriptors, - ]; - $pageStreamingDescriptors = self::getPageStreamingDescriptors(); - foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { - $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.monitoring.v3.GroupService', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createGroupServiceStubFunction = function ($hostname, $opts, $channel) { - return new GroupServiceGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createGroupServiceStubFunction', $options)) { - $createGroupServiceStubFunction = $options['createGroupServiceStubFunction']; - } - $this->groupServiceStub = $this->grpcCredentialsHelper->createStub($createGroupServiceStubFunction); + $this->setClientOptions($options + self::$clientDefaults); } /** @@ -463,24 +397,15 @@ public function listGroups($name, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listGroups']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->groupServiceStub, - 'ListGroups', - $mergedSettings, - $this->descriptors['listGroups'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListGroups', + ListGroupsResponse::class, + $request + ), + $this->configureCallSettings('listGroups', $optionalArgs), + $this->descriptors['listGroups']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -519,24 +444,14 @@ public function getGroup($name, $optionalArgs = []) $request = new GetGroupRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['getGroup']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->groupServiceStub, - 'GetGroup', - $mergedSettings, - $this->descriptors['getGroup'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetGroup', + Group::class, + $request + ), + $this->configureCallSettings('getGroup', $optionalArgs) + )->wait(); } /** @@ -584,24 +499,14 @@ public function createGroup($name, $group, $optionalArgs = []) $request->setValidateOnly($optionalArgs['validateOnly']); } - $defaultCallSettings = $this->defaultCallSettings['createGroup']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->groupServiceStub, - 'CreateGroup', - $mergedSettings, - $this->descriptors['createGroup'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/CreateGroup', + Group::class, + $request + ), + $this->configureCallSettings('createGroup', $optionalArgs) + )->wait(); } /** @@ -646,24 +551,14 @@ public function updateGroup($group, $optionalArgs = []) $request->setValidateOnly($optionalArgs['validateOnly']); } - $defaultCallSettings = $this->defaultCallSettings['updateGroup']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->groupServiceStub, - 'UpdateGroup', - $mergedSettings, - $this->descriptors['updateGroup'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/UpdateGroup', + Group::class, + $request + ), + $this->configureCallSettings('updateGroup', $optionalArgs) + )->wait(); } /** @@ -700,24 +595,14 @@ public function deleteGroup($name, $optionalArgs = []) $request = new DeleteGroupRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['deleteGroup']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->groupServiceStub, - 'DeleteGroup', - $mergedSettings, - $this->descriptors['deleteGroup'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteGroup', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteGroup', $optionalArgs) + )->wait(); } /** @@ -802,24 +687,15 @@ public function listGroupMembers($name, $optionalArgs = []) $request->setInterval($optionalArgs['interval']); } - $defaultCallSettings = $this->defaultCallSettings['listGroupMembers']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->groupServiceStub, - 'ListGroupMembers', - $mergedSettings, - $this->descriptors['listGroupMembers'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListGroupMembers', + ListGroupMembersResponse::class, + $request + ), + $this->configureCallSettings('listGroupMembers', $optionalArgs), + $this->descriptors['listGroupMembers']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -830,11 +706,6 @@ public function listGroupMembers($name, $optionalArgs = []) */ public function close() { - $this->groupServiceStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php b/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php index ca2de1a6b585..71f32701a0b2 100644 --- a/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php +++ b/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php @@ -20,18 +20,23 @@ * This file was generated from the file * https://github.com/google/googleapis/blob/master/google/monitoring/v3/metric_service.proto * and updates to that file get reflected here through a refresh process. + * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * + * @experimental */ namespace Google\Cloud\Monitoring\V3\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; -use Google\ApiCore\PageStreamingDescriptor; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; use Google\Api\MetricDescriptor; +use Google\Api\MonitoredResourceDescriptor; use Google\Cloud\Monitoring\V3\Aggregation; use Google\Cloud\Monitoring\V3\CreateMetricDescriptorRequest; use Google\Cloud\Monitoring\V3\CreateTimeSeriesRequest; @@ -39,18 +44,24 @@ use Google\Cloud\Monitoring\V3\GetMetricDescriptorRequest; use Google\Cloud\Monitoring\V3\GetMonitoredResourceDescriptorRequest; use Google\Cloud\Monitoring\V3\ListMetricDescriptorsRequest; +use Google\Cloud\Monitoring\V3\ListMetricDescriptorsResponse; use Google\Cloud\Monitoring\V3\ListMonitoredResourceDescriptorsRequest; +use Google\Cloud\Monitoring\V3\ListMonitoredResourceDescriptorsResponse; use Google\Cloud\Monitoring\V3\ListTimeSeriesRequest; use Google\Cloud\Monitoring\V3\ListTimeSeriesRequest_TimeSeriesView as TimeSeriesView; -use Google\Cloud\Monitoring\V3\MetricServiceGrpcClient; +use Google\Cloud\Monitoring\V3\ListTimeSeriesResponse; use Google\Cloud\Monitoring\V3\TimeInterval; use Google\Cloud\Monitoring\V3\TimeSeries; -use Google\Cloud\Version; +use Google\Protobuf\GPBEmpty; /** * Service Description: Manages metric descriptors, monitored resource descriptors, and * time series data. * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * * This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * @@ -80,9 +91,18 @@ * 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. + * + * @experimental */ class MetricServiceGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.monitoring.v3.MetricService'; + /** * The default address of the service. */ @@ -107,18 +127,24 @@ class MetricServiceGapicClient private static $metricDescriptorNameTemplate; private static $monitoredResourceDescriptorNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $metricServiceStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + 'https://www.googleapis.com/auth/monitoring.write', + ], + 'clientConfigPath' => __DIR__.'/../resources/metric_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/metric_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/metric_service_descriptor_config.php', + ]; private static function getProjectNameTemplate() { - if (self::$projectNameTemplate == null) { + if (null == self::$projectNameTemplate) { self::$projectNameTemplate = new PathTemplate('projects/{project}'); } @@ -127,7 +153,7 @@ private static function getProjectNameTemplate() private static function getMetricDescriptorNameTemplate() { - if (self::$metricDescriptorNameTemplate == null) { + if (null == self::$metricDescriptorNameTemplate) { self::$metricDescriptorNameTemplate = new PathTemplate('projects/{project}/metricDescriptors/{metric_descriptor=**}'); } @@ -136,7 +162,7 @@ private static function getMetricDescriptorNameTemplate() private static function getMonitoredResourceDescriptorNameTemplate() { - if (self::$monitoredResourceDescriptorNameTemplate == null) { + if (null == self::$monitoredResourceDescriptorNameTemplate) { self::$monitoredResourceDescriptorNameTemplate = new PathTemplate('projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}'); } @@ -145,7 +171,7 @@ private static function getMonitoredResourceDescriptorNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'project' => self::getProjectNameTemplate(), 'metricDescriptor' => self::getMetricDescriptorNameTemplate(), @@ -156,59 +182,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getPageStreamingDescriptors() - { - $listMonitoredResourceDescriptorsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getResourceDescriptors', - ]); - $listMetricDescriptorsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getMetricDescriptors', - ]); - $listTimeSeriesPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getTimeSeries', - ]); - - $pageStreamingDescriptors = [ - 'listMonitoredResourceDescriptors' => $listMonitoredResourceDescriptorsPageStreamingDescriptor, - 'listMetricDescriptors' => $listMetricDescriptorsPageStreamingDescriptor, - 'listTimeSeries' => $listTimeSeriesPageStreamingDescriptor, - ]; - - return $pageStreamingDescriptors; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a project resource. @@ -314,16 +287,19 @@ public static function parseName($formattedName, $template = null) * Default 'monitoring.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -342,75 +318,23 @@ public static function parseName($formattedName, $template = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/monitoring', - 'https://www.googleapis.com/auth/monitoring.read', - 'https://www.googleapis.com/auth/monitoring.write', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/metric_service_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'listMonitoredResourceDescriptors' => $defaultDescriptors, - 'getMonitoredResourceDescriptor' => $defaultDescriptors, - 'listMetricDescriptors' => $defaultDescriptors, - 'getMetricDescriptor' => $defaultDescriptors, - 'createMetricDescriptor' => $defaultDescriptors, - 'deleteMetricDescriptor' => $defaultDescriptors, - 'listTimeSeries' => $defaultDescriptors, - 'createTimeSeries' => $defaultDescriptors, - ]; - $pageStreamingDescriptors = self::getPageStreamingDescriptors(); - foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { - $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.monitoring.v3.MetricService', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createMetricServiceStubFunction = function ($hostname, $opts, $channel) { - return new MetricServiceGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createMetricServiceStubFunction', $options)) { - $createMetricServiceStubFunction = $options['createMetricServiceStubFunction']; - } - $this->metricServiceStub = $this->grpcCredentialsHelper->createStub($createMetricServiceStubFunction); + $this->setClientOptions($options + self::$clientDefaults); } /** @@ -487,24 +411,15 @@ public function listMonitoredResourceDescriptors($name, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listMonitoredResourceDescriptors']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->metricServiceStub, - 'ListMonitoredResourceDescriptors', - $mergedSettings, - $this->descriptors['listMonitoredResourceDescriptors'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListMonitoredResourceDescriptors', + ListMonitoredResourceDescriptorsResponse::class, + $request + ), + $this->configureCallSettings('listMonitoredResourceDescriptors', $optionalArgs), + $this->descriptors['listMonitoredResourceDescriptors']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -545,24 +460,14 @@ public function getMonitoredResourceDescriptor($name, $optionalArgs = []) $request = new GetMonitoredResourceDescriptorRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['getMonitoredResourceDescriptor']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->metricServiceStub, - 'GetMonitoredResourceDescriptor', - $mergedSettings, - $this->descriptors['getMonitoredResourceDescriptor'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetMonitoredResourceDescriptor', + MonitoredResourceDescriptor::class, + $request + ), + $this->configureCallSettings('getMonitoredResourceDescriptor', $optionalArgs) + )->wait(); } /** @@ -640,24 +545,15 @@ public function listMetricDescriptors($name, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listMetricDescriptors']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->metricServiceStub, - 'ListMetricDescriptors', - $mergedSettings, - $this->descriptors['listMetricDescriptors'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListMetricDescriptors', + ListMetricDescriptorsResponse::class, + $request + ), + $this->configureCallSettings('listMetricDescriptors', $optionalArgs), + $this->descriptors['listMetricDescriptors']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -698,24 +594,14 @@ public function getMetricDescriptor($name, $optionalArgs = []) $request = new GetMetricDescriptorRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['getMetricDescriptor']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->metricServiceStub, - 'GetMetricDescriptor', - $mergedSettings, - $this->descriptors['getMetricDescriptor'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetMetricDescriptor', + MetricDescriptor::class, + $request + ), + $this->configureCallSettings('getMetricDescriptor', $optionalArgs) + )->wait(); } /** @@ -760,24 +646,14 @@ public function createMetricDescriptor($name, $metricDescriptor, $optionalArgs = $request->setName($name); $request->setMetricDescriptor($metricDescriptor); - $defaultCallSettings = $this->defaultCallSettings['createMetricDescriptor']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->metricServiceStub, - 'CreateMetricDescriptor', - $mergedSettings, - $this->descriptors['createMetricDescriptor'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/CreateMetricDescriptor', + MetricDescriptor::class, + $request + ), + $this->configureCallSettings('createMetricDescriptor', $optionalArgs) + )->wait(); } /** @@ -817,24 +693,14 @@ public function deleteMetricDescriptor($name, $optionalArgs = []) $request = new DeleteMetricDescriptorRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['deleteMetricDescriptor']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->metricServiceStub, - 'DeleteMetricDescriptor', - $mergedSettings, - $this->descriptors['deleteMetricDescriptor'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteMetricDescriptor', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteMetricDescriptor', $optionalArgs) + )->wait(); } /** @@ -932,24 +798,15 @@ public function listTimeSeries($name, $filter, $interval, $view, $optionalArgs = $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listTimeSeries']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->metricServiceStub, - 'ListTimeSeries', - $mergedSettings, - $this->descriptors['listTimeSeries'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListTimeSeries', + ListTimeSeriesResponse::class, + $request + ), + $this->configureCallSettings('listTimeSeries', $optionalArgs), + $this->descriptors['listTimeSeries']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -996,24 +853,14 @@ public function createTimeSeries($name, $timeSeries, $optionalArgs = []) $request->setName($name); $request->setTimeSeries($timeSeries); - $defaultCallSettings = $this->defaultCallSettings['createTimeSeries']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->metricServiceStub, - 'CreateTimeSeries', - $mergedSettings, - $this->descriptors['createTimeSeries'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/CreateTimeSeries', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('createTimeSeries', $optionalArgs) + )->wait(); } /** @@ -1024,11 +871,6 @@ public function createTimeSeries($name, $timeSeries, $optionalArgs = []) */ public function close() { - $this->metricServiceStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php b/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php new file mode 100644 index 000000000000..b51313d02866 --- /dev/null +++ b/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php @@ -0,0 +1,672 @@ +projectName('[PROJECT]'); + * // Iterate through all elements + * $pagedResponse = $uptimeCheckServiceClient->listUptimeCheckConfigs($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * + * // OR iterate over pages of elements + * $pagedResponse = $uptimeCheckServiceClient->listUptimeCheckConfigs($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * } finally { + * $uptimeCheckServiceClient->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. + * + * @experimental + */ +class UptimeCheckServiceGapicClient +{ + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.monitoring.v3.UptimeCheckService'; + + /** + * The default address of the service. + */ + const SERVICE_ADDRESS = 'monitoring.googleapis.com'; + + /** + * 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 code generator version, to be included in the agent header. + */ + const CODEGEN_VERSION = '0.0.5'; + + private static $projectNameTemplate; + private static $uptimeCheckConfigNameTemplate; + private static $pathTemplateMap; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + 'https://www.googleapis.com/auth/monitoring.write', + ], + 'clientConfigPath' => __DIR__.'/../resources/uptime_check_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/uptime_check_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/uptime_check_service_descriptor_config.php', + ]; + + private static function getProjectNameTemplate() + { + if (null == self::$projectNameTemplate) { + self::$projectNameTemplate = new PathTemplate('projects/{project}'); + } + + return self::$projectNameTemplate; + } + + private static function getUptimeCheckConfigNameTemplate() + { + if (null == self::$uptimeCheckConfigNameTemplate) { + self::$uptimeCheckConfigNameTemplate = new PathTemplate('projects/{project}/uptimeCheckConfigs/{uptime_check_config}'); + } + + return self::$uptimeCheckConfigNameTemplate; + } + + private static function getPathTemplateMap() + { + if (null == self::$pathTemplateMap) { + self::$pathTemplateMap = [ + 'project' => self::getProjectNameTemplate(), + 'uptimeCheckConfig' => self::getUptimeCheckConfigNameTemplate(), + ]; + } + + return self::$pathTemplateMap; + } + + /** + * Formats a string containing the fully-qualified path to represent + * a project resource. + * + * @param string $project + * + * @return string The formatted project resource. + * @experimental + */ + public static function projectName($project) + { + return self::getProjectNameTemplate()->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent + * a uptime_check_config resource. + * + * @param string $project + * @param string $uptimeCheckConfig + * + * @return string The formatted uptime_check_config resource. + * @experimental + */ + public static function uptimeCheckConfigName($project, $uptimeCheckConfig) + { + return self::getUptimeCheckConfigNameTemplate()->render([ + 'project' => $project, + 'uptime_check_config' => $uptimeCheckConfig, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - project: projects/{project} + * - uptimeCheckConfig: projects/{project}/uptimeCheckConfigs/{uptime_check_config}. + * + * 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. + * @experimental + */ + 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"); + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $serviceAddress The domain name of the API remote host. + * Default 'monitoring.googleapis.com'. + * @type mixed $port The port on which to connect to the remote host. Default 443. + * @type \Grpc\Channel $channel + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. + * @type \Grpc\ChannelCredentials $sslCreds + * A `ChannelCredentials` object for use with an SSL-enabled channel. + * Default: a credentials object returned from + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. + * @type bool $forceNewChannel + * If true, this forces gRPC to create a new channel instead of using a persistent channel. + * Defaults to false. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. + * @type \Google\Auth\CredentialsLoader $credentialsLoader + * A CredentialsLoader object created using the Google\Auth library. + * @type array $scopes A string array of scopes to use when acquiring credentials. + * Defaults to the scopes for the Stackdriver Monitoring API. + * @type string $clientConfigPath + * Path to a JSON file containing client method configuration, including retry settings. + * Specify this setting to specify the retry behavior of all methods on the client. + * By default this settings points to the default client config file, which is provided + * in the resources folder. The retry settings provided in this option can be overridden + * by settings in $retryingOverride + * @type array $retryingOverride + * An associative array in which the keys are method names (e.g. 'createFoo'), and + * the values are retry settings to use for that method. The retry settings for each + * method can be a {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on {@see Google\ApiCore\RetrySettings} + * for example usage. Passing a value of null is equivalent to a value of + * ['retriesEnabled' => false]. Retry settings provided in this setting override the + * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. + * } + * @experimental + */ + public function __construct($options = []) + { + $this->setClientOptions($options + self::$clientDefaults); + } + + /** + * Lists the existing valid uptime check configurations for the project, + * leaving out any invalid configurations. + * + * Sample code: + * ``` + * try { + * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); + * $formattedParent = $uptimeCheckServiceClient->projectName('[PROJECT]'); + * // Iterate through all elements + * $pagedResponse = $uptimeCheckServiceClient->listUptimeCheckConfigs($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * + * // OR iterate over pages of elements + * $pagedResponse = $uptimeCheckServiceClient->listUptimeCheckConfigs($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * } finally { + * $uptimeCheckServiceClient->close(); + * } + * ``` + * + * @param string $parent The project whose uptime check configurations are listed. The format is + * + * `projects/[PROJECT_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 \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function listUptimeCheckConfigs($parent, $optionalArgs = []) + { + $request = new ListUptimeCheckConfigsRequest(); + $request->setParent($parent); + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListUptimeCheckConfigs', + ListUptimeCheckConfigsResponse::class, + $request + ), + $this->configureCallSettings('listUptimeCheckConfigs', $optionalArgs), + $this->descriptors['listUptimeCheckConfigs']['pageStreaming'] + ); + } + + /** + * Gets a single uptime check configuration. + * + * Sample code: + * ``` + * try { + * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); + * $formattedName = $uptimeCheckServiceClient->uptimeCheckConfigName('[PROJECT]', '[UPTIME_CHECK_CONFIG]'); + * $response = $uptimeCheckServiceClient->getUptimeCheckConfig($formattedName); + * } finally { + * $uptimeCheckServiceClient->close(); + * } + * ``` + * + * @param string $name The uptime check configuration to retrieve. The format is + * + * `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`. + * @param array $optionalArgs { + * Optional. + * + * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function getUptimeCheckConfig($name, $optionalArgs = []) + { + $request = new GetUptimeCheckConfigRequest(); + $request->setName($name); + + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetUptimeCheckConfig', + UptimeCheckConfig::class, + $request + ), + $this->configureCallSettings('getUptimeCheckConfig', $optionalArgs) + )->wait(); + } + + /** + * Creates a new uptime check configuration. + * + * Sample code: + * ``` + * try { + * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); + * $formattedParent = $uptimeCheckServiceClient->projectName('[PROJECT]'); + * $uptimeCheckConfig = new UptimeCheckConfig(); + * $response = $uptimeCheckServiceClient->createUptimeCheckConfig($formattedParent, $uptimeCheckConfig); + * } finally { + * $uptimeCheckServiceClient->close(); + * } + * ``` + * + * @param string $parent The project in which to create the uptime check. The format is: + * + * `projects/[PROJECT_ID]`. + * @param UptimeCheckConfig $uptimeCheckConfig The new uptime check configuration. + * @param array $optionalArgs { + * Optional. + * + * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function createUptimeCheckConfig($parent, $uptimeCheckConfig, $optionalArgs = []) + { + $request = new CreateUptimeCheckConfigRequest(); + $request->setParent($parent); + $request->setUptimeCheckConfig($uptimeCheckConfig); + + return $this->startCall( + new Call( + self::SERVICE_NAME.'/CreateUptimeCheckConfig', + UptimeCheckConfig::class, + $request + ), + $this->configureCallSettings('createUptimeCheckConfig', $optionalArgs) + )->wait(); + } + + /** + * Updates an uptime check configuration. You can either replace the entire + * configuration with a new one or replace only certain fields in the current + * configuration by specifying the fields to be updated via `"updateMask"`. + * Returns the updated configuration. + * + * Sample code: + * ``` + * try { + * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); + * $uptimeCheckConfig = new UptimeCheckConfig(); + * $response = $uptimeCheckServiceClient->updateUptimeCheckConfig($uptimeCheckConfig); + * } finally { + * $uptimeCheckServiceClient->close(); + * } + * ``` + * + * @param UptimeCheckConfig $uptimeCheckConfig Required. If an `"updateMask"` has been specified, this field gives + * the values for the set of fields mentioned in the `"updateMask"`. If an + * `"updateMask"` has not been given, this uptime check configuration replaces + * the current configuration. If a field is mentioned in `"updateMask`" but + * the corresonding field is omitted in this partial uptime check + * configuration, it has the effect of deleting/clearing the field from the + * configuration on the server. + * @param array $optionalArgs { + * Optional. + * + * @type FieldMask $updateMask + * Optional. If present, only the listed fields in the current uptime check + * configuration are updated with values from the new configuration. If this + * field is empty, then the current configuration is completely replaced with + * the new configuration. + * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function updateUptimeCheckConfig($uptimeCheckConfig, $optionalArgs = []) + { + $request = new UpdateUptimeCheckConfigRequest(); + $request->setUptimeCheckConfig($uptimeCheckConfig); + if (isset($optionalArgs['updateMask'])) { + $request->setUpdateMask($optionalArgs['updateMask']); + } + + return $this->startCall( + new Call( + self::SERVICE_NAME.'/UpdateUptimeCheckConfig', + UptimeCheckConfig::class, + $request + ), + $this->configureCallSettings('updateUptimeCheckConfig', $optionalArgs) + )->wait(); + } + + /** + * Deletes an uptime check configuration. Note that this method will fail + * if the uptime check configuration is referenced by an alert policy or + * other dependent configs that would be rendered invalid by the deletion. + * + * Sample code: + * ``` + * try { + * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); + * $formattedName = $uptimeCheckServiceClient->uptimeCheckConfigName('[PROJECT]', '[UPTIME_CHECK_CONFIG]'); + * $uptimeCheckServiceClient->deleteUptimeCheckConfig($formattedName); + * } finally { + * $uptimeCheckServiceClient->close(); + * } + * ``` + * + * @param string $name The uptime check configuration to delete. The format is + * + * `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`. + * @param array $optionalArgs { + * Optional. + * + * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function deleteUptimeCheckConfig($name, $optionalArgs = []) + { + $request = new DeleteUptimeCheckConfigRequest(); + $request->setName($name); + + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteUptimeCheckConfig', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteUptimeCheckConfig', $optionalArgs) + )->wait(); + } + + /** + * Returns the list of IPs that checkers run from. + * + * Sample code: + * ``` + * try { + * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); + * + * // Iterate through all elements + * $pagedResponse = $uptimeCheckServiceClient->listUptimeCheckIps(); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * + * // OR iterate over pages of elements + * $pagedResponse = $uptimeCheckServiceClient->listUptimeCheckIps(); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * } finally { + * $uptimeCheckServiceClient->close(); + * } + * ``` + * + * @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 \Google\ApiCore\RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws \Google\ApiCore\ApiException if the remote call fails + * @experimental + */ + public function listUptimeCheckIps($optionalArgs = []) + { + $request = new ListUptimeCheckIpsRequest(); + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListUptimeCheckIps', + ListUptimeCheckIpsResponse::class, + $request + ), + $this->configureCallSettings('listUptimeCheckIps', $optionalArgs), + $this->descriptors['listUptimeCheckIps']['pageStreaming'] + ); + } + + /** + * Initiates an orderly shutdown in which preexisting calls continue but new + * calls are immediately cancelled. + * + * @experimental + */ + public function close() + { + $this->transport->close(); + } +} diff --git a/src/Monitoring/V3/UptimeCheckServiceClient.php b/src/Monitoring/V3/UptimeCheckServiceClient.php new file mode 100644 index 000000000000..3b8303bf2bb3 --- /dev/null +++ b/src/Monitoring/V3/UptimeCheckServiceClient.php @@ -0,0 +1,42 @@ + [ + 'google.monitoring.v3.GroupService' => [ + 'listGroups' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getGroup', + ], + ], + 'listGroupMembers' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getMembers', + ], + ], + ], + ], +]; diff --git a/src/Monitoring/V3/resources/group_service_rest_client_config.php b/src/Monitoring/V3/resources/group_service_rest_client_config.php new file mode 100644 index 000000000000..bc4eb32f9c31 --- /dev/null +++ b/src/Monitoring/V3/resources/group_service_rest_client_config.php @@ -0,0 +1,65 @@ + [ + 'google.monitoring.v3.GroupService' => [ + 'ListGroups' => [ + 'method' => 'get', + 'uri' => '/v3/{name=projects/*}/groups', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'GetGroup' => [ + 'method' => 'get', + 'uri' => '/v3/{name=projects/*/groups/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'CreateGroup' => [ + 'method' => 'post', + 'uri' => '/v3/{name=projects/*}/groups', + 'body' => 'group', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'UpdateGroup' => [ + 'method' => 'put', + 'uri' => '/v3/{group.name=projects/*/groups/*}', + 'body' => 'group', + 'placeholders' => [ + 'group.name' => [ + 'getGroup', + 'getName', + ], + ], + ], + 'DeleteGroup' => [ + 'method' => 'delete', + 'uri' => '/v3/{name=projects/*/groups/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'ListGroupMembers' => [ + 'method' => 'get', + 'uri' => '/v3/{name=projects/*/groups/*}/members', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + ], + ], +]; diff --git a/src/Monitoring/V3/resources/metric_service_descriptor_config.php b/src/Monitoring/V3/resources/metric_service_descriptor_config.php new file mode 100644 index 000000000000..57f8e2202a05 --- /dev/null +++ b/src/Monitoring/V3/resources/metric_service_descriptor_config.php @@ -0,0 +1,38 @@ + [ + 'google.monitoring.v3.MetricService' => [ + 'listMonitoredResourceDescriptors' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getResourceDescriptors', + ], + ], + 'listMetricDescriptors' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getMetricDescriptors', + ], + ], + 'listTimeSeries' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getTimeSeries', + ], + ], + ], + ], +]; diff --git a/src/Monitoring/V3/resources/metric_service_rest_client_config.php b/src/Monitoring/V3/resources/metric_service_rest_client_config.php new file mode 100644 index 000000000000..3ad982f52a4e --- /dev/null +++ b/src/Monitoring/V3/resources/metric_service_rest_client_config.php @@ -0,0 +1,82 @@ + [ + 'google.monitoring.v3.MetricService' => [ + 'ListMonitoredResourceDescriptors' => [ + 'method' => 'get', + 'uri' => '/v3/{name=projects/*}/monitoredResourceDescriptors', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'GetMonitoredResourceDescriptor' => [ + 'method' => 'get', + 'uri' => '/v3/{name=projects/*/monitoredResourceDescriptors/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'ListMetricDescriptors' => [ + 'method' => 'get', + 'uri' => '/v3/{name=projects/*}/metricDescriptors', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'GetMetricDescriptor' => [ + 'method' => 'get', + 'uri' => '/v3/{name=projects/*/metricDescriptors/**}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'CreateMetricDescriptor' => [ + 'method' => 'post', + 'uri' => '/v3/{name=projects/*}/metricDescriptors', + 'body' => 'metric_descriptor', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'DeleteMetricDescriptor' => [ + 'method' => 'delete', + 'uri' => '/v3/{name=projects/*/metricDescriptors/**}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'ListTimeSeries' => [ + 'method' => 'get', + 'uri' => '/v3/{name=projects/*}/timeSeries', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'CreateTimeSeries' => [ + 'method' => 'post', + 'uri' => '/v3/{name=projects/*}/timeSeries', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + ], + ], +]; diff --git a/src/Monitoring/V3/resources/uptime_check_service_client_config.json b/src/Monitoring/V3/resources/uptime_check_service_client_config.json new file mode 100644 index 000000000000..11705881bb15 --- /dev/null +++ b/src/Monitoring/V3/resources/uptime_check_service_client_config.json @@ -0,0 +1,56 @@ +{ + "interfaces": { + "google.monitoring.v3.UptimeCheckService": { + "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 20000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListUptimeCheckConfigs": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetUptimeCheckConfig": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateUptimeCheckConfig": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateUptimeCheckConfig": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteUptimeCheckConfig": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListUptimeCheckIps": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/src/Monitoring/V3/resources/uptime_check_service_descriptor_config.php b/src/Monitoring/V3/resources/uptime_check_service_descriptor_config.php new file mode 100644 index 000000000000..71a8aa121be0 --- /dev/null +++ b/src/Monitoring/V3/resources/uptime_check_service_descriptor_config.php @@ -0,0 +1,28 @@ + [ + 'google.monitoring.v3.UptimeCheckService' => [ + 'listUptimeCheckConfigs' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getUptimeCheckConfigs', + ], + ], + 'listUptimeCheckIps' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getUptimeCheckIps', + ], + ], + ], + ], +]; diff --git a/src/Monitoring/V3/resources/uptime_check_service_rest_client_config.php b/src/Monitoring/V3/resources/uptime_check_service_rest_client_config.php new file mode 100644 index 000000000000..da593359d43d --- /dev/null +++ b/src/Monitoring/V3/resources/uptime_check_service_rest_client_config.php @@ -0,0 +1,60 @@ + [ + 'google.monitoring.v3.UptimeCheckService' => [ + 'ListUptimeCheckConfigs' => [ + 'method' => 'get', + 'uri' => '/v3/{parent=projects/*}/uptimeCheckConfigs', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'GetUptimeCheckConfig' => [ + 'method' => 'get', + 'uri' => '/v3/{name=projects/*/uptimeCheckConfigs/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'CreateUptimeCheckConfig' => [ + 'method' => 'post', + 'uri' => '/v3/{parent=projects/*}/uptimeCheckConfigs', + 'body' => 'uptime_check_config', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'UpdateUptimeCheckConfig' => [ + 'method' => 'patch', + 'uri' => '/v3/{uptime_check_config.name=projects/*/uptimeCheckConfigs/*}', + 'body' => 'uptime_check_config', + 'placeholders' => [ + 'uptime_check_config.name' => [ + 'getUptime_check_config', + 'getName', + ], + ], + ], + 'DeleteUptimeCheckConfig' => [ + 'method' => 'delete', + 'uri' => '/v3/{name=projects/*/uptimeCheckConfigs/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'ListUptimeCheckIps' => [ + 'method' => 'get', + 'uri' => '/v3/uptimeCheckIps', + ], + ], + ], +]; diff --git a/src/PubSub/V1/Gapic/PublisherGapicClient.php b/src/PubSub/V1/Gapic/PublisherGapicClient.php index 5d70abd40a95..75e3be4db722 100644 --- a/src/PubSub/V1/Gapic/PublisherGapicClient.php +++ b/src/PubSub/V1/Gapic/PublisherGapicClient.php @@ -30,29 +30,29 @@ namespace Google\Cloud\PubSub\V1\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; -use Google\ApiCore\PageStreamingDescriptor; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; use Google\Cloud\Iam\V1\GetIamPolicyRequest; -use Google\Cloud\Iam\V1\IAMPolicyGrpcClient; use Google\Cloud\Iam\V1\Policy; use Google\Cloud\Iam\V1\SetIamPolicyRequest; use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; use Google\Cloud\PubSub\V1\DeleteTopicRequest; use Google\Cloud\PubSub\V1\GetTopicRequest; use Google\Cloud\PubSub\V1\ListTopicSubscriptionsRequest; +use Google\Cloud\PubSub\V1\ListTopicSubscriptionsResponse; use Google\Cloud\PubSub\V1\ListTopicsRequest; +use Google\Cloud\PubSub\V1\ListTopicsResponse; use Google\Cloud\PubSub\V1\PublishRequest; -use Google\Cloud\PubSub\V1\PublisherGrpcClient; +use Google\Cloud\PubSub\V1\PublishResponse; use Google\Cloud\PubSub\V1\PubsubMessage; use Google\Cloud\PubSub\V1\Topic; use Google\Cloud\PubSub\V1\UpdateTopicRequest; -use Google\Cloud\Version; use Google\Protobuf\FieldMask; +use Google\Protobuf\GPBEmpty; /** * Service Description: The service that an application uses to manipulate topics, and to send @@ -84,6 +84,13 @@ */ class PublisherGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.pubsub.v1.Publisher'; + /** * The default address of the service. */ @@ -107,19 +114,22 @@ class PublisherGapicClient private static $projectNameTemplate; private static $topicNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $iamPolicyStub; - protected $publisherStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/pubsub', + ], + 'clientConfigPath' => __DIR__.'/../resources/publisher_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/publisher_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/publisher_descriptor_config.php', + ]; private static function getProjectNameTemplate() { - if (self::$projectNameTemplate == null) { + if (null == self::$projectNameTemplate) { self::$projectNameTemplate = new PathTemplate('projects/{project}'); } @@ -128,7 +138,7 @@ private static function getProjectNameTemplate() private static function getTopicNameTemplate() { - if (self::$topicNameTemplate == null) { + if (null == self::$topicNameTemplate) { self::$topicNameTemplate = new PathTemplate('projects/{project}/topics/{topic}'); } @@ -137,7 +147,7 @@ private static function getTopicNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'project' => self::getProjectNameTemplate(), 'topic' => self::getTopicNameTemplate(), @@ -147,49 +157,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getPageStreamingDescriptors() - { - $listTopicsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getTopics', - ]); - $listTopicSubscriptionsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getSubscriptions', - ]); - - $pageStreamingDescriptors = [ - 'listTopics' => $listTopicsPageStreamingDescriptor, - 'listTopicSubscriptions' => $listTopicSubscriptionsPageStreamingDescriptor, - ]; - - return $pageStreamingDescriptors; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a project resource. @@ -276,16 +243,19 @@ public static function parseName($formattedName, $template = null) * Default 'pubsub.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -304,82 +274,23 @@ public static function parseName($formattedName, $template = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/pubsub', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/publisher_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'createTopic' => $defaultDescriptors, - 'updateTopic' => $defaultDescriptors, - 'publish' => $defaultDescriptors, - 'getTopic' => $defaultDescriptors, - 'listTopics' => $defaultDescriptors, - 'listTopicSubscriptions' => $defaultDescriptors, - 'deleteTopic' => $defaultDescriptors, - 'setIamPolicy' => $defaultDescriptors, - 'getIamPolicy' => $defaultDescriptors, - 'testIamPermissions' => $defaultDescriptors, - ]; - $pageStreamingDescriptors = self::getPageStreamingDescriptors(); - foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { - $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.pubsub.v1.Publisher', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createIamPolicyStubFunction = function ($hostname, $opts, $channel) { - return new IAMPolicyGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createIamPolicyStubFunction', $options)) { - $createIamPolicyStubFunction = $options['createIamPolicyStubFunction']; - } - $this->iamPolicyStub = $this->grpcCredentialsHelper->createStub($createIamPolicyStubFunction); - $createPublisherStubFunction = function ($hostname, $opts, $channel) { - return new PublisherGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createPublisherStubFunction', $options)) { - $createPublisherStubFunction = $options['createPublisherStubFunction']; - } - $this->publisherStub = $this->grpcCredentialsHelper->createStub($createPublisherStubFunction); + $this->setClientOptions($options + self::$clientDefaults); } /** @@ -427,24 +338,14 @@ public function createTopic($name, $optionalArgs = []) $request->setLabels($optionalArgs['labels']); } - $defaultCallSettings = $this->defaultCallSettings['createTopic']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->publisherStub, - 'CreateTopic', - $mergedSettings, - $this->descriptors['createTopic'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/CreateTopic', + Topic::class, + $request + ), + $this->configureCallSettings('createTopic', $optionalArgs) + )->wait(); } /** @@ -491,24 +392,14 @@ public function updateTopic($topic, $updateMask, $optionalArgs = []) $request->setTopic($topic); $request->setUpdateMask($updateMask); - $defaultCallSettings = $this->defaultCallSettings['updateTopic']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->publisherStub, - 'UpdateTopic', - $mergedSettings, - $this->descriptors['updateTopic'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/UpdateTopic', + Topic::class, + $request + ), + $this->configureCallSettings('updateTopic', $optionalArgs) + )->wait(); } /** @@ -555,24 +446,14 @@ public function publish($topic, $messages, $optionalArgs = []) $request->setTopic($topic); $request->setMessages($messages); - $defaultCallSettings = $this->defaultCallSettings['publish']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->publisherStub, - 'Publish', - $mergedSettings, - $this->descriptors['publish'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/Publish', + PublishResponse::class, + $request + ), + $this->configureCallSettings('publish', $optionalArgs) + )->wait(); } /** @@ -611,24 +492,14 @@ public function getTopic($topic, $optionalArgs = []) $request = new GetTopicRequest(); $request->setTopic($topic); - $defaultCallSettings = $this->defaultCallSettings['getTopic']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->publisherStub, - 'GetTopic', - $mergedSettings, - $this->descriptors['getTopic'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetTopic', + Topic::class, + $request + ), + $this->configureCallSettings('getTopic', $optionalArgs) + )->wait(); } /** @@ -694,24 +565,15 @@ public function listTopics($project, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listTopics']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->publisherStub, - 'ListTopics', - $mergedSettings, - $this->descriptors['listTopics'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListTopics', + ListTopicsResponse::class, + $request + ), + $this->configureCallSettings('listTopics', $optionalArgs), + $this->descriptors['listTopics']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -777,24 +639,15 @@ public function listTopicSubscriptions($topic, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listTopicSubscriptions']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->publisherStub, - 'ListTopicSubscriptions', - $mergedSettings, - $this->descriptors['listTopicSubscriptions'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListTopicSubscriptions', + ListTopicSubscriptionsResponse::class, + $request + ), + $this->configureCallSettings('listTopicSubscriptions', $optionalArgs), + $this->descriptors['listTopicSubscriptions']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -835,24 +688,14 @@ public function deleteTopic($topic, $optionalArgs = []) $request = new DeleteTopicRequest(); $request->setTopic($topic); - $defaultCallSettings = $this->defaultCallSettings['deleteTopic']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->publisherStub, - 'DeleteTopic', - $mergedSettings, - $this->descriptors['deleteTopic'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteTopic', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteTopic', $optionalArgs) + )->wait(); } /** @@ -899,24 +742,14 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) $request->setResource($resource); $request->setPolicy($policy); - $defaultCallSettings = $this->defaultCallSettings['setIamPolicy']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->iamPolicyStub, - 'SetIamPolicy', - $mergedSettings, - $this->descriptors['setIamPolicy'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/SetIamPolicy', + Policy::class, + $request + ), + $this->configureCallSettings('setIamPolicy', $optionalArgs) + )->wait(); } /** @@ -958,24 +791,14 @@ public function getIamPolicy($resource, $optionalArgs = []) $request = new GetIamPolicyRequest(); $request->setResource($resource); - $defaultCallSettings = $this->defaultCallSettings['getIamPolicy']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->iamPolicyStub, - 'GetIamPolicy', - $mergedSettings, - $this->descriptors['getIamPolicy'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetIamPolicy', + Policy::class, + $request + ), + $this->configureCallSettings('getIamPolicy', $optionalArgs) + )->wait(); } /** @@ -1023,24 +846,14 @@ public function testIamPermissions($resource, $permissions, $optionalArgs = []) $request->setResource($resource); $request->setPermissions($permissions); - $defaultCallSettings = $this->defaultCallSettings['testIamPermissions']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->iamPolicyStub, - 'TestIamPermissions', - $mergedSettings, - $this->descriptors['testIamPermissions'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/TestIamPermissions', + TestIamPermissionsResponse::class, + $request + ), + $this->configureCallSettings('testIamPermissions', $optionalArgs) + )->wait(); } /** @@ -1051,12 +864,6 @@ public function testIamPermissions($resource, $permissions, $optionalArgs = []) */ public function close() { - $this->iamPolicyStub->close(); - $this->publisherStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/PubSub/V1/Gapic/SubscriberGapicClient.php b/src/PubSub/V1/Gapic/SubscriberGapicClient.php index 25e2497d0826..2ddf3a8b04a1 100644 --- a/src/PubSub/V1/Gapic/SubscriberGapicClient.php +++ b/src/PubSub/V1/Gapic/SubscriberGapicClient.php @@ -30,39 +30,41 @@ namespace Google\Cloud\PubSub\V1\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; -use Google\ApiCore\PageStreamingDescriptor; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; use Google\Cloud\Iam\V1\GetIamPolicyRequest; -use Google\Cloud\Iam\V1\IAMPolicyGrpcClient; use Google\Cloud\Iam\V1\Policy; use Google\Cloud\Iam\V1\SetIamPolicyRequest; use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; use Google\Cloud\PubSub\V1\AcknowledgeRequest; use Google\Cloud\PubSub\V1\CreateSnapshotRequest; use Google\Cloud\PubSub\V1\DeleteSnapshotRequest; use Google\Cloud\PubSub\V1\DeleteSubscriptionRequest; use Google\Cloud\PubSub\V1\GetSubscriptionRequest; use Google\Cloud\PubSub\V1\ListSnapshotsRequest; +use Google\Cloud\PubSub\V1\ListSnapshotsResponse; use Google\Cloud\PubSub\V1\ListSubscriptionsRequest; +use Google\Cloud\PubSub\V1\ListSubscriptionsResponse; use Google\Cloud\PubSub\V1\ModifyAckDeadlineRequest; use Google\Cloud\PubSub\V1\ModifyPushConfigRequest; use Google\Cloud\PubSub\V1\PullRequest; +use Google\Cloud\PubSub\V1\PullResponse; use Google\Cloud\PubSub\V1\PushConfig; use Google\Cloud\PubSub\V1\SeekRequest; +use Google\Cloud\PubSub\V1\SeekResponse; use Google\Cloud\PubSub\V1\Snapshot; use Google\Cloud\PubSub\V1\StreamingPullRequest; -use Google\Cloud\PubSub\V1\SubscriberGrpcClient; +use Google\Cloud\PubSub\V1\StreamingPullResponse; use Google\Cloud\PubSub\V1\Subscription; use Google\Cloud\PubSub\V1\UpdateSnapshotRequest; use Google\Cloud\PubSub\V1\UpdateSubscriptionRequest; -use Google\Cloud\Version; use Google\Protobuf\Duration; use Google\Protobuf\FieldMask; +use Google\Protobuf\GPBEmpty; use Google\Protobuf\Timestamp; /** @@ -96,6 +98,13 @@ */ class SubscriberGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.pubsub.v1.Subscriber'; + /** * The default address of the service. */ @@ -121,19 +130,22 @@ class SubscriberGapicClient private static $subscriptionNameTemplate; private static $topicNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $iamPolicyStub; - protected $subscriberStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/pubsub', + ], + 'clientConfigPath' => __DIR__.'/../resources/subscriber_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/subscriber_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/subscriber_descriptor_config.php', + ]; private static function getProjectNameTemplate() { - if (self::$projectNameTemplate == null) { + if (null == self::$projectNameTemplate) { self::$projectNameTemplate = new PathTemplate('projects/{project}'); } @@ -142,7 +154,7 @@ private static function getProjectNameTemplate() private static function getSnapshotNameTemplate() { - if (self::$snapshotNameTemplate == null) { + if (null == self::$snapshotNameTemplate) { self::$snapshotNameTemplate = new PathTemplate('projects/{project}/snapshots/{snapshot}'); } @@ -151,7 +163,7 @@ private static function getSnapshotNameTemplate() private static function getSubscriptionNameTemplate() { - if (self::$subscriptionNameTemplate == null) { + if (null == self::$subscriptionNameTemplate) { self::$subscriptionNameTemplate = new PathTemplate('projects/{project}/subscriptions/{subscription}'); } @@ -160,7 +172,7 @@ private static function getSubscriptionNameTemplate() private static function getTopicNameTemplate() { - if (self::$topicNameTemplate == null) { + if (null == self::$topicNameTemplate) { self::$topicNameTemplate = new PathTemplate('projects/{project}/topics/{topic}'); } @@ -169,7 +181,7 @@ private static function getTopicNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'project' => self::getProjectNameTemplate(), 'snapshot' => self::getSnapshotNameTemplate(), @@ -181,59 +193,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getPageStreamingDescriptors() - { - $listSubscriptionsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getSubscriptions', - ]); - $listSnapshotsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getSnapshots', - ]); - - $pageStreamingDescriptors = [ - 'listSubscriptions' => $listSubscriptionsPageStreamingDescriptor, - 'listSnapshots' => $listSnapshotsPageStreamingDescriptor, - ]; - - return $pageStreamingDescriptors; - } - - private static function getGrpcStreamingDescriptors() - { - return [ - 'streamingPull' => [ - 'grpcStreamingType' => 'BidiStreaming', - 'resourcesGetMethod' => 'getReceivedMessages', - ], - ]; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a project resource. @@ -358,16 +317,19 @@ public static function parseName($formattedName, $template = null) * Default 'pubsub.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -386,94 +348,23 @@ public static function parseName($formattedName, $template = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/pubsub', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/subscriber_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'createSubscription' => $defaultDescriptors, - 'getSubscription' => $defaultDescriptors, - 'updateSubscription' => $defaultDescriptors, - 'listSubscriptions' => $defaultDescriptors, - 'deleteSubscription' => $defaultDescriptors, - 'modifyAckDeadline' => $defaultDescriptors, - 'acknowledge' => $defaultDescriptors, - 'pull' => $defaultDescriptors, - 'streamingPull' => $defaultDescriptors, - 'modifyPushConfig' => $defaultDescriptors, - 'listSnapshots' => $defaultDescriptors, - 'createSnapshot' => $defaultDescriptors, - 'updateSnapshot' => $defaultDescriptors, - 'deleteSnapshot' => $defaultDescriptors, - 'seek' => $defaultDescriptors, - 'setIamPolicy' => $defaultDescriptors, - 'getIamPolicy' => $defaultDescriptors, - 'testIamPermissions' => $defaultDescriptors, - ]; - $pageStreamingDescriptors = self::getPageStreamingDescriptors(); - foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { - $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; - } - $grpcStreamingDescriptors = self::getGrpcStreamingDescriptors(); - foreach ($grpcStreamingDescriptors as $method => $grpcStreamingDescriptor) { - $this->descriptors[$method]['grpcStreamingDescriptor'] = $grpcStreamingDescriptor; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.pubsub.v1.Subscriber', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createIamPolicyStubFunction = function ($hostname, $opts, $channel) { - return new IAMPolicyGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createIamPolicyStubFunction', $options)) { - $createIamPolicyStubFunction = $options['createIamPolicyStubFunction']; - } - $this->iamPolicyStub = $this->grpcCredentialsHelper->createStub($createIamPolicyStubFunction); - $createSubscriberStubFunction = function ($hostname, $opts, $channel) { - return new SubscriberGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createSubscriberStubFunction', $options)) { - $createSubscriberStubFunction = $options['createSubscriberStubFunction']; - } - $this->subscriberStub = $this->grpcCredentialsHelper->createStub($createSubscriberStubFunction); + $this->setClientOptions($options + self::$clientDefaults); } /** @@ -584,24 +475,14 @@ public function createSubscription($name, $topic, $optionalArgs = []) $request->setLabels($optionalArgs['labels']); } - $defaultCallSettings = $this->defaultCallSettings['createSubscription']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->subscriberStub, - 'CreateSubscription', - $mergedSettings, - $this->descriptors['createSubscription'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/CreateSubscription', + Subscription::class, + $request + ), + $this->configureCallSettings('createSubscription', $optionalArgs) + )->wait(); } /** @@ -640,24 +521,14 @@ public function getSubscription($subscription, $optionalArgs = []) $request = new GetSubscriptionRequest(); $request->setSubscription($subscription); - $defaultCallSettings = $this->defaultCallSettings['getSubscription']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->subscriberStub, - 'GetSubscription', - $mergedSettings, - $this->descriptors['getSubscription'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetSubscription', + Subscription::class, + $request + ), + $this->configureCallSettings('getSubscription', $optionalArgs) + )->wait(); } /** @@ -709,24 +580,14 @@ public function updateSubscription($subscription, $updateMask, $optionalArgs = [ $request->setSubscription($subscription); $request->setUpdateMask($updateMask); - $defaultCallSettings = $this->defaultCallSettings['updateSubscription']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->subscriberStub, - 'UpdateSubscription', - $mergedSettings, - $this->descriptors['updateSubscription'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/UpdateSubscription', + Subscription::class, + $request + ), + $this->configureCallSettings('updateSubscription', $optionalArgs) + )->wait(); } /** @@ -792,24 +653,15 @@ public function listSubscriptions($project, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listSubscriptions']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->subscriberStub, - 'ListSubscriptions', - $mergedSettings, - $this->descriptors['listSubscriptions'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListSubscriptions', + ListSubscriptionsResponse::class, + $request + ), + $this->configureCallSettings('listSubscriptions', $optionalArgs), + $this->descriptors['listSubscriptions']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -850,24 +702,14 @@ public function deleteSubscription($subscription, $optionalArgs = []) $request = new DeleteSubscriptionRequest(); $request->setSubscription($subscription); - $defaultCallSettings = $this->defaultCallSettings['deleteSubscription']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->subscriberStub, - 'DeleteSubscription', - $mergedSettings, - $this->descriptors['deleteSubscription'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteSubscription', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteSubscription', $optionalArgs) + )->wait(); } /** @@ -920,24 +762,14 @@ public function modifyAckDeadline($subscription, $ackIds, $ackDeadlineSeconds, $ $request->setAckIds($ackIds); $request->setAckDeadlineSeconds($ackDeadlineSeconds); - $defaultCallSettings = $this->defaultCallSettings['modifyAckDeadline']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->subscriberStub, - 'ModifyAckDeadline', - $mergedSettings, - $this->descriptors['modifyAckDeadline'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/ModifyAckDeadline', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('modifyAckDeadline', $optionalArgs) + )->wait(); } /** @@ -984,24 +816,14 @@ public function acknowledge($subscription, $ackIds, $optionalArgs = []) $request->setSubscription($subscription); $request->setAckIds($ackIds); - $defaultCallSettings = $this->defaultCallSettings['acknowledge']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->subscriberStub, - 'Acknowledge', - $mergedSettings, - $this->descriptors['acknowledge'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/Acknowledge', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('acknowledge', $optionalArgs) + )->wait(); } /** @@ -1057,24 +879,14 @@ public function pull($subscription, $maxMessages, $optionalArgs = []) $request->setReturnImmediately($optionalArgs['returnImmediately']); } - $defaultCallSettings = $this->defaultCallSettings['pull']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->subscriberStub, - 'Pull', - $mergedSettings, - $this->descriptors['pull'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/Pull', + PullResponse::class, + $request + ), + $this->configureCallSettings('pull', $optionalArgs) + )->wait(); } /** @@ -1145,31 +957,14 @@ public function pull($subscription, $maxMessages, $optionalArgs = []) */ public function streamingPull($optionalArgs = []) { - if (array_key_exists('timeoutMillis', $optionalArgs)) { - $optionalArgs['retrySettings'] = [ - 'retriesEnabled' => false, - 'noRetriesRpcTimeoutMillis' => $optionalArgs['timeoutMillis'], - ]; - } - - $defaultCallSettings = $this->defaultCallSettings['streamingPull']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->subscriberStub, - 'StreamingPull', - $mergedSettings, - $this->descriptors['streamingPull'] + return $this->transport->startBidiStreamingCall( + new Call( + self::SERVICE_NAME.'/StreamingPull', + StreamingPullResponse::class + ), + $this->configureCallSettings('streamingPull', $optionalArgs), + $this->descriptors['streamingPull']['grpcStreaming'] ); - - return $callable( - null, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -1219,24 +1014,14 @@ public function modifyPushConfig($subscription, $pushConfig, $optionalArgs = []) $request->setSubscription($subscription); $request->setPushConfig($pushConfig); - $defaultCallSettings = $this->defaultCallSettings['modifyPushConfig']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->subscriberStub, - 'ModifyPushConfig', - $mergedSettings, - $this->descriptors['modifyPushConfig'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/ModifyPushConfig', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('modifyPushConfig', $optionalArgs) + )->wait(); } /** @@ -1302,24 +1087,15 @@ public function listSnapshots($project, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listSnapshots']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->subscriberStub, - 'ListSnapshots', - $mergedSettings, - $this->descriptors['listSnapshots'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListSnapshots', + ListSnapshotsResponse::class, + $request + ), + $this->configureCallSettings('listSnapshots', $optionalArgs), + $this->descriptors['listSnapshots']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -1381,24 +1157,14 @@ public function createSnapshot($name, $subscription, $optionalArgs = []) $request->setName($name); $request->setSubscription($subscription); - $defaultCallSettings = $this->defaultCallSettings['createSnapshot']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->subscriberStub, - 'CreateSnapshot', - $mergedSettings, - $this->descriptors['createSnapshot'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/CreateSnapshot', + Snapshot::class, + $request + ), + $this->configureCallSettings('createSnapshot', $optionalArgs) + )->wait(); } /** @@ -1452,24 +1218,14 @@ public function updateSnapshot($snapshot, $updateMask, $optionalArgs = []) $request->setSnapshot($snapshot); $request->setUpdateMask($updateMask); - $defaultCallSettings = $this->defaultCallSettings['updateSnapshot']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->subscriberStub, - 'UpdateSnapshot', - $mergedSettings, - $this->descriptors['updateSnapshot'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/UpdateSnapshot', + Snapshot::class, + $request + ), + $this->configureCallSettings('updateSnapshot', $optionalArgs) + )->wait(); } /** @@ -1509,24 +1265,14 @@ public function deleteSnapshot($snapshot, $optionalArgs = []) $request = new DeleteSnapshotRequest(); $request->setSnapshot($snapshot); - $defaultCallSettings = $this->defaultCallSettings['deleteSnapshot']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->subscriberStub, - 'DeleteSnapshot', - $mergedSettings, - $this->descriptors['deleteSnapshot'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteSnapshot', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteSnapshot', $optionalArgs) + )->wait(); } /** @@ -1587,24 +1333,14 @@ public function seek($subscription, $optionalArgs = []) $request->setSnapshot($optionalArgs['snapshot']); } - $defaultCallSettings = $this->defaultCallSettings['seek']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->subscriberStub, - 'Seek', - $mergedSettings, - $this->descriptors['seek'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/Seek', + SeekResponse::class, + $request + ), + $this->configureCallSettings('seek', $optionalArgs) + )->wait(); } /** @@ -1651,24 +1387,14 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) $request->setResource($resource); $request->setPolicy($policy); - $defaultCallSettings = $this->defaultCallSettings['setIamPolicy']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->iamPolicyStub, - 'SetIamPolicy', - $mergedSettings, - $this->descriptors['setIamPolicy'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/SetIamPolicy', + Policy::class, + $request + ), + $this->configureCallSettings('setIamPolicy', $optionalArgs) + )->wait(); } /** @@ -1710,24 +1436,14 @@ public function getIamPolicy($resource, $optionalArgs = []) $request = new GetIamPolicyRequest(); $request->setResource($resource); - $defaultCallSettings = $this->defaultCallSettings['getIamPolicy']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->iamPolicyStub, - 'GetIamPolicy', - $mergedSettings, - $this->descriptors['getIamPolicy'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetIamPolicy', + Policy::class, + $request + ), + $this->configureCallSettings('getIamPolicy', $optionalArgs) + )->wait(); } /** @@ -1775,24 +1491,14 @@ public function testIamPermissions($resource, $permissions, $optionalArgs = []) $request->setResource($resource); $request->setPermissions($permissions); - $defaultCallSettings = $this->defaultCallSettings['testIamPermissions']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->iamPolicyStub, - 'TestIamPermissions', - $mergedSettings, - $this->descriptors['testIamPermissions'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/TestIamPermissions', + TestIamPermissionsResponse::class, + $request + ), + $this->configureCallSettings('testIamPermissions', $optionalArgs) + )->wait(); } /** @@ -1803,12 +1509,6 @@ public function testIamPermissions($resource, $permissions, $optionalArgs = []) */ public function close() { - $this->iamPolicyStub->close(); - $this->subscriberStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/PubSub/V1/resources/publisher_descriptor_config.php b/src/PubSub/V1/resources/publisher_descriptor_config.php new file mode 100644 index 000000000000..6f91c7b264cf --- /dev/null +++ b/src/PubSub/V1/resources/publisher_descriptor_config.php @@ -0,0 +1,28 @@ + [ + 'google.pubsub.v1.Publisher' => [ + 'listTopics' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getTopics', + ], + ], + 'listTopicSubscriptions' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getSubscriptions', + ], + ], + ], + ], +]; diff --git a/src/PubSub/V1/resources/publisher_rest_client_config.php b/src/PubSub/V1/resources/publisher_rest_client_config.php new file mode 100644 index 000000000000..0c68ef6bb188 --- /dev/null +++ b/src/PubSub/V1/resources/publisher_rest_client_config.php @@ -0,0 +1,105 @@ + [ + 'google.pubsub.v1.Publisher' => [ + 'CreateTopic' => [ + 'method' => 'put', + 'uri' => '/v1/{name=projects/*/topics/*}', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'UpdateTopic' => [ + 'method' => 'patch', + 'uri' => '/v1/{topic.name=projects/*/topics/*}', + 'body' => '*', + 'placeholders' => [ + 'topic.name' => [ + 'getTopic', + 'getName', + ], + ], + ], + 'Publish' => [ + 'method' => 'post', + 'uri' => '/v1/{topic=projects/*/topics/*}:publish', + 'body' => '*', + 'placeholders' => [ + 'topic' => [ + 'getTopic', + ], + ], + ], + 'GetTopic' => [ + 'method' => 'get', + 'uri' => '/v1/{topic=projects/*/topics/*}', + 'placeholders' => [ + 'topic' => [ + 'getTopic', + ], + ], + ], + 'ListTopics' => [ + 'method' => 'get', + 'uri' => '/v1/{project=projects/*}/topics', + 'placeholders' => [ + 'project' => [ + 'getProject', + ], + ], + ], + 'ListTopicSubscriptions' => [ + 'method' => 'get', + 'uri' => '/v1/{topic=projects/*/topics/*}/subscriptions', + 'placeholders' => [ + 'topic' => [ + 'getTopic', + ], + ], + ], + 'DeleteTopic' => [ + 'method' => 'delete', + 'uri' => '/v1/{topic=projects/*/topics/*}', + 'placeholders' => [ + 'topic' => [ + 'getTopic', + ], + ], + ], + 'SetIamPolicy' => [ + 'method' => 'post', + 'uri' => '/v1/{resource=**}:setIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getResource', + ], + ], + ], + 'GetIamPolicy' => [ + 'method' => 'post', + 'uri' => '/v1/{resource=**}:getIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getResource', + ], + ], + ], + 'TestIamPermissions' => [ + 'method' => 'post', + 'uri' => '/v1/{resource=**}:testIamPermissions', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getResource', + ], + ], + ], + ], + ], +]; diff --git a/src/PubSub/V1/resources/subscriber_descriptor_config.php b/src/PubSub/V1/resources/subscriber_descriptor_config.php new file mode 100644 index 000000000000..146b491ec59a --- /dev/null +++ b/src/PubSub/V1/resources/subscriber_descriptor_config.php @@ -0,0 +1,34 @@ + [ + 'google.pubsub.v1.Subscriber' => [ + 'listSubscriptions' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getSubscriptions', + ], + ], + 'listSnapshots' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getSnapshots', + ], + ], + 'streamingPull' => [ + 'grpcStreaming' => [ + 'grpcStreamingType' => 'BidiStreaming', + 'resourcesGetMethod' => 'getReceivedMessages', + ], + ], + ], + ], +]; diff --git a/src/PubSub/V1/resources/subscriber_rest_client_config.php b/src/PubSub/V1/resources/subscriber_rest_client_config.php new file mode 100644 index 000000000000..fac4f8339451 --- /dev/null +++ b/src/PubSub/V1/resources/subscriber_rest_client_config.php @@ -0,0 +1,175 @@ + [ + 'google.pubsub.v1.Subscriber' => [ + 'CreateSubscription' => [ + 'method' => 'put', + 'uri' => '/v1/{name=projects/*/subscriptions/*}', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'GetSubscription' => [ + 'method' => 'get', + 'uri' => '/v1/{subscription=projects/*/subscriptions/*}', + 'placeholders' => [ + 'subscription' => [ + 'getSubscription', + ], + ], + ], + 'UpdateSubscription' => [ + 'method' => 'patch', + 'uri' => '/v1/{subscription.name=projects/*/subscriptions/*}', + 'body' => '*', + 'placeholders' => [ + 'subscription.name' => [ + 'getSubscription', + 'getName', + ], + ], + ], + 'ListSubscriptions' => [ + 'method' => 'get', + 'uri' => '/v1/{project=projects/*}/subscriptions', + 'placeholders' => [ + 'project' => [ + 'getProject', + ], + ], + ], + 'DeleteSubscription' => [ + 'method' => 'delete', + 'uri' => '/v1/{subscription=projects/*/subscriptions/*}', + 'placeholders' => [ + 'subscription' => [ + 'getSubscription', + ], + ], + ], + 'ModifyAckDeadline' => [ + 'method' => 'post', + 'uri' => '/v1/{subscription=projects/*/subscriptions/*}:modifyAckDeadline', + 'body' => '*', + 'placeholders' => [ + 'subscription' => [ + 'getSubscription', + ], + ], + ], + 'Acknowledge' => [ + 'method' => 'post', + 'uri' => '/v1/{subscription=projects/*/subscriptions/*}:acknowledge', + 'body' => '*', + 'placeholders' => [ + 'subscription' => [ + 'getSubscription', + ], + ], + ], + 'Pull' => [ + 'method' => 'post', + 'uri' => '/v1/{subscription=projects/*/subscriptions/*}:pull', + 'body' => '*', + 'placeholders' => [ + 'subscription' => [ + 'getSubscription', + ], + ], + ], + 'ModifyPushConfig' => [ + 'method' => 'post', + 'uri' => '/v1/{subscription=projects/*/subscriptions/*}:modifyPushConfig', + 'body' => '*', + 'placeholders' => [ + 'subscription' => [ + 'getSubscription', + ], + ], + ], + 'ListSnapshots' => [ + 'method' => 'get', + 'uri' => '/v1/{project=projects/*}/snapshots', + 'placeholders' => [ + 'project' => [ + 'getProject', + ], + ], + ], + 'CreateSnapshot' => [ + 'method' => 'put', + 'uri' => '/v1/{name=projects/*/snapshots/*}', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'UpdateSnapshot' => [ + 'method' => 'patch', + 'uri' => '/v1/{snapshot.name=projects/*/snapshots/*}', + 'body' => '*', + 'placeholders' => [ + 'snapshot.name' => [ + 'getSnapshot', + 'getName', + ], + ], + ], + 'DeleteSnapshot' => [ + 'method' => 'delete', + 'uri' => '/v1/{snapshot=projects/*/snapshots/*}', + 'placeholders' => [ + 'snapshot' => [ + 'getSnapshot', + ], + ], + ], + 'Seek' => [ + 'method' => 'post', + 'uri' => '/v1/{subscription=projects/*/subscriptions/*}:seek', + 'body' => '*', + 'placeholders' => [ + 'subscription' => [ + 'getSubscription', + ], + ], + ], + 'SetIamPolicy' => [ + 'method' => 'post', + 'uri' => '/v1/{resource=**}:setIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getResource', + ], + ], + ], + 'GetIamPolicy' => [ + 'method' => 'post', + 'uri' => '/v1/{resource=**}:getIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getResource', + ], + ], + ], + 'TestIamPermissions' => [ + 'method' => 'post', + 'uri' => '/v1/{resource=**}:testIamPermissions', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getResource', + ], + ], + ], + ], + ], +]; diff --git a/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php b/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php index 2c234ecf2702..8f46fa6ed30d 100644 --- a/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php +++ b/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php @@ -30,30 +30,31 @@ namespace Google\Cloud\Spanner\Admin\Database\V1\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\OperationResponse; -use Google\ApiCore\PageStreamingDescriptor; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; use Google\Cloud\Iam\V1\GetIamPolicyRequest; use Google\Cloud\Iam\V1\Policy; use Google\Cloud\Iam\V1\SetIamPolicyRequest; use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; use Google\Cloud\Spanner\Admin\Database\V1\CreateDatabaseMetadata; use Google\Cloud\Spanner\Admin\Database\V1\CreateDatabaseRequest; use Google\Cloud\Spanner\Admin\Database\V1\Database; -use Google\Cloud\Spanner\Admin\Database\V1\DatabaseAdminGrpcClient; use Google\Cloud\Spanner\Admin\Database\V1\DropDatabaseRequest; use Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseDdlRequest; +use Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseDdlResponse; use Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseRequest; use Google\Cloud\Spanner\Admin\Database\V1\ListDatabasesRequest; +use Google\Cloud\Spanner\Admin\Database\V1\ListDatabasesResponse; use Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseDdlMetadata; use Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseDdlRequest; -use Google\Cloud\Version; +use Google\LongRunning\Operation; +use Google\Protobuf\GPBEmpty; /** * Service Description: Cloud Spanner Database Admin API. @@ -100,6 +101,13 @@ */ class DatabaseAdminGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.spanner.admin.database.v1.DatabaseAdmin'; + /** * The default address of the service. */ @@ -123,19 +131,24 @@ class DatabaseAdminGapicClient private static $instanceNameTemplate; private static $databaseNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/spanner.admin', + ], + 'clientConfigPath' => __DIR__.'/../resources/database_admin_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/database_admin_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/database_admin_descriptor_config.php', + ]; - protected $grpcCredentialsHelper; - protected $databaseAdminStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; private $operationsClient; private static function getInstanceNameTemplate() { - if (self::$instanceNameTemplate == null) { + if (null == self::$instanceNameTemplate) { self::$instanceNameTemplate = new PathTemplate('projects/{project}/instances/{instance}'); } @@ -144,7 +157,7 @@ private static function getInstanceNameTemplate() private static function getDatabaseNameTemplate() { - if (self::$databaseNameTemplate == null) { + if (null == self::$databaseNameTemplate) { self::$databaseNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/databases/{database}'); } @@ -153,7 +166,7 @@ private static function getDatabaseNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'instance' => self::getInstanceNameTemplate(), 'database' => self::getDatabaseNameTemplate(), @@ -163,53 +176,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getPageStreamingDescriptors() - { - $listDatabasesPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getDatabases', - ]); - - $pageStreamingDescriptors = [ - 'listDatabases' => $listDatabasesPageStreamingDescriptor, - ]; - - return $pageStreamingDescriptors; - } - - private static function getLongRunningDescriptors() - { - return [ - 'createDatabase' => [ - 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\Database', - 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\CreateDatabaseMetadata', - ], - 'updateDatabaseDdl' => [ - 'operationReturnType' => '\Google\Protobuf\GPBEmpty', - 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseDdlMetadata', - ], - ]; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a instance resource. @@ -316,12 +282,9 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $lroDescriptors = self::getLongRunningDescriptors(); - if (!is_null($methodName) && array_key_exists($methodName, $lroDescriptors)) { - $options = $lroDescriptors[$methodName]; - } else { - $options = []; - } + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); @@ -338,16 +301,19 @@ public function resumeOperation($operationName, $methodName = null) * Default 'spanner.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -366,87 +332,31 @@ public function resumeOperation($operationName, $methodName = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/spanner.admin', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/database_admin_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - if (array_key_exists('operationsClient', $options)) { - $this->operationsClient = $options['operationsClient']; - } else { - $operationsClientOptions = $options; - unset($operationsClientOptions['retryingOverride']); - unset($operationsClientOptions['clientConfigPath']); - $this->operationsClient = new OperationsClient($operationsClientOptions); - } - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'listDatabases' => $defaultDescriptors, - 'createDatabase' => $defaultDescriptors, - 'getDatabase' => $defaultDescriptors, - 'updateDatabaseDdl' => $defaultDescriptors, - 'dropDatabase' => $defaultDescriptors, - 'getDatabaseDdl' => $defaultDescriptors, - 'setIamPolicy' => $defaultDescriptors, - 'getIamPolicy' => $defaultDescriptors, - 'testIamPermissions' => $defaultDescriptors, - ]; - $pageStreamingDescriptors = self::getPageStreamingDescriptors(); - foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { - $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; - } - $longRunningDescriptors = self::getLongRunningDescriptors(); - foreach ($longRunningDescriptors as $method => $longRunningDescriptor) { - $this->descriptors[$method]['longRunningDescriptor'] = $longRunningDescriptor + ['operationsClient' => $this->operationsClient]; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.spanner.admin.database.v1.DatabaseAdmin', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createDatabaseAdminStubFunction = function ($hostname, $opts, $channel) { - return new DatabaseAdminGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createDatabaseAdminStubFunction', $options)) { - $createDatabaseAdminStubFunction = $options['createDatabaseAdminStubFunction']; - } - $this->databaseAdminStub = $this->grpcCredentialsHelper->createStub($createDatabaseAdminStubFunction); + $options += self::$clientDefaults; + $this->setClientOptions($options); + $this->pluckArray([ + 'serviceName', + 'clientConfigPath', + 'restClientConfigPath', + 'descriptorsConfigPath', + ], $options); + $this->operationsClient = new OperationsClient($options); } /** @@ -512,24 +422,15 @@ public function listDatabases($parent, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listDatabases']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->databaseAdminStub, - 'ListDatabases', - $mergedSettings, - $this->descriptors['listDatabases'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListDatabases', + ListDatabasesResponse::class, + $request + ), + $this->configureCallSettings('listDatabases', $optionalArgs), + $this->descriptors['listDatabases']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -615,24 +516,17 @@ public function createDatabase($parent, $createStatement, $optionalArgs = []) $request->setExtraStatements($optionalArgs['extraStatements']); } - $defaultCallSettings = $this->defaultCallSettings['createDatabase']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->databaseAdminStub, - 'CreateDatabase', - $mergedSettings, - $this->descriptors['createDatabase'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startOperationsCall( + new Call( + self::SERVICE_NAME.'/CreateDatabase', + Operation::class, + $request + ), + $this->configureCallSettings('createDatabase', $optionalArgs), + $this->descriptors['createDatabase']['longRunning'] + [ + 'operationsClient' => $this->getOperationsClient(), + ] + )->wait(); } /** @@ -671,24 +565,14 @@ public function getDatabase($name, $optionalArgs = []) $request = new GetDatabaseRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['getDatabase']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->databaseAdminStub, - 'GetDatabase', - $mergedSettings, - $this->descriptors['getDatabase'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetDatabase', + Database::class, + $request + ), + $this->configureCallSettings('getDatabase', $optionalArgs) + )->wait(); } /** @@ -781,24 +665,17 @@ public function updateDatabaseDdl($database, $statements, $optionalArgs = []) $request->setOperationId($optionalArgs['operationId']); } - $defaultCallSettings = $this->defaultCallSettings['updateDatabaseDdl']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->databaseAdminStub, - 'UpdateDatabaseDdl', - $mergedSettings, - $this->descriptors['updateDatabaseDdl'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startOperationsCall( + new Call( + self::SERVICE_NAME.'/UpdateDatabaseDdl', + Operation::class, + $request + ), + $this->configureCallSettings('updateDatabaseDdl', $optionalArgs), + $this->descriptors['updateDatabaseDdl']['longRunning'] + [ + 'operationsClient' => $this->getOperationsClient(), + ] + )->wait(); } /** @@ -834,24 +711,14 @@ public function dropDatabase($database, $optionalArgs = []) $request = new DropDatabaseRequest(); $request->setDatabase($database); - $defaultCallSettings = $this->defaultCallSettings['dropDatabase']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->databaseAdminStub, - 'DropDatabase', - $mergedSettings, - $this->descriptors['dropDatabase'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DropDatabase', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('dropDatabase', $optionalArgs) + )->wait(); } /** @@ -891,24 +758,14 @@ public function getDatabaseDdl($database, $optionalArgs = []) $request = new GetDatabaseDdlRequest(); $request->setDatabase($database); - $defaultCallSettings = $this->defaultCallSettings['getDatabaseDdl']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->databaseAdminStub, - 'GetDatabaseDdl', - $mergedSettings, - $this->descriptors['getDatabaseDdl'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetDatabaseDdl', + GetDatabaseDdlResponse::class, + $request + ), + $this->configureCallSettings('getDatabaseDdl', $optionalArgs) + )->wait(); } /** @@ -958,24 +815,14 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) $request->setResource($resource); $request->setPolicy($policy); - $defaultCallSettings = $this->defaultCallSettings['setIamPolicy']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->databaseAdminStub, - 'SetIamPolicy', - $mergedSettings, - $this->descriptors['setIamPolicy'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/SetIamPolicy', + Policy::class, + $request + ), + $this->configureCallSettings('setIamPolicy', $optionalArgs) + )->wait(); } /** @@ -1019,24 +866,14 @@ public function getIamPolicy($resource, $optionalArgs = []) $request = new GetIamPolicyRequest(); $request->setResource($resource); - $defaultCallSettings = $this->defaultCallSettings['getIamPolicy']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->databaseAdminStub, - 'GetIamPolicy', - $mergedSettings, - $this->descriptors['getIamPolicy'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetIamPolicy', + Policy::class, + $request + ), + $this->configureCallSettings('getIamPolicy', $optionalArgs) + )->wait(); } /** @@ -1087,24 +924,14 @@ public function testIamPermissions($resource, $permissions, $optionalArgs = []) $request->setResource($resource); $request->setPermissions($permissions); - $defaultCallSettings = $this->defaultCallSettings['testIamPermissions']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->databaseAdminStub, - 'TestIamPermissions', - $mergedSettings, - $this->descriptors['testIamPermissions'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/TestIamPermissions', + TestIamPermissionsResponse::class, + $request + ), + $this->configureCallSettings('testIamPermissions', $optionalArgs) + )->wait(); } /** @@ -1115,11 +942,6 @@ public function testIamPermissions($resource, $permissions, $optionalArgs = []) */ public function close() { - $this->databaseAdminStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Spanner/Admin/Database/V1/resources/database_admin_descriptor_config.php b/src/Spanner/Admin/Database/V1/resources/database_admin_descriptor_config.php new file mode 100644 index 000000000000..3e4bf8b5f071 --- /dev/null +++ b/src/Spanner/Admin/Database/V1/resources/database_admin_descriptor_config.php @@ -0,0 +1,30 @@ + [ + 'google.spanner.admin.database.v1.DatabaseAdmin' => [ + 'createDatabase' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\Database', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\CreateDatabaseMetadata', + ], + ], + 'updateDatabaseDdl' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Protobuf\GPBEmpty', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseDdlMetadata', + ], + ], + 'listDatabases' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getDatabases', + ], + ], + ], + ], +]; diff --git a/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php b/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php new file mode 100644 index 000000000000..638e8fb6391e --- /dev/null +++ b/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php @@ -0,0 +1,94 @@ + [ + 'google.spanner.admin.database.v1.DatabaseAdmin' => [ + 'ListDatabases' => [ + 'method' => 'get', + 'uri' => '/v1/{parent=projects/*/instances/*}/databases', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'CreateDatabase' => [ + 'method' => 'post', + 'uri' => '/v1/{parent=projects/*/instances/*}/databases', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'GetDatabase' => [ + 'method' => 'get', + 'uri' => '/v1/{name=projects/*/instances/*/databases/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'UpdateDatabaseDdl' => [ + 'method' => 'patch', + 'uri' => '/v1/{database=projects/*/instances/*/databases/*}/ddl', + 'body' => '*', + 'placeholders' => [ + 'database' => [ + 'getDatabase', + ], + ], + ], + 'DropDatabase' => [ + 'method' => 'delete', + 'uri' => '/v1/{database=projects/*/instances/*/databases/*}', + 'placeholders' => [ + 'database' => [ + 'getDatabase', + ], + ], + ], + 'GetDatabaseDdl' => [ + 'method' => 'get', + 'uri' => '/v1/{database=projects/*/instances/*/databases/*}/ddl', + 'placeholders' => [ + 'database' => [ + 'getDatabase', + ], + ], + ], + 'SetIamPolicy' => [ + 'method' => 'post', + 'uri' => '/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getResource', + ], + ], + ], + 'GetIamPolicy' => [ + 'method' => 'post', + 'uri' => '/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getResource', + ], + ], + ], + 'TestIamPermissions' => [ + 'method' => 'post', + 'uri' => '/v1/{resource=projects/*/instances/*/databases/*}:testIamPermissions', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getResource', + ], + ], + ], + ], + ], +]; diff --git a/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php b/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php index 1f5009ec9ad5..16161490e183 100644 --- a/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php +++ b/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php @@ -30,32 +30,34 @@ namespace Google\Cloud\Spanner\Admin\Instance\V1\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\OperationResponse; -use Google\ApiCore\PageStreamingDescriptor; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; use Google\Cloud\Iam\V1\GetIamPolicyRequest; use Google\Cloud\Iam\V1\Policy; use Google\Cloud\Iam\V1\SetIamPolicyRequest; use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; use Google\Cloud\Spanner\Admin\Instance\V1\CreateInstanceMetadata; use Google\Cloud\Spanner\Admin\Instance\V1\CreateInstanceRequest; use Google\Cloud\Spanner\Admin\Instance\V1\DeleteInstanceRequest; use Google\Cloud\Spanner\Admin\Instance\V1\GetInstanceConfigRequest; use Google\Cloud\Spanner\Admin\Instance\V1\GetInstanceRequest; use Google\Cloud\Spanner\Admin\Instance\V1\Instance; -use Google\Cloud\Spanner\Admin\Instance\V1\InstanceAdminGrpcClient; +use Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig; use Google\Cloud\Spanner\Admin\Instance\V1\ListInstanceConfigsRequest; +use Google\Cloud\Spanner\Admin\Instance\V1\ListInstanceConfigsResponse; use Google\Cloud\Spanner\Admin\Instance\V1\ListInstancesRequest; +use Google\Cloud\Spanner\Admin\Instance\V1\ListInstancesResponse; use Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceMetadata; use Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceRequest; -use Google\Cloud\Version; +use Google\LongRunning\Operation; use Google\Protobuf\FieldMask; +use Google\Protobuf\GPBEmpty; /** * Service Description: Cloud Spanner Instance Admin API. @@ -118,6 +120,13 @@ */ class InstanceAdminGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.spanner.admin.instance.v1.InstanceAdmin'; + /** * The default address of the service. */ @@ -142,19 +151,24 @@ class InstanceAdminGapicClient private static $instanceConfigNameTemplate; private static $instanceNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/spanner.admin', + ], + 'clientConfigPath' => __DIR__.'/../resources/instance_admin_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/instance_admin_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/instance_admin_descriptor_config.php', + ]; - protected $grpcCredentialsHelper; - protected $instanceAdminStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; private $operationsClient; private static function getProjectNameTemplate() { - if (self::$projectNameTemplate == null) { + if (null == self::$projectNameTemplate) { self::$projectNameTemplate = new PathTemplate('projects/{project}'); } @@ -163,7 +177,7 @@ private static function getProjectNameTemplate() private static function getInstanceConfigNameTemplate() { - if (self::$instanceConfigNameTemplate == null) { + if (null == self::$instanceConfigNameTemplate) { self::$instanceConfigNameTemplate = new PathTemplate('projects/{project}/instanceConfigs/{instance_config}'); } @@ -172,7 +186,7 @@ private static function getInstanceConfigNameTemplate() private static function getInstanceNameTemplate() { - if (self::$instanceNameTemplate == null) { + if (null == self::$instanceNameTemplate) { self::$instanceNameTemplate = new PathTemplate('projects/{project}/instances/{instance}'); } @@ -181,7 +195,7 @@ private static function getInstanceNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'project' => self::getProjectNameTemplate(), 'instanceConfig' => self::getInstanceConfigNameTemplate(), @@ -192,63 +206,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getPageStreamingDescriptors() - { - $listInstanceConfigsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getInstanceConfigs', - ]); - $listInstancesPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getInstances', - ]); - - $pageStreamingDescriptors = [ - 'listInstanceConfigs' => $listInstanceConfigsPageStreamingDescriptor, - 'listInstances' => $listInstancesPageStreamingDescriptor, - ]; - - return $pageStreamingDescriptors; - } - - private static function getLongRunningDescriptors() - { - return [ - 'createInstance' => [ - 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\Instance', - 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\CreateInstanceMetadata', - ], - 'updateInstance' => [ - 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\Instance', - 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceMetadata', - ], - ]; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a project resource. @@ -370,12 +327,9 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $lroDescriptors = self::getLongRunningDescriptors(); - if (!is_null($methodName) && array_key_exists($methodName, $lroDescriptors)) { - $options = $lroDescriptors[$methodName]; - } else { - $options = []; - } + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); @@ -392,16 +346,19 @@ public function resumeOperation($operationName, $methodName = null) * Default 'spanner.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -420,88 +377,31 @@ public function resumeOperation($operationName, $methodName = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/spanner.admin', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/instance_admin_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - if (array_key_exists('operationsClient', $options)) { - $this->operationsClient = $options['operationsClient']; - } else { - $operationsClientOptions = $options; - unset($operationsClientOptions['retryingOverride']); - unset($operationsClientOptions['clientConfigPath']); - $this->operationsClient = new OperationsClient($operationsClientOptions); - } - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'listInstanceConfigs' => $defaultDescriptors, - 'getInstanceConfig' => $defaultDescriptors, - 'listInstances' => $defaultDescriptors, - 'getInstance' => $defaultDescriptors, - 'createInstance' => $defaultDescriptors, - 'updateInstance' => $defaultDescriptors, - 'deleteInstance' => $defaultDescriptors, - 'setIamPolicy' => $defaultDescriptors, - 'getIamPolicy' => $defaultDescriptors, - 'testIamPermissions' => $defaultDescriptors, - ]; - $pageStreamingDescriptors = self::getPageStreamingDescriptors(); - foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { - $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; - } - $longRunningDescriptors = self::getLongRunningDescriptors(); - foreach ($longRunningDescriptors as $method => $longRunningDescriptor) { - $this->descriptors[$method]['longRunningDescriptor'] = $longRunningDescriptor + ['operationsClient' => $this->operationsClient]; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.spanner.admin.instance.v1.InstanceAdmin', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createInstanceAdminStubFunction = function ($hostname, $opts, $channel) { - return new InstanceAdminGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createInstanceAdminStubFunction', $options)) { - $createInstanceAdminStubFunction = $options['createInstanceAdminStubFunction']; - } - $this->instanceAdminStub = $this->grpcCredentialsHelper->createStub($createInstanceAdminStubFunction); + $options += self::$clientDefaults; + $this->setClientOptions($options); + $this->pluckArray([ + 'serviceName', + 'clientConfigPath', + 'restClientConfigPath', + 'descriptorsConfigPath', + ], $options); + $this->operationsClient = new OperationsClient($options); } /** @@ -568,24 +468,15 @@ public function listInstanceConfigs($parent, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listInstanceConfigs']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->instanceAdminStub, - 'ListInstanceConfigs', - $mergedSettings, - $this->descriptors['listInstanceConfigs'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListInstanceConfigs', + ListInstanceConfigsResponse::class, + $request + ), + $this->configureCallSettings('listInstanceConfigs', $optionalArgs), + $this->descriptors['listInstanceConfigs']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -624,24 +515,14 @@ public function getInstanceConfig($name, $optionalArgs = []) $request = new GetInstanceConfigRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['getInstanceConfig']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->instanceAdminStub, - 'GetInstanceConfig', - $mergedSettings, - $this->descriptors['getInstanceConfig'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetInstanceConfig', + InstanceConfig::class, + $request + ), + $this->configureCallSettings('getInstanceConfig', $optionalArgs) + )->wait(); } /** @@ -730,24 +611,15 @@ public function listInstances($parent, $optionalArgs = []) $request->setFilter($optionalArgs['filter']); } - $defaultCallSettings = $this->defaultCallSettings['listInstances']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->instanceAdminStub, - 'ListInstances', - $mergedSettings, - $this->descriptors['listInstances'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListInstances', + ListInstancesResponse::class, + $request + ), + $this->configureCallSettings('listInstances', $optionalArgs), + $this->descriptors['listInstances']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -786,24 +658,14 @@ public function getInstance($name, $optionalArgs = []) $request = new GetInstanceRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['getInstance']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->instanceAdminStub, - 'GetInstance', - $mergedSettings, - $this->descriptors['getInstance'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetInstance', + Instance::class, + $request + ), + $this->configureCallSettings('getInstance', $optionalArgs) + )->wait(); } /** @@ -909,24 +771,17 @@ public function createInstance($parent, $instanceId, $instance, $optionalArgs = $request->setInstanceId($instanceId); $request->setInstance($instance); - $defaultCallSettings = $this->defaultCallSettings['createInstance']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->instanceAdminStub, - 'CreateInstance', - $mergedSettings, - $this->descriptors['createInstance'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startOperationsCall( + new Call( + self::SERVICE_NAME.'/CreateInstance', + Operation::class, + $request + ), + $this->configureCallSettings('createInstance', $optionalArgs), + $this->descriptors['createInstance']['longRunning'] + [ + 'operationsClient' => $this->getOperationsClient(), + ] + )->wait(); } /** @@ -1035,24 +890,17 @@ public function updateInstance($instance, $fieldMask, $optionalArgs = []) $request->setInstance($instance); $request->setFieldMask($fieldMask); - $defaultCallSettings = $this->defaultCallSettings['updateInstance']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->instanceAdminStub, - 'UpdateInstance', - $mergedSettings, - $this->descriptors['updateInstance'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startOperationsCall( + new Call( + self::SERVICE_NAME.'/UpdateInstance', + Operation::class, + $request + ), + $this->configureCallSettings('updateInstance', $optionalArgs), + $this->descriptors['updateInstance']['longRunning'] + [ + 'operationsClient' => $this->getOperationsClient(), + ] + )->wait(); } /** @@ -1099,24 +947,14 @@ public function deleteInstance($name, $optionalArgs = []) $request = new DeleteInstanceRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['deleteInstance']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->instanceAdminStub, - 'DeleteInstance', - $mergedSettings, - $this->descriptors['deleteInstance'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteInstance', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteInstance', $optionalArgs) + )->wait(); } /** @@ -1166,24 +1004,14 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) $request->setResource($resource); $request->setPolicy($policy); - $defaultCallSettings = $this->defaultCallSettings['setIamPolicy']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->instanceAdminStub, - 'SetIamPolicy', - $mergedSettings, - $this->descriptors['setIamPolicy'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/SetIamPolicy', + Policy::class, + $request + ), + $this->configureCallSettings('setIamPolicy', $optionalArgs) + )->wait(); } /** @@ -1227,24 +1055,14 @@ public function getIamPolicy($resource, $optionalArgs = []) $request = new GetIamPolicyRequest(); $request->setResource($resource); - $defaultCallSettings = $this->defaultCallSettings['getIamPolicy']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->instanceAdminStub, - 'GetIamPolicy', - $mergedSettings, - $this->descriptors['getIamPolicy'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetIamPolicy', + Policy::class, + $request + ), + $this->configureCallSettings('getIamPolicy', $optionalArgs) + )->wait(); } /** @@ -1295,24 +1113,14 @@ public function testIamPermissions($resource, $permissions, $optionalArgs = []) $request->setResource($resource); $request->setPermissions($permissions); - $defaultCallSettings = $this->defaultCallSettings['testIamPermissions']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->instanceAdminStub, - 'TestIamPermissions', - $mergedSettings, - $this->descriptors['testIamPermissions'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/TestIamPermissions', + TestIamPermissionsResponse::class, + $request + ), + $this->configureCallSettings('testIamPermissions', $optionalArgs) + )->wait(); } /** @@ -1323,11 +1131,6 @@ public function testIamPermissions($resource, $permissions, $optionalArgs = []) */ public function close() { - $this->instanceAdminStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Spanner/Admin/Instance/V1/resources/instance_admin_descriptor_config.php b/src/Spanner/Admin/Instance/V1/resources/instance_admin_descriptor_config.php new file mode 100644 index 000000000000..6650d1de407a --- /dev/null +++ b/src/Spanner/Admin/Instance/V1/resources/instance_admin_descriptor_config.php @@ -0,0 +1,40 @@ + [ + 'google.spanner.admin.instance.v1.InstanceAdmin' => [ + 'createInstance' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\Instance', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\CreateInstanceMetadata', + ], + ], + 'updateInstance' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\Instance', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceMetadata', + ], + ], + 'listInstanceConfigs' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getInstanceConfigs', + ], + ], + 'listInstances' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getInstances', + ], + ], + ], + ], +]; diff --git a/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php b/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php new file mode 100644 index 000000000000..f04652899b6b --- /dev/null +++ b/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php @@ -0,0 +1,104 @@ + [ + 'google.spanner.admin.instance.v1.InstanceAdmin' => [ + 'ListInstanceConfigs' => [ + 'method' => 'get', + 'uri' => '/v1/{parent=projects/*}/instanceConfigs', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'GetInstanceConfig' => [ + 'method' => 'get', + 'uri' => '/v1/{name=projects/*/instanceConfigs/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'ListInstances' => [ + 'method' => 'get', + 'uri' => '/v1/{parent=projects/*}/instances', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'GetInstance' => [ + 'method' => 'get', + 'uri' => '/v1/{name=projects/*/instances/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'CreateInstance' => [ + 'method' => 'post', + 'uri' => '/v1/{parent=projects/*}/instances', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getParent', + ], + ], + ], + 'UpdateInstance' => [ + 'method' => 'patch', + 'uri' => '/v1/{instance.name=projects/*/instances/*}', + 'body' => '*', + 'placeholders' => [ + 'instance.name' => [ + 'getInstance', + 'getName', + ], + ], + ], + 'DeleteInstance' => [ + 'method' => 'delete', + 'uri' => '/v1/{name=projects/*/instances/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'SetIamPolicy' => [ + 'method' => 'post', + 'uri' => '/v1/{resource=projects/*/instances/*}:setIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getResource', + ], + ], + ], + 'GetIamPolicy' => [ + 'method' => 'post', + 'uri' => '/v1/{resource=projects/*/instances/*}:getIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getResource', + ], + ], + ], + 'TestIamPermissions' => [ + 'method' => 'post', + 'uri' => '/v1/{resource=projects/*/instances/*}:testIamPermissions', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getResource', + ], + ], + ], + ], + ], +]; diff --git a/src/Spanner/V1/Gapic/SpannerGapicClient.php b/src/Spanner/V1/Gapic/SpannerGapicClient.php index 64559441e6d2..5114259f492f 100644 --- a/src/Spanner/V1/Gapic/SpannerGapicClient.php +++ b/src/Spanner/V1/Gapic/SpannerGapicClient.php @@ -30,15 +30,14 @@ namespace Google\Cloud\Spanner\V1\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; -use Google\ApiCore\PageStreamingDescriptor; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\PathTemplate; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; use Google\Cloud\Spanner\V1\BeginTransactionRequest; use Google\Cloud\Spanner\V1\CommitRequest; +use Google\Cloud\Spanner\V1\CommitResponse; use Google\Cloud\Spanner\V1\CreateSessionRequest; use Google\Cloud\Spanner\V1\DeleteSessionRequest; use Google\Cloud\Spanner\V1\ExecuteSqlRequest; @@ -46,14 +45,17 @@ use Google\Cloud\Spanner\V1\GetSessionRequest; use Google\Cloud\Spanner\V1\KeySet; use Google\Cloud\Spanner\V1\ListSessionsRequest; +use Google\Cloud\Spanner\V1\ListSessionsResponse; use Google\Cloud\Spanner\V1\Mutation; +use Google\Cloud\Spanner\V1\PartialResultSet; use Google\Cloud\Spanner\V1\ReadRequest; +use Google\Cloud\Spanner\V1\ResultSet; use Google\Cloud\Spanner\V1\RollbackRequest; use Google\Cloud\Spanner\V1\Session; -use Google\Cloud\Spanner\V1\SpannerGrpcClient; +use Google\Cloud\Spanner\V1\Transaction; use Google\Cloud\Spanner\V1\TransactionOptions; use Google\Cloud\Spanner\V1\TransactionSelector; -use Google\Cloud\Version; +use Google\Protobuf\GPBEmpty; use Google\Protobuf\Struct; /** @@ -88,6 +90,13 @@ */ class SpannerGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.spanner.v1.Spanner'; + /** * The default address of the service. */ @@ -111,18 +120,22 @@ class SpannerGapicClient private static $databaseNameTemplate; private static $sessionNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $spannerStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/spanner.data', + ], + 'clientConfigPath' => __DIR__.'/../resources/spanner_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/spanner_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/spanner_descriptor_config.php', + ]; private static function getDatabaseNameTemplate() { - if (self::$databaseNameTemplate == null) { + if (null == self::$databaseNameTemplate) { self::$databaseNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/databases/{database}'); } @@ -131,7 +144,7 @@ private static function getDatabaseNameTemplate() private static function getSessionNameTemplate() { - if (self::$sessionNameTemplate == null) { + if (null == self::$sessionNameTemplate) { self::$sessionNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/databases/{database}/sessions/{session}'); } @@ -140,7 +153,7 @@ private static function getSessionNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'database' => self::getDatabaseNameTemplate(), 'session' => self::getSessionNameTemplate(), @@ -150,51 +163,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getPageStreamingDescriptors() - { - $listSessionsPageStreamingDescriptor = - new PageStreamingDescriptor([ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getSessions', - ]); - - $pageStreamingDescriptors = [ - 'listSessions' => $listSessionsPageStreamingDescriptor, - ]; - - return $pageStreamingDescriptors; - } - - private static function getGrpcStreamingDescriptors() - { - return [ - 'executeStreamingSql' => [ - 'grpcStreamingType' => 'ServerStreaming', - ], - 'streamingRead' => [ - 'grpcStreamingType' => 'ServerStreaming', - ], - ]; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a database resource. @@ -289,16 +257,19 @@ public static function parseName($formattedName, $template = null) * Default 'spanner.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -317,80 +288,23 @@ public static function parseName($formattedName, $template = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/spanner.data', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/spanner_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'createSession' => $defaultDescriptors, - 'getSession' => $defaultDescriptors, - 'listSessions' => $defaultDescriptors, - 'deleteSession' => $defaultDescriptors, - 'executeSql' => $defaultDescriptors, - 'executeStreamingSql' => $defaultDescriptors, - 'read' => $defaultDescriptors, - 'streamingRead' => $defaultDescriptors, - 'beginTransaction' => $defaultDescriptors, - 'commit' => $defaultDescriptors, - 'rollback' => $defaultDescriptors, - ]; - $pageStreamingDescriptors = self::getPageStreamingDescriptors(); - foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { - $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; - } - $grpcStreamingDescriptors = self::getGrpcStreamingDescriptors(); - foreach ($grpcStreamingDescriptors as $method => $grpcStreamingDescriptor) { - $this->descriptors[$method]['grpcStreamingDescriptor'] = $grpcStreamingDescriptor; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.spanner.v1.Spanner', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createSpannerStubFunction = function ($hostname, $opts, $channel) { - return new SpannerGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createSpannerStubFunction', $options)) { - $createSpannerStubFunction = $options['createSpannerStubFunction']; - } - $this->spannerStub = $this->grpcCredentialsHelper->createStub($createSpannerStubFunction); + $this->setClientOptions($options + self::$clientDefaults); } /** @@ -451,24 +365,14 @@ public function createSession($database, $optionalArgs = []) $request->setSession($optionalArgs['session']); } - $defaultCallSettings = $this->defaultCallSettings['createSession']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->spannerStub, - 'CreateSession', - $mergedSettings, - $this->descriptors['createSession'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/CreateSession', + Session::class, + $request + ), + $this->configureCallSettings('createSession', $optionalArgs) + )->wait(); } /** @@ -508,24 +412,14 @@ public function getSession($name, $optionalArgs = []) $request = new GetSessionRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['getSession']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->spannerStub, - 'GetSession', - $mergedSettings, - $this->descriptors['getSession'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/GetSession', + Session::class, + $request + ), + $this->configureCallSettings('getSession', $optionalArgs) + )->wait(); } /** @@ -604,24 +498,15 @@ public function listSessions($database, $optionalArgs = []) $request->setFilter($optionalArgs['filter']); } - $defaultCallSettings = $this->defaultCallSettings['listSessions']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->spannerStub, - 'ListSessions', - $mergedSettings, - $this->descriptors['listSessions'] + return $this->getPagedListResponse( + new Call( + self::SERVICE_NAME.'/ListSessions', + ListSessionsResponse::class, + $request + ), + $this->configureCallSettings('listSessions', $optionalArgs), + $this->descriptors['listSessions']['pageStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -657,24 +542,14 @@ public function deleteSession($name, $optionalArgs = []) $request = new DeleteSessionRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['deleteSession']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->spannerStub, - 'DeleteSession', - $mergedSettings, - $this->descriptors['deleteSession'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/DeleteSession', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('deleteSession', $optionalArgs) + )->wait(); } /** @@ -778,24 +653,14 @@ public function executeSql($session, $sql, $optionalArgs = []) $request->setQueryMode($optionalArgs['queryMode']); } - $defaultCallSettings = $this->defaultCallSettings['executeSql']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->spannerStub, - 'ExecuteSql', - $mergedSettings, - $this->descriptors['executeSql'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/ExecuteSql', + ResultSet::class, + $request + ), + $this->configureCallSettings('executeSql', $optionalArgs) + )->wait(); } /** @@ -894,31 +759,15 @@ public function executeStreamingSql($session, $sql, $optionalArgs = []) $request->setQueryMode($optionalArgs['queryMode']); } - if (array_key_exists('timeoutMillis', $optionalArgs)) { - $optionalArgs['retrySettings'] = [ - 'retriesEnabled' => false, - 'noRetriesRpcTimeoutMillis' => $optionalArgs['timeoutMillis'], - ]; - } - - $defaultCallSettings = $this->defaultCallSettings['executeStreamingSql']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->spannerStub, - 'ExecuteStreamingSql', - $mergedSettings, - $this->descriptors['executeStreamingSql'] + return $this->transport->startServerStreamingCall( + new Call( + self::SERVICE_NAME.'/ExecuteStreamingSql', + \Google\ApiCore\ServerStream::class, + $request + ), + $this->configureCallSettings('executeStreamingSql', $optionalArgs), + $this->descriptors['executeStreamingSql']['grpcStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -1016,24 +865,14 @@ public function read($session, $table, $columns, $keySet, $optionalArgs = []) $request->setResumeToken($optionalArgs['resumeToken']); } - $defaultCallSettings = $this->defaultCallSettings['read']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->spannerStub, - 'Read', - $mergedSettings, - $this->descriptors['read'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/Read', + ResultSet::class, + $request + ), + $this->configureCallSettings('read', $optionalArgs) + )->wait(); } /** @@ -1124,31 +963,15 @@ public function streamingRead($session, $table, $columns, $keySet, $optionalArgs $request->setResumeToken($optionalArgs['resumeToken']); } - if (array_key_exists('timeoutMillis', $optionalArgs)) { - $optionalArgs['retrySettings'] = [ - 'retriesEnabled' => false, - 'noRetriesRpcTimeoutMillis' => $optionalArgs['timeoutMillis'], - ]; - } - - $defaultCallSettings = $this->defaultCallSettings['streamingRead']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->spannerStub, - 'StreamingRead', - $mergedSettings, - $this->descriptors['streamingRead'] + return $this->transport->startServerStreamingCall( + new Call( + self::SERVICE_NAME.'/StreamingRead', + \Google\ApiCore\ServerStream::class, + $request + ), + $this->configureCallSettings('streamingRead', $optionalArgs), + $this->descriptors['streamingRead']['grpcStreaming'] ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -1192,24 +1015,14 @@ public function beginTransaction($session, $options, $optionalArgs = []) $request->setSession($session); $request->setOptions($options); - $defaultCallSettings = $this->defaultCallSettings['beginTransaction']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->spannerStub, - 'BeginTransaction', - $mergedSettings, - $this->descriptors['beginTransaction'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/BeginTransaction', + Transaction::class, + $request + ), + $this->configureCallSettings('beginTransaction', $optionalArgs) + )->wait(); } /** @@ -1277,24 +1090,14 @@ public function commit($session, $mutations, $optionalArgs = []) $request->setSingleUseTransaction($optionalArgs['singleUseTransaction']); } - $defaultCallSettings = $this->defaultCallSettings['commit']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->spannerStub, - 'Commit', - $mergedSettings, - $this->descriptors['commit'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/Commit', + CommitResponse::class, + $request + ), + $this->configureCallSettings('commit', $optionalArgs) + )->wait(); } /** @@ -1340,24 +1143,14 @@ public function rollback($session, $transactionId, $optionalArgs = []) $request->setSession($session); $request->setTransactionId($transactionId); - $defaultCallSettings = $this->defaultCallSettings['rollback']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->spannerStub, - 'Rollback', - $mergedSettings, - $this->descriptors['rollback'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/Rollback', + GPBEmpty::class, + $request + ), + $this->configureCallSettings('rollback', $optionalArgs) + )->wait(); } /** @@ -1368,11 +1161,6 @@ public function rollback($session, $transactionId, $optionalArgs = []) */ public function close() { - $this->spannerStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Spanner/V1/resources/spanner_descriptor_config.php b/src/Spanner/V1/resources/spanner_descriptor_config.php new file mode 100644 index 000000000000..bf61743e89a6 --- /dev/null +++ b/src/Spanner/V1/resources/spanner_descriptor_config.php @@ -0,0 +1,28 @@ + [ + 'google.spanner.v1.Spanner' => [ + 'listSessions' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getSessions', + ], + ], + 'executeStreamingSql' => [ + 'grpcStreaming' => [ + 'grpcStreamingType' => 'ServerStreaming', + ], + ], + 'streamingRead' => [ + 'grpcStreaming' => [ + 'grpcStreamingType' => 'ServerStreaming', + ], + ], + ], + ], +]; diff --git a/src/Spanner/V1/resources/spanner_rest_client_config.php b/src/Spanner/V1/resources/spanner_rest_client_config.php new file mode 100644 index 000000000000..35b11cb03a96 --- /dev/null +++ b/src/Spanner/V1/resources/spanner_rest_client_config.php @@ -0,0 +1,115 @@ + [ + 'google.spanner.v1.Spanner' => [ + 'CreateSession' => [ + 'method' => 'post', + 'uri' => '/v1/{database=projects/*/instances/*/databases/*}/sessions', + 'body' => '*', + 'placeholders' => [ + 'database' => [ + 'getDatabase', + ], + ], + ], + 'GetSession' => [ + 'method' => 'get', + 'uri' => '/v1/{name=projects/*/instances/*/databases/*/sessions/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'ListSessions' => [ + 'method' => 'get', + 'uri' => '/v1/{database=projects/*/instances/*/databases/*}/sessions', + 'placeholders' => [ + 'database' => [ + 'getDatabase', + ], + ], + ], + 'DeleteSession' => [ + 'method' => 'delete', + 'uri' => '/v1/{name=projects/*/instances/*/databases/*/sessions/*}', + 'placeholders' => [ + 'name' => [ + 'getName', + ], + ], + ], + 'ExecuteSql' => [ + 'method' => 'post', + 'uri' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeSql', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getSession', + ], + ], + ], + 'ExecuteStreamingSql' => [ + 'method' => 'post', + 'uri' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeStreamingSql', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getSession', + ], + ], + ], + 'Read' => [ + 'method' => 'post', + 'uri' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:read', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getSession', + ], + ], + ], + 'StreamingRead' => [ + 'method' => 'post', + 'uri' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:streamingRead', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getSession', + ], + ], + ], + 'BeginTransaction' => [ + 'method' => 'post', + 'uri' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:beginTransaction', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getSession', + ], + ], + ], + 'Commit' => [ + 'method' => 'post', + 'uri' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:commit', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getSession', + ], + ], + ], + 'Rollback' => [ + 'method' => 'post', + 'uri' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:rollback', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getSession', + ], + ], + ], + ], + ], +]; diff --git a/src/Speech/V1/Gapic/SpeechGapicClient.php b/src/Speech/V1/Gapic/SpeechGapicClient.php index 27790660e0a6..a11d0063e7af 100644 --- a/src/Speech/V1/Gapic/SpeechGapicClient.php +++ b/src/Speech/V1/Gapic/SpeechGapicClient.php @@ -30,20 +30,20 @@ namespace Google\Cloud\Speech\V1\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\Cloud\Speech\V1\LongRunningRecognizeRequest; use Google\Cloud\Speech\V1\LongRunningRecognizeResponse; use Google\Cloud\Speech\V1\RecognitionAudio; use Google\Cloud\Speech\V1\RecognitionConfig; use Google\Cloud\Speech\V1\RecognizeRequest; -use Google\Cloud\Speech\V1\SpeechGrpcClient; +use Google\Cloud\Speech\V1\RecognizeResponse; use Google\Cloud\Speech\V1\StreamingRecognizeRequest; -use Google\Cloud\Version; +use Google\Cloud\Speech\V1\StreamingRecognizeResponse; +use Google\LongRunning\Operation; /** * Service Description: Service that implements Google Cloud Speech API. @@ -78,6 +78,13 @@ */ class SpeechGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.cloud.speech.v1.Speech'; + /** * The default address of the service. */ @@ -98,49 +105,20 @@ class SpeechGapicClient */ const CODEGEN_VERSION = '0.0.5'; - private static $gapicVersion; - private static $gapicVersionLoaded = false; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/speech_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/speech_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/speech_descriptor_config.php', + ]; - protected $grpcCredentialsHelper; - protected $speechStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; private $operationsClient; - private static function getLongRunningDescriptors() - { - return [ - 'longRunningRecognize' => [ - 'operationReturnType' => '\Google\Cloud\Speech\V1\LongRunningRecognizeResponse', - 'metadataReturnType' => '\Google\Cloud\Speech\V1\LongRunningRecognizeMetadata', - ], - ]; - } - - private static function getGrpcStreamingDescriptors() - { - return [ - 'streamingRecognize' => [ - 'grpcStreamingType' => 'BidiStreaming', - ], - ]; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Return an OperationsClient object with the same endpoint as $this. * @@ -167,12 +145,9 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $lroDescriptors = self::getLongRunningDescriptors(); - if (!is_null($methodName) && array_key_exists($methodName, $lroDescriptors)) { - $options = $lroDescriptors[$methodName]; - } else { - $options = []; - } + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); @@ -189,16 +164,19 @@ public function resumeOperation($operationName, $methodName = null) * Default 'speech.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -217,80 +195,31 @@ public function resumeOperation($operationName, $methodName = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/speech_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - if (array_key_exists('operationsClient', $options)) { - $this->operationsClient = $options['operationsClient']; - } else { - $operationsClientOptions = $options; - unset($operationsClientOptions['retryingOverride']); - unset($operationsClientOptions['clientConfigPath']); - $this->operationsClient = new OperationsClient($operationsClientOptions); - } - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'recognize' => $defaultDescriptors, - 'longRunningRecognize' => $defaultDescriptors, - 'streamingRecognize' => $defaultDescriptors, - ]; - $longRunningDescriptors = self::getLongRunningDescriptors(); - foreach ($longRunningDescriptors as $method => $longRunningDescriptor) { - $this->descriptors[$method]['longRunningDescriptor'] = $longRunningDescriptor + ['operationsClient' => $this->operationsClient]; - } - $grpcStreamingDescriptors = self::getGrpcStreamingDescriptors(); - foreach ($grpcStreamingDescriptors as $method => $grpcStreamingDescriptor) { - $this->descriptors[$method]['grpcStreamingDescriptor'] = $grpcStreamingDescriptor; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.cloud.speech.v1.Speech', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createSpeechStubFunction = function ($hostname, $opts, $channel) { - return new SpeechGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createSpeechStubFunction', $options)) { - $createSpeechStubFunction = $options['createSpeechStubFunction']; - } - $this->speechStub = $this->grpcCredentialsHelper->createStub($createSpeechStubFunction); + $options += self::$clientDefaults; + $this->setClientOptions($options); + $this->pluckArray([ + 'serviceName', + 'clientConfigPath', + 'restClientConfigPath', + 'descriptorsConfigPath', + ], $options); + $this->operationsClient = new OperationsClient($options); } /** @@ -341,24 +270,14 @@ public function recognize($config, $audio, $optionalArgs = []) $request->setConfig($config); $request->setAudio($audio); - $defaultCallSettings = $this->defaultCallSettings['recognize']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->speechStub, - 'Recognize', - $mergedSettings, - $this->descriptors['recognize'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/Recognize', + RecognizeResponse::class, + $request + ), + $this->configureCallSettings('recognize', $optionalArgs) + )->wait(); } /** @@ -436,24 +355,17 @@ public function longRunningRecognize($config, $audio, $optionalArgs = []) $request->setConfig($config); $request->setAudio($audio); - $defaultCallSettings = $this->defaultCallSettings['longRunningRecognize']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->speechStub, - 'LongRunningRecognize', - $mergedSettings, - $this->descriptors['longRunningRecognize'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startOperationsCall( + new Call( + self::SERVICE_NAME.'/LongRunningRecognize', + Operation::class, + $request + ), + $this->configureCallSettings('longRunningRecognize', $optionalArgs), + $this->descriptors['longRunningRecognize']['longRunning'] + [ + 'operationsClient' => $this->getOperationsClient(), + ] + )->wait(); } /** @@ -510,31 +422,14 @@ public function longRunningRecognize($config, $audio, $optionalArgs = []) */ public function streamingRecognize($optionalArgs = []) { - if (array_key_exists('timeoutMillis', $optionalArgs)) { - $optionalArgs['retrySettings'] = [ - 'retriesEnabled' => false, - 'noRetriesRpcTimeoutMillis' => $optionalArgs['timeoutMillis'], - ]; - } - - $defaultCallSettings = $this->defaultCallSettings['streamingRecognize']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->speechStub, - 'StreamingRecognize', - $mergedSettings, - $this->descriptors['streamingRecognize'] + return $this->transport->startBidiStreamingCall( + new Call( + self::SERVICE_NAME.'/StreamingRecognize', + StreamingRecognizeResponse::class + ), + $this->configureCallSettings('streamingRecognize', $optionalArgs), + $this->descriptors['streamingRecognize']['grpcStreaming'] ); - - return $callable( - null, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -545,11 +440,6 @@ public function streamingRecognize($optionalArgs = []) */ public function close() { - $this->speechStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Speech/V1/resources/speech_descriptor_config.php b/src/Speech/V1/resources/speech_descriptor_config.php new file mode 100644 index 000000000000..c6e5724ffc29 --- /dev/null +++ b/src/Speech/V1/resources/speech_descriptor_config.php @@ -0,0 +1,19 @@ + [ + 'google.cloud.speech.v1.Speech' => [ + 'longRunningRecognize' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Speech\V1\LongRunningRecognizeResponse', + 'metadataReturnType' => '\Google\Cloud\Speech\V1\LongRunningRecognizeMetadata', + ], + ], + 'streamingRecognize' => [ + 'grpcStreaming' => [ + 'grpcStreamingType' => 'BidiStreaming', + ], + ], + ], + ], +]; diff --git a/src/Speech/V1/resources/speech_rest_client_config.php b/src/Speech/V1/resources/speech_rest_client_config.php new file mode 100644 index 000000000000..dec8852a899b --- /dev/null +++ b/src/Speech/V1/resources/speech_rest_client_config.php @@ -0,0 +1,18 @@ + [ + 'google.cloud.speech.v1.Speech' => [ + 'Recognize' => [ + 'method' => 'post', + 'uri' => '/v1/speech:recognize', + 'body' => '*', + ], + 'LongRunningRecognize' => [ + 'method' => 'post', + 'uri' => '/v1/speech:longrunningrecognize', + 'body' => '*', + ], + ], + ], +]; diff --git a/src/Speech/V1beta1/Gapic/SpeechGapicClient.php b/src/Speech/V1beta1/Gapic/SpeechGapicClient.php index 65b07efb457b..0645a672e0a7 100644 --- a/src/Speech/V1beta1/Gapic/SpeechGapicClient.php +++ b/src/Speech/V1beta1/Gapic/SpeechGapicClient.php @@ -30,20 +30,20 @@ namespace Google\Cloud\Speech\V1beta1\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\Cloud\Speech\V1beta1\AsyncRecognizeRequest; use Google\Cloud\Speech\V1beta1\AsyncRecognizeResponse; use Google\Cloud\Speech\V1beta1\RecognitionAudio; use Google\Cloud\Speech\V1beta1\RecognitionConfig; -use Google\Cloud\Speech\V1beta1\SpeechGrpcClient; use Google\Cloud\Speech\V1beta1\StreamingRecognizeRequest; +use Google\Cloud\Speech\V1beta1\StreamingRecognizeResponse; use Google\Cloud\Speech\V1beta1\SyncRecognizeRequest; -use Google\Cloud\Version; +use Google\Cloud\Speech\V1beta1\SyncRecognizeResponse; +use Google\LongRunning\Operation; /** * Service Description: Service that implements Google Cloud Speech API. @@ -76,6 +76,13 @@ */ class SpeechGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.cloud.speech.v1beta1.Speech'; + /** * The default address of the service. */ @@ -96,49 +103,20 @@ class SpeechGapicClient */ const CODEGEN_VERSION = '0.0.5'; - private static $gapicVersion; - private static $gapicVersionLoaded = false; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/speech_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/speech_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/speech_descriptor_config.php', + ]; - protected $grpcCredentialsHelper; - protected $speechStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; private $operationsClient; - private static function getLongRunningDescriptors() - { - return [ - 'asyncRecognize' => [ - 'operationReturnType' => '\Google\Cloud\Speech\V1beta1\AsyncRecognizeResponse', - 'metadataReturnType' => '\Google\Cloud\Speech\V1beta1\AsyncRecognizeMetadata', - ], - ]; - } - - private static function getGrpcStreamingDescriptors() - { - return [ - 'streamingRecognize' => [ - 'grpcStreamingType' => 'BidiStreaming', - ], - ]; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Return an OperationsClient object with the same endpoint as $this. * @@ -165,12 +143,9 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $lroDescriptors = self::getLongRunningDescriptors(); - if (!is_null($methodName) && array_key_exists($methodName, $lroDescriptors)) { - $options = $lroDescriptors[$methodName]; - } else { - $options = []; - } + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); @@ -187,16 +162,19 @@ public function resumeOperation($operationName, $methodName = null) * Default 'speech.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -215,80 +193,31 @@ public function resumeOperation($operationName, $methodName = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/speech_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - if (array_key_exists('operationsClient', $options)) { - $this->operationsClient = $options['operationsClient']; - } else { - $operationsClientOptions = $options; - unset($operationsClientOptions['retryingOverride']); - unset($operationsClientOptions['clientConfigPath']); - $this->operationsClient = new OperationsClient($operationsClientOptions); - } - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'syncRecognize' => $defaultDescriptors, - 'asyncRecognize' => $defaultDescriptors, - 'streamingRecognize' => $defaultDescriptors, - ]; - $longRunningDescriptors = self::getLongRunningDescriptors(); - foreach ($longRunningDescriptors as $method => $longRunningDescriptor) { - $this->descriptors[$method]['longRunningDescriptor'] = $longRunningDescriptor + ['operationsClient' => $this->operationsClient]; - } - $grpcStreamingDescriptors = self::getGrpcStreamingDescriptors(); - foreach ($grpcStreamingDescriptors as $method => $grpcStreamingDescriptor) { - $this->descriptors[$method]['grpcStreamingDescriptor'] = $grpcStreamingDescriptor; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.cloud.speech.v1beta1.Speech', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createSpeechStubFunction = function ($hostname, $opts, $channel) { - return new SpeechGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createSpeechStubFunction', $options)) { - $createSpeechStubFunction = $options['createSpeechStubFunction']; - } - $this->speechStub = $this->grpcCredentialsHelper->createStub($createSpeechStubFunction); + $options += self::$clientDefaults; + $this->setClientOptions($options); + $this->pluckArray([ + 'serviceName', + 'clientConfigPath', + 'restClientConfigPath', + 'descriptorsConfigPath', + ], $options); + $this->operationsClient = new OperationsClient($options); } /** @@ -337,24 +266,14 @@ public function syncRecognize($config, $audio, $optionalArgs = []) $request->setConfig($config); $request->setAudio($audio); - $defaultCallSettings = $this->defaultCallSettings['syncRecognize']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->speechStub, - 'SyncRecognize', - $mergedSettings, - $this->descriptors['syncRecognize'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/SyncRecognize', + SyncRecognizeResponse::class, + $request + ), + $this->configureCallSettings('syncRecognize', $optionalArgs) + )->wait(); } /** @@ -432,24 +351,17 @@ public function asyncRecognize($config, $audio, $optionalArgs = []) $request->setConfig($config); $request->setAudio($audio); - $defaultCallSettings = $this->defaultCallSettings['asyncRecognize']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->speechStub, - 'AsyncRecognize', - $mergedSettings, - $this->descriptors['asyncRecognize'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startOperationsCall( + new Call( + self::SERVICE_NAME.'/AsyncRecognize', + Operation::class, + $request + ), + $this->configureCallSettings('asyncRecognize', $optionalArgs), + $this->descriptors['asyncRecognize']['longRunning'] + [ + 'operationsClient' => $this->getOperationsClient(), + ] + )->wait(); } /** @@ -506,31 +418,14 @@ public function asyncRecognize($config, $audio, $optionalArgs = []) */ public function streamingRecognize($optionalArgs = []) { - if (array_key_exists('timeoutMillis', $optionalArgs)) { - $optionalArgs['retrySettings'] = [ - 'retriesEnabled' => false, - 'noRetriesRpcTimeoutMillis' => $optionalArgs['timeoutMillis'], - ]; - } - - $defaultCallSettings = $this->defaultCallSettings['streamingRecognize']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->speechStub, - 'StreamingRecognize', - $mergedSettings, - $this->descriptors['streamingRecognize'] + return $this->transport->startBidiStreamingCall( + new Call( + self::SERVICE_NAME.'/StreamingRecognize', + StreamingRecognizeResponse::class + ), + $this->configureCallSettings('streamingRecognize', $optionalArgs), + $this->descriptors['streamingRecognize']['grpcStreaming'] ); - - return $callable( - null, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -541,11 +436,6 @@ public function streamingRecognize($optionalArgs = []) */ public function close() { - $this->speechStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Speech/V1beta1/resources/speech_descriptor_config.php b/src/Speech/V1beta1/resources/speech_descriptor_config.php new file mode 100644 index 000000000000..5f78c228052d --- /dev/null +++ b/src/Speech/V1beta1/resources/speech_descriptor_config.php @@ -0,0 +1,19 @@ + [ + 'google.cloud.speech.v1beta1.Speech' => [ + 'asyncRecognize' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Speech\V1beta1\AsyncRecognizeResponse', + 'metadataReturnType' => '\Google\Cloud\Speech\V1beta1\AsyncRecognizeMetadata', + ], + ], + 'streamingRecognize' => [ + 'grpcStreaming' => [ + 'grpcStreamingType' => 'BidiStreaming', + ], + ], + ], + ], +]; diff --git a/src/Speech/V1beta1/resources/speech_rest_client_config.php b/src/Speech/V1beta1/resources/speech_rest_client_config.php new file mode 100644 index 000000000000..de00de4dc016 --- /dev/null +++ b/src/Speech/V1beta1/resources/speech_rest_client_config.php @@ -0,0 +1,18 @@ + [ + 'google.cloud.speech.v1beta1.Speech' => [ + 'SyncRecognize' => [ + 'method' => 'post', + 'uri' => '/v1beta1/speech:syncrecognize', + 'body' => '*', + ], + 'AsyncRecognize' => [ + 'method' => 'post', + 'uri' => '/v1beta1/speech:asyncrecognize', + 'body' => '*', + ], + ], + ], +]; diff --git a/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php index 817ce970107c..48a6616ed5c8 100644 --- a/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php @@ -20,27 +20,35 @@ * This file was generated from the file * https://github.com/google/googleapis/blob/master/google/cloud/videointelligence/v1/video_intelligence.proto * and updates to that file get reflected here through a refresh process. + * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * + * @experimental */ namespace Google\Cloud\VideoIntelligence\V1\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\OperationResponse; -use Google\Cloud\Version; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\Cloud\VideoIntelligence\V1\AnnotateVideoProgress; use Google\Cloud\VideoIntelligence\V1\AnnotateVideoRequest; use Google\Cloud\VideoIntelligence\V1\AnnotateVideoResponse; use Google\Cloud\VideoIntelligence\V1\Feature; use Google\Cloud\VideoIntelligence\V1\VideoContext; -use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceGrpcClient; +use Google\LongRunning\Operation; /** * Service Description: Service that implements Google Cloud Video Intelligence API. * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * * This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * @@ -79,9 +87,17 @@ * } * ``` * + * @experimental */ class VideoIntelligenceServiceGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.cloud.videointelligence.v1.VideoIntelligenceService'; + /** * The default address of the service. */ @@ -102,40 +118,20 @@ class VideoIntelligenceServiceGapicClient */ const CODEGEN_VERSION = '0.0.5'; - private static $gapicVersion; - private static $gapicVersionLoaded = false; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/video_intelligence_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/video_intelligence_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/video_intelligence_service_descriptor_config.php', + ]; - protected $grpcCredentialsHelper; - protected $videoIntelligenceServiceStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; private $operationsClient; - private static function getLongRunningDescriptors() - { - return [ - 'annotateVideo' => [ - 'operationReturnType' => '\Google\Cloud\VideoIntelligence\V1\AnnotateVideoResponse', - 'metadataReturnType' => '\Google\Cloud\VideoIntelligence\V1\AnnotateVideoProgress', - ], - ]; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Return an OperationsClient object with the same endpoint as $this. * @@ -162,12 +158,9 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $lroDescriptors = self::getLongRunningDescriptors(); - if (!is_null($methodName) && array_key_exists($methodName, $lroDescriptors)) { - $options = $lroDescriptors[$methodName]; - } else { - $options = []; - } + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); @@ -184,16 +177,19 @@ public function resumeOperation($operationName, $methodName = null) * Default 'videointelligence.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -212,74 +208,31 @@ public function resumeOperation($operationName, $methodName = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/video_intelligence_service_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - if (array_key_exists('operationsClient', $options)) { - $this->operationsClient = $options['operationsClient']; - } else { - $operationsClientOptions = $options; - unset($operationsClientOptions['retryingOverride']); - unset($operationsClientOptions['clientConfigPath']); - $this->operationsClient = new OperationsClient($operationsClientOptions); - } - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'annotateVideo' => $defaultDescriptors, - ]; - $longRunningDescriptors = self::getLongRunningDescriptors(); - foreach ($longRunningDescriptors as $method => $longRunningDescriptor) { - $this->descriptors[$method]['longRunningDescriptor'] = $longRunningDescriptor + ['operationsClient' => $this->operationsClient]; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.cloud.videointelligence.v1.VideoIntelligenceService', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createVideoIntelligenceServiceStubFunction = function ($hostname, $opts, $channel) { - return new VideoIntelligenceServiceGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createVideoIntelligenceServiceStubFunction', $options)) { - $createVideoIntelligenceServiceStubFunction = $options['createVideoIntelligenceServiceStubFunction']; - } - $this->videoIntelligenceServiceStub = $this->grpcCredentialsHelper->createStub($createVideoIntelligenceServiceStubFunction); + $options += self::$clientDefaults; + $this->setClientOptions($options); + $this->pluckArray([ + 'serviceName', + 'clientConfigPath', + 'restClientConfigPath', + 'descriptorsConfigPath', + ], $options); + $this->operationsClient = new OperationsClient($options); } /** @@ -392,24 +345,17 @@ public function annotateVideo($optionalArgs = []) $request->setLocationId($optionalArgs['locationId']); } - $defaultCallSettings = $this->defaultCallSettings['annotateVideo']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->videoIntelligenceServiceStub, - 'AnnotateVideo', - $mergedSettings, - $this->descriptors['annotateVideo'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startOperationsCall( + new Call( + self::SERVICE_NAME.'/AnnotateVideo', + Operation::class, + $request + ), + $this->configureCallSettings('annotateVideo', $optionalArgs), + $this->descriptors['annotateVideo']['longRunning'] + [ + 'operationsClient' => $this->getOperationsClient(), + ] + )->wait(); } /** @@ -420,11 +366,6 @@ public function annotateVideo($optionalArgs = []) */ public function close() { - $this->videoIntelligenceServiceStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/VideoIntelligence/V1/resources/video_intelligence_service_descriptor_config.php b/src/VideoIntelligence/V1/resources/video_intelligence_service_descriptor_config.php new file mode 100644 index 000000000000..015b342cbdca --- /dev/null +++ b/src/VideoIntelligence/V1/resources/video_intelligence_service_descriptor_config.php @@ -0,0 +1,14 @@ + [ + 'google.cloud.videointelligence.v1.VideoIntelligenceService' => [ + 'annotateVideo' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\VideoIntelligence\V1\AnnotateVideoResponse', + 'metadataReturnType' => '\Google\Cloud\VideoIntelligence\V1\AnnotateVideoProgress', + ], + ], + ], + ], +]; diff --git a/src/VideoIntelligence/V1/resources/video_intelligence_service_rest_client_config.php b/src/VideoIntelligence/V1/resources/video_intelligence_service_rest_client_config.php new file mode 100644 index 000000000000..8497e3842aae --- /dev/null +++ b/src/VideoIntelligence/V1/resources/video_intelligence_service_rest_client_config.php @@ -0,0 +1,13 @@ + [ + 'google.cloud.videointelligence.v1.VideoIntelligenceService' => [ + 'AnnotateVideo' => [ + 'method' => 'post', + 'uri' => '/v1/videos:annotate', + 'body' => '*', + ], + ], + ], +]; diff --git a/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php index 265cb39fa3cb..265d53e5450a 100644 --- a/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php @@ -20,27 +20,35 @@ * This file was generated from the file * https://github.com/google/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto * and updates to that file get reflected here through a refresh process. + * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * + * @experimental */ namespace Google\Cloud\VideoIntelligence\V1beta1\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\OperationResponse; -use Google\Cloud\Version; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\Cloud\VideoIntelligence\V1beta1\AnnotateVideoProgress; use Google\Cloud\VideoIntelligence\V1beta1\AnnotateVideoRequest; use Google\Cloud\VideoIntelligence\V1beta1\AnnotateVideoResponse; use Google\Cloud\VideoIntelligence\V1beta1\Feature; use Google\Cloud\VideoIntelligence\V1beta1\VideoContext; -use Google\Cloud\VideoIntelligence\V1beta1\VideoIntelligenceServiceGrpcClient; +use Google\LongRunning\Operation; /** * Service Description: Service that implements Google Cloud Video Intelligence API. * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * * This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * @@ -80,9 +88,18 @@ * $videoIntelligenceServiceClient->close(); * } * ``` + * + * @experimental */ class VideoIntelligenceServiceGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.cloud.videointelligence.v1beta1.VideoIntelligenceService'; + /** * The default address of the service. */ @@ -103,40 +120,20 @@ class VideoIntelligenceServiceGapicClient */ const CODEGEN_VERSION = '0.0.5'; - private static $gapicVersion; - private static $gapicVersionLoaded = false; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/video_intelligence_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/video_intelligence_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/video_intelligence_service_descriptor_config.php', + ]; - protected $grpcCredentialsHelper; - protected $videoIntelligenceServiceStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; private $operationsClient; - private static function getLongRunningDescriptors() - { - return [ - 'annotateVideo' => [ - 'operationReturnType' => '\Google\Cloud\VideoIntelligence\V1beta1\AnnotateVideoResponse', - 'metadataReturnType' => '\Google\Cloud\VideoIntelligence\V1beta1\AnnotateVideoProgress', - ], - ]; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Return an OperationsClient object with the same endpoint as $this. * @@ -163,12 +160,9 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $lroDescriptors = self::getLongRunningDescriptors(); - if (!is_null($methodName) && array_key_exists($methodName, $lroDescriptors)) { - $options = $lroDescriptors[$methodName]; - } else { - $options = []; - } + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); @@ -185,16 +179,19 @@ public function resumeOperation($operationName, $methodName = null) * Default 'videointelligence.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -213,74 +210,31 @@ public function resumeOperation($operationName, $methodName = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/video_intelligence_service_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - if (array_key_exists('operationsClient', $options)) { - $this->operationsClient = $options['operationsClient']; - } else { - $operationsClientOptions = $options; - unset($operationsClientOptions['retryingOverride']); - unset($operationsClientOptions['clientConfigPath']); - $this->operationsClient = new OperationsClient($operationsClientOptions); - } - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'annotateVideo' => $defaultDescriptors, - ]; - $longRunningDescriptors = self::getLongRunningDescriptors(); - foreach ($longRunningDescriptors as $method => $longRunningDescriptor) { - $this->descriptors[$method]['longRunningDescriptor'] = $longRunningDescriptor + ['operationsClient' => $this->operationsClient]; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.cloud.videointelligence.v1beta1.VideoIntelligenceService', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createVideoIntelligenceServiceStubFunction = function ($hostname, $opts, $channel) { - return new VideoIntelligenceServiceGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createVideoIntelligenceServiceStubFunction', $options)) { - $createVideoIntelligenceServiceStubFunction = $options['createVideoIntelligenceServiceStubFunction']; - } - $this->videoIntelligenceServiceStub = $this->grpcCredentialsHelper->createStub($createVideoIntelligenceServiceStubFunction); + $options += self::$clientDefaults; + $this->setClientOptions($options); + $this->pluckArray([ + 'serviceName', + 'clientConfigPath', + 'restClientConfigPath', + 'descriptorsConfigPath', + ], $options); + $this->operationsClient = new OperationsClient($options); } /** @@ -388,24 +342,17 @@ public function annotateVideo($inputUri, $features, $optionalArgs = []) $request->setLocationId($optionalArgs['locationId']); } - $defaultCallSettings = $this->defaultCallSettings['annotateVideo']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->videoIntelligenceServiceStub, - 'AnnotateVideo', - $mergedSettings, - $this->descriptors['annotateVideo'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startOperationsCall( + new Call( + self::SERVICE_NAME.'/AnnotateVideo', + Operation::class, + $request + ), + $this->configureCallSettings('annotateVideo', $optionalArgs), + $this->descriptors['annotateVideo']['longRunning'] + [ + 'operationsClient' => $this->getOperationsClient(), + ] + )->wait(); } /** @@ -416,11 +363,6 @@ public function annotateVideo($inputUri, $features, $optionalArgs = []) */ public function close() { - $this->videoIntelligenceServiceStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/VideoIntelligence/V1beta1/resources/video_intelligence_service_descriptor_config.php b/src/VideoIntelligence/V1beta1/resources/video_intelligence_service_descriptor_config.php new file mode 100644 index 000000000000..0f2793ad70a7 --- /dev/null +++ b/src/VideoIntelligence/V1beta1/resources/video_intelligence_service_descriptor_config.php @@ -0,0 +1,14 @@ + [ + 'google.cloud.videointelligence.v1beta1.VideoIntelligenceService' => [ + 'annotateVideo' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\VideoIntelligence\V1beta1\AnnotateVideoResponse', + 'metadataReturnType' => '\Google\Cloud\VideoIntelligence\V1beta1\AnnotateVideoProgress', + ], + ], + ], + ], +]; diff --git a/src/VideoIntelligence/V1beta1/resources/video_intelligence_service_rest_client_config.php b/src/VideoIntelligence/V1beta1/resources/video_intelligence_service_rest_client_config.php new file mode 100644 index 000000000000..91da4a2d096b --- /dev/null +++ b/src/VideoIntelligence/V1beta1/resources/video_intelligence_service_rest_client_config.php @@ -0,0 +1,13 @@ + [ + 'google.cloud.videointelligence.v1beta1.VideoIntelligenceService' => [ + 'AnnotateVideo' => [ + 'method' => 'post', + 'uri' => '/v1beta1/videos:annotate', + 'body' => '*', + ], + ], + ], +]; diff --git a/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php index 8ade7f69cbf9..e7ffa8214f86 100644 --- a/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php @@ -20,27 +20,35 @@ * This file was generated from the file * https://github.com/google/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto * and updates to that file get reflected here through a refresh process. + * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * + * @experimental */ namespace Google\Cloud\VideoIntelligence\V1beta2\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\OperationResponse; -use Google\Cloud\Version; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\Cloud\VideoIntelligence\V1beta2\AnnotateVideoProgress; use Google\Cloud\VideoIntelligence\V1beta2\AnnotateVideoRequest; use Google\Cloud\VideoIntelligence\V1beta2\AnnotateVideoResponse; use Google\Cloud\VideoIntelligence\V1beta2\Feature; use Google\Cloud\VideoIntelligence\V1beta2\VideoContext; -use Google\Cloud\VideoIntelligence\V1beta2\VideoIntelligenceServiceGrpcClient; +use Google\LongRunning\Operation; /** * Service Description: Service that implements Google Cloud Video Intelligence API. * + * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change + * more frequently than those which have been declared beta or 1.0, including changes which break + * backwards compatibility. + * * This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * @@ -78,9 +86,18 @@ * $videoIntelligenceServiceClient->close(); * } * ``` + * + * @experimental */ class VideoIntelligenceServiceGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.cloud.videointelligence.v1beta2.VideoIntelligenceService'; + /** * The default address of the service. */ @@ -101,40 +118,20 @@ class VideoIntelligenceServiceGapicClient */ const CODEGEN_VERSION = '0.0.5'; - private static $gapicVersion; - private static $gapicVersionLoaded = false; + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/video_intelligence_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/video_intelligence_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/video_intelligence_service_descriptor_config.php', + ]; - protected $grpcCredentialsHelper; - protected $videoIntelligenceServiceStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; private $operationsClient; - private static function getLongRunningDescriptors() - { - return [ - 'annotateVideo' => [ - 'operationReturnType' => '\Google\Cloud\VideoIntelligence\V1beta2\AnnotateVideoResponse', - 'metadataReturnType' => '\Google\Cloud\VideoIntelligence\V1beta2\AnnotateVideoProgress', - ], - ]; - } - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Return an OperationsClient object with the same endpoint as $this. * @@ -161,12 +158,9 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $lroDescriptors = self::getLongRunningDescriptors(); - if (!is_null($methodName) && array_key_exists($methodName, $lroDescriptors)) { - $options = $lroDescriptors[$methodName]; - } else { - $options = []; - } + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); @@ -183,16 +177,19 @@ public function resumeOperation($operationName, $methodName = null) * Default 'videointelligence.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -211,74 +208,31 @@ public function resumeOperation($operationName, $methodName = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/video_intelligence_service_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - if (array_key_exists('operationsClient', $options)) { - $this->operationsClient = $options['operationsClient']; - } else { - $operationsClientOptions = $options; - unset($operationsClientOptions['retryingOverride']); - unset($operationsClientOptions['clientConfigPath']); - $this->operationsClient = new OperationsClient($operationsClientOptions); - } - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'annotateVideo' => $defaultDescriptors, - ]; - $longRunningDescriptors = self::getLongRunningDescriptors(); - foreach ($longRunningDescriptors as $method => $longRunningDescriptor) { - $this->descriptors[$method]['longRunningDescriptor'] = $longRunningDescriptor + ['operationsClient' => $this->operationsClient]; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.cloud.videointelligence.v1beta2.VideoIntelligenceService', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createVideoIntelligenceServiceStubFunction = function ($hostname, $opts, $channel) { - return new VideoIntelligenceServiceGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createVideoIntelligenceServiceStubFunction', $options)) { - $createVideoIntelligenceServiceStubFunction = $options['createVideoIntelligenceServiceStubFunction']; - } - $this->videoIntelligenceServiceStub = $this->grpcCredentialsHelper->createStub($createVideoIntelligenceServiceStubFunction); + $options += self::$clientDefaults; + $this->setClientOptions($options); + $this->pluckArray([ + 'serviceName', + 'clientConfigPath', + 'restClientConfigPath', + 'descriptorsConfigPath', + ], $options); + $this->operationsClient = new OperationsClient($options); } /** @@ -391,24 +345,17 @@ public function annotateVideo($optionalArgs = []) $request->setLocationId($optionalArgs['locationId']); } - $defaultCallSettings = $this->defaultCallSettings['annotateVideo']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->videoIntelligenceServiceStub, - 'AnnotateVideo', - $mergedSettings, - $this->descriptors['annotateVideo'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startOperationsCall( + new Call( + self::SERVICE_NAME.'/AnnotateVideo', + Operation::class, + $request + ), + $this->configureCallSettings('annotateVideo', $optionalArgs), + $this->descriptors['annotateVideo']['longRunning'] + [ + 'operationsClient' => $this->getOperationsClient(), + ] + )->wait(); } /** @@ -419,11 +366,6 @@ public function annotateVideo($optionalArgs = []) */ public function close() { - $this->videoIntelligenceServiceStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/VideoIntelligence/V1beta2/resources/video_intelligence_service_descriptor_config.php b/src/VideoIntelligence/V1beta2/resources/video_intelligence_service_descriptor_config.php new file mode 100644 index 000000000000..1a93d9c51b8b --- /dev/null +++ b/src/VideoIntelligence/V1beta2/resources/video_intelligence_service_descriptor_config.php @@ -0,0 +1,14 @@ + [ + 'google.cloud.videointelligence.v1beta2.VideoIntelligenceService' => [ + 'annotateVideo' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\VideoIntelligence\V1beta2\AnnotateVideoResponse', + 'metadataReturnType' => '\Google\Cloud\VideoIntelligence\V1beta2\AnnotateVideoProgress', + ], + ], + ], + ], +]; diff --git a/src/VideoIntelligence/V1beta2/resources/video_intelligence_service_rest_client_config.php b/src/VideoIntelligence/V1beta2/resources/video_intelligence_service_rest_client_config.php new file mode 100644 index 000000000000..d7c73271fa4b --- /dev/null +++ b/src/VideoIntelligence/V1beta2/resources/video_intelligence_service_rest_client_config.php @@ -0,0 +1,13 @@ + [ + 'google.cloud.videointelligence.v1beta2.VideoIntelligenceService' => [ + 'AnnotateVideo' => [ + 'method' => 'post', + 'uri' => '/v1beta2/videos:annotate', + 'body' => '*', + ], + ], + ], +]; diff --git a/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php b/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php index 98bd067e582c..6481291d8e15 100644 --- a/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php +++ b/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php @@ -30,14 +30,12 @@ namespace Google\Cloud\Vision\V1\Gapic; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\ApiCallable; -use Google\ApiCore\CallSettings; -use Google\ApiCore\GrpcCredentialsHelper; -use Google\Cloud\Version; +use Google\ApiCore\Call; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\Cloud\Vision\V1\AnnotateImageRequest; use Google\Cloud\Vision\V1\BatchAnnotateImagesRequest; -use Google\Cloud\Vision\V1\ImageAnnotatorGrpcClient; +use Google\Cloud\Vision\V1\BatchAnnotateImagesResponse; /** * Service Description: Service that performs Google Cloud Vision API detection tasks over client @@ -65,6 +63,13 @@ */ class ImageAnnotatorGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.cloud.vision.v1.ImageAnnotator'; + /** * The default address of the service. */ @@ -85,28 +90,18 @@ class ImageAnnotatorGapicClient */ const CODEGEN_VERSION = '0.0.5'; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $imageAnnotatorStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; - - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } + private static $clientDefaults = [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-vision', + ], + 'clientConfigPath' => __DIR__.'/../resources/image_annotator_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/image_annotator_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/image_annotator_descriptor_config.php', + ]; /** * Constructor. @@ -118,16 +113,19 @@ private static function getGapicVersion() * Default 'vision.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. * @type \Grpc\ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. * @type array $scopes A string array of scopes to use when acquiring credentials. @@ -146,62 +144,23 @@ private static function getGapicVersion() * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|ApiTransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-vision', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/image_annotator_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'batchAnnotateImages' => $defaultDescriptors, - ]; - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.cloud.vision.v1.ImageAnnotator', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createImageAnnotatorStubFunction = function ($hostname, $opts, $channel) { - return new ImageAnnotatorGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createImageAnnotatorStubFunction', $options)) { - $createImageAnnotatorStubFunction = $options['createImageAnnotatorStubFunction']; - } - $this->imageAnnotatorStub = $this->grpcCredentialsHelper->createStub($createImageAnnotatorStubFunction); + $this->setClientOptions($options + self::$clientDefaults); } /** @@ -239,24 +198,14 @@ public function batchAnnotateImages($requests, $optionalArgs = []) $request = new BatchAnnotateImagesRequest(); $request->setRequests($requests); - $defaultCallSettings = $this->defaultCallSettings['batchAnnotateImages']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->imageAnnotatorStub, - 'BatchAnnotateImages', - $mergedSettings, - $this->descriptors['batchAnnotateImages'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + return $this->startCall( + new Call( + self::SERVICE_NAME.'/BatchAnnotateImages', + BatchAnnotateImagesResponse::class, + $request + ), + $this->configureCallSettings('batchAnnotateImages', $optionalArgs) + )->wait(); } /** @@ -267,11 +216,6 @@ public function batchAnnotateImages($requests, $optionalArgs = []) */ public function close() { - $this->imageAnnotatorStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + $this->transport->close(); } } diff --git a/src/Vision/V1/resources/image_annotator_descriptor_config.php b/src/Vision/V1/resources/image_annotator_descriptor_config.php new file mode 100644 index 000000000000..23db1fbbe366 --- /dev/null +++ b/src/Vision/V1/resources/image_annotator_descriptor_config.php @@ -0,0 +1,8 @@ + [ + 'google.cloud.vision.v1.ImageAnnotator' => [ + ], + ], +]; diff --git a/src/Vision/V1/resources/image_annotator_rest_client_config.php b/src/Vision/V1/resources/image_annotator_rest_client_config.php new file mode 100644 index 000000000000..1cd2df07cfbe --- /dev/null +++ b/src/Vision/V1/resources/image_annotator_rest_client_config.php @@ -0,0 +1,13 @@ + [ + 'google.cloud.vision.v1.ImageAnnotator' => [ + 'BatchAnnotateImages' => [ + 'method' => 'post', + 'uri' => '/v1/images:annotate', + 'body' => '*', + ], + ], + ], +]; From f183f94078eedc617314d2d45f161027fa00df94 Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Thu, 14 Dec 2017 15:02:11 -0500 Subject: [PATCH 02/21] cs fix --- .../V1beta1/resources/firestore_rest_client_config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Firestore/V1beta1/resources/firestore_rest_client_config.php b/src/Firestore/V1beta1/resources/firestore_rest_client_config.php index 52d9d22eb13f..241a85d50916 100644 --- a/src/Firestore/V1beta1/resources/firestore_rest_client_config.php +++ b/src/Firestore/V1beta1/resources/firestore_rest_client_config.php @@ -119,4 +119,4 @@ ], ] ] -]; \ No newline at end of file +]; From 7be22b19c958f3f11ebc141a80eda41913f3a55c Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Fri, 15 Dec 2017 08:40:19 -0500 Subject: [PATCH 03/21] regenerate with fix for server streaming calls --- src/Bigtable/V2/Gapic/BigtableGapicClient.php | 8 +++++--- src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php | 6 ++++-- src/Spanner/V1/Gapic/SpannerGapicClient.php | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Bigtable/V2/Gapic/BigtableGapicClient.php b/src/Bigtable/V2/Gapic/BigtableGapicClient.php index 1c912c5451e6..038063fa1ae2 100644 --- a/src/Bigtable/V2/Gapic/BigtableGapicClient.php +++ b/src/Bigtable/V2/Gapic/BigtableGapicClient.php @@ -41,6 +41,7 @@ use Google\Cloud\Bigtable\V2\MutateRowResponse; use Google\Cloud\Bigtable\V2\MutateRowsRequest; use Google\Cloud\Bigtable\V2\MutateRowsRequest_Entry as Entry; +use Google\Cloud\Bigtable\V2\MutateRowsResponse; use Google\Cloud\Bigtable\V2\Mutation; use Google\Cloud\Bigtable\V2\ReadModifyWriteRowRequest; use Google\Cloud\Bigtable\V2\ReadModifyWriteRowResponse; @@ -50,6 +51,7 @@ use Google\Cloud\Bigtable\V2\RowFilter; use Google\Cloud\Bigtable\V2\RowSet; use Google\Cloud\Bigtable\V2\SampleRowKeysRequest; +use Google\Cloud\Bigtable\V2\SampleRowKeysResponse; /** * Service Description: Service for reading from and writing to existing Bigtable tables. @@ -344,7 +346,7 @@ public function readRows($tableName, $optionalArgs = []) return $this->transport->startServerStreamingCall( new Call( self::SERVICE_NAME.'/ReadRows', - \Google\ApiCore\ServerStream::class, + ReadRowsResponse::class, $request ), $this->configureCallSettings('readRows', $optionalArgs), @@ -407,7 +409,7 @@ public function sampleRowKeys($tableName, $optionalArgs = []) return $this->transport->startServerStreamingCall( new Call( self::SERVICE_NAME.'/SampleRowKeys', - \Google\ApiCore\ServerStream::class, + SampleRowKeysResponse::class, $request ), $this->configureCallSettings('sampleRowKeys', $optionalArgs), @@ -541,7 +543,7 @@ public function mutateRows($tableName, $entries, $optionalArgs = []) return $this->transport->startServerStreamingCall( new Call( self::SERVICE_NAME.'/MutateRows', - \Google\ApiCore\ServerStream::class, + MutateRowsResponse::class, $request ), $this->configureCallSettings('mutateRows', $optionalArgs), diff --git a/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php b/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php index 72ad8705c5b1..1e788500360a 100644 --- a/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php +++ b/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php @@ -36,6 +36,7 @@ use Google\ApiCore\Transport\ApiTransportInterface; use Google\ApiCore\ValidationException; use Google\Cloud\Firestore\V1beta1\BatchGetDocumentsRequest; +use Google\Cloud\Firestore\V1beta1\BatchGetDocumentsResponse; use Google\Cloud\Firestore\V1beta1\BeginTransactionRequest; use Google\Cloud\Firestore\V1beta1\BeginTransactionResponse; use Google\Cloud\Firestore\V1beta1\CommitRequest; @@ -54,6 +55,7 @@ use Google\Cloud\Firestore\V1beta1\Precondition; use Google\Cloud\Firestore\V1beta1\RollbackRequest; use Google\Cloud\Firestore\V1beta1\RunQueryRequest; +use Google\Cloud\Firestore\V1beta1\RunQueryResponse; use Google\Cloud\Firestore\V1beta1\StructuredQuery; use Google\Cloud\Firestore\V1beta1\Target; use Google\Cloud\Firestore\V1beta1\TransactionOptions; @@ -828,7 +830,7 @@ public function batchGetDocuments($database, $documents, $optionalArgs = []) return $this->transport->startServerStreamingCall( new Call( self::SERVICE_NAME.'/BatchGetDocuments', - \Google\ApiCore\ServerStream::class, + BatchGetDocumentsResponse::class, $request ), $this->configureCallSettings('batchGetDocuments', $optionalArgs), @@ -1059,7 +1061,7 @@ public function runQuery($parent, $optionalArgs = []) return $this->transport->startServerStreamingCall( new Call( self::SERVICE_NAME.'/RunQuery', - \Google\ApiCore\ServerStream::class, + RunQueryResponse::class, $request ), $this->configureCallSettings('runQuery', $optionalArgs), diff --git a/src/Spanner/V1/Gapic/SpannerGapicClient.php b/src/Spanner/V1/Gapic/SpannerGapicClient.php index 5114259f492f..cc7a2b377f5d 100644 --- a/src/Spanner/V1/Gapic/SpannerGapicClient.php +++ b/src/Spanner/V1/Gapic/SpannerGapicClient.php @@ -762,7 +762,7 @@ public function executeStreamingSql($session, $sql, $optionalArgs = []) return $this->transport->startServerStreamingCall( new Call( self::SERVICE_NAME.'/ExecuteStreamingSql', - \Google\ApiCore\ServerStream::class, + PartialResultSet::class, $request ), $this->configureCallSettings('executeStreamingSql', $optionalArgs), @@ -966,7 +966,7 @@ public function streamingRead($session, $table, $columns, $keySet, $optionalArgs return $this->transport->startServerStreamingCall( new Call( self::SERVICE_NAME.'/StreamingRead', - \Google\ApiCore\ServerStream::class, + PartialResultSet::class, $request ), $this->configureCallSettings('streamingRead', $optionalArgs), From db48f78d8b692aaf492537c5164ed895e5418cb8 Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Fri, 15 Dec 2017 09:09:12 -0500 Subject: [PATCH 04/21] update spanner async delete call --- src/Spanner/Connection/Grpc.php | 42 ++++++++----------- src/Spanner/V1/SpannerClient.php | 22 +++------- tests/unit/Spanner/Connection/GrpcTest.php | 34 +++++++-------- .../Spanner/Session/CacheSessionPoolTest.php | 8 ++-- 4 files changed, 41 insertions(+), 65 deletions(-) diff --git a/src/Spanner/Connection/Grpc.php b/src/Spanner/Connection/Grpc.php index a25c433b24e1..b1db4ac349c1 100644 --- a/src/Spanner/Connection/Grpc.php +++ b/src/Spanner/Connection/Grpc.php @@ -17,7 +17,9 @@ namespace Google\Cloud\Spanner\Connection; -use Grpc\UnaryCall; +use Google\ApiCore\Call; +use Google\ApiCore\CallSettings; +use Google\ApiCore\Serializer; use Google\Cloud\Core\GrpcRequestWrapper; use Google\Cloud\Core\GrpcTrait; use Google\Cloud\Core\LongRunning\OperationResponseTrait; @@ -26,8 +28,6 @@ use Google\Cloud\Spanner\Operation; use Google\Cloud\Spanner\SpannerClient as ManualSpannerClient; use Google\Cloud\Spanner\V1\SpannerClient; -use Google\ApiCore\AgentHeaderDescriptor; -use Google\ApiCore\Serializer; use Google\Protobuf; use Google\Protobuf\FieldMask; use Google\Protobuf\GPBEmpty; @@ -46,6 +46,7 @@ use Google\Cloud\Spanner\V1\TransactionOptions_ReadWrite; use Google\Cloud\Spanner\V1\TransactionSelector; use Google\Cloud\Spanner\V1\Type; +use GuzzleHttp\Promise\PromiseInterface; /** * Connection to Cloud Spanner over gRPC @@ -119,11 +120,6 @@ class Grpc implements ConnectionInterface */ private $longRunningGrpcClients; - /** - * @var AgentHeaderDescriptor - */ - private $headerDescriptor; - /** * @param array $config [optional] */ @@ -161,9 +157,6 @@ public function __construct(array $config = []) $this->instanceAdminClient, $this->databaseAdminClient ]; - $this->headerDescriptor = new AgentHeaderDescriptor([ - 'gapicVersion' => trim(file_get_contents(__DIR__ . '/../VERSION')) - ]); } /** @@ -462,27 +455,26 @@ public function deleteSession(array $args) * * @access private * @param array $args - * @return UnaryCall + * @return PromiseInterface * @experimental */ public function deleteSessionAsync(array $args) { $database = $this->pluck('database', $args); - $headers = $this->headerDescriptor->getHeader() - + $this->addResourcePrefixHeader($args, $database)['userHeaders']; + $settings = new CallSettings($this->addResourcePrefixHeader($args, $database)); $request = new DeleteSessionRequest(); $request->setName($this->pluck('name', $args)); - $credentialsCallback = $this->spannerClient - ->getCredentialsHelper() - ->createCallCredentialsCallback(); - - return $this->spannerClient - ->getStub() - ->DeleteSession( - $request, - $headers, - ['call_credentials_callback' => $credentialsCallback] - ); + $transport = $this->spannerClient->getTransport(); + $callable = $transport->getCallable($settings); + + return $callable( + new Call( + 'google.spanner.v1.Spanner/DeleteSession', + GPBEmpty::class, + $request + ), + $settings + ); } /** diff --git a/src/Spanner/V1/SpannerClient.php b/src/Spanner/V1/SpannerClient.php index 00a45e48afeb..c4dbdd2affbc 100644 --- a/src/Spanner/V1/SpannerClient.php +++ b/src/Spanner/V1/SpannerClient.php @@ -30,8 +30,8 @@ namespace Google\Cloud\Spanner\V1; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\Cloud\Spanner\V1\Gapic\SpannerGapicClient; -use Google\ApiCore\GrpcCredentialsHelper; use Google\Cloud\Spanner\V1\SpannerGrpcClient; /** @@ -40,26 +40,14 @@ class SpannerClient extends SpannerGapicClient { /** - * Returns the underlying stub. + * Returns the underlying transport. * * @access private - * @return SpannerGrpcClient + * @return ApiTransportInterface * @experimental */ - public function getStub() + public function getTransport() { - return $this->spannerStub; - } - - /** - * Returns the underlying gRPC credentials helper. - * - * @access private - * @return GrpcCredentialsHelper - * @experimental - */ - public function getCredentialsHelper() - { - return $this->grpcCredentialsHelper; + return $this->transport; } } diff --git a/tests/unit/Spanner/Connection/GrpcTest.php b/tests/unit/Spanner/Connection/GrpcTest.php index 63fc4aa46d24..2a3322307472 100644 --- a/tests/unit/Spanner/Connection/GrpcTest.php +++ b/tests/unit/Spanner/Connection/GrpcTest.php @@ -17,16 +17,17 @@ namespace Google\Cloud\Tests\Unit\Spanner\Connection; -use Grpc\UnaryCall; +use Google\ApiCore\Call; +use Google\ApiCore\CallSettings; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\Serializer; +use Google\ApiCore\Transport\ApiTransportInterface; use Google\Cloud\Core\GrpcRequestWrapper; use Google\Cloud\Core\GrpcTrait; use Google\Cloud\Spanner\Connection\Grpc; use Google\Cloud\Spanner\V1\SpannerClient; use Google\Cloud\Spanner\ValueMapper; use Google\Cloud\Tests\GrpcTestTrait; -use Google\ApiCore\GrpcCredentialsHelper; -use Google\ApiCore\OperationResponse; -use Google\ApiCore\Serializer; use Google\Protobuf\FieldMask; use Google\Protobuf\Struct; use Google\Cloud\Spanner\Admin\Instance\V1\Instance; @@ -41,6 +42,7 @@ use Google\Cloud\Spanner\V1\TransactionOptions; use Google\Cloud\Spanner\V1\TransactionSelector; use Google\Cloud\Spanner\V1\Type; +use GuzzleHttp\Promise\PromiseInterface; use Prophecy\Argument; use PHPUnit\Framework\TestCase; @@ -67,33 +69,27 @@ public function setUp() public function testDeleteSessionAsync() { - $cb = function () {}; + $cb = function (Call $call, CallSettings $settings) { + return $this->prophesize(PromiseInterface::class) + ->reveal(); + }; $sessionName = 'session1'; $databaseName = 'database1'; $request = new DeleteSessionRequest(); $request->setName($sessionName); - $unaryCall = $this->prophesize(UnaryCall::class); - $credentialsHelper = $this->prophesize(GrpcCredentialsHelper::class); $client = $this->prophesize(SpannerClient::class); - $stub = $this->prophesize(SpannerGrpcClient::class); - $credentialsHelper->createCallCredentialsCallback() + $transport = $this->prophesize(ApiTransportInterface::class); + $transport->getCallable(Argument::type(CallSettings::class)) ->willReturn($cb); - $stub->DeleteSession( - $request, - Argument::type('array'), - Argument::withKey('call_credentials_callback') - )->willReturn($unaryCall->reveal()); - $client->getStub() - ->willReturn($stub->reveal()); - $client->getCredentialsHelper() - ->willReturn($credentialsHelper->reveal()); + $client->getTransport() + ->willReturn($transport->reveal()); $grpc = new Grpc(['gapicSpannerClient' => $client->reveal()]); $call = $grpc->deleteSessionAsync([ 'name' => $sessionName, 'database' => $databaseName ]); - $this->assertInstanceOf(UnaryCall::class, $call); + $this->assertInstanceOf(PromiseInterface::class, $call); } /** diff --git a/tests/unit/Spanner/Session/CacheSessionPoolTest.php b/tests/unit/Spanner/Session/CacheSessionPoolTest.php index 51da3ef64f30..74dd3b3b4748 100644 --- a/tests/unit/Spanner/Session/CacheSessionPoolTest.php +++ b/tests/unit/Spanner/Session/CacheSessionPoolTest.php @@ -26,7 +26,7 @@ use Google\Cloud\Spanner\Session\CacheSessionPool; use Google\Cloud\Spanner\Session\Session; use Google\Cloud\Tests\GrpcTestTrait; -use Grpc\UnaryCall; +use GuzzleHttp\Promise\PromiseInterface; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Prophecy\Argument; @@ -633,17 +633,17 @@ private function getDatabase($shouldCreateThrowException = false, $willDeleteSes $createdSession = $this->prophesize(Session::class); $session = $this->prophesize(Session::class); $connection = $this->prophesize(Grpc::class); - $unaryCall = $this->prophesize(UnaryCall::class); + $promise = $this->prophesize(PromiseInterface::class); $createdSession->expiration() ->willReturn($this->time + 3600); $session->expiration() ->willReturn($this->time + 3600); $session->exists() ->willReturn(false); - $unaryCall->wait() + $promise->wait() ->willReturn(null); $connection->deleteSessionAsync(Argument::any()) - ->willReturn($unaryCall->reveal()); + ->willReturn($promise->reveal()); if ($willDeleteSessions) { $session->delete() From 0fad551f8796da04ab95bc3797e16281fe8e24ae Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Fri, 15 Dec 2017 11:07:26 -0500 Subject: [PATCH 05/21] gapic refresh --- .../BigtableInstanceAdminGapicClient.php | 44 ++++++++------- .../Gapic/BigtableTableAdminGapicClient.php | 44 ++++++++------- ...able_instance_admin_rest_client_config.php | 2 +- src/Bigtable/V2/Gapic/BigtableGapicClient.php | 38 +++++++------ .../resources/bigtable_rest_client_config.php | 12 ++-- .../V2beta1/Gapic/DlpServiceGapicClient.php | 28 ++++++---- .../Gapic/ErrorGroupServiceGapicClient.php | 28 ++++++---- .../Gapic/ErrorStatsServiceGapicClient.php | 28 ++++++---- .../Gapic/ReportErrorsServiceGapicClient.php | 28 ++++++---- ...error_group_service_rest_client_config.php | 2 +- ...error_stats_service_rest_client_config.php | 6 +- ...port_errors_service_rest_client_config.php | 2 +- .../V1beta1/Gapic/FirestoreGapicClient.php | 30 +++++----- .../firestore_rest_client_config.php | 56 +++++++++---------- .../Gapic/LanguageServiceGapicClient.php | 27 +++++---- .../V2/Gapic/ConfigServiceV2GapicClient.php | 36 ++++++------ .../V2/Gapic/LoggingServiceV2GapicClient.php | 36 ++++++------ .../V2/Gapic/MetricsServiceV2GapicClient.php | 36 ++++++------ .../config_service_v2_rest_client_config.php | 6 +- .../logging_service_v2_rest_client_config.php | 2 +- .../metrics_service_v2_rest_client_config.php | 6 +- .../V3/Gapic/GroupServiceGapicClient.php | 34 ++++++----- .../V3/Gapic/MetricServiceGapicClient.php | 34 ++++++----- .../Gapic/UptimeCheckServiceGapicClient.php | 34 ++++++----- ...ptime_check_service_rest_client_config.php | 2 +- src/PubSub/V1/Gapic/PublisherGapicClient.php | 30 +++++----- src/PubSub/V1/Gapic/SubscriberGapicClient.php | 30 +++++----- .../V1/Gapic/DatabaseAdminGapicClient.php | 30 +++++----- .../V1/Gapic/InstanceAdminGapicClient.php | 30 +++++----- src/Spanner/V1/Gapic/SpannerGapicClient.php | 30 +++++----- src/Speech/V1/Gapic/SpeechGapicClient.php | 29 +++++----- .../V1beta1/Gapic/SpeechGapicClient.php | 29 +++++----- .../VideoIntelligenceServiceGapicClient.php | 29 +++++----- .../VideoIntelligenceServiceGapicClient.php | 29 +++++----- .../VideoIntelligenceServiceGapicClient.php | 29 +++++----- .../V1/Gapic/ImageAnnotatorGapicClient.php | 29 +++++----- 36 files changed, 511 insertions(+), 414 deletions(-) diff --git a/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php b/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php index ebdb523aa03d..4425fda287c9 100644 --- a/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php +++ b/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php @@ -160,28 +160,32 @@ class BigtableInstanceAdminGapicClient private static $clusterNameTemplate; private static $locationNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/bigtable.admin', - 'https://www.googleapis.com/auth/bigtable.admin.cluster', - 'https://www.googleapis.com/auth/bigtable.admin.instance', - 'https://www.googleapis.com/auth/bigtable.admin.table', - 'https://www.googleapis.com/auth/cloud-bigtable.admin', - 'https://www.googleapis.com/auth/cloud-bigtable.admin.cluster', - 'https://www.googleapis.com/auth/cloud-bigtable.admin.table', - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - ], - 'clientConfigPath' => __DIR__.'/../resources/bigtable_instance_admin_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/bigtable_instance_admin_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/bigtable_instance_admin_descriptor_config.php', - ]; private $operationsClient; + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/bigtable.admin', + 'https://www.googleapis.com/auth/bigtable.admin.cluster', + 'https://www.googleapis.com/auth/bigtable.admin.instance', + 'https://www.googleapis.com/auth/bigtable.admin.table', + 'https://www.googleapis.com/auth/cloud-bigtable.admin', + 'https://www.googleapis.com/auth/cloud-bigtable.admin.cluster', + 'https://www.googleapis.com/auth/cloud-bigtable.admin.table', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ], + 'clientConfigPath' => __DIR__.'/../resources/bigtable_instance_admin_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/bigtable_instance_admin_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/bigtable_instance_admin_descriptor_config.php', + ]; + } + private static function getProjectNameTemplate() { if (null == self::$projectNameTemplate) { @@ -471,7 +475,7 @@ public function resumeOperation($operationName, $methodName = null) */ public function __construct($options = []) { - $options += self::$clientDefaults; + $options += self::getClientDefaults(); $this->setClientOptions($options); $this->pluckArray([ 'serviceName', diff --git a/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php b/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php index b67c238e04bc..9ded78b8b42d 100644 --- a/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php +++ b/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php @@ -130,28 +130,32 @@ class BigtableTableAdminGapicClient private static $snapshotNameTemplate; private static $tableNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/bigtable.admin', - 'https://www.googleapis.com/auth/bigtable.admin.cluster', - 'https://www.googleapis.com/auth/bigtable.admin.instance', - 'https://www.googleapis.com/auth/bigtable.admin.table', - 'https://www.googleapis.com/auth/cloud-bigtable.admin', - 'https://www.googleapis.com/auth/cloud-bigtable.admin.cluster', - 'https://www.googleapis.com/auth/cloud-bigtable.admin.table', - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - ], - 'clientConfigPath' => __DIR__.'/../resources/bigtable_table_admin_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/bigtable_table_admin_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/bigtable_table_admin_descriptor_config.php', - ]; private $operationsClient; + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/bigtable.admin', + 'https://www.googleapis.com/auth/bigtable.admin.cluster', + 'https://www.googleapis.com/auth/bigtable.admin.instance', + 'https://www.googleapis.com/auth/bigtable.admin.table', + 'https://www.googleapis.com/auth/cloud-bigtable.admin', + 'https://www.googleapis.com/auth/cloud-bigtable.admin.cluster', + 'https://www.googleapis.com/auth/cloud-bigtable.admin.table', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ], + 'clientConfigPath' => __DIR__.'/../resources/bigtable_table_admin_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/bigtable_table_admin_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/bigtable_table_admin_descriptor_config.php', + ]; + } + private static function getInstanceNameTemplate() { if (null == self::$instanceNameTemplate) { @@ -418,7 +422,7 @@ public function resumeOperation($operationName, $methodName = null) */ public function __construct($options = []) { - $options += self::$clientDefaults; + $options += self::getClientDefaults(); $this->setClientOptions($options); $this->pluckArray([ 'serviceName', diff --git a/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_rest_client_config.php b/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_rest_client_config.php index cdded2a41d12..dae4a6ed060e 100644 --- a/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_rest_client_config.php +++ b/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_rest_client_config.php @@ -142,7 +142,7 @@ 'body' => 'app_profile', 'placeholders' => [ 'app_profile.name' => [ - 'getApp_profile', + 'getAppProfile', 'getName', ], ], diff --git a/src/Bigtable/V2/Gapic/BigtableGapicClient.php b/src/Bigtable/V2/Gapic/BigtableGapicClient.php index 038063fa1ae2..c9e1835c3a27 100644 --- a/src/Bigtable/V2/Gapic/BigtableGapicClient.php +++ b/src/Bigtable/V2/Gapic/BigtableGapicClient.php @@ -115,22 +115,26 @@ class BigtableGapicClient private static $tableNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/bigtable.data', - 'https://www.googleapis.com/auth/bigtable.data.readonly', - 'https://www.googleapis.com/auth/cloud-bigtable.data', - 'https://www.googleapis.com/auth/cloud-bigtable.data.readonly', - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - ], - 'clientConfigPath' => __DIR__.'/../resources/bigtable_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/bigtable_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/bigtable_descriptor_config.php', - ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/bigtable.data', + 'https://www.googleapis.com/auth/bigtable.data.readonly', + 'https://www.googleapis.com/auth/cloud-bigtable.data', + 'https://www.googleapis.com/auth/cloud-bigtable.data.readonly', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ], + 'clientConfigPath' => __DIR__.'/../resources/bigtable_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/bigtable_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/bigtable_descriptor_config.php', + ]; + } private static function getTableNameTemplate() { @@ -270,7 +274,7 @@ public static function parseName($formattedName, $template = null) */ public function __construct($options = []) { - $this->setClientOptions($options + self::$clientDefaults); + $this->setClientOptions($options + self::getClientDefaults()); } /** diff --git a/src/Bigtable/V2/resources/bigtable_rest_client_config.php b/src/Bigtable/V2/resources/bigtable_rest_client_config.php index 90df75ea73e4..15e1278e7459 100644 --- a/src/Bigtable/V2/resources/bigtable_rest_client_config.php +++ b/src/Bigtable/V2/resources/bigtable_rest_client_config.php @@ -9,7 +9,7 @@ 'body' => '*', 'placeholders' => [ 'table_name' => [ - 'getTable_name', + 'getTableName', ], ], ], @@ -18,7 +18,7 @@ 'uri' => '/v2/{table_name=projects/*/instances/*/tables/*}:sampleRowKeys', 'placeholders' => [ 'table_name' => [ - 'getTable_name', + 'getTableName', ], ], ], @@ -28,7 +28,7 @@ 'body' => '*', 'placeholders' => [ 'table_name' => [ - 'getTable_name', + 'getTableName', ], ], ], @@ -38,7 +38,7 @@ 'body' => '*', 'placeholders' => [ 'table_name' => [ - 'getTable_name', + 'getTableName', ], ], ], @@ -48,7 +48,7 @@ 'body' => '*', 'placeholders' => [ 'table_name' => [ - 'getTable_name', + 'getTableName', ], ], ], @@ -58,7 +58,7 @@ 'body' => '*', 'placeholders' => [ 'table_name' => [ - 'getTable_name', + 'getTableName', ], ], ], diff --git a/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php b/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php index 526dbb24ff06..a1f1be7446e8 100644 --- a/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php +++ b/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php @@ -137,20 +137,24 @@ class DlpServiceGapicClient private static $resultNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'clientConfigPath' => __DIR__.'/../resources/dlp_service_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/dlp_service_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/dlp_service_descriptor_config.php', - ]; private $operationsClient; + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/dlp_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/dlp_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/dlp_service_descriptor_config.php', + ]; + } + private static function getResultNameTemplate() { if (null == self::$resultNameTemplate) { @@ -320,7 +324,7 @@ public function resumeOperation($operationName, $methodName = null) */ public function __construct($options = []) { - $options += self::$clientDefaults; + $options += self::getClientDefaults(); $this->setClientOptions($options); $this->pluckArray([ 'serviceName', diff --git a/src/ErrorReporting/V1beta1/Gapic/ErrorGroupServiceGapicClient.php b/src/ErrorReporting/V1beta1/Gapic/ErrorGroupServiceGapicClient.php index fae9e14ea7ae..c4e529cd11f5 100644 --- a/src/ErrorReporting/V1beta1/Gapic/ErrorGroupServiceGapicClient.php +++ b/src/ErrorReporting/V1beta1/Gapic/ErrorGroupServiceGapicClient.php @@ -97,17 +97,21 @@ class ErrorGroupServiceGapicClient private static $groupNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'clientConfigPath' => __DIR__.'/../resources/error_group_service_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/error_group_service_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/error_group_service_descriptor_config.php', - ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/error_group_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/error_group_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/error_group_service_descriptor_config.php', + ]; + } private static function getGroupNameTemplate() { @@ -245,7 +249,7 @@ public static function parseName($formattedName, $template = null) */ public function __construct($options = []) { - $this->setClientOptions($options + self::$clientDefaults); + $this->setClientOptions($options + self::getClientDefaults()); } /** diff --git a/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php b/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php index 0dcdd0920ac8..1349eed157eb 100644 --- a/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php +++ b/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php @@ -118,17 +118,21 @@ class ErrorStatsServiceGapicClient private static $projectNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'clientConfigPath' => __DIR__.'/../resources/error_stats_service_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/error_stats_service_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/error_stats_service_descriptor_config.php', - ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/error_stats_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/error_stats_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/error_stats_service_descriptor_config.php', + ]; + } private static function getProjectNameTemplate() { @@ -264,7 +268,7 @@ public static function parseName($formattedName, $template = null) */ public function __construct($options = []) { - $this->setClientOptions($options + self::$clientDefaults); + $this->setClientOptions($options + self::getClientDefaults()); } /** diff --git a/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php b/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php index 989fff9d3863..39d129eb9b90 100644 --- a/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php +++ b/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php @@ -98,17 +98,21 @@ class ReportErrorsServiceGapicClient private static $projectNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'clientConfigPath' => __DIR__.'/../resources/report_errors_service_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/report_errors_service_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/report_errors_service_descriptor_config.php', - ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/report_errors_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/report_errors_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/report_errors_service_descriptor_config.php', + ]; + } private static function getProjectNameTemplate() { @@ -244,7 +248,7 @@ public static function parseName($formattedName, $template = null) */ public function __construct($options = []) { - $this->setClientOptions($options + self::$clientDefaults); + $this->setClientOptions($options + self::getClientDefaults()); } /** diff --git a/src/ErrorReporting/V1beta1/resources/error_group_service_rest_client_config.php b/src/ErrorReporting/V1beta1/resources/error_group_service_rest_client_config.php index 099e7a8b836f..e5061fdee013 100644 --- a/src/ErrorReporting/V1beta1/resources/error_group_service_rest_client_config.php +++ b/src/ErrorReporting/V1beta1/resources/error_group_service_rest_client_config.php @@ -8,7 +8,7 @@ 'uri' => '/v1beta1/{group_name=projects/*/groups/*}', 'placeholders' => [ 'group_name' => [ - 'getGroup_name', + 'getGroupName', ], ], ], diff --git a/src/ErrorReporting/V1beta1/resources/error_stats_service_rest_client_config.php b/src/ErrorReporting/V1beta1/resources/error_stats_service_rest_client_config.php index 4d422839f6c9..ec136d0a6aac 100644 --- a/src/ErrorReporting/V1beta1/resources/error_stats_service_rest_client_config.php +++ b/src/ErrorReporting/V1beta1/resources/error_stats_service_rest_client_config.php @@ -8,7 +8,7 @@ 'uri' => '/v1beta1/{project_name=projects/*}/groupStats', 'placeholders' => [ 'project_name' => [ - 'getProject_name', + 'getProjectName', ], ], ], @@ -17,7 +17,7 @@ 'uri' => '/v1beta1/{project_name=projects/*}/events', 'placeholders' => [ 'project_name' => [ - 'getProject_name', + 'getProjectName', ], ], ], @@ -26,7 +26,7 @@ 'uri' => '/v1beta1/{project_name=projects/*}/events', 'placeholders' => [ 'project_name' => [ - 'getProject_name', + 'getProjectName', ], ], ], diff --git a/src/ErrorReporting/V1beta1/resources/report_errors_service_rest_client_config.php b/src/ErrorReporting/V1beta1/resources/report_errors_service_rest_client_config.php index 75b3cb2155bd..7513e50831c8 100644 --- a/src/ErrorReporting/V1beta1/resources/report_errors_service_rest_client_config.php +++ b/src/ErrorReporting/V1beta1/resources/report_errors_service_rest_client_config.php @@ -9,7 +9,7 @@ 'body' => 'event', 'placeholders' => [ 'project_name' => [ - 'getProject_name', + 'getProjectName', ], ], ], diff --git a/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php b/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php index 1e788500360a..6dbf8b3d607b 100644 --- a/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php +++ b/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php @@ -142,18 +142,22 @@ class FirestoreGapicClient private static $documentPathNameTemplate; private static $anyPathNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/datastore', - ], - 'clientConfigPath' => __DIR__.'/../resources/firestore_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/firestore_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/firestore_descriptor_config.php', - ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/datastore', + ], + 'clientConfigPath' => __DIR__.'/../resources/firestore_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/firestore_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/firestore_descriptor_config.php', + ]; + } private static function getDatabaseRootNameTemplate() { @@ -384,7 +388,7 @@ public static function parseName($formattedName, $template = null) */ public function __construct($options = []) { - $this->setClientOptions($options + self::$clientDefaults); + $this->setClientOptions($options + self::getClientDefaults()); } /** diff --git a/src/Firestore/V1beta1/resources/firestore_rest_client_config.php b/src/Firestore/V1beta1/resources/firestore_rest_client_config.php index 241a85d50916..f53187dad9f9 100644 --- a/src/Firestore/V1beta1/resources/firestore_rest_client_config.php +++ b/src/Firestore/V1beta1/resources/firestore_rest_client_config.php @@ -9,8 +9,8 @@ 'placeholders' => [ 'name' => [ 'getName', - ] - ] + ], + ], ], 'ListDocuments' => [ 'method' => 'get', @@ -18,11 +18,11 @@ 'placeholders' => [ 'parent' => [ 'getParent', - ] + ], 'collection_id' => [ - 'getCollection_id', - ] - ] + 'getCollectionId', + ], + ], ], 'CreateDocument' => [ 'method' => 'post', @@ -31,11 +31,11 @@ 'placeholders' => [ 'parent' => [ 'getParent', - ] + ], 'collection_id' => [ - 'getCollection_id', - ] - ] + 'getCollectionId', + ], + ], ], 'UpdateDocument' => [ 'method' => 'patch', @@ -45,8 +45,8 @@ 'document.name' => [ 'getDocument', 'getName', - ] - ] + ], + ], ], 'DeleteDocument' => [ 'method' => 'delete', @@ -54,8 +54,8 @@ 'placeholders' => [ 'name' => [ 'getName', - ] - ] + ], + ], ], 'BatchGetDocuments' => [ 'method' => 'post', @@ -64,8 +64,8 @@ 'placeholders' => [ 'database' => [ 'getDatabase', - ] - ] + ], + ], ], 'BeginTransaction' => [ 'method' => 'post', @@ -74,8 +74,8 @@ 'placeholders' => [ 'database' => [ 'getDatabase', - ] - ] + ], + ], ], 'Commit' => [ 'method' => 'post', @@ -84,8 +84,8 @@ 'placeholders' => [ 'database' => [ 'getDatabase', - ] - ] + ], + ], ], 'Rollback' => [ 'method' => 'post', @@ -94,8 +94,8 @@ 'placeholders' => [ 'database' => [ 'getDatabase', - ] - ] + ], + ], ], 'RunQuery' => [ 'method' => 'post', @@ -104,8 +104,8 @@ 'placeholders' => [ 'parent' => [ 'getParent', - ] - ] + ], + ], ], 'ListCollectionIds' => [ 'method' => 'post', @@ -114,9 +114,9 @@ 'placeholders' => [ 'parent' => [ 'getParent', - ] - ] + ], + ], ], - ] - ] + ], + ], ]; diff --git a/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php b/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php index dea725026916..a38ee95fc205 100644 --- a/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php +++ b/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php @@ -101,17 +101,20 @@ class LanguageServiceGapicClient */ const CODEGEN_VERSION = '0.0.5'; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'clientConfigPath' => __DIR__.'/../resources/language_service_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/language_service_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/language_service_descriptor_config.php', - ]; + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/language_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/language_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/language_service_descriptor_config.php', + ]; + } /** * Constructor. @@ -170,7 +173,7 @@ class LanguageServiceGapicClient */ public function __construct($options = []) { - $this->setClientOptions($options + self::$clientDefaults); + $this->setClientOptions($options + self::getClientDefaults()); } /** diff --git a/src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php b/src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php index e9ae29ff57c7..af55c645445d 100644 --- a/src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php +++ b/src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php @@ -125,21 +125,25 @@ class ConfigServiceV2GapicClient private static $sinkNameTemplate; private static $exclusionNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - 'https://www.googleapis.com/auth/logging.admin', - 'https://www.googleapis.com/auth/logging.read', - 'https://www.googleapis.com/auth/logging.write', - ], - 'clientConfigPath' => __DIR__.'/../resources/config_service_v2_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/config_service_v2_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/config_service_v2_descriptor_config.php', - ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/logging.admin', + 'https://www.googleapis.com/auth/logging.read', + 'https://www.googleapis.com/auth/logging.write', + ], + 'clientConfigPath' => __DIR__.'/../resources/config_service_v2_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/config_service_v2_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/config_service_v2_descriptor_config.php', + ]; + } private static function getProjectNameTemplate() { @@ -333,7 +337,7 @@ public static function parseName($formattedName, $template = null) */ public function __construct($options = []) { - $this->setClientOptions($options + self::$clientDefaults); + $this->setClientOptions($options + self::getClientDefaults()); } /** diff --git a/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php b/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php index 9bbd91edc112..56caad0761cf 100644 --- a/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php +++ b/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php @@ -107,21 +107,25 @@ class LoggingServiceV2GapicClient private static $projectNameTemplate; private static $logNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - 'https://www.googleapis.com/auth/logging.admin', - 'https://www.googleapis.com/auth/logging.read', - 'https://www.googleapis.com/auth/logging.write', - ], - 'clientConfigPath' => __DIR__.'/../resources/logging_service_v2_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/logging_service_v2_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/logging_service_v2_descriptor_config.php', - ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/logging.admin', + 'https://www.googleapis.com/auth/logging.read', + 'https://www.googleapis.com/auth/logging.write', + ], + 'clientConfigPath' => __DIR__.'/../resources/logging_service_v2_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/logging_service_v2_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/logging_service_v2_descriptor_config.php', + ]; + } private static function getProjectNameTemplate() { @@ -286,7 +290,7 @@ public static function parseName($formattedName, $template = null) */ public function __construct($options = []) { - $this->setClientOptions($options + self::$clientDefaults); + $this->setClientOptions($options + self::getClientDefaults()); } /** diff --git a/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php b/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php index 8f774f277030..648cf5d3596e 100644 --- a/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php +++ b/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php @@ -115,21 +115,25 @@ class MetricsServiceV2GapicClient private static $projectNameTemplate; private static $metricNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - 'https://www.googleapis.com/auth/logging.admin', - 'https://www.googleapis.com/auth/logging.read', - 'https://www.googleapis.com/auth/logging.write', - ], - 'clientConfigPath' => __DIR__.'/../resources/metrics_service_v2_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/metrics_service_v2_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/metrics_service_v2_descriptor_config.php', - ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/logging.admin', + 'https://www.googleapis.com/auth/logging.read', + 'https://www.googleapis.com/auth/logging.write', + ], + 'clientConfigPath' => __DIR__.'/../resources/metrics_service_v2_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/metrics_service_v2_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/metrics_service_v2_descriptor_config.php', + ]; + } private static function getProjectNameTemplate() { @@ -294,7 +298,7 @@ public static function parseName($formattedName, $template = null) */ public function __construct($options = []) { - $this->setClientOptions($options + self::$clientDefaults); + $this->setClientOptions($options + self::getClientDefaults()); } /** diff --git a/src/Logging/V2/resources/config_service_v2_rest_client_config.php b/src/Logging/V2/resources/config_service_v2_rest_client_config.php index 939fc6eb9239..063c59a6eee6 100644 --- a/src/Logging/V2/resources/config_service_v2_rest_client_config.php +++ b/src/Logging/V2/resources/config_service_v2_rest_client_config.php @@ -17,7 +17,7 @@ 'uri' => '/v2/{sink_name=*/*/sinks/*}', 'placeholders' => [ 'sink_name' => [ - 'getSink_name', + 'getSinkName', ], ], ], @@ -37,7 +37,7 @@ 'body' => 'sink', 'placeholders' => [ 'sink_name' => [ - 'getSink_name', + 'getSinkName', ], ], ], @@ -46,7 +46,7 @@ 'uri' => '/v2/{sink_name=*/*/sinks/*}', 'placeholders' => [ 'sink_name' => [ - 'getSink_name', + 'getSinkName', ], ], ], diff --git a/src/Logging/V2/resources/logging_service_v2_rest_client_config.php b/src/Logging/V2/resources/logging_service_v2_rest_client_config.php index 3ee5436b0276..1c8e9d7f064b 100644 --- a/src/Logging/V2/resources/logging_service_v2_rest_client_config.php +++ b/src/Logging/V2/resources/logging_service_v2_rest_client_config.php @@ -8,7 +8,7 @@ 'uri' => '/v2beta1/{log_name=projects/*/logs/*}', 'placeholders' => [ 'log_name' => [ - 'getLog_name', + 'getLogName', ], ], ], diff --git a/src/Logging/V2/resources/metrics_service_v2_rest_client_config.php b/src/Logging/V2/resources/metrics_service_v2_rest_client_config.php index 785e270847b2..51eab37a1400 100644 --- a/src/Logging/V2/resources/metrics_service_v2_rest_client_config.php +++ b/src/Logging/V2/resources/metrics_service_v2_rest_client_config.php @@ -17,7 +17,7 @@ 'uri' => '/v2/{metric_name=projects/*/metrics/*}', 'placeholders' => [ 'metric_name' => [ - 'getMetric_name', + 'getMetricName', ], ], ], @@ -37,7 +37,7 @@ 'body' => 'metric', 'placeholders' => [ 'metric_name' => [ - 'getMetric_name', + 'getMetricName', ], ], ], @@ -46,7 +46,7 @@ 'uri' => '/v2/{metric_name=projects/*/metrics/*}', 'placeholders' => [ 'metric_name' => [ - 'getMetric_name', + 'getMetricName', ], ], ], diff --git a/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php b/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php index 93d1197a18f8..c2f0bd7fb5c2 100644 --- a/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php +++ b/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php @@ -129,20 +129,24 @@ class GroupServiceGapicClient private static $projectNameTemplate; private static $groupNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/monitoring', - 'https://www.googleapis.com/auth/monitoring.read', - 'https://www.googleapis.com/auth/monitoring.write', - ], - 'clientConfigPath' => __DIR__.'/../resources/group_service_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/group_service_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/group_service_descriptor_config.php', - ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + 'https://www.googleapis.com/auth/monitoring.write', + ], + 'clientConfigPath' => __DIR__.'/../resources/group_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/group_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/group_service_descriptor_config.php', + ]; + } private static function getProjectNameTemplate() { @@ -307,7 +311,7 @@ public static function parseName($formattedName, $template = null) */ public function __construct($options = []) { - $this->setClientOptions($options + self::$clientDefaults); + $this->setClientOptions($options + self::getClientDefaults()); } /** diff --git a/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php b/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php index 71f32701a0b2..bb2828c92b81 100644 --- a/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php +++ b/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php @@ -127,20 +127,24 @@ class MetricServiceGapicClient private static $metricDescriptorNameTemplate; private static $monitoredResourceDescriptorNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/monitoring', - 'https://www.googleapis.com/auth/monitoring.read', - 'https://www.googleapis.com/auth/monitoring.write', - ], - 'clientConfigPath' => __DIR__.'/../resources/metric_service_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/metric_service_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/metric_service_descriptor_config.php', - ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + 'https://www.googleapis.com/auth/monitoring.write', + ], + 'clientConfigPath' => __DIR__.'/../resources/metric_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/metric_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/metric_service_descriptor_config.php', + ]; + } private static function getProjectNameTemplate() { @@ -334,7 +338,7 @@ public static function parseName($formattedName, $template = null) */ public function __construct($options = []) { - $this->setClientOptions($options + self::$clientDefaults); + $this->setClientOptions($options + self::getClientDefaults()); } /** diff --git a/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php b/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php index b51313d02866..0fa43def1c0b 100644 --- a/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php +++ b/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php @@ -125,20 +125,24 @@ class UptimeCheckServiceGapicClient private static $projectNameTemplate; private static $uptimeCheckConfigNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/monitoring', - 'https://www.googleapis.com/auth/monitoring.read', - 'https://www.googleapis.com/auth/monitoring.write', - ], - 'clientConfigPath' => __DIR__.'/../resources/uptime_check_service_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/uptime_check_service_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/uptime_check_service_descriptor_config.php', - ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + 'https://www.googleapis.com/auth/monitoring.write', + ], + 'clientConfigPath' => __DIR__.'/../resources/uptime_check_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/uptime_check_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/uptime_check_service_descriptor_config.php', + ]; + } private static function getProjectNameTemplate() { @@ -303,7 +307,7 @@ public static function parseName($formattedName, $template = null) */ public function __construct($options = []) { - $this->setClientOptions($options + self::$clientDefaults); + $this->setClientOptions($options + self::getClientDefaults()); } /** diff --git a/src/Monitoring/V3/resources/uptime_check_service_rest_client_config.php b/src/Monitoring/V3/resources/uptime_check_service_rest_client_config.php index da593359d43d..a3c94384128a 100644 --- a/src/Monitoring/V3/resources/uptime_check_service_rest_client_config.php +++ b/src/Monitoring/V3/resources/uptime_check_service_rest_client_config.php @@ -37,7 +37,7 @@ 'body' => 'uptime_check_config', 'placeholders' => [ 'uptime_check_config.name' => [ - 'getUptime_check_config', + 'getUptimeCheckConfig', 'getName', ], ], diff --git a/src/PubSub/V1/Gapic/PublisherGapicClient.php b/src/PubSub/V1/Gapic/PublisherGapicClient.php index 75e3be4db722..d0d4b6e63153 100644 --- a/src/PubSub/V1/Gapic/PublisherGapicClient.php +++ b/src/PubSub/V1/Gapic/PublisherGapicClient.php @@ -114,18 +114,22 @@ class PublisherGapicClient private static $projectNameTemplate; private static $topicNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/pubsub', - ], - 'clientConfigPath' => __DIR__.'/../resources/publisher_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/publisher_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/publisher_descriptor_config.php', - ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/pubsub', + ], + 'clientConfigPath' => __DIR__.'/../resources/publisher_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/publisher_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/publisher_descriptor_config.php', + ]; + } private static function getProjectNameTemplate() { @@ -290,7 +294,7 @@ public static function parseName($formattedName, $template = null) */ public function __construct($options = []) { - $this->setClientOptions($options + self::$clientDefaults); + $this->setClientOptions($options + self::getClientDefaults()); } /** diff --git a/src/PubSub/V1/Gapic/SubscriberGapicClient.php b/src/PubSub/V1/Gapic/SubscriberGapicClient.php index 2ddf3a8b04a1..eaf8a92f0e15 100644 --- a/src/PubSub/V1/Gapic/SubscriberGapicClient.php +++ b/src/PubSub/V1/Gapic/SubscriberGapicClient.php @@ -130,18 +130,22 @@ class SubscriberGapicClient private static $subscriptionNameTemplate; private static $topicNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/pubsub', - ], - 'clientConfigPath' => __DIR__.'/../resources/subscriber_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/subscriber_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/subscriber_descriptor_config.php', - ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/pubsub', + ], + 'clientConfigPath' => __DIR__.'/../resources/subscriber_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/subscriber_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/subscriber_descriptor_config.php', + ]; + } private static function getProjectNameTemplate() { @@ -364,7 +368,7 @@ public static function parseName($formattedName, $template = null) */ public function __construct($options = []) { - $this->setClientOptions($options + self::$clientDefaults); + $this->setClientOptions($options + self::getClientDefaults()); } /** diff --git a/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php b/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php index 8f46fa6ed30d..769a5e06c515 100644 --- a/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php +++ b/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php @@ -131,21 +131,25 @@ class DatabaseAdminGapicClient private static $instanceNameTemplate; private static $databaseNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/spanner.admin', - ], - 'clientConfigPath' => __DIR__.'/../resources/database_admin_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/database_admin_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/database_admin_descriptor_config.php', - ]; private $operationsClient; + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/spanner.admin', + ], + 'clientConfigPath' => __DIR__.'/../resources/database_admin_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/database_admin_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/database_admin_descriptor_config.php', + ]; + } + private static function getInstanceNameTemplate() { if (null == self::$instanceNameTemplate) { @@ -348,7 +352,7 @@ public function resumeOperation($operationName, $methodName = null) */ public function __construct($options = []) { - $options += self::$clientDefaults; + $options += self::getClientDefaults(); $this->setClientOptions($options); $this->pluckArray([ 'serviceName', diff --git a/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php b/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php index 16161490e183..2ac9eb88a619 100644 --- a/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php +++ b/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php @@ -151,21 +151,25 @@ class InstanceAdminGapicClient private static $instanceConfigNameTemplate; private static $instanceNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/spanner.admin', - ], - 'clientConfigPath' => __DIR__.'/../resources/instance_admin_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/instance_admin_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/instance_admin_descriptor_config.php', - ]; private $operationsClient; + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/spanner.admin', + ], + 'clientConfigPath' => __DIR__.'/../resources/instance_admin_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/instance_admin_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/instance_admin_descriptor_config.php', + ]; + } + private static function getProjectNameTemplate() { if (null == self::$projectNameTemplate) { @@ -393,7 +397,7 @@ public function resumeOperation($operationName, $methodName = null) */ public function __construct($options = []) { - $options += self::$clientDefaults; + $options += self::getClientDefaults(); $this->setClientOptions($options); $this->pluckArray([ 'serviceName', diff --git a/src/Spanner/V1/Gapic/SpannerGapicClient.php b/src/Spanner/V1/Gapic/SpannerGapicClient.php index cc7a2b377f5d..356cd015168b 100644 --- a/src/Spanner/V1/Gapic/SpannerGapicClient.php +++ b/src/Spanner/V1/Gapic/SpannerGapicClient.php @@ -120,18 +120,22 @@ class SpannerGapicClient private static $databaseNameTemplate; private static $sessionNameTemplate; private static $pathTemplateMap; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/spanner.data', - ], - 'clientConfigPath' => __DIR__.'/../resources/spanner_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/spanner_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/spanner_descriptor_config.php', - ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/spanner.data', + ], + 'clientConfigPath' => __DIR__.'/../resources/spanner_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/spanner_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/spanner_descriptor_config.php', + ]; + } private static function getDatabaseNameTemplate() { @@ -304,7 +308,7 @@ public static function parseName($formattedName, $template = null) */ public function __construct($options = []) { - $this->setClientOptions($options + self::$clientDefaults); + $this->setClientOptions($options + self::getClientDefaults()); } /** diff --git a/src/Speech/V1/Gapic/SpeechGapicClient.php b/src/Speech/V1/Gapic/SpeechGapicClient.php index a11d0063e7af..51211136faa4 100644 --- a/src/Speech/V1/Gapic/SpeechGapicClient.php +++ b/src/Speech/V1/Gapic/SpeechGapicClient.php @@ -105,20 +105,23 @@ class SpeechGapicClient */ const CODEGEN_VERSION = '0.0.5'; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'clientConfigPath' => __DIR__.'/../resources/speech_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/speech_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/speech_descriptor_config.php', - ]; - private $operationsClient; + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/speech_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/speech_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/speech_descriptor_config.php', + ]; + } + /** * Return an OperationsClient object with the same endpoint as $this. * @@ -211,7 +214,7 @@ public function resumeOperation($operationName, $methodName = null) */ public function __construct($options = []) { - $options += self::$clientDefaults; + $options += self::getClientDefaults(); $this->setClientOptions($options); $this->pluckArray([ 'serviceName', diff --git a/src/Speech/V1beta1/Gapic/SpeechGapicClient.php b/src/Speech/V1beta1/Gapic/SpeechGapicClient.php index 0645a672e0a7..e98f5de4e424 100644 --- a/src/Speech/V1beta1/Gapic/SpeechGapicClient.php +++ b/src/Speech/V1beta1/Gapic/SpeechGapicClient.php @@ -103,20 +103,23 @@ class SpeechGapicClient */ const CODEGEN_VERSION = '0.0.5'; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'clientConfigPath' => __DIR__.'/../resources/speech_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/speech_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/speech_descriptor_config.php', - ]; - private $operationsClient; + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/speech_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/speech_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/speech_descriptor_config.php', + ]; + } + /** * Return an OperationsClient object with the same endpoint as $this. * @@ -209,7 +212,7 @@ public function resumeOperation($operationName, $methodName = null) */ public function __construct($options = []) { - $options += self::$clientDefaults; + $options += self::getClientDefaults(); $this->setClientOptions($options); $this->pluckArray([ 'serviceName', diff --git a/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php index 48a6616ed5c8..24e1f5948b66 100644 --- a/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php @@ -118,20 +118,23 @@ class VideoIntelligenceServiceGapicClient */ const CODEGEN_VERSION = '0.0.5'; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'clientConfigPath' => __DIR__.'/../resources/video_intelligence_service_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/video_intelligence_service_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/video_intelligence_service_descriptor_config.php', - ]; - private $operationsClient; + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/video_intelligence_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/video_intelligence_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/video_intelligence_service_descriptor_config.php', + ]; + } + /** * Return an OperationsClient object with the same endpoint as $this. * @@ -224,7 +227,7 @@ public function resumeOperation($operationName, $methodName = null) */ public function __construct($options = []) { - $options += self::$clientDefaults; + $options += self::getClientDefaults(); $this->setClientOptions($options); $this->pluckArray([ 'serviceName', diff --git a/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php index 265d53e5450a..824592a7531e 100644 --- a/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php @@ -120,20 +120,23 @@ class VideoIntelligenceServiceGapicClient */ const CODEGEN_VERSION = '0.0.5'; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'clientConfigPath' => __DIR__.'/../resources/video_intelligence_service_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/video_intelligence_service_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/video_intelligence_service_descriptor_config.php', - ]; - private $operationsClient; + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/video_intelligence_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/video_intelligence_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/video_intelligence_service_descriptor_config.php', + ]; + } + /** * Return an OperationsClient object with the same endpoint as $this. * @@ -226,7 +229,7 @@ public function resumeOperation($operationName, $methodName = null) */ public function __construct($options = []) { - $options += self::$clientDefaults; + $options += self::getClientDefaults(); $this->setClientOptions($options); $this->pluckArray([ 'serviceName', diff --git a/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php index e7ffa8214f86..c8db5ef10807 100644 --- a/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php @@ -118,20 +118,23 @@ class VideoIntelligenceServiceGapicClient */ const CODEGEN_VERSION = '0.0.5'; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'clientConfigPath' => __DIR__.'/../resources/video_intelligence_service_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/video_intelligence_service_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/video_intelligence_service_descriptor_config.php', - ]; - private $operationsClient; + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/video_intelligence_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/video_intelligence_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/video_intelligence_service_descriptor_config.php', + ]; + } + /** * Return an OperationsClient object with the same endpoint as $this. * @@ -224,7 +227,7 @@ public function resumeOperation($operationName, $methodName = null) */ public function __construct($options = []) { - $options += self::$clientDefaults; + $options += self::getClientDefaults(); $this->setClientOptions($options); $this->pluckArray([ 'serviceName', diff --git a/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php b/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php index 6481291d8e15..ee89d6c83a05 100644 --- a/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php +++ b/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php @@ -90,18 +90,21 @@ class ImageAnnotatorGapicClient */ const CODEGEN_VERSION = '0.0.5'; - private static $clientDefaults = [ - 'serviceName' => self::SERVICE_NAME, - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-vision', - ], - 'clientConfigPath' => __DIR__.'/../resources/image_annotator_client_config.json', - 'restClientConfigPath' => __DIR__.'/../resources/image_annotator_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__.'/../resources/image_annotator_descriptor_config.php', - ]; + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-vision', + ], + 'clientConfigPath' => __DIR__.'/../resources/image_annotator_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/image_annotator_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/image_annotator_descriptor_config.php', + ]; + } /** * Constructor. @@ -160,7 +163,7 @@ class ImageAnnotatorGapicClient */ public function __construct($options = []) { - $this->setClientOptions($options + self::$clientDefaults); + $this->setClientOptions($options + self::getClientDefaults()); } /** From bb14a5f292d6470cb4959e78c8dce7c53beab562 Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Fri, 15 Dec 2017 16:03:35 -0500 Subject: [PATCH 06/21] refresh gapics --- .../V2/Gapic/BigtableInstanceAdminGapicClient.php | 15 ++++++--------- .../V2/Gapic/BigtableTableAdminGapicClient.php | 5 ++--- src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php | 10 ++++------ .../V1/Gapic/DatabaseAdminGapicClient.php | 10 ++++------ .../V1/Gapic/InstanceAdminGapicClient.php | 10 ++++------ src/Speech/V1/Gapic/SpeechGapicClient.php | 5 ++--- src/Speech/V1beta1/Gapic/SpeechGapicClient.php | 5 ++--- .../Gapic/VideoIntelligenceServiceGapicClient.php | 5 ++--- .../Gapic/VideoIntelligenceServiceGapicClient.php | 5 ++--- .../Gapic/VideoIntelligenceServiceGapicClient.php | 5 ++--- 10 files changed, 30 insertions(+), 45 deletions(-) diff --git a/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php b/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php index 4425fda287c9..1f592cba0565 100644 --- a/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php +++ b/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php @@ -570,9 +570,8 @@ public function createInstance($parent, $instanceId, $instance, $clusters, $opti $request ), $this->configureCallSettings('createInstance', $optionalArgs), - $this->descriptors['createInstance']['longRunning'] + [ - 'operationsClient' => $this->getOperationsClient(), - ] + $this->getOperationsClient(), + $this->descriptors['createInstance']['longRunning'] )->wait(); } @@ -920,9 +919,8 @@ public function createCluster($parent, $clusterId, $cluster, $optionalArgs = []) $request ), $this->configureCallSettings('createCluster', $optionalArgs), - $this->descriptors['createCluster']['longRunning'] + [ - 'operationsClient' => $this->getOperationsClient(), - ] + $this->getOperationsClient(), + $this->descriptors['createCluster']['longRunning'] )->wait(); } @@ -1120,9 +1118,8 @@ public function updateCluster($name, $location, $serveNodes, $optionalArgs = []) $request ), $this->configureCallSettings('updateCluster', $optionalArgs), - $this->descriptors['updateCluster']['longRunning'] + [ - 'operationsClient' => $this->getOperationsClient(), - ] + $this->getOperationsClient(), + $this->descriptors['updateCluster']['longRunning'] )->wait(); } diff --git a/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php b/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php index 9ded78b8b42d..6fa1e73dceee 100644 --- a/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php +++ b/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php @@ -592,9 +592,8 @@ public function createTableFromSnapshot($parent, $tableId, $sourceSnapshot, $opt $request ), $this->configureCallSettings('createTableFromSnapshot', $optionalArgs), - $this->descriptors['createTableFromSnapshot']['longRunning'] + [ - 'operationsClient' => $this->getOperationsClient(), - ] + $this->getOperationsClient(), + $this->descriptors['createTableFromSnapshot']['longRunning'] )->wait(); } diff --git a/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php b/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php index a1f1be7446e8..b40fb34d9659 100644 --- a/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php +++ b/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php @@ -590,9 +590,8 @@ public function analyzeDataSourceRisk($privacyMetric, $sourceTable, $optionalArg $request ), $this->configureCallSettings('analyzeDataSourceRisk', $optionalArgs), - $this->descriptors['analyzeDataSourceRisk']['longRunning'] + [ - 'operationsClient' => $this->getOperationsClient(), - ] + $this->getOperationsClient(), + $this->descriptors['analyzeDataSourceRisk']['longRunning'] )->wait(); } @@ -686,9 +685,8 @@ public function createInspectOperation($inspectConfig, $storageConfig, $outputCo $request ), $this->configureCallSettings('createInspectOperation', $optionalArgs), - $this->descriptors['createInspectOperation']['longRunning'] + [ - 'operationsClient' => $this->getOperationsClient(), - ] + $this->getOperationsClient(), + $this->descriptors['createInspectOperation']['longRunning'] )->wait(); } diff --git a/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php b/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php index 769a5e06c515..8d0166dc20c4 100644 --- a/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php +++ b/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php @@ -527,9 +527,8 @@ public function createDatabase($parent, $createStatement, $optionalArgs = []) $request ), $this->configureCallSettings('createDatabase', $optionalArgs), - $this->descriptors['createDatabase']['longRunning'] + [ - 'operationsClient' => $this->getOperationsClient(), - ] + $this->getOperationsClient(), + $this->descriptors['createDatabase']['longRunning'] )->wait(); } @@ -676,9 +675,8 @@ public function updateDatabaseDdl($database, $statements, $optionalArgs = []) $request ), $this->configureCallSettings('updateDatabaseDdl', $optionalArgs), - $this->descriptors['updateDatabaseDdl']['longRunning'] + [ - 'operationsClient' => $this->getOperationsClient(), - ] + $this->getOperationsClient(), + $this->descriptors['updateDatabaseDdl']['longRunning'] )->wait(); } diff --git a/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php b/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php index 2ac9eb88a619..af653b4620de 100644 --- a/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php +++ b/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php @@ -782,9 +782,8 @@ public function createInstance($parent, $instanceId, $instance, $optionalArgs = $request ), $this->configureCallSettings('createInstance', $optionalArgs), - $this->descriptors['createInstance']['longRunning'] + [ - 'operationsClient' => $this->getOperationsClient(), - ] + $this->getOperationsClient(), + $this->descriptors['createInstance']['longRunning'] )->wait(); } @@ -901,9 +900,8 @@ public function updateInstance($instance, $fieldMask, $optionalArgs = []) $request ), $this->configureCallSettings('updateInstance', $optionalArgs), - $this->descriptors['updateInstance']['longRunning'] + [ - 'operationsClient' => $this->getOperationsClient(), - ] + $this->getOperationsClient(), + $this->descriptors['updateInstance']['longRunning'] )->wait(); } diff --git a/src/Speech/V1/Gapic/SpeechGapicClient.php b/src/Speech/V1/Gapic/SpeechGapicClient.php index 51211136faa4..642b1783863f 100644 --- a/src/Speech/V1/Gapic/SpeechGapicClient.php +++ b/src/Speech/V1/Gapic/SpeechGapicClient.php @@ -365,9 +365,8 @@ public function longRunningRecognize($config, $audio, $optionalArgs = []) $request ), $this->configureCallSettings('longRunningRecognize', $optionalArgs), - $this->descriptors['longRunningRecognize']['longRunning'] + [ - 'operationsClient' => $this->getOperationsClient(), - ] + $this->getOperationsClient(), + $this->descriptors['longRunningRecognize']['longRunning'] )->wait(); } diff --git a/src/Speech/V1beta1/Gapic/SpeechGapicClient.php b/src/Speech/V1beta1/Gapic/SpeechGapicClient.php index e98f5de4e424..e51f64e44c64 100644 --- a/src/Speech/V1beta1/Gapic/SpeechGapicClient.php +++ b/src/Speech/V1beta1/Gapic/SpeechGapicClient.php @@ -361,9 +361,8 @@ public function asyncRecognize($config, $audio, $optionalArgs = []) $request ), $this->configureCallSettings('asyncRecognize', $optionalArgs), - $this->descriptors['asyncRecognize']['longRunning'] + [ - 'operationsClient' => $this->getOperationsClient(), - ] + $this->getOperationsClient(), + $this->descriptors['asyncRecognize']['longRunning'] )->wait(); } diff --git a/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php index 24e1f5948b66..d1c0e09d3364 100644 --- a/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php @@ -355,9 +355,8 @@ public function annotateVideo($optionalArgs = []) $request ), $this->configureCallSettings('annotateVideo', $optionalArgs), - $this->descriptors['annotateVideo']['longRunning'] + [ - 'operationsClient' => $this->getOperationsClient(), - ] + $this->getOperationsClient(), + $this->descriptors['annotateVideo']['longRunning'] )->wait(); } diff --git a/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php index 824592a7531e..f845b7e1b71c 100644 --- a/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php @@ -352,9 +352,8 @@ public function annotateVideo($inputUri, $features, $optionalArgs = []) $request ), $this->configureCallSettings('annotateVideo', $optionalArgs), - $this->descriptors['annotateVideo']['longRunning'] + [ - 'operationsClient' => $this->getOperationsClient(), - ] + $this->getOperationsClient(), + $this->descriptors['annotateVideo']['longRunning'] )->wait(); } diff --git a/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php index c8db5ef10807..6af3dd7f06be 100644 --- a/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php @@ -355,9 +355,8 @@ public function annotateVideo($optionalArgs = []) $request ), $this->configureCallSettings('annotateVideo', $optionalArgs), - $this->descriptors['annotateVideo']['longRunning'] + [ - 'operationsClient' => $this->getOperationsClient(), - ] + $this->getOperationsClient(), + $this->descriptors['annotateVideo']['longRunning'] )->wait(); } From 8d4623c401a44df516580f9cb80fc8c6d8f36212 Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Mon, 8 Jan 2018 13:50:24 -0500 Subject: [PATCH 07/21] refresh gapics --- .../Admin/V2/BigtableInstanceAdminClient.php | 4 +- .../Admin/V2/BigtableTableAdminClient.php | 4 +- .../BigtableInstanceAdminGapicClient.php | 356 ++++++++---------- .../Gapic/BigtableTableAdminGapicClient.php | 257 ++++++------- ...table_instance_admin_descriptor_config.php | 8 +- ...able_instance_admin_rest_client_config.php | 118 ++++-- ...bigtable_table_admin_descriptor_config.php | 6 +- ...igtable_table_admin_rest_client_config.php | 78 ++-- src/Bigtable/V2/BigtableClient.php | 4 +- src/Bigtable/V2/Gapic/BigtableGapicClient.php | 142 +++---- .../resources/bigtable_descriptor_config.php | 6 +- .../resources/bigtable_rest_client_config.php | 47 +-- src/Core/GrpcTrait.php | 3 +- src/Dlp/V2beta1/DlpServiceClient.php | 4 +- .../V2beta1/Gapic/DlpServiceGapicClient.php | 187 +++++---- .../dlp_service_descriptor_config.php | 4 +- .../dlp_service_rest_client_config.php | 24 +- .../V1beta1/ErrorGroupServiceClient.php | 4 +- .../V1beta1/ErrorStatsServiceClient.php | 4 +- .../Gapic/ErrorGroupServiceGapicClient.php | 73 ++-- .../Gapic/ErrorStatsServiceGapicClient.php | 91 ++--- .../Gapic/ReportErrorsServiceGapicClient.php | 57 ++- .../V1beta1/ReportErrorsServiceClient.php | 4 +- ...error_group_service_rest_client_config.php | 14 +- .../error_stats_service_descriptor_config.php | 4 +- ...error_stats_service_rest_client_config.php | 18 +- ...port_errors_service_rest_client_config.php | 6 +- src/Firestore/V1beta1/FirestoreClient.php | 4 +- .../V1beta1/Gapic/FirestoreGapicClient.php | 256 ++++++------- .../resources/firestore_descriptor_config.php | 12 +- .../firestore_rest_client_config.php | 84 +++-- .../Gapic/LanguageServiceGapicClient.php | 137 +++---- .../V1beta2/LanguageServiceClient.php | 4 +- .../language_service_rest_client_config.php | 12 +- src/Logging/V2/ConfigServiceV2Client.php | 4 +- .../V2/Gapic/ConfigServiceV2GapicClient.php | 203 +++++----- .../V2/Gapic/LoggingServiceV2GapicClient.php | 124 +++--- .../V2/Gapic/MetricsServiceV2GapicClient.php | 122 +++--- src/Logging/V2/LoggingServiceV2Client.php | 4 +- src/Logging/V2/MetricsServiceV2Client.php | 4 +- .../config_service_v2_descriptor_config.php | 4 +- .../config_service_v2_rest_client_config.php | 60 ++- .../logging_service_v2_descriptor_config.php | 6 +- .../logging_service_v2_rest_client_config.php | 18 +- .../metrics_service_v2_descriptor_config.php | 2 +- .../metrics_service_v2_rest_client_config.php | 30 +- .../V3/Gapic/GroupServiceGapicClient.php | 139 +++---- .../V3/Gapic/MetricServiceGapicClient.php | 172 ++++----- .../Gapic/UptimeCheckServiceGapicClient.php | 139 +++---- src/Monitoring/V3/GroupServiceClient.php | 4 +- src/Monitoring/V3/MetricServiceClient.php | 4 +- .../V3/UptimeCheckServiceClient.php | 4 +- .../group_service_descriptor_config.php | 4 +- .../group_service_rest_client_config.php | 38 +- .../metric_service_descriptor_config.php | 6 +- .../metric_service_rest_client_config.php | 48 ++- ...uptime_check_service_descriptor_config.php | 4 +- ...ptime_check_service_rest_client_config.php | 34 +- src/PubSub/V1/Gapic/PublisherGapicClient.php | 203 +++++----- src/PubSub/V1/Gapic/SubscriberGapicClient.php | 331 +++++++--------- src/PubSub/V1/PublisherClient.php | 4 +- src/PubSub/V1/SubscriberClient.php | 4 +- .../resources/publisher_descriptor_config.php | 4 +- .../publisher_rest_client_config.php | 62 +-- .../subscriber_descriptor_config.php | 6 +- .../subscriber_rest_client_config.php | 106 ++++-- .../Admin/Database/V1/DatabaseAdminClient.php | 4 +- .../V1/Gapic/DatabaseAdminGapicClient.php | 194 ++++------ .../database_admin_descriptor_config.php | 6 +- .../database_admin_rest_client_config.php | 54 ++- .../V1/Gapic/InstanceAdminGapicClient.php | 211 +++++------ .../Admin/Instance/V1/InstanceAdminClient.php | 4 +- .../instance_admin_descriptor_config.php | 8 +- .../instance_admin_rest_client_config.php | 62 +-- src/Spanner/V1/Gapic/SpannerGapicClient.php | 221 +++++------ src/Spanner/V1/SpannerClient.php | 9 +- .../resources/spanner_descriptor_config.php | 6 +- .../resources/spanner_rest_client_config.php | 74 ++-- src/Speech/V1/Gapic/SpeechGapicClient.php | 95 ++--- src/Speech/V1/SpeechClient.php | 4 +- .../V1/resources/speech_descriptor_config.php | 4 +- .../resources/speech_rest_client_config.php | 4 +- .../V1beta1/Gapic/SpeechGapicClient.php | 95 ++--- src/Speech/V1beta1/SpeechClient.php | 4 +- .../resources/speech_descriptor_config.php | 4 +- .../resources/speech_rest_client_config.php | 4 +- .../VideoIntelligenceServiceGapicClient.php | 79 ++-- .../V1/VideoIntelligenceServiceClient.php | 4 +- ...intelligence_service_descriptor_config.php | 2 +- ...ntelligence_service_rest_client_config.php | 2 +- .../VideoIntelligenceServiceGapicClient.php | 63 ++-- .../VideoIntelligenceServiceClient.php | 4 +- ...intelligence_service_descriptor_config.php | 2 +- ...ntelligence_service_rest_client_config.php | 2 +- .../VideoIntelligenceServiceGapicClient.php | 79 ++-- .../VideoIntelligenceServiceClient.php | 4 +- ...intelligence_service_descriptor_config.php | 2 +- ...ntelligence_service_rest_client_config.php | 2 +- .../V1/Gapic/ImageAnnotatorGapicClient.php | 57 ++- src/Vision/V1/ImageAnnotatorClient.php | 4 +- .../image_annotator_rest_client_config.php | 2 +- 101 files changed, 2479 insertions(+), 2829 deletions(-) diff --git a/src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php b/src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php index ca5dcbf7c65b..a2275c345903 100644 --- a/src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php +++ b/src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php @@ -1,12 +1,12 @@ projectName('[PROJECT]'); * $instanceId = ''; * $instance = new Instance(); @@ -183,6 +187,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/bigtable_instance_admin_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/bigtable_instance_admin_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/bigtable_instance_admin_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -386,7 +391,7 @@ public static function parseName($formattedName, $template = null) /** * Return an OperationsClient object with the same endpoint as $this. * - * @return \Google\ApiCore\LongRunning\OperationsClient + * @return OperationsClient * @experimental */ public function getOperationsClient() @@ -404,7 +409,7 @@ public function getOperationsClient() * @param string $operationName The name of the long running operation * @param string $methodName The name of the method used to start the operation * - * @return \Google\ApiCore\OperationResponse + * @return OperationResponse * @experimental */ public function resumeOperation($operationName, $methodName = null) @@ -427,10 +432,10 @@ public function resumeOperation($operationName, $methodName = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'bigtableadmin.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -441,9 +446,9 @@ public function resumeOperation($operationName, $methodName = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Cloud Bigtable Admin API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -461,12 +466,11 @@ public function resumeOperation($operationName, $methodName = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -491,8 +495,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedParent = $bigtableInstanceAdminClient->projectName('[PROJECT]'); * $instanceId = ''; * $instance = new Instance(); @@ -543,7 +547,7 @@ public function __construct($options = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -552,7 +556,7 @@ public function __construct($options = []) * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createInstance($parent, $instanceId, $instance, $clusters, $optionalArgs = []) @@ -564,14 +568,10 @@ public function createInstance($parent, $instanceId, $instance, $clusters, $opti $request->setClusters($clusters); return $this->startOperationsCall( - new Call( - self::SERVICE_NAME.'/CreateInstance', - Operation::class, - $request - ), - $this->configureCallSettings('createInstance', $optionalArgs), - $this->getOperationsClient(), - $this->descriptors['createInstance']['longRunning'] + 'CreateInstance', + $optionalArgs, + $request, + $this->getOperationsClient() )->wait(); } @@ -580,8 +580,8 @@ public function createInstance($parent, $instanceId, $instance, $clusters, $opti * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedName = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $response = $bigtableInstanceAdminClient->getInstance($formattedName); * } finally { @@ -594,7 +594,7 @@ public function createInstance($parent, $instanceId, $instance, $clusters, $opti * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -603,7 +603,7 @@ public function createInstance($parent, $instanceId, $instance, $clusters, $opti * * @return \Google\Cloud\Bigtable\Admin\V2\Instance * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getInstance($name, $optionalArgs = []) @@ -612,12 +612,10 @@ public function getInstance($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetInstance', - Instance::class, - $request - ), - $this->configureCallSettings('getInstance', $optionalArgs) + 'GetInstance', + Instance::class, + $optionalArgs, + $request )->wait(); } @@ -626,8 +624,8 @@ public function getInstance($name, $optionalArgs = []) * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedParent = $bigtableInstanceAdminClient->projectName('[PROJECT]'); * $response = $bigtableInstanceAdminClient->listInstances($formattedParent); * } finally { @@ -642,7 +640,7 @@ public function getInstance($name, $optionalArgs = []) * * @type string $pageToken * The value of `next_page_token` returned by a previous call. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -651,7 +649,7 @@ public function getInstance($name, $optionalArgs = []) * * @return \Google\Cloud\Bigtable\Admin\V2\ListInstancesResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listInstances($parent, $optionalArgs = []) @@ -663,12 +661,10 @@ public function listInstances($parent, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/ListInstances', - ListInstancesResponse::class, - $request - ), - $this->configureCallSettings('listInstances', $optionalArgs) + 'ListInstances', + ListInstancesResponse::class, + $optionalArgs, + $request )->wait(); } @@ -677,8 +673,8 @@ public function listInstances($parent, $optionalArgs = []) * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedName = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $displayName = ''; * $type = Type::TYPE_UNSPECIFIED; @@ -715,7 +711,7 @@ public function listInstances($parent, $optionalArgs = []) * (`OutputOnly`) * The current state of the instance. * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\Instance_State} - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -724,7 +720,7 @@ public function listInstances($parent, $optionalArgs = []) * * @return \Google\Cloud\Bigtable\Admin\V2\Instance * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateInstance($name, $displayName, $type, $labels, $optionalArgs = []) @@ -739,12 +735,10 @@ public function updateInstance($name, $displayName, $type, $labels, $optionalArg } return $this->startCall( - new Call( - self::SERVICE_NAME.'/UpdateInstance', - Instance::class, - $request - ), - $this->configureCallSettings('updateInstance', $optionalArgs) + 'UpdateInstance', + Instance::class, + $optionalArgs, + $request )->wait(); } @@ -753,8 +747,8 @@ public function updateInstance($name, $displayName, $type, $labels, $optionalArg * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $instance = new Instance(); * $updateMask = new FieldMask(); * $response = $bigtableInstanceAdminClient->partialUpdateInstance($instance, $updateMask); @@ -769,7 +763,7 @@ public function updateInstance($name, $displayName, $type, $labels, $optionalArg * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -778,7 +772,7 @@ public function updateInstance($name, $displayName, $type, $labels, $optionalArg * * @return \Google\LongRunning\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function partialUpdateInstance($instance, $updateMask, $optionalArgs = []) @@ -788,12 +782,10 @@ public function partialUpdateInstance($instance, $updateMask, $optionalArgs = [] $request->setUpdateMask($updateMask); return $this->startCall( - new Call( - self::SERVICE_NAME.'/PartialUpdateInstance', - Operation::class, - $request - ), - $this->configureCallSettings('partialUpdateInstance', $optionalArgs) + 'PartialUpdateInstance', + Operation::class, + $optionalArgs, + $request )->wait(); } @@ -802,8 +794,8 @@ public function partialUpdateInstance($instance, $updateMask, $optionalArgs = [] * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedName = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $bigtableInstanceAdminClient->deleteInstance($formattedName); * } finally { @@ -816,14 +808,14 @@ public function partialUpdateInstance($instance, $updateMask, $optionalArgs = [] * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteInstance($name, $optionalArgs = []) @@ -832,12 +824,10 @@ public function deleteInstance($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteInstance', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteInstance', $optionalArgs) + 'DeleteInstance', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -846,8 +836,8 @@ public function deleteInstance($name, $optionalArgs = []) * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedParent = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $clusterId = ''; * $cluster = new Cluster(); @@ -893,7 +883,7 @@ public function deleteInstance($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -902,7 +892,7 @@ public function deleteInstance($name, $optionalArgs = []) * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createCluster($parent, $clusterId, $cluster, $optionalArgs = []) @@ -913,14 +903,10 @@ public function createCluster($parent, $clusterId, $cluster, $optionalArgs = []) $request->setCluster($cluster); return $this->startOperationsCall( - new Call( - self::SERVICE_NAME.'/CreateCluster', - Operation::class, - $request - ), - $this->configureCallSettings('createCluster', $optionalArgs), - $this->getOperationsClient(), - $this->descriptors['createCluster']['longRunning'] + 'CreateCluster', + $optionalArgs, + $request, + $this->getOperationsClient() )->wait(); } @@ -929,8 +915,8 @@ public function createCluster($parent, $clusterId, $cluster, $optionalArgs = []) * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedName = $bigtableInstanceAdminClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); * $response = $bigtableInstanceAdminClient->getCluster($formattedName); * } finally { @@ -943,7 +929,7 @@ public function createCluster($parent, $clusterId, $cluster, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -952,7 +938,7 @@ public function createCluster($parent, $clusterId, $cluster, $optionalArgs = []) * * @return \Google\Cloud\Bigtable\Admin\V2\Cluster * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getCluster($name, $optionalArgs = []) @@ -961,12 +947,10 @@ public function getCluster($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetCluster', - Cluster::class, - $request - ), - $this->configureCallSettings('getCluster', $optionalArgs) + 'GetCluster', + Cluster::class, + $optionalArgs, + $request )->wait(); } @@ -975,8 +959,8 @@ public function getCluster($name, $optionalArgs = []) * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedParent = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $response = $bigtableInstanceAdminClient->listClusters($formattedParent); * } finally { @@ -993,7 +977,7 @@ public function getCluster($name, $optionalArgs = []) * * @type string $pageToken * The value of `next_page_token` returned by a previous call. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1002,7 +986,7 @@ public function getCluster($name, $optionalArgs = []) * * @return \Google\Cloud\Bigtable\Admin\V2\ListClustersResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listClusters($parent, $optionalArgs = []) @@ -1014,12 +998,10 @@ public function listClusters($parent, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/ListClusters', - ListClustersResponse::class, - $request - ), - $this->configureCallSettings('listClusters', $optionalArgs) + 'ListClusters', + ListClustersResponse::class, + $optionalArgs, + $request )->wait(); } @@ -1028,8 +1010,8 @@ public function listClusters($parent, $optionalArgs = []) * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedName = $bigtableInstanceAdminClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); * $location = ''; * $serveNodes = 0; @@ -1086,7 +1068,7 @@ public function listClusters($parent, $optionalArgs = []) * The type of storage used by this cluster to serve its * parent instance's tables, unless explicitly overridden. * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\StorageType} - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1095,7 +1077,7 @@ public function listClusters($parent, $optionalArgs = []) * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateCluster($name, $location, $serveNodes, $optionalArgs = []) @@ -1112,14 +1094,10 @@ public function updateCluster($name, $location, $serveNodes, $optionalArgs = []) } return $this->startOperationsCall( - new Call( - self::SERVICE_NAME.'/UpdateCluster', - Operation::class, - $request - ), - $this->configureCallSettings('updateCluster', $optionalArgs), - $this->getOperationsClient(), - $this->descriptors['updateCluster']['longRunning'] + 'UpdateCluster', + $optionalArgs, + $request, + $this->getOperationsClient() )->wait(); } @@ -1128,8 +1106,8 @@ public function updateCluster($name, $location, $serveNodes, $optionalArgs = []) * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedName = $bigtableInstanceAdminClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); * $bigtableInstanceAdminClient->deleteCluster($formattedName); * } finally { @@ -1142,14 +1120,14 @@ public function updateCluster($name, $location, $serveNodes, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteCluster($name, $optionalArgs = []) @@ -1158,12 +1136,10 @@ public function deleteCluster($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteCluster', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteCluster', $optionalArgs) + 'DeleteCluster', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -1177,8 +1153,8 @@ public function deleteCluster($name, $optionalArgs = []) * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedParent = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $appProfileId = ''; * $appProfile = new AppProfile(); @@ -1201,7 +1177,7 @@ public function deleteCluster($name, $optionalArgs = []) * * @type bool $ignoreWarnings * If true, ignore safety checks when creating the app profile. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1210,7 +1186,7 @@ public function deleteCluster($name, $optionalArgs = []) * * @return \Google\Cloud\Bigtable\Admin\V2\AppProfile * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createAppProfile($parent, $appProfileId, $appProfile, $optionalArgs = []) @@ -1224,12 +1200,10 @@ public function createAppProfile($parent, $appProfileId, $appProfile, $optionalA } return $this->startCall( - new Call( - self::SERVICE_NAME.'/CreateAppProfile', - AppProfile::class, - $request - ), - $this->configureCallSettings('createAppProfile', $optionalArgs) + 'CreateAppProfile', + AppProfile::class, + $optionalArgs, + $request )->wait(); } @@ -1243,8 +1217,8 @@ public function createAppProfile($parent, $appProfileId, $appProfile, $optionalA * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedName = $bigtableInstanceAdminClient->appProfileName('[PROJECT]', '[INSTANCE]', '[APP_PROFILE]'); * $response = $bigtableInstanceAdminClient->getAppProfile($formattedName); * } finally { @@ -1257,7 +1231,7 @@ public function createAppProfile($parent, $appProfileId, $appProfile, $optionalA * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1266,7 +1240,7 @@ public function createAppProfile($parent, $appProfileId, $appProfile, $optionalA * * @return \Google\Cloud\Bigtable\Admin\V2\AppProfile * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getAppProfile($name, $optionalArgs = []) @@ -1275,12 +1249,10 @@ public function getAppProfile($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetAppProfile', - AppProfile::class, - $request - ), - $this->configureCallSettings('getAppProfile', $optionalArgs) + 'GetAppProfile', + AppProfile::class, + $optionalArgs, + $request )->wait(); } @@ -1294,8 +1266,8 @@ public function getAppProfile($name, $optionalArgs = []) * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedParent = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * // Iterate through all elements * $pagedResponse = $bigtableInstanceAdminClient->listAppProfiles($formattedParent); @@ -1326,7 +1298,7 @@ public function getAppProfile($name, $optionalArgs = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1335,7 +1307,7 @@ public function getAppProfile($name, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listAppProfiles($parent, $optionalArgs = []) @@ -1347,13 +1319,10 @@ public function listAppProfiles($parent, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListAppProfiles', - ListAppProfilesResponse::class, - $request - ), - $this->configureCallSettings('listAppProfiles', $optionalArgs), - $this->descriptors['listAppProfiles']['pageStreaming'] + 'ListAppProfiles', + $optionalArgs, + ListAppProfilesResponse::class, + $request ); } @@ -1367,8 +1336,8 @@ public function listAppProfiles($parent, $optionalArgs = []) * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $appProfile = new AppProfile(); * $updateMask = new FieldMask(); * $response = $bigtableInstanceAdminClient->updateAppProfile($appProfile, $updateMask); @@ -1385,7 +1354,7 @@ public function listAppProfiles($parent, $optionalArgs = []) * * @type bool $ignoreWarnings * If true, ignore safety checks when updating the app profile. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1394,7 +1363,7 @@ public function listAppProfiles($parent, $optionalArgs = []) * * @return \Google\LongRunning\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateAppProfile($appProfile, $updateMask, $optionalArgs = []) @@ -1407,12 +1376,10 @@ public function updateAppProfile($appProfile, $updateMask, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/UpdateAppProfile', - Operation::class, - $request - ), - $this->configureCallSettings('updateAppProfile', $optionalArgs) + 'UpdateAppProfile', + Operation::class, + $optionalArgs, + $request )->wait(); } @@ -1426,8 +1393,8 @@ public function updateAppProfile($appProfile, $updateMask, $optionalArgs = []) * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedName = $bigtableInstanceAdminClient->appProfileName('[PROJECT]', '[INSTANCE]', '[APP_PROFILE]'); * $ignoreWarnings = false; * $bigtableInstanceAdminClient->deleteAppProfile($formattedName, $ignoreWarnings); @@ -1442,14 +1409,14 @@ public function updateAppProfile($appProfile, $updateMask, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteAppProfile($name, $ignoreWarnings, $optionalArgs = []) @@ -1459,12 +1426,10 @@ public function deleteAppProfile($name, $ignoreWarnings, $optionalArgs = []) $request->setIgnoreWarnings($ignoreWarnings); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteAppProfile', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteAppProfile', $optionalArgs) + 'DeleteAppProfile', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -1480,8 +1445,8 @@ public function deleteAppProfile($name, $ignoreWarnings, $optionalArgs = []) * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedResource = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $response = $bigtableInstanceAdminClient->getIamPolicy($formattedResource); * } finally { @@ -1495,7 +1460,7 @@ public function deleteAppProfile($name, $ignoreWarnings, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1504,7 +1469,7 @@ public function deleteAppProfile($name, $ignoreWarnings, $optionalArgs = []) * * @return \Google\Cloud\Iam\V1\Policy * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getIamPolicy($resource, $optionalArgs = []) @@ -1513,12 +1478,10 @@ public function getIamPolicy($resource, $optionalArgs = []) $request->setResource($resource); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetIamPolicy', - Policy::class, - $request - ), - $this->configureCallSettings('getIamPolicy', $optionalArgs) + 'GetIamPolicy', + Policy::class, + $optionalArgs, + $request )->wait(); } @@ -1534,8 +1497,8 @@ public function getIamPolicy($resource, $optionalArgs = []) * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedResource = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $policy = new Policy(); * $response = $bigtableInstanceAdminClient->setIamPolicy($formattedResource, $policy); @@ -1554,7 +1517,7 @@ public function getIamPolicy($resource, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1563,7 +1526,7 @@ public function getIamPolicy($resource, $optionalArgs = []) * * @return \Google\Cloud\Iam\V1\Policy * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setIamPolicy($resource, $policy, $optionalArgs = []) @@ -1573,12 +1536,10 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) $request->setPolicy($policy); return $this->startCall( - new Call( - self::SERVICE_NAME.'/SetIamPolicy', - Policy::class, - $request - ), - $this->configureCallSettings('setIamPolicy', $optionalArgs) + 'SetIamPolicy', + Policy::class, + $optionalArgs, + $request )->wait(); } @@ -1593,8 +1554,8 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) * * Sample code: * ``` + * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * try { - * $bigtableInstanceAdminClient = new BigtableInstanceAdminClient(); * $formattedResource = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $permissions = []; * $response = $bigtableInstanceAdminClient->testIamPermissions($formattedResource, $permissions); @@ -1613,7 +1574,7 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1622,7 +1583,7 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) * * @return \Google\Cloud\Iam\V1\TestIamPermissionsResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function testIamPermissions($resource, $permissions, $optionalArgs = []) @@ -1632,23 +1593,10 @@ public function testIamPermissions($resource, $permissions, $optionalArgs = []) $request->setPermissions($permissions); return $this->startCall( - new Call( - self::SERVICE_NAME.'/TestIamPermissions', - TestIamPermissionsResponse::class, - $request - ), - $this->configureCallSettings('testIamPermissions', $optionalArgs) + 'TestIamPermissions', + TestIamPermissionsResponse::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php b/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php index 6fa1e73dceee..e382acb2c46f 100644 --- a/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php +++ b/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php @@ -1,12 +1,12 @@ instanceName('[PROJECT]', '[INSTANCE]'); * $tableId = ''; * $table = new Table(); @@ -153,6 +157,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/bigtable_table_admin_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/bigtable_table_admin_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/bigtable_table_admin_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -333,7 +338,7 @@ public static function parseName($formattedName, $template = null) /** * Return an OperationsClient object with the same endpoint as $this. * - * @return \Google\ApiCore\LongRunning\OperationsClient + * @return OperationsClient * @experimental */ public function getOperationsClient() @@ -351,7 +356,7 @@ public function getOperationsClient() * @param string $operationName The name of the long running operation * @param string $methodName The name of the method used to start the operation * - * @return \Google\ApiCore\OperationResponse + * @return OperationResponse * @experimental */ public function resumeOperation($operationName, $methodName = null) @@ -374,10 +379,10 @@ public function resumeOperation($operationName, $methodName = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'bigtableadmin.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -388,9 +393,9 @@ public function resumeOperation($operationName, $methodName = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Cloud Bigtable Admin API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -408,12 +413,11 @@ public function resumeOperation($operationName, $methodName = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -440,8 +444,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $bigtableTableAdminClient = new BigtableTableAdminClient(); * try { - * $bigtableTableAdminClient = new BigtableTableAdminClient(); * $formattedParent = $bigtableTableAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $tableId = ''; * $table = new Table(); @@ -476,7 +480,7 @@ public function __construct($options = []) * - Tablet 3 `[customer_1, customer_2) => {"customer_1"}.` * - Tablet 4 `[customer_2, other) => {"customer_2"}.` * - Tablet 5 `[other, ) => {"other", "zz"}.` - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -485,7 +489,7 @@ public function __construct($options = []) * * @return \Google\Cloud\Bigtable\Admin\V2\Table * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createTable($parent, $tableId, $table, $optionalArgs = []) @@ -499,12 +503,10 @@ public function createTable($parent, $tableId, $table, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/CreateTable', - Table::class, - $request - ), - $this->configureCallSettings('createTable', $optionalArgs) + 'CreateTable', + Table::class, + $optionalArgs, + $request )->wait(); } @@ -519,8 +521,8 @@ public function createTable($parent, $tableId, $table, $optionalArgs = []) * * Sample code: * ``` + * $bigtableTableAdminClient = new BigtableTableAdminClient(); * try { - * $bigtableTableAdminClient = new BigtableTableAdminClient(); * $formattedParent = $bigtableTableAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $tableId = ''; * $sourceSnapshot = ''; @@ -566,7 +568,7 @@ public function createTable($parent, $tableId, $table, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -575,7 +577,7 @@ public function createTable($parent, $tableId, $table, $optionalArgs = []) * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createTableFromSnapshot($parent, $tableId, $sourceSnapshot, $optionalArgs = []) @@ -586,14 +588,10 @@ public function createTableFromSnapshot($parent, $tableId, $sourceSnapshot, $opt $request->setSourceSnapshot($sourceSnapshot); return $this->startOperationsCall( - new Call( - self::SERVICE_NAME.'/CreateTableFromSnapshot', - Operation::class, - $request - ), - $this->configureCallSettings('createTableFromSnapshot', $optionalArgs), - $this->getOperationsClient(), - $this->descriptors['createTableFromSnapshot']['longRunning'] + 'CreateTableFromSnapshot', + $optionalArgs, + $request, + $this->getOperationsClient() )->wait(); } @@ -602,8 +600,8 @@ public function createTableFromSnapshot($parent, $tableId, $sourceSnapshot, $opt * * Sample code: * ``` + * $bigtableTableAdminClient = new BigtableTableAdminClient(); * try { - * $bigtableTableAdminClient = new BigtableTableAdminClient(); * $formattedParent = $bigtableTableAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * // Iterate through all elements * $pagedResponse = $bigtableTableAdminClient->listTables($formattedParent); @@ -637,7 +635,7 @@ public function createTableFromSnapshot($parent, $tableId, $sourceSnapshot, $opt * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -646,7 +644,7 @@ public function createTableFromSnapshot($parent, $tableId, $sourceSnapshot, $opt * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listTables($parent, $optionalArgs = []) @@ -661,13 +659,10 @@ public function listTables($parent, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListTables', - ListTablesResponse::class, - $request - ), - $this->configureCallSettings('listTables', $optionalArgs), - $this->descriptors['listTables']['pageStreaming'] + 'ListTables', + $optionalArgs, + ListTablesResponse::class, + $request ); } @@ -676,8 +671,8 @@ public function listTables($parent, $optionalArgs = []) * * Sample code: * ``` + * $bigtableTableAdminClient = new BigtableTableAdminClient(); * try { - * $bigtableTableAdminClient = new BigtableTableAdminClient(); * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); * $response = $bigtableTableAdminClient->getTable($formattedName); * } finally { @@ -695,7 +690,7 @@ public function listTables($parent, $optionalArgs = []) * The view to be applied to the returned table's fields. * Defaults to `SCHEMA_VIEW` if unspecified. * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\Table_View} - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -704,7 +699,7 @@ public function listTables($parent, $optionalArgs = []) * * @return \Google\Cloud\Bigtable\Admin\V2\Table * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getTable($name, $optionalArgs = []) @@ -716,12 +711,10 @@ public function getTable($name, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetTable', - Table::class, - $request - ), - $this->configureCallSettings('getTable', $optionalArgs) + 'GetTable', + Table::class, + $optionalArgs, + $request )->wait(); } @@ -730,8 +723,8 @@ public function getTable($name, $optionalArgs = []) * * Sample code: * ``` + * $bigtableTableAdminClient = new BigtableTableAdminClient(); * try { - * $bigtableTableAdminClient = new BigtableTableAdminClient(); * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); * $bigtableTableAdminClient->deleteTable($formattedName); * } finally { @@ -745,14 +738,14 @@ public function getTable($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteTable($name, $optionalArgs = []) @@ -761,12 +754,10 @@ public function deleteTable($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteTable', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteTable', $optionalArgs) + 'DeleteTable', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -778,8 +769,8 @@ public function deleteTable($name, $optionalArgs = []) * * Sample code: * ``` + * $bigtableTableAdminClient = new BigtableTableAdminClient(); * try { - * $bigtableTableAdminClient = new BigtableTableAdminClient(); * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); * $modifications = []; * $response = $bigtableTableAdminClient->modifyColumnFamilies($formattedName, $modifications); @@ -798,7 +789,7 @@ public function deleteTable($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -807,7 +798,7 @@ public function deleteTable($name, $optionalArgs = []) * * @return \Google\Cloud\Bigtable\Admin\V2\Table * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function modifyColumnFamilies($name, $modifications, $optionalArgs = []) @@ -817,12 +808,10 @@ public function modifyColumnFamilies($name, $modifications, $optionalArgs = []) $request->setModifications($modifications); return $this->startCall( - new Call( - self::SERVICE_NAME.'/ModifyColumnFamilies', - Table::class, - $request - ), - $this->configureCallSettings('modifyColumnFamilies', $optionalArgs) + 'ModifyColumnFamilies', + Table::class, + $optionalArgs, + $request )->wait(); } @@ -833,8 +822,8 @@ public function modifyColumnFamilies($name, $modifications, $optionalArgs = []) * * Sample code: * ``` + * $bigtableTableAdminClient = new BigtableTableAdminClient(); * try { - * $bigtableTableAdminClient = new BigtableTableAdminClient(); * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); * $bigtableTableAdminClient->dropRowRange($formattedName); * } finally { @@ -853,14 +842,14 @@ public function modifyColumnFamilies($name, $modifications, $optionalArgs = []) * zero length. * @type bool $deleteAllDataFromTable * Delete all rows in the table. Setting this to false is a no-op. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function dropRowRange($name, $optionalArgs = []) @@ -875,12 +864,10 @@ public function dropRowRange($name, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/DropRowRange', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('dropRowRange', $optionalArgs) + 'DropRowRange', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -897,8 +884,8 @@ public function dropRowRange($name, $optionalArgs = []) * * Sample code: * ``` + * $bigtableTableAdminClient = new BigtableTableAdminClient(); * try { - * $bigtableTableAdminClient = new BigtableTableAdminClient(); * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); * $response = $bigtableTableAdminClient->generateConsistencyToken($formattedName); * } finally { @@ -912,7 +899,7 @@ public function dropRowRange($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -921,7 +908,7 @@ public function dropRowRange($name, $optionalArgs = []) * * @return \Google\Cloud\Bigtable\Admin\V2\GenerateConsistencyTokenResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function generateConsistencyToken($name, $optionalArgs = []) @@ -930,12 +917,10 @@ public function generateConsistencyToken($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GenerateConsistencyToken', - GenerateConsistencyTokenResponse::class, - $request - ), - $this->configureCallSettings('generateConsistencyToken', $optionalArgs) + 'GenerateConsistencyToken', + GenerateConsistencyTokenResponse::class, + $optionalArgs, + $request )->wait(); } @@ -951,8 +936,8 @@ public function generateConsistencyToken($name, $optionalArgs = []) * * Sample code: * ``` + * $bigtableTableAdminClient = new BigtableTableAdminClient(); * try { - * $bigtableTableAdminClient = new BigtableTableAdminClient(); * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); * $consistencyToken = ''; * $response = $bigtableTableAdminClient->checkConsistency($formattedName, $consistencyToken); @@ -968,7 +953,7 @@ public function generateConsistencyToken($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -977,7 +962,7 @@ public function generateConsistencyToken($name, $optionalArgs = []) * * @return \Google\Cloud\Bigtable\Admin\V2\CheckConsistencyResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function checkConsistency($name, $consistencyToken, $optionalArgs = []) @@ -987,12 +972,10 @@ public function checkConsistency($name, $consistencyToken, $optionalArgs = []) $request->setConsistencyToken($consistencyToken); return $this->startCall( - new Call( - self::SERVICE_NAME.'/CheckConsistency', - CheckConsistencyResponse::class, - $request - ), - $this->configureCallSettings('checkConsistency', $optionalArgs) + 'CheckConsistency', + CheckConsistencyResponse::class, + $optionalArgs, + $request )->wait(); } @@ -1007,8 +990,8 @@ public function checkConsistency($name, $consistencyToken, $optionalArgs = []) * * Sample code: * ``` + * $bigtableTableAdminClient = new BigtableTableAdminClient(); * try { - * $bigtableTableAdminClient = new BigtableTableAdminClient(); * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); * $cluster = ''; * $snapshotId = ''; @@ -1038,7 +1021,7 @@ public function checkConsistency($name, $consistencyToken, $optionalArgs = []) * created. Once 'ttl' expires, the snapshot will get deleted. The maximum * amount of time a snapshot can stay active is 7 days. If 'ttl' is not * specified, the default value of 24 hours will be used. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1047,7 +1030,7 @@ public function checkConsistency($name, $consistencyToken, $optionalArgs = []) * * @return \Google\LongRunning\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function snapshotTable($name, $cluster, $snapshotId, $description, $optionalArgs = []) @@ -1062,12 +1045,10 @@ public function snapshotTable($name, $cluster, $snapshotId, $description, $optio } return $this->startCall( - new Call( - self::SERVICE_NAME.'/SnapshotTable', - Operation::class, - $request - ), - $this->configureCallSettings('snapshotTable', $optionalArgs) + 'SnapshotTable', + Operation::class, + $optionalArgs, + $request )->wait(); } @@ -1081,8 +1062,8 @@ public function snapshotTable($name, $cluster, $snapshotId, $description, $optio * * Sample code: * ``` + * $bigtableTableAdminClient = new BigtableTableAdminClient(); * try { - * $bigtableTableAdminClient = new BigtableTableAdminClient(); * $formattedName = $bigtableTableAdminClient->snapshotName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[SNAPSHOT]'); * $response = $bigtableTableAdminClient->getSnapshot($formattedName); * } finally { @@ -1096,7 +1077,7 @@ public function snapshotTable($name, $cluster, $snapshotId, $description, $optio * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1105,7 +1086,7 @@ public function snapshotTable($name, $cluster, $snapshotId, $description, $optio * * @return \Google\Cloud\Bigtable\Admin\V2\Snapshot * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getSnapshot($name, $optionalArgs = []) @@ -1114,12 +1095,10 @@ public function getSnapshot($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetSnapshot', - Snapshot::class, - $request - ), - $this->configureCallSettings('getSnapshot', $optionalArgs) + 'GetSnapshot', + Snapshot::class, + $optionalArgs, + $request )->wait(); } @@ -1133,8 +1112,8 @@ public function getSnapshot($name, $optionalArgs = []) * * Sample code: * ``` + * $bigtableTableAdminClient = new BigtableTableAdminClient(); * try { - * $bigtableTableAdminClient = new BigtableTableAdminClient(); * $formattedParent = $bigtableTableAdminClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); * // Iterate through all elements * $pagedResponse = $bigtableTableAdminClient->listSnapshots($formattedParent); @@ -1171,7 +1150,7 @@ public function getSnapshot($name, $optionalArgs = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1180,7 +1159,7 @@ public function getSnapshot($name, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listSnapshots($parent, $optionalArgs = []) @@ -1195,13 +1174,10 @@ public function listSnapshots($parent, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListSnapshots', - ListSnapshotsResponse::class, - $request - ), - $this->configureCallSettings('listSnapshots', $optionalArgs), - $this->descriptors['listSnapshots']['pageStreaming'] + 'ListSnapshots', + $optionalArgs, + ListSnapshotsResponse::class, + $request ); } @@ -1215,8 +1191,8 @@ public function listSnapshots($parent, $optionalArgs = []) * * Sample code: * ``` + * $bigtableTableAdminClient = new BigtableTableAdminClient(); * try { - * $bigtableTableAdminClient = new BigtableTableAdminClient(); * $formattedName = $bigtableTableAdminClient->snapshotName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[SNAPSHOT]'); * $bigtableTableAdminClient->deleteSnapshot($formattedName); * } finally { @@ -1230,14 +1206,14 @@ public function listSnapshots($parent, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteSnapshot($name, $optionalArgs = []) @@ -1246,23 +1222,10 @@ public function deleteSnapshot($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteSnapshot', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteSnapshot', $optionalArgs) + 'DeleteSnapshot', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_descriptor_config.php b/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_descriptor_config.php index 3d39322f1abd..16e2b2862947 100644 --- a/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_descriptor_config.php +++ b/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_descriptor_config.php @@ -3,25 +3,25 @@ return [ 'interfaces' => [ 'google.bigtable.admin.v2.BigtableInstanceAdmin' => [ - 'createInstance' => [ + 'CreateInstance' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\Bigtable\Admin\V2\Instance', 'metadataReturnType' => '\Google\Cloud\Bigtable\Admin\V2\CreateInstanceMetadata', ], ], - 'createCluster' => [ + 'CreateCluster' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\Bigtable\Admin\V2\Cluster', 'metadataReturnType' => '\Google\Cloud\Bigtable\Admin\V2\CreateClusterMetadata', ], ], - 'updateCluster' => [ + 'UpdateCluster' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\Bigtable\Admin\V2\Cluster', 'metadataReturnType' => '\Google\Cloud\Bigtable\Admin\V2\UpdateClusterMetadata', ], ], - 'listAppProfiles' => [ + 'ListAppProfiles' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', diff --git a/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_rest_client_config.php b/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_rest_client_config.php index dae4a6ed060e..6fe9405c3708 100644 --- a/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_rest_client_config.php +++ b/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_rest_client_config.php @@ -5,184 +5,222 @@ 'google.bigtable.admin.v2.BigtableInstanceAdmin' => [ 'CreateInstance' => [ 'method' => 'post', - 'uri' => '/v2/{parent=projects/*}/instances', + 'uriTemplate' => '/v2/{parent=projects/*}/instances', 'body' => '*', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'GetInstance' => [ 'method' => 'get', - 'uri' => '/v2/{name=projects/*/instances/*}', + 'uriTemplate' => '/v2/{name=projects/*/instances/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'ListInstances' => [ 'method' => 'get', - 'uri' => '/v2/{parent=projects/*}/instances', + 'uriTemplate' => '/v2/{parent=projects/*}/instances', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'UpdateInstance' => [ 'method' => 'put', - 'uri' => '/v2/{name=projects/*/instances/*}', + 'uriTemplate' => '/v2/{name=projects/*/instances/*}', 'body' => '*', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'PartialUpdateInstance' => [ 'method' => 'patch', - 'uri' => '/v2/{instance.name=projects/*/instances/*}', + 'uriTemplate' => '/v2/{instance.name=projects/*/instances/*}', 'body' => 'instance', 'placeholders' => [ 'instance.name' => [ - 'getInstance', - 'getName', + 'getters' => [ + 'getInstance', + 'getName', + ], ], ], ], 'DeleteInstance' => [ 'method' => 'delete', - 'uri' => '/v2/{name=projects/*/instances/*}', + 'uriTemplate' => '/v2/{name=projects/*/instances/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'CreateCluster' => [ 'method' => 'post', - 'uri' => '/v2/{parent=projects/*/instances/*}/clusters', + 'uriTemplate' => '/v2/{parent=projects/*/instances/*}/clusters', 'body' => 'cluster', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'GetCluster' => [ 'method' => 'get', - 'uri' => '/v2/{name=projects/*/instances/*/clusters/*}', + 'uriTemplate' => '/v2/{name=projects/*/instances/*/clusters/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'ListClusters' => [ 'method' => 'get', - 'uri' => '/v2/{parent=projects/*/instances/*}/clusters', + 'uriTemplate' => '/v2/{parent=projects/*/instances/*}/clusters', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'UpdateCluster' => [ 'method' => 'put', - 'uri' => '/v2/{name=projects/*/instances/*/clusters/*}', + 'uriTemplate' => '/v2/{name=projects/*/instances/*/clusters/*}', 'body' => '*', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'DeleteCluster' => [ 'method' => 'delete', - 'uri' => '/v2/{name=projects/*/instances/*/clusters/*}', + 'uriTemplate' => '/v2/{name=projects/*/instances/*/clusters/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'CreateAppProfile' => [ 'method' => 'post', - 'uri' => '/v2/{parent=projects/*/instances/*}/appProfiles', + 'uriTemplate' => '/v2/{parent=projects/*/instances/*}/appProfiles', 'body' => 'app_profile', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'GetAppProfile' => [ 'method' => 'get', - 'uri' => '/v2/{name=projects/*/instances/*/appProfiles/*}', + 'uriTemplate' => '/v2/{name=projects/*/instances/*/appProfiles/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'ListAppProfiles' => [ 'method' => 'get', - 'uri' => '/v2/{parent=projects/*/instances/*}/appProfiles', + 'uriTemplate' => '/v2/{parent=projects/*/instances/*}/appProfiles', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'UpdateAppProfile' => [ 'method' => 'patch', - 'uri' => '/v2/{app_profile.name=projects/*/instances/*/appProfiles/*}', + 'uriTemplate' => '/v2/{app_profile.name=projects/*/instances/*/appProfiles/*}', 'body' => 'app_profile', 'placeholders' => [ 'app_profile.name' => [ - 'getAppProfile', - 'getName', + 'getters' => [ + 'getAppProfile', + 'getName', + ], ], ], ], 'DeleteAppProfile' => [ 'method' => 'delete', - 'uri' => '/v2/{name=projects/*/instances/*/appProfiles/*}', + 'uriTemplate' => '/v2/{name=projects/*/instances/*/appProfiles/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'GetIamPolicy' => [ 'method' => 'post', - 'uri' => '/v2/{resource=projects/*/instances/*}:getIamPolicy', + 'uriTemplate' => '/v2/{resource=projects/*/instances/*}:getIamPolicy', 'body' => '*', 'placeholders' => [ 'resource' => [ - 'getResource', + 'getters' => [ + 'getResource', + ], ], ], ], 'SetIamPolicy' => [ 'method' => 'post', - 'uri' => '/v2/{resource=projects/*/instances/*}:setIamPolicy', + 'uriTemplate' => '/v2/{resource=projects/*/instances/*}:setIamPolicy', 'body' => '*', 'placeholders' => [ 'resource' => [ - 'getResource', + 'getters' => [ + 'getResource', + ], ], ], ], 'TestIamPermissions' => [ 'method' => 'post', - 'uri' => '/v2/{resource=projects/*/instances/*}:testIamPermissions', + 'uriTemplate' => '/v2/{resource=projects/*/instances/*}:testIamPermissions', 'body' => '*', 'placeholders' => [ 'resource' => [ - 'getResource', + 'getters' => [ + 'getResource', + ], ], ], ], diff --git a/src/Bigtable/Admin/V2/resources/bigtable_table_admin_descriptor_config.php b/src/Bigtable/Admin/V2/resources/bigtable_table_admin_descriptor_config.php index b8ede8384cef..691f5f6623eb 100644 --- a/src/Bigtable/Admin/V2/resources/bigtable_table_admin_descriptor_config.php +++ b/src/Bigtable/Admin/V2/resources/bigtable_table_admin_descriptor_config.php @@ -3,13 +3,13 @@ return [ 'interfaces' => [ 'google.bigtable.admin.v2.BigtableTableAdmin' => [ - 'createTableFromSnapshot' => [ + 'CreateTableFromSnapshot' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\Bigtable\Admin\V2\Table', 'metadataReturnType' => '\Google\Cloud\Bigtable\Admin\V2\CreateTableFromSnapshotMetadata', ], ], - 'listTables' => [ + 'ListTables' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', @@ -17,7 +17,7 @@ 'resourcesGetMethod' => 'getTables', ], ], - 'listSnapshots' => [ + 'ListSnapshots' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', diff --git a/src/Bigtable/Admin/V2/resources/bigtable_table_admin_rest_client_config.php b/src/Bigtable/Admin/V2/resources/bigtable_table_admin_rest_client_config.php index ee59e3caff02..a5c9314a9e82 100644 --- a/src/Bigtable/Admin/V2/resources/bigtable_table_admin_rest_client_config.php +++ b/src/Bigtable/Admin/V2/resources/bigtable_table_admin_rest_client_config.php @@ -5,125 +5,151 @@ 'google.bigtable.admin.v2.BigtableTableAdmin' => [ 'CreateTable' => [ 'method' => 'post', - 'uri' => '/v2/{parent=projects/*/instances/*}/tables', + 'uriTemplate' => '/v2/{parent=projects/*/instances/*}/tables', 'body' => '*', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'CreateTableFromSnapshot' => [ 'method' => 'post', - 'uri' => '/v2/{parent=projects/*/instances/*}/tables:createFromSnapshot', + 'uriTemplate' => '/v2/{parent=projects/*/instances/*}/tables:createFromSnapshot', 'body' => '*', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'ListTables' => [ 'method' => 'get', - 'uri' => '/v2/{parent=projects/*/instances/*}/tables', + 'uriTemplate' => '/v2/{parent=projects/*/instances/*}/tables', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'GetTable' => [ 'method' => 'get', - 'uri' => '/v2/{name=projects/*/instances/*/tables/*}', + 'uriTemplate' => '/v2/{name=projects/*/instances/*/tables/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'DeleteTable' => [ 'method' => 'delete', - 'uri' => '/v2/{name=projects/*/instances/*/tables/*}', + 'uriTemplate' => '/v2/{name=projects/*/instances/*/tables/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'ModifyColumnFamilies' => [ 'method' => 'post', - 'uri' => '/v2/{name=projects/*/instances/*/tables/*}:modifyColumnFamilies', + 'uriTemplate' => '/v2/{name=projects/*/instances/*/tables/*}:modifyColumnFamilies', 'body' => '*', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'DropRowRange' => [ 'method' => 'post', - 'uri' => '/v2/{name=projects/*/instances/*/tables/*}:dropRowRange', + 'uriTemplate' => '/v2/{name=projects/*/instances/*/tables/*}:dropRowRange', 'body' => '*', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'GenerateConsistencyToken' => [ 'method' => 'post', - 'uri' => '/v2/{name=projects/*/instances/*/tables/*}:generateConsistencyToken', + 'uriTemplate' => '/v2/{name=projects/*/instances/*/tables/*}:generateConsistencyToken', 'body' => '*', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'CheckConsistency' => [ 'method' => 'post', - 'uri' => '/v2/{name=projects/*/instances/*/tables/*}:checkConsistency', + 'uriTemplate' => '/v2/{name=projects/*/instances/*/tables/*}:checkConsistency', 'body' => '*', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'SnapshotTable' => [ 'method' => 'post', - 'uri' => '/v2/{name=projects/*/instances/*/tables/*}:snapshot', + 'uriTemplate' => '/v2/{name=projects/*/instances/*/tables/*}:snapshot', 'body' => '*', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'GetSnapshot' => [ 'method' => 'get', - 'uri' => '/v2/{name=projects/*/instances/*/clusters/*/snapshots/*}', + 'uriTemplate' => '/v2/{name=projects/*/instances/*/clusters/*/snapshots/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'ListSnapshots' => [ 'method' => 'get', - 'uri' => '/v2/{parent=projects/*/instances/*/clusters/*}/snapshots', + 'uriTemplate' => '/v2/{parent=projects/*/instances/*/clusters/*}/snapshots', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'DeleteSnapshot' => [ 'method' => 'delete', - 'uri' => '/v2/{name=projects/*/instances/*/clusters/*/snapshots/*}', + 'uriTemplate' => '/v2/{name=projects/*/instances/*/clusters/*/snapshots/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], diff --git a/src/Bigtable/V2/BigtableClient.php b/src/Bigtable/V2/BigtableClient.php index 3a5a90e5fa65..3d460f7cfd21 100644 --- a/src/Bigtable/V2/BigtableClient.php +++ b/src/Bigtable/V2/BigtableClient.php @@ -1,12 +1,12 @@ tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); * // Read all responses until the stream is complete * $stream = $bigtableClient->readRows($formattedTableName); @@ -133,6 +138,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/bigtable_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/bigtable_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/bigtable_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -226,10 +232,10 @@ public static function parseName($formattedName, $template = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'bigtable.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -240,9 +246,9 @@ public static function parseName($formattedName, $template = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Cloud Bigtable API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -260,12 +266,11 @@ public static function parseName($formattedName, $template = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -286,8 +291,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $bigtableClient = new BigtableClient(); * try { - * $bigtableClient = new BigtableClient(); * $formattedTableName = $bigtableClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); * // Read all responses until the stream is complete * $stream = $bigtableClient->readRows($formattedTableName); @@ -327,7 +332,7 @@ public function __construct($options = []) * * @return \Google\ApiCore\ServerStream * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function readRows($tableName, $optionalArgs = []) @@ -347,14 +352,12 @@ public function readRows($tableName, $optionalArgs = []) $request->setRowsLimit($optionalArgs['rowsLimit']); } - return $this->transport->startServerStreamingCall( - new Call( - self::SERVICE_NAME.'/ReadRows', - ReadRowsResponse::class, - $request - ), - $this->configureCallSettings('readRows', $optionalArgs), - $this->descriptors['readRows']['grpcStreaming'] + return $this->startCall( + 'ReadRows', + ReadRowsResponse::class, + $optionalArgs, + $request, + Call::SERVER_STREAMING_CALL ); } @@ -366,8 +369,8 @@ public function readRows($tableName, $optionalArgs = []) * * Sample code: * ``` + * $bigtableClient = new BigtableClient(); * try { - * $bigtableClient = new BigtableClient(); * $formattedTableName = $bigtableClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); * // Read all responses until the stream is complete * $stream = $bigtableClient->sampleRowKeys($formattedTableName); @@ -399,7 +402,7 @@ public function readRows($tableName, $optionalArgs = []) * * @return \Google\ApiCore\ServerStream * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function sampleRowKeys($tableName, $optionalArgs = []) @@ -410,14 +413,12 @@ public function sampleRowKeys($tableName, $optionalArgs = []) $request->setAppProfileId($optionalArgs['appProfileId']); } - return $this->transport->startServerStreamingCall( - new Call( - self::SERVICE_NAME.'/SampleRowKeys', - SampleRowKeysResponse::class, - $request - ), - $this->configureCallSettings('sampleRowKeys', $optionalArgs), - $this->descriptors['sampleRowKeys']['grpcStreaming'] + return $this->startCall( + 'SampleRowKeys', + SampleRowKeysResponse::class, + $optionalArgs, + $request, + Call::SERVER_STREAMING_CALL ); } @@ -427,8 +428,8 @@ public function sampleRowKeys($tableName, $optionalArgs = []) * * Sample code: * ``` + * $bigtableClient = new BigtableClient(); * try { - * $bigtableClient = new BigtableClient(); * $formattedTableName = $bigtableClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); * $rowKey = ''; * $mutations = []; @@ -456,7 +457,7 @@ public function sampleRowKeys($tableName, $optionalArgs = []) * * This value specifies routing for replication. If not specified, the * "default" application profile will be used. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -465,7 +466,7 @@ public function sampleRowKeys($tableName, $optionalArgs = []) * * @return \Google\Cloud\Bigtable\V2\MutateRowResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function mutateRow($tableName, $rowKey, $mutations, $optionalArgs = []) @@ -479,12 +480,10 @@ public function mutateRow($tableName, $rowKey, $mutations, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/MutateRow', - MutateRowResponse::class, - $request - ), - $this->configureCallSettings('mutateRow', $optionalArgs) + 'MutateRow', + MutateRowResponse::class, + $optionalArgs, + $request )->wait(); } @@ -495,8 +494,8 @@ public function mutateRow($tableName, $rowKey, $mutations, $optionalArgs = []) * * Sample code: * ``` + * $bigtableClient = new BigtableClient(); * try { - * $bigtableClient = new BigtableClient(); * $formattedTableName = $bigtableClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); * $entries = []; * // Read all responses until the stream is complete @@ -532,7 +531,7 @@ public function mutateRow($tableName, $rowKey, $mutations, $optionalArgs = []) * * @return \Google\ApiCore\ServerStream * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function mutateRows($tableName, $entries, $optionalArgs = []) @@ -544,14 +543,12 @@ public function mutateRows($tableName, $entries, $optionalArgs = []) $request->setAppProfileId($optionalArgs['appProfileId']); } - return $this->transport->startServerStreamingCall( - new Call( - self::SERVICE_NAME.'/MutateRows', - MutateRowsResponse::class, - $request - ), - $this->configureCallSettings('mutateRows', $optionalArgs), - $this->descriptors['mutateRows']['grpcStreaming'] + return $this->startCall( + 'MutateRows', + MutateRowsResponse::class, + $optionalArgs, + $request, + Call::SERVER_STREAMING_CALL ); } @@ -560,8 +557,8 @@ public function mutateRows($tableName, $entries, $optionalArgs = []) * * Sample code: * ``` + * $bigtableClient = new BigtableClient(); * try { - * $bigtableClient = new BigtableClient(); * $formattedTableName = $bigtableClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); * $rowKey = ''; * $response = $bigtableClient->checkAndMutateRow($formattedTableName, $rowKey); @@ -603,7 +600,7 @@ public function mutateRows($tableName, $entries, $optionalArgs = []) * order, meaning that earlier mutations can be masked by later ones. * Must contain at least one entry if `true_mutations` is empty, and at most * 100000. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -612,7 +609,7 @@ public function mutateRows($tableName, $entries, $optionalArgs = []) * * @return \Google\Cloud\Bigtable\V2\CheckAndMutateRowResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function checkAndMutateRow($tableName, $rowKey, $optionalArgs = []) @@ -634,12 +631,10 @@ public function checkAndMutateRow($tableName, $rowKey, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/CheckAndMutateRow', - CheckAndMutateRowResponse::class, - $request - ), - $this->configureCallSettings('checkAndMutateRow', $optionalArgs) + 'CheckAndMutateRow', + CheckAndMutateRowResponse::class, + $optionalArgs, + $request )->wait(); } @@ -652,8 +647,8 @@ public function checkAndMutateRow($tableName, $rowKey, $optionalArgs = []) * * Sample code: * ``` + * $bigtableClient = new BigtableClient(); * try { - * $bigtableClient = new BigtableClient(); * $formattedTableName = $bigtableClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); * $rowKey = ''; * $rules = []; @@ -682,7 +677,7 @@ public function checkAndMutateRow($tableName, $rowKey, $optionalArgs = []) * * This value specifies routing for replication. If not specified, the * "default" application profile will be used. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -691,7 +686,7 @@ public function checkAndMutateRow($tableName, $rowKey, $optionalArgs = []) * * @return \Google\Cloud\Bigtable\V2\ReadModifyWriteRowResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function readModifyWriteRow($tableName, $rowKey, $rules, $optionalArgs = []) @@ -705,23 +700,10 @@ public function readModifyWriteRow($tableName, $rowKey, $rules, $optionalArgs = } return $this->startCall( - new Call( - self::SERVICE_NAME.'/ReadModifyWriteRow', - ReadModifyWriteRowResponse::class, - $request - ), - $this->configureCallSettings('readModifyWriteRow', $optionalArgs) + 'ReadModifyWriteRow', + ReadModifyWriteRowResponse::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Bigtable/V2/resources/bigtable_descriptor_config.php b/src/Bigtable/V2/resources/bigtable_descriptor_config.php index 4ec79d17970b..5435b202973f 100644 --- a/src/Bigtable/V2/resources/bigtable_descriptor_config.php +++ b/src/Bigtable/V2/resources/bigtable_descriptor_config.php @@ -3,17 +3,17 @@ return [ 'interfaces' => [ 'google.bigtable.v2.Bigtable' => [ - 'readRows' => [ + 'ReadRows' => [ 'grpcStreaming' => [ 'grpcStreamingType' => 'ServerStreaming', ], ], - 'sampleRowKeys' => [ + 'SampleRowKeys' => [ 'grpcStreaming' => [ 'grpcStreamingType' => 'ServerStreaming', ], ], - 'mutateRows' => [ + 'MutateRows' => [ 'grpcStreaming' => [ 'grpcStreamingType' => 'ServerStreaming', ], diff --git a/src/Bigtable/V2/resources/bigtable_rest_client_config.php b/src/Bigtable/V2/resources/bigtable_rest_client_config.php index 15e1278e7459..5888ae91fb03 100644 --- a/src/Bigtable/V2/resources/bigtable_rest_client_config.php +++ b/src/Bigtable/V2/resources/bigtable_rest_client_config.php @@ -3,62 +3,39 @@ return [ 'interfaces' => [ 'google.bigtable.v2.Bigtable' => [ - 'ReadRows' => [ - 'method' => 'post', - 'uri' => '/v2/{table_name=projects/*/instances/*/tables/*}:readRows', - 'body' => '*', - 'placeholders' => [ - 'table_name' => [ - 'getTableName', - ], - ], - ], - 'SampleRowKeys' => [ - 'method' => 'get', - 'uri' => '/v2/{table_name=projects/*/instances/*/tables/*}:sampleRowKeys', - 'placeholders' => [ - 'table_name' => [ - 'getTableName', - ], - ], - ], 'MutateRow' => [ 'method' => 'post', - 'uri' => '/v2/{table_name=projects/*/instances/*/tables/*}:mutateRow', - 'body' => '*', - 'placeholders' => [ - 'table_name' => [ - 'getTableName', - ], - ], - ], - 'MutateRows' => [ - 'method' => 'post', - 'uri' => '/v2/{table_name=projects/*/instances/*/tables/*}:mutateRows', + 'uriTemplate' => '/v2/{table_name=projects/*/instances/*/tables/*}:mutateRow', 'body' => '*', 'placeholders' => [ 'table_name' => [ - 'getTableName', + 'getters' => [ + 'getTableName', + ], ], ], ], 'CheckAndMutateRow' => [ 'method' => 'post', - 'uri' => '/v2/{table_name=projects/*/instances/*/tables/*}:checkAndMutateRow', + 'uriTemplate' => '/v2/{table_name=projects/*/instances/*/tables/*}:checkAndMutateRow', 'body' => '*', 'placeholders' => [ 'table_name' => [ - 'getTableName', + 'getters' => [ + 'getTableName', + ], ], ], ], 'ReadModifyWriteRow' => [ 'method' => 'post', - 'uri' => '/v2/{table_name=projects/*/instances/*/tables/*}:readModifyWriteRow', + 'uriTemplate' => '/v2/{table_name=projects/*/instances/*/tables/*}:readModifyWriteRow', 'body' => '*', 'placeholders' => [ 'table_name' => [ - 'getTableName', + 'getters' => [ + 'getTableName', + ], ], ], ], diff --git a/src/Core/GrpcTrait.php b/src/Core/GrpcTrait.php index a8d6acb0c50e..f61015148661 100644 --- a/src/Core/GrpcTrait.php +++ b/src/Core/GrpcTrait.php @@ -98,7 +98,8 @@ private function getGaxConfig($version) 'credentialsLoader' => $this->requestWrapper->getCredentialsFetcher(), 'enableCaching' => false, 'libName' => 'gccl', - 'libVersion' => $version + 'libVersion' => $version, + 'transport' => 'grpc' ]; } diff --git a/src/Dlp/V2beta1/DlpServiceClient.php b/src/Dlp/V2beta1/DlpServiceClient.php index 97e4174f21a4..d497a82f26df 100644 --- a/src/Dlp/V2beta1/DlpServiceClient.php +++ b/src/Dlp/V2beta1/DlpServiceClient.php @@ -1,12 +1,12 @@ setName($name); @@ -152,6 +156,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/dlp_service_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/dlp_service_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/dlp_service_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -235,7 +240,7 @@ public static function parseName($formattedName, $template = null) /** * Return an OperationsClient object with the same endpoint as $this. * - * @return \Google\ApiCore\LongRunning\OperationsClient + * @return OperationsClient * @experimental */ public function getOperationsClient() @@ -253,7 +258,7 @@ public function getOperationsClient() * @param string $operationName The name of the long running operation * @param string $methodName The name of the method used to start the operation * - * @return \Google\ApiCore\OperationResponse + * @return OperationResponse * @experimental */ public function resumeOperation($operationName, $methodName = null) @@ -276,10 +281,10 @@ public function resumeOperation($operationName, $methodName = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'dlp.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -290,9 +295,9 @@ public function resumeOperation($operationName, $methodName = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the DLP API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -310,12 +315,11 @@ public function resumeOperation($operationName, $methodName = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -341,8 +345,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $dlpServiceClient = new DlpServiceClient(); * try { - * $dlpServiceClient = new DlpServiceClient(); * $name = 'EMAIL_ADDRESS'; * $infoTypesElement = new InfoType(); * $infoTypesElement->setName($name); @@ -368,7 +372,7 @@ public function __construct($options = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -377,7 +381,7 @@ public function __construct($options = []) * * @return \Google\Cloud\Dlp\V2beta1\InspectContentResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function inspectContent($inspectConfig, $items, $optionalArgs = []) @@ -387,12 +391,10 @@ public function inspectContent($inspectConfig, $items, $optionalArgs = []) $request->setItems($items); return $this->startCall( - new Call( - self::SERVICE_NAME.'/InspectContent', - InspectContentResponse::class, - $request - ), - $this->configureCallSettings('inspectContent', $optionalArgs) + 'InspectContent', + InspectContentResponse::class, + $optionalArgs, + $request )->wait(); } @@ -402,8 +404,8 @@ public function inspectContent($inspectConfig, $items, $optionalArgs = []) * * Sample code: * ``` + * $dlpServiceClient = new DlpServiceClient(); * try { - * $dlpServiceClient = new DlpServiceClient(); * $name = 'EMAIL_ADDRESS'; * $infoTypesElement = new InfoType(); * $infoTypesElement->setName($name); @@ -416,7 +418,15 @@ public function inspectContent($inspectConfig, $items, $optionalArgs = []) * $itemsElement->setType($type); * $itemsElement->setValue($value); * $items = [$itemsElement]; - * $response = $dlpServiceClient->redactContent($inspectConfig, $items); + * $name2 = 'EMAIL_ADDRESS'; + * $infoType = new InfoType(); + * $infoType->setName($name2); + * $replaceWith = 'REDACTED'; + * $replaceConfigsElement = new ReplaceConfig(); + * $replaceConfigsElement->setInfoType($infoType); + * $replaceConfigsElement->setReplaceWith($replaceWith); + * $replaceConfigs = [$replaceConfigsElement]; + * $response = $dlpServiceClient->redactContent($inspectConfig, $items, ['replaceConfigs' => $replaceConfigs]); * } finally { * $dlpServiceClient->close(); * } @@ -432,7 +442,7 @@ public function inspectContent($inspectConfig, $items, $optionalArgs = []) * one of these or one ImageRedactionConfig if redacting images. * @type ImageRedactionConfig[] $imageRedactionConfigs * The configuration for specifying what content to redact from images. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -441,7 +451,7 @@ public function inspectContent($inspectConfig, $items, $optionalArgs = []) * * @return \Google\Cloud\Dlp\V2beta1\RedactContentResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function redactContent($inspectConfig, $items, $optionalArgs = []) @@ -457,12 +467,10 @@ public function redactContent($inspectConfig, $items, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/RedactContent', - RedactContentResponse::class, - $request - ), - $this->configureCallSettings('redactContent', $optionalArgs) + 'RedactContent', + RedactContentResponse::class, + $optionalArgs, + $request )->wait(); } @@ -472,8 +480,8 @@ public function redactContent($inspectConfig, $items, $optionalArgs = []) * * Sample code: * ``` + * $dlpServiceClient = new DlpServiceClient(); * try { - * $dlpServiceClient = new DlpServiceClient(); * $deidentifyConfig = new DeidentifyConfig(); * $inspectConfig = new InspectConfig(); * $items = []; @@ -490,7 +498,7 @@ public function redactContent($inspectConfig, $items, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -499,7 +507,7 @@ public function redactContent($inspectConfig, $items, $optionalArgs = []) * * @return \Google\Cloud\Dlp\V2beta1\DeidentifyContentResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deidentifyContent($deidentifyConfig, $inspectConfig, $items, $optionalArgs = []) @@ -510,12 +518,10 @@ public function deidentifyContent($deidentifyConfig, $inspectConfig, $items, $op $request->setItems($items); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeidentifyContent', - DeidentifyContentResponse::class, - $request - ), - $this->configureCallSettings('deidentifyContent', $optionalArgs) + 'DeidentifyContent', + DeidentifyContentResponse::class, + $optionalArgs, + $request )->wait(); } @@ -525,8 +531,8 @@ public function deidentifyContent($deidentifyConfig, $inspectConfig, $items, $op * * Sample code: * ``` + * $dlpServiceClient = new DlpServiceClient(); * try { - * $dlpServiceClient = new DlpServiceClient(); * $privacyMetric = new PrivacyMetric(); * $sourceTable = new BigQueryTable(); * $operationResponse = $dlpServiceClient->analyzeDataSourceRisk($privacyMetric, $sourceTable); @@ -565,7 +571,7 @@ public function deidentifyContent($deidentifyConfig, $inspectConfig, $items, $op * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -574,7 +580,7 @@ public function deidentifyContent($deidentifyConfig, $inspectConfig, $items, $op * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function analyzeDataSourceRisk($privacyMetric, $sourceTable, $optionalArgs = []) @@ -584,14 +590,10 @@ public function analyzeDataSourceRisk($privacyMetric, $sourceTable, $optionalArg $request->setSourceTable($sourceTable); return $this->startOperationsCall( - new Call( - self::SERVICE_NAME.'/AnalyzeDataSourceRisk', - Operation::class, - $request - ), - $this->configureCallSettings('analyzeDataSourceRisk', $optionalArgs), - $this->getOperationsClient(), - $this->descriptors['analyzeDataSourceRisk']['longRunning'] + 'AnalyzeDataSourceRisk', + $optionalArgs, + $request, + $this->getOperationsClient() )->wait(); } @@ -601,8 +603,8 @@ public function analyzeDataSourceRisk($privacyMetric, $sourceTable, $optionalArg * * Sample code: * ``` + * $dlpServiceClient = new DlpServiceClient(); * try { - * $dlpServiceClient = new DlpServiceClient(); * $name = 'EMAIL_ADDRESS'; * $infoTypesElement = new InfoType(); * $infoTypesElement->setName($name); @@ -656,7 +658,7 @@ public function analyzeDataSourceRisk($privacyMetric, $sourceTable, $optionalArg * * @type OperationConfig $operationConfig * Additional configuration settings for long running operations. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -665,7 +667,7 @@ public function analyzeDataSourceRisk($privacyMetric, $sourceTable, $optionalArg * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createInspectOperation($inspectConfig, $storageConfig, $outputConfig, $optionalArgs = []) @@ -679,14 +681,10 @@ public function createInspectOperation($inspectConfig, $storageConfig, $outputCo } return $this->startOperationsCall( - new Call( - self::SERVICE_NAME.'/CreateInspectOperation', - Operation::class, - $request - ), - $this->configureCallSettings('createInspectOperation', $optionalArgs), - $this->getOperationsClient(), - $this->descriptors['createInspectOperation']['longRunning'] + 'CreateInspectOperation', + $optionalArgs, + $request, + $this->getOperationsClient() )->wait(); } @@ -695,8 +693,8 @@ public function createInspectOperation($inspectConfig, $storageConfig, $outputCo * * Sample code: * ``` + * $dlpServiceClient = new DlpServiceClient(); * try { - * $dlpServiceClient = new DlpServiceClient(); * $formattedName = $dlpServiceClient->resultName('[RESULT]'); * $response = $dlpServiceClient->listInspectFindings($formattedName); * } finally { @@ -727,7 +725,7 @@ public function createInspectOperation($inspectConfig, $storageConfig, $outputCo * - likelihood=VERY_LIKELY * - likelihood=VERY_LIKELY,LIKELY * - info_type=EMAIL_ADDRESS,likelihood=VERY_LIKELY,LIKELY - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -736,7 +734,7 @@ public function createInspectOperation($inspectConfig, $storageConfig, $outputCo * * @return \Google\Cloud\Dlp\V2beta1\ListInspectFindingsResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listInspectFindings($name, $optionalArgs = []) @@ -754,12 +752,10 @@ public function listInspectFindings($name, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/ListInspectFindings', - ListInspectFindingsResponse::class, - $request - ), - $this->configureCallSettings('listInspectFindings', $optionalArgs) + 'ListInspectFindings', + ListInspectFindingsResponse::class, + $optionalArgs, + $request )->wait(); } @@ -768,8 +764,8 @@ public function listInspectFindings($name, $optionalArgs = []) * * Sample code: * ``` + * $dlpServiceClient = new DlpServiceClient(); * try { - * $dlpServiceClient = new DlpServiceClient(); * $category = 'PII'; * $languageCode = 'en'; * $response = $dlpServiceClient->listInfoTypes($category, $languageCode); @@ -785,7 +781,7 @@ public function listInspectFindings($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -794,7 +790,7 @@ public function listInspectFindings($name, $optionalArgs = []) * * @return \Google\Cloud\Dlp\V2beta1\ListInfoTypesResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listInfoTypes($category, $languageCode, $optionalArgs = []) @@ -804,12 +800,10 @@ public function listInfoTypes($category, $languageCode, $optionalArgs = []) $request->setLanguageCode($languageCode); return $this->startCall( - new Call( - self::SERVICE_NAME.'/ListInfoTypes', - ListInfoTypesResponse::class, - $request - ), - $this->configureCallSettings('listInfoTypes', $optionalArgs) + 'ListInfoTypes', + ListInfoTypesResponse::class, + $optionalArgs, + $request )->wait(); } @@ -818,8 +812,8 @@ public function listInfoTypes($category, $languageCode, $optionalArgs = []) * * Sample code: * ``` + * $dlpServiceClient = new DlpServiceClient(); * try { - * $dlpServiceClient = new DlpServiceClient(); * $languageCode = 'en'; * $response = $dlpServiceClient->listRootCategories($languageCode); * } finally { @@ -833,7 +827,7 @@ public function listInfoTypes($category, $languageCode, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -842,7 +836,7 @@ public function listInfoTypes($category, $languageCode, $optionalArgs = []) * * @return \Google\Cloud\Dlp\V2beta1\ListRootCategoriesResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listRootCategories($languageCode, $optionalArgs = []) @@ -851,23 +845,10 @@ public function listRootCategories($languageCode, $optionalArgs = []) $request->setLanguageCode($languageCode); return $this->startCall( - new Call( - self::SERVICE_NAME.'/ListRootCategories', - ListRootCategoriesResponse::class, - $request - ), - $this->configureCallSettings('listRootCategories', $optionalArgs) + 'ListRootCategories', + ListRootCategoriesResponse::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Dlp/V2beta1/resources/dlp_service_descriptor_config.php b/src/Dlp/V2beta1/resources/dlp_service_descriptor_config.php index 2c9faf25cc96..121ef2d9be43 100644 --- a/src/Dlp/V2beta1/resources/dlp_service_descriptor_config.php +++ b/src/Dlp/V2beta1/resources/dlp_service_descriptor_config.php @@ -3,13 +3,13 @@ return [ 'interfaces' => [ 'google.privacy.dlp.v2beta1.DlpService' => [ - 'analyzeDataSourceRisk' => [ + 'AnalyzeDataSourceRisk' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\Dlp\V2beta1\RiskAnalysisOperationResult', 'metadataReturnType' => '\Google\Cloud\Dlp\V2beta1\RiskAnalysisOperationMetadata', ], ], - 'createInspectOperation' => [ + 'CreateInspectOperation' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\Dlp\V2beta1\InspectOperationResult', 'metadataReturnType' => '\Google\Cloud\Dlp\V2beta1\InspectOperationMetadata', diff --git a/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php b/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php index c52ccfeede6a..810de5139b2c 100644 --- a/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php +++ b/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php @@ -5,50 +5,54 @@ 'google.privacy.dlp.v2beta1.DlpService' => [ 'InspectContent' => [ 'method' => 'post', - 'uri' => '/v2beta1/content:inspect', + 'uriTemplate' => '/v2beta1/content:inspect', 'body' => '*', ], 'RedactContent' => [ 'method' => 'post', - 'uri' => '/v2beta1/content:redact', + 'uriTemplate' => '/v2beta1/content:redact', 'body' => '*', ], 'DeidentifyContent' => [ 'method' => 'post', - 'uri' => '/v2beta1/content:deidentify', + 'uriTemplate' => '/v2beta1/content:deidentify', 'body' => '*', ], 'AnalyzeDataSourceRisk' => [ 'method' => 'post', - 'uri' => '/v2beta1/dataSource:analyze', + 'uriTemplate' => '/v2beta1/dataSource:analyze', 'body' => '*', ], 'CreateInspectOperation' => [ 'method' => 'post', - 'uri' => '/v2beta1/inspect/operations', + 'uriTemplate' => '/v2beta1/inspect/operations', 'body' => '*', ], 'ListInspectFindings' => [ 'method' => 'get', - 'uri' => '/v2beta1/{name=inspect/results/*}/findings', + 'uriTemplate' => '/v2beta1/{name=inspect/results/*}/findings', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'ListInfoTypes' => [ 'method' => 'get', - 'uri' => '/v2beta1/rootCategories/{category=*}/infoTypes', + 'uriTemplate' => '/v2beta1/rootCategories/{category=*}/infoTypes', 'placeholders' => [ 'category' => [ - 'getCategory', + 'getters' => [ + 'getCategory', + ], ], ], ], 'ListRootCategories' => [ 'method' => 'get', - 'uri' => '/v2beta1/rootCategories', + 'uriTemplate' => '/v2beta1/rootCategories', ], ], ], diff --git a/src/ErrorReporting/V1beta1/ErrorGroupServiceClient.php b/src/ErrorReporting/V1beta1/ErrorGroupServiceClient.php index 7e3257e7bb2d..9c9ad5f00d61 100644 --- a/src/ErrorReporting/V1beta1/ErrorGroupServiceClient.php +++ b/src/ErrorReporting/V1beta1/ErrorGroupServiceClient.php @@ -1,12 +1,12 @@ groupName('[PROJECT]', '[GROUP]'); * $response = $errorGroupServiceClient->getGroup($formattedGroupName); * } finally { @@ -110,6 +114,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/error_group_service_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/error_group_service_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/error_group_service_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -201,10 +206,10 @@ public static function parseName($formattedName, $template = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'clouderrorreporting.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -215,9 +220,9 @@ public static function parseName($formattedName, $template = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Stackdriver Error Reporting API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -235,12 +240,11 @@ public static function parseName($formattedName, $template = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -257,8 +261,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $errorGroupServiceClient = new ErrorGroupServiceClient(); * try { - * $errorGroupServiceClient = new ErrorGroupServiceClient(); * $formattedGroupName = $errorGroupServiceClient->groupName('[PROJECT]', '[GROUP]'); * $response = $errorGroupServiceClient->getGroup($formattedGroupName); * } finally { @@ -277,7 +281,7 @@ public function __construct($options = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -286,7 +290,7 @@ public function __construct($options = []) * * @return \Google\Cloud\ErrorReporting\V1beta1\ErrorGroup * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getGroup($groupName, $optionalArgs = []) @@ -295,12 +299,10 @@ public function getGroup($groupName, $optionalArgs = []) $request->setGroupName($groupName); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetGroup', - ErrorGroup::class, - $request - ), - $this->configureCallSettings('getGroup', $optionalArgs) + 'GetGroup', + ErrorGroup::class, + $optionalArgs, + $request )->wait(); } @@ -310,8 +312,8 @@ public function getGroup($groupName, $optionalArgs = []) * * Sample code: * ``` + * $errorGroupServiceClient = new ErrorGroupServiceClient(); * try { - * $errorGroupServiceClient = new ErrorGroupServiceClient(); * $group = new ErrorGroup(); * $response = $errorGroupServiceClient->updateGroup($group); * } finally { @@ -323,7 +325,7 @@ public function getGroup($groupName, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -332,7 +334,7 @@ public function getGroup($groupName, $optionalArgs = []) * * @return \Google\Cloud\ErrorReporting\V1beta1\ErrorGroup * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateGroup($group, $optionalArgs = []) @@ -341,23 +343,10 @@ public function updateGroup($group, $optionalArgs = []) $request->setGroup($group); return $this->startCall( - new Call( - self::SERVICE_NAME.'/UpdateGroup', - ErrorGroup::class, - $request - ), - $this->configureCallSettings('updateGroup', $optionalArgs) + 'UpdateGroup', + ErrorGroup::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php b/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php index 1349eed157eb..1ed6394e280b 100644 --- a/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php +++ b/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php @@ -1,12 +1,12 @@ projectName('[PROJECT]'); * $timeRange = new QueryTimeRange(); * // Iterate through all elements @@ -131,6 +135,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/error_stats_service_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/error_stats_service_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/error_stats_service_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -220,10 +225,10 @@ public static function parseName($formattedName, $template = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'clouderrorreporting.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -234,9 +239,9 @@ public static function parseName($formattedName, $template = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Stackdriver Error Reporting API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -254,12 +259,11 @@ public static function parseName($formattedName, $template = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -276,8 +280,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $errorStatsServiceClient = new ErrorStatsServiceClient(); * try { - * $errorStatsServiceClient = new ErrorStatsServiceClient(); * $formattedProjectName = $errorStatsServiceClient->projectName('[PROJECT]'); * $timeRange = new QueryTimeRange(); * // Iterate through all elements @@ -343,7 +347,7 @@ public function __construct($options = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -352,7 +356,7 @@ public function __construct($options = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listGroupStats($projectName, $timeRange, $optionalArgs = []) @@ -386,13 +390,10 @@ public function listGroupStats($projectName, $timeRange, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListGroupStats', - ListGroupStatsResponse::class, - $request - ), - $this->configureCallSettings('listGroupStats', $optionalArgs), - $this->descriptors['listGroupStats']['pageStreaming'] + 'ListGroupStats', + $optionalArgs, + ListGroupStatsResponse::class, + $request ); } @@ -401,8 +402,8 @@ public function listGroupStats($projectName, $timeRange, $optionalArgs = []) * * Sample code: * ``` + * $errorStatsServiceClient = new ErrorStatsServiceClient(); * try { - * $errorStatsServiceClient = new ErrorStatsServiceClient(); * $formattedProjectName = $errorStatsServiceClient->projectName('[PROJECT]'); * $groupId = ''; * // Iterate through all elements @@ -449,7 +450,7 @@ public function listGroupStats($projectName, $timeRange, $optionalArgs = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -458,7 +459,7 @@ public function listGroupStats($projectName, $timeRange, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listEvents($projectName, $groupId, $optionalArgs = []) @@ -480,13 +481,10 @@ public function listEvents($projectName, $groupId, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListEvents', - ListEventsResponse::class, - $request - ), - $this->configureCallSettings('listEvents', $optionalArgs), - $this->descriptors['listEvents']['pageStreaming'] + 'ListEvents', + $optionalArgs, + ListEventsResponse::class, + $request ); } @@ -495,8 +493,8 @@ public function listEvents($projectName, $groupId, $optionalArgs = []) * * Sample code: * ``` + * $errorStatsServiceClient = new ErrorStatsServiceClient(); * try { - * $errorStatsServiceClient = new ErrorStatsServiceClient(); * $formattedProjectName = $errorStatsServiceClient->projectName('[PROJECT]'); * $response = $errorStatsServiceClient->deleteEvents($formattedProjectName); * } finally { @@ -512,7 +510,7 @@ public function listEvents($projectName, $groupId, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -521,7 +519,7 @@ public function listEvents($projectName, $groupId, $optionalArgs = []) * * @return \Google\Cloud\ErrorReporting\V1beta1\DeleteEventsResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteEvents($projectName, $optionalArgs = []) @@ -530,23 +528,10 @@ public function deleteEvents($projectName, $optionalArgs = []) $request->setProjectName($projectName); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteEvents', - DeleteEventsResponse::class, - $request - ), - $this->configureCallSettings('deleteEvents', $optionalArgs) + 'DeleteEvents', + DeleteEventsResponse::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php b/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php index 39d129eb9b90..361512b2860e 100644 --- a/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php +++ b/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php @@ -1,12 +1,12 @@ projectName('[PROJECT]'); * $event = new ReportedErrorEvent(); * $response = $reportErrorsServiceClient->reportErrorEvent($formattedProjectName, $event); @@ -111,6 +115,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/report_errors_service_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/report_errors_service_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/report_errors_service_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -200,10 +205,10 @@ public static function parseName($formattedName, $template = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'clouderrorreporting.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -214,9 +219,9 @@ public static function parseName($formattedName, $template = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Stackdriver Error Reporting API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -234,12 +239,11 @@ public static function parseName($formattedName, $template = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -263,8 +267,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $reportErrorsServiceClient = new ReportErrorsServiceClient(); * try { - * $reportErrorsServiceClient = new ReportErrorsServiceClient(); * $formattedProjectName = $reportErrorsServiceClient->projectName('[PROJECT]'); * $event = new ReportedErrorEvent(); * $response = $reportErrorsServiceClient->reportErrorEvent($formattedProjectName, $event); @@ -281,7 +285,7 @@ public function __construct($options = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -290,7 +294,7 @@ public function __construct($options = []) * * @return \Google\Cloud\ErrorReporting\V1beta1\ReportErrorEventResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function reportErrorEvent($projectName, $event, $optionalArgs = []) @@ -300,23 +304,10 @@ public function reportErrorEvent($projectName, $event, $optionalArgs = []) $request->setEvent($event); return $this->startCall( - new Call( - self::SERVICE_NAME.'/ReportErrorEvent', - ReportErrorEventResponse::class, - $request - ), - $this->configureCallSettings('reportErrorEvent', $optionalArgs) + 'ReportErrorEvent', + ReportErrorEventResponse::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/ErrorReporting/V1beta1/ReportErrorsServiceClient.php b/src/ErrorReporting/V1beta1/ReportErrorsServiceClient.php index 8644d612af3c..ddcf0e3e0385 100644 --- a/src/ErrorReporting/V1beta1/ReportErrorsServiceClient.php +++ b/src/ErrorReporting/V1beta1/ReportErrorsServiceClient.php @@ -1,12 +1,12 @@ [ 'GetGroup' => [ 'method' => 'get', - 'uri' => '/v1beta1/{group_name=projects/*/groups/*}', + 'uriTemplate' => '/v1beta1/{group_name=projects/*/groups/*}', 'placeholders' => [ 'group_name' => [ - 'getGroupName', + 'getters' => [ + 'getGroupName', + ], ], ], ], 'UpdateGroup' => [ 'method' => 'put', - 'uri' => '/v1beta1/{group.name=projects/*/groups/*}', + 'uriTemplate' => '/v1beta1/{group.name=projects/*/groups/*}', 'body' => 'group', 'placeholders' => [ 'group.name' => [ - 'getGroup', - 'getName', + 'getters' => [ + 'getGroup', + 'getName', + ], ], ], ], diff --git a/src/ErrorReporting/V1beta1/resources/error_stats_service_descriptor_config.php b/src/ErrorReporting/V1beta1/resources/error_stats_service_descriptor_config.php index 14f1b47a87bf..3e892a7ac884 100644 --- a/src/ErrorReporting/V1beta1/resources/error_stats_service_descriptor_config.php +++ b/src/ErrorReporting/V1beta1/resources/error_stats_service_descriptor_config.php @@ -3,7 +3,7 @@ return [ 'interfaces' => [ 'google.devtools.clouderrorreporting.v1beta1.ErrorStatsService' => [ - 'listGroupStats' => [ + 'ListGroupStats' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', @@ -13,7 +13,7 @@ 'resourcesGetMethod' => 'getErrorGroupStats', ], ], - 'listEvents' => [ + 'ListEvents' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', diff --git a/src/ErrorReporting/V1beta1/resources/error_stats_service_rest_client_config.php b/src/ErrorReporting/V1beta1/resources/error_stats_service_rest_client_config.php index ec136d0a6aac..850e39943267 100644 --- a/src/ErrorReporting/V1beta1/resources/error_stats_service_rest_client_config.php +++ b/src/ErrorReporting/V1beta1/resources/error_stats_service_rest_client_config.php @@ -5,28 +5,34 @@ 'google.devtools.clouderrorreporting.v1beta1.ErrorStatsService' => [ 'ListGroupStats' => [ 'method' => 'get', - 'uri' => '/v1beta1/{project_name=projects/*}/groupStats', + 'uriTemplate' => '/v1beta1/{project_name=projects/*}/groupStats', 'placeholders' => [ 'project_name' => [ - 'getProjectName', + 'getters' => [ + 'getProjectName', + ], ], ], ], 'ListEvents' => [ 'method' => 'get', - 'uri' => '/v1beta1/{project_name=projects/*}/events', + 'uriTemplate' => '/v1beta1/{project_name=projects/*}/events', 'placeholders' => [ 'project_name' => [ - 'getProjectName', + 'getters' => [ + 'getProjectName', + ], ], ], ], 'DeleteEvents' => [ 'method' => 'delete', - 'uri' => '/v1beta1/{project_name=projects/*}/events', + 'uriTemplate' => '/v1beta1/{project_name=projects/*}/events', 'placeholders' => [ 'project_name' => [ - 'getProjectName', + 'getters' => [ + 'getProjectName', + ], ], ], ], diff --git a/src/ErrorReporting/V1beta1/resources/report_errors_service_rest_client_config.php b/src/ErrorReporting/V1beta1/resources/report_errors_service_rest_client_config.php index 7513e50831c8..f2c99ae79229 100644 --- a/src/ErrorReporting/V1beta1/resources/report_errors_service_rest_client_config.php +++ b/src/ErrorReporting/V1beta1/resources/report_errors_service_rest_client_config.php @@ -5,11 +5,13 @@ 'google.devtools.clouderrorreporting.v1beta1.ReportErrorsService' => [ 'ReportErrorEvent' => [ 'method' => 'post', - 'uri' => '/v1beta1/{project_name=projects/*}/events:report', + 'uriTemplate' => '/v1beta1/{project_name=projects/*}/events:report', 'body' => 'event', 'placeholders' => [ 'project_name' => [ - 'getProjectName', + 'getters' => [ + 'getProjectName', + ], ], ], ], diff --git a/src/Firestore/V1beta1/FirestoreClient.php b/src/Firestore/V1beta1/FirestoreClient.php index 89b1042cc55a..dc32bbc745e3 100644 --- a/src/Firestore/V1beta1/FirestoreClient.php +++ b/src/Firestore/V1beta1/FirestoreClient.php @@ -1,12 +1,12 @@ anyPathName('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); * $response = $firestoreClient->getDocument($formattedName); * } finally { @@ -156,6 +161,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/firestore_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/firestore_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/firestore_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -340,10 +346,10 @@ public static function parseName($formattedName, $template = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'firestore.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -354,9 +360,9 @@ public static function parseName($formattedName, $template = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Google Cloud Firestore API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -374,12 +380,11 @@ public static function parseName($formattedName, $template = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -396,8 +401,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $firestoreClient = new FirestoreClient(); * try { - * $firestoreClient = new FirestoreClient(); * $formattedName = $firestoreClient->anyPathName('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); * $response = $firestoreClient->getDocument($formattedName); * } finally { @@ -420,7 +425,7 @@ public function __construct($options = []) * @type Timestamp $readTime * Reads the version of the document at the given time. * This may not be older than 60 seconds. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -429,7 +434,7 @@ public function __construct($options = []) * * @return \Google\Cloud\Firestore\V1beta1\Document * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getDocument($name, $optionalArgs = []) @@ -447,12 +452,10 @@ public function getDocument($name, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetDocument', - Document::class, - $request - ), - $this->configureCallSettings('getDocument', $optionalArgs) + 'GetDocument', + Document::class, + $optionalArgs, + $request )->wait(); } @@ -461,8 +464,8 @@ public function getDocument($name, $optionalArgs = []) * * Sample code: * ``` + * $firestoreClient = new FirestoreClient(); * try { - * $firestoreClient = new FirestoreClient(); * $formattedParent = $firestoreClient->anyPathName('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); * $collectionId = ''; * // Iterate through all elements @@ -523,7 +526,7 @@ public function getDocument($name, $optionalArgs = []) * * Requests with `show_missing` may not specify `where` or * `order_by`. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -532,7 +535,7 @@ public function getDocument($name, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listDocuments($parent, $collectionId, $optionalArgs = []) @@ -563,13 +566,10 @@ public function listDocuments($parent, $collectionId, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListDocuments', - ListDocumentsResponse::class, - $request - ), - $this->configureCallSettings('listDocuments', $optionalArgs), - $this->descriptors['listDocuments']['pageStreaming'] + 'ListDocuments', + $optionalArgs, + ListDocumentsResponse::class, + $request ); } @@ -578,8 +578,8 @@ public function listDocuments($parent, $collectionId, $optionalArgs = []) * * Sample code: * ``` + * $firestoreClient = new FirestoreClient(); * try { - * $firestoreClient = new FirestoreClient(); * $formattedParent = $firestoreClient->anyPathName('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); * $collectionId = ''; * $documentId = ''; @@ -606,7 +606,7 @@ public function listDocuments($parent, $collectionId, $optionalArgs = []) * * If the document has a field that is not present in this mask, that field * will not be returned in the response. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -615,7 +615,7 @@ public function listDocuments($parent, $collectionId, $optionalArgs = []) * * @return \Google\Cloud\Firestore\V1beta1\Document * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createDocument($parent, $collectionId, $documentId, $document, $optionalArgs = []) @@ -630,12 +630,10 @@ public function createDocument($parent, $collectionId, $documentId, $document, $ } return $this->startCall( - new Call( - self::SERVICE_NAME.'/CreateDocument', - Document::class, - $request - ), - $this->configureCallSettings('createDocument', $optionalArgs) + 'CreateDocument', + Document::class, + $optionalArgs, + $request )->wait(); } @@ -644,8 +642,8 @@ public function createDocument($parent, $collectionId, $documentId, $document, $ * * Sample code: * ``` + * $firestoreClient = new FirestoreClient(); * try { - * $firestoreClient = new FirestoreClient(); * $document = new Document(); * $updateMask = new DocumentMask(); * $response = $firestoreClient->updateDocument($document, $updateMask); @@ -674,7 +672,7 @@ public function createDocument($parent, $collectionId, $documentId, $document, $ * @type Precondition $currentDocument * An optional precondition on the document. * The request will fail if this is set and not met by the target document. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -683,7 +681,7 @@ public function createDocument($parent, $collectionId, $documentId, $document, $ * * @return \Google\Cloud\Firestore\V1beta1\Document * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateDocument($document, $updateMask, $optionalArgs = []) @@ -699,12 +697,10 @@ public function updateDocument($document, $updateMask, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/UpdateDocument', - Document::class, - $request - ), - $this->configureCallSettings('updateDocument', $optionalArgs) + 'UpdateDocument', + Document::class, + $optionalArgs, + $request )->wait(); } @@ -713,8 +709,8 @@ public function updateDocument($document, $updateMask, $optionalArgs = []) * * Sample code: * ``` + * $firestoreClient = new FirestoreClient(); * try { - * $firestoreClient = new FirestoreClient(); * $formattedName = $firestoreClient->anyPathName('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); * $firestoreClient->deleteDocument($formattedName); * } finally { @@ -730,14 +726,14 @@ public function updateDocument($document, $updateMask, $optionalArgs = []) * @type Precondition $currentDocument * An optional precondition on the document. * The request will fail if this is set and not met by the target document. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteDocument($name, $optionalArgs = []) @@ -749,12 +745,10 @@ public function deleteDocument($name, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteDocument', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteDocument', $optionalArgs) + 'DeleteDocument', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -766,8 +760,8 @@ public function deleteDocument($name, $optionalArgs = []) * * Sample code: * ``` + * $firestoreClient = new FirestoreClient(); * try { - * $firestoreClient = new FirestoreClient(); * $formattedDatabase = $firestoreClient->databaseRootName('[PROJECT]', '[DATABASE]'); * $documents = []; * // Read all responses until the stream is complete @@ -810,7 +804,7 @@ public function deleteDocument($name, $optionalArgs = []) * * @return \Google\ApiCore\ServerStream * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function batchGetDocuments($database, $documents, $optionalArgs = []) @@ -831,14 +825,12 @@ public function batchGetDocuments($database, $documents, $optionalArgs = []) $request->setReadTime($optionalArgs['readTime']); } - return $this->transport->startServerStreamingCall( - new Call( - self::SERVICE_NAME.'/BatchGetDocuments', - BatchGetDocumentsResponse::class, - $request - ), - $this->configureCallSettings('batchGetDocuments', $optionalArgs), - $this->descriptors['batchGetDocuments']['grpcStreaming'] + return $this->startCall( + 'BatchGetDocuments', + BatchGetDocumentsResponse::class, + $optionalArgs, + $request, + Call::SERVER_STREAMING_CALL ); } @@ -847,8 +839,8 @@ public function batchGetDocuments($database, $documents, $optionalArgs = []) * * Sample code: * ``` + * $firestoreClient = new FirestoreClient(); * try { - * $firestoreClient = new FirestoreClient(); * $formattedDatabase = $firestoreClient->databaseRootName('[PROJECT]', '[DATABASE]'); * $response = $firestoreClient->beginTransaction($formattedDatabase); * } finally { @@ -864,7 +856,7 @@ public function batchGetDocuments($database, $documents, $optionalArgs = []) * @type TransactionOptions $options * The options for the transaction. * Defaults to a read-write transaction. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -873,7 +865,7 @@ public function batchGetDocuments($database, $documents, $optionalArgs = []) * * @return \Google\Cloud\Firestore\V1beta1\BeginTransactionResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function beginTransaction($database, $optionalArgs = []) @@ -885,12 +877,10 @@ public function beginTransaction($database, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/BeginTransaction', - BeginTransactionResponse::class, - $request - ), - $this->configureCallSettings('beginTransaction', $optionalArgs) + 'BeginTransaction', + BeginTransactionResponse::class, + $optionalArgs, + $request )->wait(); } @@ -899,8 +889,8 @@ public function beginTransaction($database, $optionalArgs = []) * * Sample code: * ``` + * $firestoreClient = new FirestoreClient(); * try { - * $firestoreClient = new FirestoreClient(); * $formattedDatabase = $firestoreClient->databaseRootName('[PROJECT]', '[DATABASE]'); * $writes = []; * $response = $firestoreClient->commit($formattedDatabase, $writes); @@ -919,7 +909,7 @@ public function beginTransaction($database, $optionalArgs = []) * * @type string $transaction * If set, applies all writes in this transaction, and commits it. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -928,7 +918,7 @@ public function beginTransaction($database, $optionalArgs = []) * * @return \Google\Cloud\Firestore\V1beta1\CommitResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function commit($database, $writes, $optionalArgs = []) @@ -941,12 +931,10 @@ public function commit($database, $writes, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/Commit', - CommitResponse::class, - $request - ), - $this->configureCallSettings('commit', $optionalArgs) + 'Commit', + CommitResponse::class, + $optionalArgs, + $request )->wait(); } @@ -955,8 +943,8 @@ public function commit($database, $writes, $optionalArgs = []) * * Sample code: * ``` + * $firestoreClient = new FirestoreClient(); * try { - * $firestoreClient = new FirestoreClient(); * $formattedDatabase = $firestoreClient->databaseRootName('[PROJECT]', '[DATABASE]'); * $transaction = ''; * $firestoreClient->rollback($formattedDatabase, $transaction); @@ -971,14 +959,14 @@ public function commit($database, $writes, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function rollback($database, $transaction, $optionalArgs = []) @@ -988,12 +976,10 @@ public function rollback($database, $transaction, $optionalArgs = []) $request->setTransaction($transaction); return $this->startCall( - new Call( - self::SERVICE_NAME.'/Rollback', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('rollback', $optionalArgs) + 'Rollback', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -1002,8 +988,8 @@ public function rollback($database, $transaction, $optionalArgs = []) * * Sample code: * ``` + * $firestoreClient = new FirestoreClient(); * try { - * $firestoreClient = new FirestoreClient(); * $formattedParent = $firestoreClient->anyPathName('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); * // Read all responses until the stream is complete * $stream = $firestoreClient->runQuery($formattedParent); @@ -1042,7 +1028,7 @@ public function rollback($database, $transaction, $optionalArgs = []) * * @return \Google\ApiCore\ServerStream * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function runQuery($parent, $optionalArgs = []) @@ -1062,14 +1048,12 @@ public function runQuery($parent, $optionalArgs = []) $request->setReadTime($optionalArgs['readTime']); } - return $this->transport->startServerStreamingCall( - new Call( - self::SERVICE_NAME.'/RunQuery', - RunQueryResponse::class, - $request - ), - $this->configureCallSettings('runQuery', $optionalArgs), - $this->descriptors['runQuery']['grpcStreaming'] + return $this->startCall( + 'RunQuery', + RunQueryResponse::class, + $optionalArgs, + $request, + Call::SERVER_STREAMING_CALL ); } @@ -1078,8 +1062,8 @@ public function runQuery($parent, $optionalArgs = []) * * Sample code: * ``` + * $firestoreClient = new FirestoreClient(); * try { - * $firestoreClient = new FirestoreClient(); * $formattedDatabase = $firestoreClient->databaseRootName('[PROJECT]', '[DATABASE]'); * $request = new WriteRequest(); * $request->setDatabase($formattedDatabase); @@ -1123,18 +1107,17 @@ public function runQuery($parent, $optionalArgs = []) * * @return \Google\ApiCore\BidiStream * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function write($optionalArgs = []) { - return $this->transport->startBidiStreamingCall( - new Call( - self::SERVICE_NAME.'/Write', - WriteResponse::class - ), - $this->configureCallSettings('write', $optionalArgs), - $this->descriptors['write']['grpcStreaming'] + return $this->startCall( + 'Write', + WriteResponse::class, + $optionalArgs, + null, + Call::BIDI_STREAMING_CALL ); } @@ -1143,8 +1126,8 @@ public function write($optionalArgs = []) * * Sample code: * ``` + * $firestoreClient = new FirestoreClient(); * try { - * $firestoreClient = new FirestoreClient(); * $formattedDatabase = $firestoreClient->databaseRootName('[PROJECT]', '[DATABASE]'); * $request = new ListenRequest(); * $request->setDatabase($formattedDatabase); @@ -1188,18 +1171,17 @@ public function write($optionalArgs = []) * * @return \Google\ApiCore\BidiStream * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listen($optionalArgs = []) { - return $this->transport->startBidiStreamingCall( - new Call( - self::SERVICE_NAME.'/Listen', - ListenResponse::class - ), - $this->configureCallSettings('listen', $optionalArgs), - $this->descriptors['listen']['grpcStreaming'] + return $this->startCall( + 'Listen', + ListenResponse::class, + $optionalArgs, + null, + Call::BIDI_STREAMING_CALL ); } @@ -1208,8 +1190,8 @@ public function listen($optionalArgs = []) * * Sample code: * ``` + * $firestoreClient = new FirestoreClient(); * try { - * $firestoreClient = new FirestoreClient(); * $formattedParent = $firestoreClient->anyPathName('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); * // Iterate through all elements * $pagedResponse = $firestoreClient->listCollectionIds($formattedParent); @@ -1245,7 +1227,7 @@ public function listen($optionalArgs = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1254,7 +1236,7 @@ public function listen($optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listCollectionIds($parent, $optionalArgs = []) @@ -1269,24 +1251,10 @@ public function listCollectionIds($parent, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListCollectionIds', - ListCollectionIdsResponse::class, - $request - ), - $this->configureCallSettings('listCollectionIds', $optionalArgs), - $this->descriptors['listCollectionIds']['pageStreaming'] + 'ListCollectionIds', + $optionalArgs, + ListCollectionIdsResponse::class, + $request ); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Firestore/V1beta1/resources/firestore_descriptor_config.php b/src/Firestore/V1beta1/resources/firestore_descriptor_config.php index c92d6bacdc23..086a90ebe92a 100644 --- a/src/Firestore/V1beta1/resources/firestore_descriptor_config.php +++ b/src/Firestore/V1beta1/resources/firestore_descriptor_config.php @@ -3,7 +3,7 @@ return [ 'interfaces' => [ 'google.firestore.v1beta1.Firestore' => [ - 'listDocuments' => [ + 'ListDocuments' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', @@ -13,7 +13,7 @@ 'resourcesGetMethod' => 'getDocuments', ], ], - 'listCollectionIds' => [ + 'ListCollectionIds' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', @@ -23,22 +23,22 @@ 'resourcesGetMethod' => 'getCollectionIds', ], ], - 'batchGetDocuments' => [ + 'BatchGetDocuments' => [ 'grpcStreaming' => [ 'grpcStreamingType' => 'ServerStreaming', ], ], - 'runQuery' => [ + 'RunQuery' => [ 'grpcStreaming' => [ 'grpcStreamingType' => 'ServerStreaming', ], ], - 'write' => [ + 'Write' => [ 'grpcStreaming' => [ 'grpcStreamingType' => 'BidiStreaming', ], ], - 'listen' => [ + 'Listen' => [ 'grpcStreaming' => [ 'grpcStreamingType' => 'BidiStreaming', ], diff --git a/src/Firestore/V1beta1/resources/firestore_rest_client_config.php b/src/Firestore/V1beta1/resources/firestore_rest_client_config.php index f53187dad9f9..cd8749c1461e 100644 --- a/src/Firestore/V1beta1/resources/firestore_rest_client_config.php +++ b/src/Firestore/V1beta1/resources/firestore_rest_client_config.php @@ -5,115 +5,117 @@ 'google.firestore.v1beta1.Firestore' => [ 'GetDocument' => [ 'method' => 'get', - 'uri' => '/v1beta1/{name=projects/*/databases/*/documents/*/**}', + 'uriTemplate' => '/v1beta1/{name=projects/*/databases/*/documents/*/**}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'ListDocuments' => [ 'method' => 'get', - 'uri' => '/v1beta1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}', + 'uriTemplate' => '/v1beta1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], 'collection_id' => [ - 'getCollectionId', + 'getters' => [ + 'getCollectionId', + ], ], ], ], 'CreateDocument' => [ 'method' => 'post', - 'uri' => '/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}', + 'uriTemplate' => '/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}', 'body' => 'document', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], 'collection_id' => [ - 'getCollectionId', + 'getters' => [ + 'getCollectionId', + ], ], ], ], 'UpdateDocument' => [ 'method' => 'patch', - 'uri' => '/v1beta1/{document.name=projects/*/databases/*/documents/*/**}', + 'uriTemplate' => '/v1beta1/{document.name=projects/*/databases/*/documents/*/**}', 'body' => 'document', 'placeholders' => [ 'document.name' => [ - 'getDocument', - 'getName', + 'getters' => [ + 'getDocument', + 'getName', + ], ], ], ], 'DeleteDocument' => [ 'method' => 'delete', - 'uri' => '/v1beta1/{name=projects/*/databases/*/documents/*/**}', + 'uriTemplate' => '/v1beta1/{name=projects/*/databases/*/documents/*/**}', 'placeholders' => [ 'name' => [ - 'getName', - ], - ], - ], - 'BatchGetDocuments' => [ - 'method' => 'post', - 'uri' => '/v1beta1/{database=projects/*/databases/*}/documents:batchGet', - 'body' => '*', - 'placeholders' => [ - 'database' => [ - 'getDatabase', + 'getters' => [ + 'getName', + ], ], ], ], 'BeginTransaction' => [ 'method' => 'post', - 'uri' => '/v1beta1/{database=projects/*/databases/*}/documents:beginTransaction', + 'uriTemplate' => '/v1beta1/{database=projects/*/databases/*}/documents:beginTransaction', 'body' => '*', 'placeholders' => [ 'database' => [ - 'getDatabase', + 'getters' => [ + 'getDatabase', + ], ], ], ], 'Commit' => [ 'method' => 'post', - 'uri' => '/v1beta1/{database=projects/*/databases/*}/documents:commit', + 'uriTemplate' => '/v1beta1/{database=projects/*/databases/*}/documents:commit', 'body' => '*', 'placeholders' => [ 'database' => [ - 'getDatabase', + 'getters' => [ + 'getDatabase', + ], ], ], ], 'Rollback' => [ 'method' => 'post', - 'uri' => '/v1beta1/{database=projects/*/databases/*}/documents:rollback', + 'uriTemplate' => '/v1beta1/{database=projects/*/databases/*}/documents:rollback', 'body' => '*', 'placeholders' => [ 'database' => [ - 'getDatabase', - ], - ], - ], - 'RunQuery' => [ - 'method' => 'post', - 'uri' => '/v1beta1/{parent=projects/*/databases/*/documents}:runQuery', - 'body' => '*', - 'placeholders' => [ - 'parent' => [ - 'getParent', + 'getters' => [ + 'getDatabase', + ], ], ], ], 'ListCollectionIds' => [ 'method' => 'post', - 'uri' => '/v1beta1/{parent=projects/*/databases/*/documents}:listCollectionIds', + 'uriTemplate' => '/v1beta1/{parent=projects/*/databases/*/documents}:listCollectionIds', 'body' => '*', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], diff --git a/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php b/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php index a38ee95fc205..966cda25bcc9 100644 --- a/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php +++ b/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php @@ -1,12 +1,12 @@ analyzeSentiment($document); * } finally { @@ -113,6 +117,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/language_service_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/language_service_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/language_service_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -125,10 +130,10 @@ private static function getClientDefaults() * @type string $serviceAddress The domain name of the API remote host. * Default 'language.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -139,9 +144,9 @@ private static function getClientDefaults() * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Google Cloud Natural Language API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -159,12 +164,11 @@ private static function getClientDefaults() * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -181,8 +185,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $languageServiceClient = new LanguageServiceClient(); * try { - * $languageServiceClient = new LanguageServiceClient(); * $document = new Document(); * $response = $languageServiceClient->analyzeSentiment($document); * } finally { @@ -198,7 +202,7 @@ public function __construct($options = []) * The encoding type used by the API to calculate sentence offsets for the * sentence sentiment. * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1beta2\EncodingType} - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -207,7 +211,7 @@ public function __construct($options = []) * * @return \Google\Cloud\Language\V1beta2\AnalyzeSentimentResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function analyzeSentiment($document, $optionalArgs = []) @@ -219,12 +223,10 @@ public function analyzeSentiment($document, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/AnalyzeSentiment', - AnalyzeSentimentResponse::class, - $request - ), - $this->configureCallSettings('analyzeSentiment', $optionalArgs) + 'AnalyzeSentiment', + AnalyzeSentimentResponse::class, + $optionalArgs, + $request )->wait(); } @@ -235,8 +237,8 @@ public function analyzeSentiment($document, $optionalArgs = []) * * Sample code: * ``` + * $languageServiceClient = new LanguageServiceClient(); * try { - * $languageServiceClient = new LanguageServiceClient(); * $document = new Document(); * $response = $languageServiceClient->analyzeEntities($document); * } finally { @@ -251,7 +253,7 @@ public function analyzeSentiment($document, $optionalArgs = []) * @type int $encodingType * The encoding type used by the API to calculate offsets. * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1beta2\EncodingType} - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -260,7 +262,7 @@ public function analyzeSentiment($document, $optionalArgs = []) * * @return \Google\Cloud\Language\V1beta2\AnalyzeEntitiesResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function analyzeEntities($document, $optionalArgs = []) @@ -272,12 +274,10 @@ public function analyzeEntities($document, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/AnalyzeEntities', - AnalyzeEntitiesResponse::class, - $request - ), - $this->configureCallSettings('analyzeEntities', $optionalArgs) + 'AnalyzeEntities', + AnalyzeEntitiesResponse::class, + $optionalArgs, + $request )->wait(); } @@ -287,8 +287,8 @@ public function analyzeEntities($document, $optionalArgs = []) * * Sample code: * ``` + * $languageServiceClient = new LanguageServiceClient(); * try { - * $languageServiceClient = new LanguageServiceClient(); * $document = new Document(); * $response = $languageServiceClient->analyzeEntitySentiment($document); * } finally { @@ -303,7 +303,7 @@ public function analyzeEntities($document, $optionalArgs = []) * @type int $encodingType * The encoding type used by the API to calculate offsets. * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1beta2\EncodingType} - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -312,7 +312,7 @@ public function analyzeEntities($document, $optionalArgs = []) * * @return \Google\Cloud\Language\V1beta2\AnalyzeEntitySentimentResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function analyzeEntitySentiment($document, $optionalArgs = []) @@ -324,12 +324,10 @@ public function analyzeEntitySentiment($document, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/AnalyzeEntitySentiment', - AnalyzeEntitySentimentResponse::class, - $request - ), - $this->configureCallSettings('analyzeEntitySentiment', $optionalArgs) + 'AnalyzeEntitySentiment', + AnalyzeEntitySentimentResponse::class, + $optionalArgs, + $request )->wait(); } @@ -340,8 +338,8 @@ public function analyzeEntitySentiment($document, $optionalArgs = []) * * Sample code: * ``` + * $languageServiceClient = new LanguageServiceClient(); * try { - * $languageServiceClient = new LanguageServiceClient(); * $document = new Document(); * $response = $languageServiceClient->analyzeSyntax($document); * } finally { @@ -356,7 +354,7 @@ public function analyzeEntitySentiment($document, $optionalArgs = []) * @type int $encodingType * The encoding type used by the API to calculate offsets. * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1beta2\EncodingType} - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -365,7 +363,7 @@ public function analyzeEntitySentiment($document, $optionalArgs = []) * * @return \Google\Cloud\Language\V1beta2\AnalyzeSyntaxResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function analyzeSyntax($document, $optionalArgs = []) @@ -377,12 +375,10 @@ public function analyzeSyntax($document, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/AnalyzeSyntax', - AnalyzeSyntaxResponse::class, - $request - ), - $this->configureCallSettings('analyzeSyntax', $optionalArgs) + 'AnalyzeSyntax', + AnalyzeSyntaxResponse::class, + $optionalArgs, + $request )->wait(); } @@ -391,8 +387,8 @@ public function analyzeSyntax($document, $optionalArgs = []) * * Sample code: * ``` + * $languageServiceClient = new LanguageServiceClient(); * try { - * $languageServiceClient = new LanguageServiceClient(); * $document = new Document(); * $response = $languageServiceClient->classifyText($document); * } finally { @@ -404,7 +400,7 @@ public function analyzeSyntax($document, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -413,7 +409,7 @@ public function analyzeSyntax($document, $optionalArgs = []) * * @return \Google\Cloud\Language\V1beta2\ClassifyTextResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function classifyText($document, $optionalArgs = []) @@ -422,12 +418,10 @@ public function classifyText($document, $optionalArgs = []) $request->setDocument($document); return $this->startCall( - new Call( - self::SERVICE_NAME.'/ClassifyText', - ClassifyTextResponse::class, - $request - ), - $this->configureCallSettings('classifyText', $optionalArgs) + 'ClassifyText', + ClassifyTextResponse::class, + $optionalArgs, + $request )->wait(); } @@ -437,8 +431,8 @@ public function classifyText($document, $optionalArgs = []) * * Sample code: * ``` + * $languageServiceClient = new LanguageServiceClient(); * try { - * $languageServiceClient = new LanguageServiceClient(); * $document = new Document(); * $features = new Features(); * $response = $languageServiceClient->annotateText($document, $features); @@ -455,7 +449,7 @@ public function classifyText($document, $optionalArgs = []) * @type int $encodingType * The encoding type used by the API to calculate offsets. * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1beta2\EncodingType} - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -464,7 +458,7 @@ public function classifyText($document, $optionalArgs = []) * * @return \Google\Cloud\Language\V1beta2\AnnotateTextResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function annotateText($document, $features, $optionalArgs = []) @@ -477,23 +471,10 @@ public function annotateText($document, $features, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/AnnotateText', - AnnotateTextResponse::class, - $request - ), - $this->configureCallSettings('annotateText', $optionalArgs) + 'AnnotateText', + AnnotateTextResponse::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Language/V1beta2/LanguageServiceClient.php b/src/Language/V1beta2/LanguageServiceClient.php index 48c460702416..9a9907a91ac8 100644 --- a/src/Language/V1beta2/LanguageServiceClient.php +++ b/src/Language/V1beta2/LanguageServiceClient.php @@ -1,12 +1,12 @@ [ 'AnalyzeSentiment' => [ 'method' => 'post', - 'uri' => '/v1beta2/documents:analyzeSentiment', + 'uriTemplate' => '/v1beta2/documents:analyzeSentiment', 'body' => '*', ], 'AnalyzeEntities' => [ 'method' => 'post', - 'uri' => '/v1beta2/documents:analyzeEntities', + 'uriTemplate' => '/v1beta2/documents:analyzeEntities', 'body' => '*', ], 'AnalyzeEntitySentiment' => [ 'method' => 'post', - 'uri' => '/v1beta2/documents:analyzeEntitySentiment', + 'uriTemplate' => '/v1beta2/documents:analyzeEntitySentiment', 'body' => '*', ], 'AnalyzeSyntax' => [ 'method' => 'post', - 'uri' => '/v1beta2/documents:analyzeSyntax', + 'uriTemplate' => '/v1beta2/documents:analyzeSyntax', 'body' => '*', ], 'ClassifyText' => [ 'method' => 'post', - 'uri' => '/v1beta2/documents:classifyText', + 'uriTemplate' => '/v1beta2/documents:classifyText', 'body' => '*', ], 'AnnotateText' => [ 'method' => 'post', - 'uri' => '/v1beta2/documents:annotateText', + 'uriTemplate' => '/v1beta2/documents:annotateText', 'body' => '*', ], ], diff --git a/src/Logging/V2/ConfigServiceV2Client.php b/src/Logging/V2/ConfigServiceV2Client.php index 21b0804f7342..f46cf221b9b9 100644 --- a/src/Logging/V2/ConfigServiceV2Client.php +++ b/src/Logging/V2/ConfigServiceV2Client.php @@ -1,12 +1,12 @@ projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $configServiceV2Client->listSinks($formattedParent); @@ -142,6 +146,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/config_service_v2_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/config_service_v2_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/config_service_v2_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -289,10 +294,10 @@ public static function parseName($formattedName, $template = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'logging.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -303,9 +308,9 @@ public static function parseName($formattedName, $template = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Stackdriver Logging API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -323,12 +328,11 @@ public static function parseName($formattedName, $template = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -345,8 +349,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $configServiceV2Client = new ConfigServiceV2Client(); * $formattedParent = $configServiceV2Client->projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $configServiceV2Client->listSinks($formattedParent); @@ -384,7 +388,7 @@ public function __construct($options = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -393,7 +397,7 @@ public function __construct($options = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listSinks($parent, $optionalArgs = []) @@ -408,13 +412,10 @@ public function listSinks($parent, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListSinks', - ListSinksResponse::class, - $request - ), - $this->configureCallSettings('listSinks', $optionalArgs), - $this->descriptors['listSinks']['pageStreaming'] + 'ListSinks', + $optionalArgs, + ListSinksResponse::class, + $request ); } @@ -423,8 +424,8 @@ public function listSinks($parent, $optionalArgs = []) * * Sample code: * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $configServiceV2Client = new ConfigServiceV2Client(); * $formattedSinkName = $configServiceV2Client->sinkName('[PROJECT]', '[SINK]'); * $response = $configServiceV2Client->getSink($formattedSinkName); * } finally { @@ -443,7 +444,7 @@ public function listSinks($parent, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -452,7 +453,7 @@ public function listSinks($parent, $optionalArgs = []) * * @return \Google\Cloud\Logging\V2\LogSink * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getSink($sinkName, $optionalArgs = []) @@ -461,12 +462,10 @@ public function getSink($sinkName, $optionalArgs = []) $request->setSinkName($sinkName); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetSink', - LogSink::class, - $request - ), - $this->configureCallSettings('getSink', $optionalArgs) + 'GetSink', + LogSink::class, + $optionalArgs, + $request )->wait(); } @@ -478,8 +477,8 @@ public function getSink($sinkName, $optionalArgs = []) * * Sample code: * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $configServiceV2Client = new ConfigServiceV2Client(); * $formattedParent = $configServiceV2Client->projectName('[PROJECT]'); * $sink = new LogSink(); * $response = $configServiceV2Client->createSink($formattedParent, $sink); @@ -513,7 +512,7 @@ public function getSink($sinkName, $optionalArgs = []) * resource such as an organization, then the value of `writer_identity` will * be a unique service account used only for exports from the new sink. For * more information, see `writer_identity` in [LogSink][google.logging.v2.LogSink]. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -522,7 +521,7 @@ public function getSink($sinkName, $optionalArgs = []) * * @return \Google\Cloud\Logging\V2\LogSink * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createSink($parent, $sink, $optionalArgs = []) @@ -535,12 +534,10 @@ public function createSink($parent, $sink, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/CreateSink', - LogSink::class, - $request - ), - $this->configureCallSettings('createSink', $optionalArgs) + 'CreateSink', + LogSink::class, + $optionalArgs, + $request )->wait(); } @@ -552,8 +549,8 @@ public function createSink($parent, $sink, $optionalArgs = []) * * Sample code: * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $configServiceV2Client = new ConfigServiceV2Client(); * $formattedSinkName = $configServiceV2Client->sinkName('[PROJECT]', '[SINK]'); * $sink = new LogSink(); * $response = $configServiceV2Client->updateSink($formattedSinkName, $sink); @@ -604,7 +601,7 @@ public function createSink($parent, $sink, $optionalArgs = []) * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask * * Example: `updateMask=filter`. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -613,7 +610,7 @@ public function createSink($parent, $sink, $optionalArgs = []) * * @return \Google\Cloud\Logging\V2\LogSink * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateSink($sinkName, $sink, $optionalArgs = []) @@ -629,12 +626,10 @@ public function updateSink($sinkName, $sink, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/UpdateSink', - LogSink::class, - $request - ), - $this->configureCallSettings('updateSink', $optionalArgs) + 'UpdateSink', + LogSink::class, + $optionalArgs, + $request )->wait(); } @@ -644,8 +639,8 @@ public function updateSink($sinkName, $sink, $optionalArgs = []) * * Sample code: * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $configServiceV2Client = new ConfigServiceV2Client(); * $formattedSinkName = $configServiceV2Client->sinkName('[PROJECT]', '[SINK]'); * $configServiceV2Client->deleteSink($formattedSinkName); * } finally { @@ -665,14 +660,14 @@ public function updateSink($sinkName, $sink, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteSink($sinkName, $optionalArgs = []) @@ -681,12 +676,10 @@ public function deleteSink($sinkName, $optionalArgs = []) $request->setSinkName($sinkName); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteSink', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteSink', $optionalArgs) + 'DeleteSink', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -695,8 +688,8 @@ public function deleteSink($sinkName, $optionalArgs = []) * * Sample code: * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $configServiceV2Client = new ConfigServiceV2Client(); * $formattedParent = $configServiceV2Client->projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $configServiceV2Client->listExclusions($formattedParent); @@ -734,7 +727,7 @@ public function deleteSink($sinkName, $optionalArgs = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -743,7 +736,7 @@ public function deleteSink($sinkName, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listExclusions($parent, $optionalArgs = []) @@ -758,13 +751,10 @@ public function listExclusions($parent, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListExclusions', - ListExclusionsResponse::class, - $request - ), - $this->configureCallSettings('listExclusions', $optionalArgs), - $this->descriptors['listExclusions']['pageStreaming'] + 'ListExclusions', + $optionalArgs, + ListExclusionsResponse::class, + $request ); } @@ -773,8 +763,8 @@ public function listExclusions($parent, $optionalArgs = []) * * Sample code: * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $configServiceV2Client = new ConfigServiceV2Client(); * $formattedName = $configServiceV2Client->exclusionName('[PROJECT]', '[EXCLUSION]'); * $response = $configServiceV2Client->getExclusion($formattedName); * } finally { @@ -793,7 +783,7 @@ public function listExclusions($parent, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -802,7 +792,7 @@ public function listExclusions($parent, $optionalArgs = []) * * @return \Google\Cloud\Logging\V2\LogExclusion * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getExclusion($name, $optionalArgs = []) @@ -811,12 +801,10 @@ public function getExclusion($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetExclusion', - LogExclusion::class, - $request - ), - $this->configureCallSettings('getExclusion', $optionalArgs) + 'GetExclusion', + LogExclusion::class, + $optionalArgs, + $request )->wait(); } @@ -827,8 +815,8 @@ public function getExclusion($name, $optionalArgs = []) * * Sample code: * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $configServiceV2Client = new ConfigServiceV2Client(); * $formattedParent = $configServiceV2Client->projectName('[PROJECT]'); * $exclusion = new LogExclusion(); * $response = $configServiceV2Client->createExclusion($formattedParent, $exclusion); @@ -850,7 +838,7 @@ public function getExclusion($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -859,7 +847,7 @@ public function getExclusion($name, $optionalArgs = []) * * @return \Google\Cloud\Logging\V2\LogExclusion * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createExclusion($parent, $exclusion, $optionalArgs = []) @@ -869,12 +857,10 @@ public function createExclusion($parent, $exclusion, $optionalArgs = []) $request->setExclusion($exclusion); return $this->startCall( - new Call( - self::SERVICE_NAME.'/CreateExclusion', - LogExclusion::class, - $request - ), - $this->configureCallSettings('createExclusion', $optionalArgs) + 'CreateExclusion', + LogExclusion::class, + $optionalArgs, + $request )->wait(); } @@ -883,8 +869,8 @@ public function createExclusion($parent, $exclusion, $optionalArgs = []) * * Sample code: * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $configServiceV2Client = new ConfigServiceV2Client(); * $formattedName = $configServiceV2Client->exclusionName('[PROJECT]', '[EXCLUSION]'); * $exclusion = new LogExclusion(); * $updateMask = new FieldMask(); @@ -914,7 +900,7 @@ public function createExclusion($parent, $exclusion, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -923,7 +909,7 @@ public function createExclusion($parent, $exclusion, $optionalArgs = []) * * @return \Google\Cloud\Logging\V2\LogExclusion * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateExclusion($name, $exclusion, $updateMask, $optionalArgs = []) @@ -934,12 +920,10 @@ public function updateExclusion($name, $exclusion, $updateMask, $optionalArgs = $request->setUpdateMask($updateMask); return $this->startCall( - new Call( - self::SERVICE_NAME.'/UpdateExclusion', - LogExclusion::class, - $request - ), - $this->configureCallSettings('updateExclusion', $optionalArgs) + 'UpdateExclusion', + LogExclusion::class, + $optionalArgs, + $request )->wait(); } @@ -948,8 +932,8 @@ public function updateExclusion($name, $exclusion, $updateMask, $optionalArgs = * * Sample code: * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $configServiceV2Client = new ConfigServiceV2Client(); * $formattedName = $configServiceV2Client->exclusionName('[PROJECT]', '[EXCLUSION]'); * $configServiceV2Client->deleteExclusion($formattedName); * } finally { @@ -968,14 +952,14 @@ public function updateExclusion($name, $exclusion, $updateMask, $optionalArgs = * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteExclusion($name, $optionalArgs = []) @@ -984,23 +968,10 @@ public function deleteExclusion($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteExclusion', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteExclusion', $optionalArgs) + 'DeleteExclusion', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php b/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php index 56caad0761cf..c5a28f12c42a 100644 --- a/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php +++ b/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php @@ -1,12 +1,12 @@ logName('[PROJECT]', '[LOG]'); * $loggingServiceV2Client->deleteLog($formattedLogName); * } finally { @@ -124,6 +128,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/logging_service_v2_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/logging_service_v2_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/logging_service_v2_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -242,10 +247,10 @@ public static function parseName($formattedName, $template = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'logging.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -256,9 +261,9 @@ public static function parseName($formattedName, $template = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Stackdriver Logging API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -276,12 +281,11 @@ public static function parseName($formattedName, $template = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -301,8 +305,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $loggingServiceV2Client = new LoggingServiceV2Client(); * try { - * $loggingServiceV2Client = new LoggingServiceV2Client(); * $formattedLogName = $loggingServiceV2Client->logName('[PROJECT]', '[LOG]'); * $loggingServiceV2Client->deleteLog($formattedLogName); * } finally { @@ -325,14 +329,14 @@ public function __construct($options = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteLog($logName, $optionalArgs = []) @@ -341,12 +345,10 @@ public function deleteLog($logName, $optionalArgs = []) $request->setLogName($logName); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteLog', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteLog', $optionalArgs) + 'DeleteLog', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -361,8 +363,8 @@ public function deleteLog($logName, $optionalArgs = []) * * Sample code: * ``` + * $loggingServiceV2Client = new LoggingServiceV2Client(); * try { - * $loggingServiceV2Client = new LoggingServiceV2Client(); * $entries = []; * $response = $loggingServiceV2Client->writeLogEntries($entries); * } finally { @@ -428,7 +430,7 @@ public function deleteLog($logName, $optionalArgs = []) * entry is not written, then the response status is the error associated * with one of the failed entries and the response includes error details * keyed by the entries' zero-based index in the `entries.write` method. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -437,7 +439,7 @@ public function deleteLog($logName, $optionalArgs = []) * * @return \Google\Cloud\Logging\V2\WriteLogEntriesResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function writeLogEntries($entries, $optionalArgs = []) @@ -458,12 +460,10 @@ public function writeLogEntries($entries, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/WriteLogEntries', - WriteLogEntriesResponse::class, - $request - ), - $this->configureCallSettings('writeLogEntries', $optionalArgs) + 'WriteLogEntries', + WriteLogEntriesResponse::class, + $optionalArgs, + $request )->wait(); } @@ -474,8 +474,8 @@ public function writeLogEntries($entries, $optionalArgs = []) * * Sample code: * ``` + * $loggingServiceV2Client = new LoggingServiceV2Client(); * try { - * $loggingServiceV2Client = new LoggingServiceV2Client(); * $resourceNames = []; * // Iterate through all elements * $pagedResponse = $loggingServiceV2Client->listLogEntries($resourceNames); @@ -537,7 +537,7 @@ public function writeLogEntries($entries, $optionalArgs = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -546,7 +546,7 @@ public function writeLogEntries($entries, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listLogEntries($resourceNames, $optionalArgs = []) @@ -570,13 +570,10 @@ public function listLogEntries($resourceNames, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListLogEntries', - ListLogEntriesResponse::class, - $request - ), - $this->configureCallSettings('listLogEntries', $optionalArgs), - $this->descriptors['listLogEntries']['pageStreaming'] + 'ListLogEntries', + $optionalArgs, + ListLogEntriesResponse::class, + $request ); } @@ -586,8 +583,8 @@ public function listLogEntries($resourceNames, $optionalArgs = []) * * Sample code: * ``` + * $loggingServiceV2Client = new LoggingServiceV2Client(); * try { - * $loggingServiceV2Client = new LoggingServiceV2Client(); * * // Iterate through all elements * $pagedResponse = $loggingServiceV2Client->listMonitoredResourceDescriptors(); @@ -619,7 +616,7 @@ public function listLogEntries($resourceNames, $optionalArgs = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -628,7 +625,7 @@ public function listLogEntries($resourceNames, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listMonitoredResourceDescriptors($optionalArgs = []) @@ -642,13 +639,10 @@ public function listMonitoredResourceDescriptors($optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListMonitoredResourceDescriptors', - ListMonitoredResourceDescriptorsResponse::class, - $request - ), - $this->configureCallSettings('listMonitoredResourceDescriptors', $optionalArgs), - $this->descriptors['listMonitoredResourceDescriptors']['pageStreaming'] + 'ListMonitoredResourceDescriptors', + $optionalArgs, + ListMonitoredResourceDescriptorsResponse::class, + $request ); } @@ -658,8 +652,8 @@ public function listMonitoredResourceDescriptors($optionalArgs = []) * * Sample code: * ``` + * $loggingServiceV2Client = new LoggingServiceV2Client(); * try { - * $loggingServiceV2Client = new LoggingServiceV2Client(); * $formattedParent = $loggingServiceV2Client->projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $loggingServiceV2Client->listLogs($formattedParent); @@ -697,7 +691,7 @@ public function listMonitoredResourceDescriptors($optionalArgs = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -706,7 +700,7 @@ public function listMonitoredResourceDescriptors($optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listLogs($parent, $optionalArgs = []) @@ -721,24 +715,10 @@ public function listLogs($parent, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListLogs', - ListLogsResponse::class, - $request - ), - $this->configureCallSettings('listLogs', $optionalArgs), - $this->descriptors['listLogs']['pageStreaming'] + 'ListLogs', + $optionalArgs, + ListLogsResponse::class, + $request ); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php b/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php index 648cf5d3596e..a90df702fb7f 100644 --- a/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php +++ b/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php @@ -1,12 +1,12 @@ projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $metricsServiceV2Client->listLogMetrics($formattedParent); @@ -132,6 +136,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/metrics_service_v2_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/metrics_service_v2_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/metrics_service_v2_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -250,10 +255,10 @@ public static function parseName($formattedName, $template = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'logging.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -264,9 +269,9 @@ public static function parseName($formattedName, $template = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Stackdriver Logging API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -284,12 +289,11 @@ public static function parseName($formattedName, $template = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -306,8 +310,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $metricsServiceV2Client = new MetricsServiceV2Client(); * try { - * $metricsServiceV2Client = new MetricsServiceV2Client(); * $formattedParent = $metricsServiceV2Client->projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $metricsServiceV2Client->listLogMetrics($formattedParent); @@ -342,7 +346,7 @@ public function __construct($options = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -351,7 +355,7 @@ public function __construct($options = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listLogMetrics($parent, $optionalArgs = []) @@ -366,13 +370,10 @@ public function listLogMetrics($parent, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListLogMetrics', - ListLogMetricsResponse::class, - $request - ), - $this->configureCallSettings('listLogMetrics', $optionalArgs), - $this->descriptors['listLogMetrics']['pageStreaming'] + 'ListLogMetrics', + $optionalArgs, + ListLogMetricsResponse::class, + $request ); } @@ -381,8 +382,8 @@ public function listLogMetrics($parent, $optionalArgs = []) * * Sample code: * ``` + * $metricsServiceV2Client = new MetricsServiceV2Client(); * try { - * $metricsServiceV2Client = new MetricsServiceV2Client(); * $formattedMetricName = $metricsServiceV2Client->metricName('[PROJECT]', '[METRIC]'); * $response = $metricsServiceV2Client->getLogMetric($formattedMetricName); * } finally { @@ -396,7 +397,7 @@ public function listLogMetrics($parent, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -405,7 +406,7 @@ public function listLogMetrics($parent, $optionalArgs = []) * * @return \Google\Cloud\Logging\V2\LogMetric * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getLogMetric($metricName, $optionalArgs = []) @@ -414,12 +415,10 @@ public function getLogMetric($metricName, $optionalArgs = []) $request->setMetricName($metricName); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetLogMetric', - LogMetric::class, - $request - ), - $this->configureCallSettings('getLogMetric', $optionalArgs) + 'GetLogMetric', + LogMetric::class, + $optionalArgs, + $request )->wait(); } @@ -428,8 +427,8 @@ public function getLogMetric($metricName, $optionalArgs = []) * * Sample code: * ``` + * $metricsServiceV2Client = new MetricsServiceV2Client(); * try { - * $metricsServiceV2Client = new MetricsServiceV2Client(); * $formattedParent = $metricsServiceV2Client->projectName('[PROJECT]'); * $metric = new LogMetric(); * $response = $metricsServiceV2Client->createLogMetric($formattedParent, $metric); @@ -448,7 +447,7 @@ public function getLogMetric($metricName, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -457,7 +456,7 @@ public function getLogMetric($metricName, $optionalArgs = []) * * @return \Google\Cloud\Logging\V2\LogMetric * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createLogMetric($parent, $metric, $optionalArgs = []) @@ -467,12 +466,10 @@ public function createLogMetric($parent, $metric, $optionalArgs = []) $request->setMetric($metric); return $this->startCall( - new Call( - self::SERVICE_NAME.'/CreateLogMetric', - LogMetric::class, - $request - ), - $this->configureCallSettings('createLogMetric', $optionalArgs) + 'CreateLogMetric', + LogMetric::class, + $optionalArgs, + $request )->wait(); } @@ -481,8 +478,8 @@ public function createLogMetric($parent, $metric, $optionalArgs = []) * * Sample code: * ``` + * $metricsServiceV2Client = new MetricsServiceV2Client(); * try { - * $metricsServiceV2Client = new MetricsServiceV2Client(); * $formattedMetricName = $metricsServiceV2Client->metricName('[PROJECT]', '[METRIC]'); * $metric = new LogMetric(); * $response = $metricsServiceV2Client->updateLogMetric($formattedMetricName, $metric); @@ -502,7 +499,7 @@ public function createLogMetric($parent, $metric, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -511,7 +508,7 @@ public function createLogMetric($parent, $metric, $optionalArgs = []) * * @return \Google\Cloud\Logging\V2\LogMetric * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateLogMetric($metricName, $metric, $optionalArgs = []) @@ -521,12 +518,10 @@ public function updateLogMetric($metricName, $metric, $optionalArgs = []) $request->setMetric($metric); return $this->startCall( - new Call( - self::SERVICE_NAME.'/UpdateLogMetric', - LogMetric::class, - $request - ), - $this->configureCallSettings('updateLogMetric', $optionalArgs) + 'UpdateLogMetric', + LogMetric::class, + $optionalArgs, + $request )->wait(); } @@ -535,8 +530,8 @@ public function updateLogMetric($metricName, $metric, $optionalArgs = []) * * Sample code: * ``` + * $metricsServiceV2Client = new MetricsServiceV2Client(); * try { - * $metricsServiceV2Client = new MetricsServiceV2Client(); * $formattedMetricName = $metricsServiceV2Client->metricName('[PROJECT]', '[METRIC]'); * $metricsServiceV2Client->deleteLogMetric($formattedMetricName); * } finally { @@ -550,14 +545,14 @@ public function updateLogMetric($metricName, $metric, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteLogMetric($metricName, $optionalArgs = []) @@ -566,23 +561,10 @@ public function deleteLogMetric($metricName, $optionalArgs = []) $request->setMetricName($metricName); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteLogMetric', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteLogMetric', $optionalArgs) + 'DeleteLogMetric', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Logging/V2/LoggingServiceV2Client.php b/src/Logging/V2/LoggingServiceV2Client.php index 068f13111427..fc71621de4ed 100644 --- a/src/Logging/V2/LoggingServiceV2Client.php +++ b/src/Logging/V2/LoggingServiceV2Client.php @@ -1,12 +1,12 @@ [ 'google.logging.v2.ConfigServiceV2' => [ - 'listSinks' => [ + 'ListSinks' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', @@ -13,7 +13,7 @@ 'resourcesGetMethod' => 'getSinks', ], ], - 'listExclusions' => [ + 'ListExclusions' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', diff --git a/src/Logging/V2/resources/config_service_v2_rest_client_config.php b/src/Logging/V2/resources/config_service_v2_rest_client_config.php index 063c59a6eee6..ef626a9d1a18 100644 --- a/src/Logging/V2/resources/config_service_v2_rest_client_config.php +++ b/src/Logging/V2/resources/config_service_v2_rest_client_config.php @@ -5,95 +5,115 @@ 'google.logging.v2.ConfigServiceV2' => [ 'ListSinks' => [ 'method' => 'get', - 'uri' => '/v2/{parent=*/*}/sinks', + 'uriTemplate' => '/v2/{parent=*/*}/sinks', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'GetSink' => [ 'method' => 'get', - 'uri' => '/v2/{sink_name=*/*/sinks/*}', + 'uriTemplate' => '/v2/{sink_name=*/*/sinks/*}', 'placeholders' => [ 'sink_name' => [ - 'getSinkName', + 'getters' => [ + 'getSinkName', + ], ], ], ], 'CreateSink' => [ 'method' => 'post', - 'uri' => '/v2/{parent=*/*}/sinks', + 'uriTemplate' => '/v2/{parent=*/*}/sinks', 'body' => 'sink', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'UpdateSink' => [ 'method' => 'put', - 'uri' => '/v2/{sink_name=*/*/sinks/*}', + 'uriTemplate' => '/v2/{sink_name=*/*/sinks/*}', 'body' => 'sink', 'placeholders' => [ 'sink_name' => [ - 'getSinkName', + 'getters' => [ + 'getSinkName', + ], ], ], ], 'DeleteSink' => [ 'method' => 'delete', - 'uri' => '/v2/{sink_name=*/*/sinks/*}', + 'uriTemplate' => '/v2/{sink_name=*/*/sinks/*}', 'placeholders' => [ 'sink_name' => [ - 'getSinkName', + 'getters' => [ + 'getSinkName', + ], ], ], ], 'ListExclusions' => [ 'method' => 'get', - 'uri' => '/v2/{parent=*/*}/exclusions', + 'uriTemplate' => '/v2/{parent=*/*}/exclusions', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'GetExclusion' => [ 'method' => 'get', - 'uri' => '/v2/{name=*/*/exclusions/*}', + 'uriTemplate' => '/v2/{name=*/*/exclusions/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'CreateExclusion' => [ 'method' => 'post', - 'uri' => '/v2/{parent=*/*}/exclusions', + 'uriTemplate' => '/v2/{parent=*/*}/exclusions', 'body' => 'exclusion', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'UpdateExclusion' => [ 'method' => 'patch', - 'uri' => '/v2/{name=*/*/exclusions/*}', + 'uriTemplate' => '/v2/{name=*/*/exclusions/*}', 'body' => 'exclusion', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'DeleteExclusion' => [ 'method' => 'delete', - 'uri' => '/v2/{name=*/*/exclusions/*}', + 'uriTemplate' => '/v2/{name=*/*/exclusions/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], diff --git a/src/Logging/V2/resources/logging_service_v2_descriptor_config.php b/src/Logging/V2/resources/logging_service_v2_descriptor_config.php index d41fd44b6b66..76c4eb0e8f01 100644 --- a/src/Logging/V2/resources/logging_service_v2_descriptor_config.php +++ b/src/Logging/V2/resources/logging_service_v2_descriptor_config.php @@ -3,7 +3,7 @@ return [ 'interfaces' => [ 'google.logging.v2.LoggingServiceV2' => [ - 'listLogEntries' => [ + 'ListLogEntries' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', @@ -13,7 +13,7 @@ 'resourcesGetMethod' => 'getEntries', ], ], - 'listMonitoredResourceDescriptors' => [ + 'ListMonitoredResourceDescriptors' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', @@ -23,7 +23,7 @@ 'resourcesGetMethod' => 'getResourceDescriptors', ], ], - 'listLogs' => [ + 'ListLogs' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', diff --git a/src/Logging/V2/resources/logging_service_v2_rest_client_config.php b/src/Logging/V2/resources/logging_service_v2_rest_client_config.php index 1c8e9d7f064b..b3e7de203cf6 100644 --- a/src/Logging/V2/resources/logging_service_v2_rest_client_config.php +++ b/src/Logging/V2/resources/logging_service_v2_rest_client_config.php @@ -5,33 +5,37 @@ 'google.logging.v2.LoggingServiceV2' => [ 'DeleteLog' => [ 'method' => 'delete', - 'uri' => '/v2beta1/{log_name=projects/*/logs/*}', + 'uriTemplate' => '/v2beta1/{log_name=projects/*/logs/*}', 'placeholders' => [ 'log_name' => [ - 'getLogName', + 'getters' => [ + 'getLogName', + ], ], ], ], 'WriteLogEntries' => [ 'method' => 'post', - 'uri' => '/v2/entries:write', + 'uriTemplate' => '/v2/entries:write', 'body' => '*', ], 'ListLogEntries' => [ 'method' => 'post', - 'uri' => '/v2/entries:list', + 'uriTemplate' => '/v2/entries:list', 'body' => '*', ], 'ListMonitoredResourceDescriptors' => [ 'method' => 'get', - 'uri' => '/v2/monitoredResourceDescriptors', + 'uriTemplate' => '/v2/monitoredResourceDescriptors', ], 'ListLogs' => [ 'method' => 'get', - 'uri' => '/v2/{parent=*/*}/logs', + 'uriTemplate' => '/v2/{parent=*/*}/logs', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], diff --git a/src/Logging/V2/resources/metrics_service_v2_descriptor_config.php b/src/Logging/V2/resources/metrics_service_v2_descriptor_config.php index d9f6efe0909b..d0dfc9cbfe12 100644 --- a/src/Logging/V2/resources/metrics_service_v2_descriptor_config.php +++ b/src/Logging/V2/resources/metrics_service_v2_descriptor_config.php @@ -3,7 +3,7 @@ return [ 'interfaces' => [ 'google.logging.v2.MetricsServiceV2' => [ - 'listLogMetrics' => [ + 'ListLogMetrics' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', diff --git a/src/Logging/V2/resources/metrics_service_v2_rest_client_config.php b/src/Logging/V2/resources/metrics_service_v2_rest_client_config.php index 51eab37a1400..58887f7467e3 100644 --- a/src/Logging/V2/resources/metrics_service_v2_rest_client_config.php +++ b/src/Logging/V2/resources/metrics_service_v2_rest_client_config.php @@ -5,48 +5,58 @@ 'google.logging.v2.MetricsServiceV2' => [ 'ListLogMetrics' => [ 'method' => 'get', - 'uri' => '/v2/{parent=projects/*}/metrics', + 'uriTemplate' => '/v2/{parent=projects/*}/metrics', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'GetLogMetric' => [ 'method' => 'get', - 'uri' => '/v2/{metric_name=projects/*/metrics/*}', + 'uriTemplate' => '/v2/{metric_name=projects/*/metrics/*}', 'placeholders' => [ 'metric_name' => [ - 'getMetricName', + 'getters' => [ + 'getMetricName', + ], ], ], ], 'CreateLogMetric' => [ 'method' => 'post', - 'uri' => '/v2/{parent=projects/*}/metrics', + 'uriTemplate' => '/v2/{parent=projects/*}/metrics', 'body' => 'metric', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'UpdateLogMetric' => [ 'method' => 'put', - 'uri' => '/v2/{metric_name=projects/*/metrics/*}', + 'uriTemplate' => '/v2/{metric_name=projects/*/metrics/*}', 'body' => 'metric', 'placeholders' => [ 'metric_name' => [ - 'getMetricName', + 'getters' => [ + 'getMetricName', + ], ], ], ], 'DeleteLogMetric' => [ 'method' => 'delete', - 'uri' => '/v2/{metric_name=projects/*/metrics/*}', + 'uriTemplate' => '/v2/{metric_name=projects/*/metrics/*}', 'placeholders' => [ 'metric_name' => [ - 'getMetricName', + 'getters' => [ + 'getMetricName', + ], ], ], ], diff --git a/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php b/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php index c2f0bd7fb5c2..e1bbda73f636 100644 --- a/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php +++ b/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php @@ -1,12 +1,12 @@ projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $groupServiceClient->listGroups($formattedName); @@ -145,6 +149,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/group_service_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/group_service_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/group_service_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -263,10 +268,10 @@ public static function parseName($formattedName, $template = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'monitoring.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -277,9 +282,9 @@ public static function parseName($formattedName, $template = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Stackdriver Monitoring API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -297,12 +302,11 @@ public static function parseName($formattedName, $template = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -319,8 +323,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $groupServiceClient = new GroupServiceClient(); * try { - * $groupServiceClient = new GroupServiceClient(); * $formattedName = $groupServiceClient->projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $groupServiceClient->listGroups($formattedName); @@ -369,7 +373,7 @@ public function __construct($options = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -378,7 +382,7 @@ public function __construct($options = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listGroups($name, $optionalArgs = []) @@ -402,13 +406,10 @@ public function listGroups($name, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListGroups', - ListGroupsResponse::class, - $request - ), - $this->configureCallSettings('listGroups', $optionalArgs), - $this->descriptors['listGroups']['pageStreaming'] + 'ListGroups', + $optionalArgs, + ListGroupsResponse::class, + $request ); } @@ -417,8 +418,8 @@ public function listGroups($name, $optionalArgs = []) * * Sample code: * ``` + * $groupServiceClient = new GroupServiceClient(); * try { - * $groupServiceClient = new GroupServiceClient(); * $formattedName = $groupServiceClient->groupName('[PROJECT]', '[GROUP]'); * $response = $groupServiceClient->getGroup($formattedName); * } finally { @@ -431,7 +432,7 @@ public function listGroups($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -440,7 +441,7 @@ public function listGroups($name, $optionalArgs = []) * * @return \Google\Cloud\Monitoring\V3\Group * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getGroup($name, $optionalArgs = []) @@ -449,12 +450,10 @@ public function getGroup($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetGroup', - Group::class, - $request - ), - $this->configureCallSettings('getGroup', $optionalArgs) + 'GetGroup', + Group::class, + $optionalArgs, + $request )->wait(); } @@ -463,8 +462,8 @@ public function getGroup($name, $optionalArgs = []) * * Sample code: * ``` + * $groupServiceClient = new GroupServiceClient(); * try { - * $groupServiceClient = new GroupServiceClient(); * $formattedName = $groupServiceClient->projectName('[PROJECT]'); * $group = new Group(); * $response = $groupServiceClient->createGroup($formattedName, $group); @@ -482,7 +481,7 @@ public function getGroup($name, $optionalArgs = []) * * @type bool $validateOnly * If true, validate this request but do not create the group. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -491,7 +490,7 @@ public function getGroup($name, $optionalArgs = []) * * @return \Google\Cloud\Monitoring\V3\Group * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createGroup($name, $group, $optionalArgs = []) @@ -504,12 +503,10 @@ public function createGroup($name, $group, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/CreateGroup', - Group::class, - $request - ), - $this->configureCallSettings('createGroup', $optionalArgs) + 'CreateGroup', + Group::class, + $optionalArgs, + $request )->wait(); } @@ -519,8 +516,8 @@ public function createGroup($name, $group, $optionalArgs = []) * * Sample code: * ``` + * $groupServiceClient = new GroupServiceClient(); * try { - * $groupServiceClient = new GroupServiceClient(); * $group = new Group(); * $response = $groupServiceClient->updateGroup($group); * } finally { @@ -535,7 +532,7 @@ public function createGroup($name, $group, $optionalArgs = []) * * @type bool $validateOnly * If true, validate this request but do not update the existing group. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -544,7 +541,7 @@ public function createGroup($name, $group, $optionalArgs = []) * * @return \Google\Cloud\Monitoring\V3\Group * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateGroup($group, $optionalArgs = []) @@ -556,12 +553,10 @@ public function updateGroup($group, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/UpdateGroup', - Group::class, - $request - ), - $this->configureCallSettings('updateGroup', $optionalArgs) + 'UpdateGroup', + Group::class, + $optionalArgs, + $request )->wait(); } @@ -570,8 +565,8 @@ public function updateGroup($group, $optionalArgs = []) * * Sample code: * ``` + * $groupServiceClient = new GroupServiceClient(); * try { - * $groupServiceClient = new GroupServiceClient(); * $formattedName = $groupServiceClient->groupName('[PROJECT]', '[GROUP]'); * $groupServiceClient->deleteGroup($formattedName); * } finally { @@ -584,14 +579,14 @@ public function updateGroup($group, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteGroup($name, $optionalArgs = []) @@ -600,12 +595,10 @@ public function deleteGroup($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteGroup', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteGroup', $optionalArgs) + 'DeleteGroup', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -614,8 +607,8 @@ public function deleteGroup($name, $optionalArgs = []) * * Sample code: * ``` + * $groupServiceClient = new GroupServiceClient(); * try { - * $groupServiceClient = new GroupServiceClient(); * $formattedName = $groupServiceClient->groupName('[PROJECT]', '[GROUP]'); * // Iterate through all elements * $pagedResponse = $groupServiceClient->listGroupMembers($formattedName); @@ -662,7 +655,7 @@ public function deleteGroup($name, $optionalArgs = []) * members that were part of the group during the specified interval are * included in the response. If no interval is provided then the group * membership over the last minute is returned. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -671,7 +664,7 @@ public function deleteGroup($name, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listGroupMembers($name, $optionalArgs = []) @@ -692,24 +685,10 @@ public function listGroupMembers($name, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListGroupMembers', - ListGroupMembersResponse::class, - $request - ), - $this->configureCallSettings('listGroupMembers', $optionalArgs), - $this->descriptors['listGroupMembers']['pageStreaming'] + 'ListGroupMembers', + $optionalArgs, + ListGroupMembersResponse::class, + $request ); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php b/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php index bb2828c92b81..1af8c0298225 100644 --- a/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php +++ b/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php @@ -1,12 +1,12 @@ projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $metricServiceClient->listMonitoredResourceDescriptors($formattedName); @@ -143,6 +147,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/metric_service_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/metric_service_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/metric_service_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -290,10 +295,10 @@ public static function parseName($formattedName, $template = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'monitoring.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -304,9 +309,9 @@ public static function parseName($formattedName, $template = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Stackdriver Monitoring API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -324,12 +329,11 @@ public static function parseName($formattedName, $template = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -346,8 +350,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $metricServiceClient = new MetricServiceClient(); * try { - * $metricServiceClient = new MetricServiceClient(); * $formattedName = $metricServiceClient->projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $metricServiceClient->listMonitoredResourceDescriptors($formattedName); @@ -389,7 +393,7 @@ public function __construct($options = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -398,7 +402,7 @@ public function __construct($options = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listMonitoredResourceDescriptors($name, $optionalArgs = []) @@ -416,13 +420,10 @@ public function listMonitoredResourceDescriptors($name, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListMonitoredResourceDescriptors', - ListMonitoredResourceDescriptorsResponse::class, - $request - ), - $this->configureCallSettings('listMonitoredResourceDescriptors', $optionalArgs), - $this->descriptors['listMonitoredResourceDescriptors']['pageStreaming'] + 'ListMonitoredResourceDescriptors', + $optionalArgs, + ListMonitoredResourceDescriptorsResponse::class, + $request ); } @@ -431,8 +432,8 @@ public function listMonitoredResourceDescriptors($name, $optionalArgs = []) * * Sample code: * ``` + * $metricServiceClient = new MetricServiceClient(); * try { - * $metricServiceClient = new MetricServiceClient(); * $formattedName = $metricServiceClient->monitoredResourceDescriptorName('[PROJECT]', '[MONITORED_RESOURCE_DESCRIPTOR]'); * $response = $metricServiceClient->getMonitoredResourceDescriptor($formattedName); * } finally { @@ -447,7 +448,7 @@ public function listMonitoredResourceDescriptors($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -456,7 +457,7 @@ public function listMonitoredResourceDescriptors($name, $optionalArgs = []) * * @return \Google\Api\MonitoredResourceDescriptor * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getMonitoredResourceDescriptor($name, $optionalArgs = []) @@ -465,12 +466,10 @@ public function getMonitoredResourceDescriptor($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetMonitoredResourceDescriptor', - MonitoredResourceDescriptor::class, - $request - ), - $this->configureCallSettings('getMonitoredResourceDescriptor', $optionalArgs) + 'GetMonitoredResourceDescriptor', + MonitoredResourceDescriptor::class, + $optionalArgs, + $request )->wait(); } @@ -479,8 +478,8 @@ public function getMonitoredResourceDescriptor($name, $optionalArgs = []) * * Sample code: * ``` + * $metricServiceClient = new MetricServiceClient(); * try { - * $metricServiceClient = new MetricServiceClient(); * $formattedName = $metricServiceClient->projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $metricServiceClient->listMetricDescriptors($formattedName); @@ -523,7 +522,7 @@ public function getMonitoredResourceDescriptor($name, $optionalArgs = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -532,7 +531,7 @@ public function getMonitoredResourceDescriptor($name, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listMetricDescriptors($name, $optionalArgs = []) @@ -550,13 +549,10 @@ public function listMetricDescriptors($name, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListMetricDescriptors', - ListMetricDescriptorsResponse::class, - $request - ), - $this->configureCallSettings('listMetricDescriptors', $optionalArgs), - $this->descriptors['listMetricDescriptors']['pageStreaming'] + 'ListMetricDescriptors', + $optionalArgs, + ListMetricDescriptorsResponse::class, + $request ); } @@ -565,8 +561,8 @@ public function listMetricDescriptors($name, $optionalArgs = []) * * Sample code: * ``` + * $metricServiceClient = new MetricServiceClient(); * try { - * $metricServiceClient = new MetricServiceClient(); * $formattedName = $metricServiceClient->metricDescriptorName('[PROJECT]', '[METRIC_DESCRIPTOR]'); * $response = $metricServiceClient->getMetricDescriptor($formattedName); * } finally { @@ -581,7 +577,7 @@ public function listMetricDescriptors($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -590,7 +586,7 @@ public function listMetricDescriptors($name, $optionalArgs = []) * * @return \Google\Api\MetricDescriptor * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getMetricDescriptor($name, $optionalArgs = []) @@ -599,12 +595,10 @@ public function getMetricDescriptor($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetMetricDescriptor', - MetricDescriptor::class, - $request - ), - $this->configureCallSettings('getMetricDescriptor', $optionalArgs) + 'GetMetricDescriptor', + MetricDescriptor::class, + $optionalArgs, + $request )->wait(); } @@ -615,8 +609,8 @@ public function getMetricDescriptor($name, $optionalArgs = []) * * Sample code: * ``` + * $metricServiceClient = new MetricServiceClient(); * try { - * $metricServiceClient = new MetricServiceClient(); * $formattedName = $metricServiceClient->projectName('[PROJECT]'); * $metricDescriptor = new MetricDescriptor(); * $response = $metricServiceClient->createMetricDescriptor($formattedName, $metricDescriptor); @@ -632,7 +626,7 @@ public function getMetricDescriptor($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -641,7 +635,7 @@ public function getMetricDescriptor($name, $optionalArgs = []) * * @return \Google\Api\MetricDescriptor * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createMetricDescriptor($name, $metricDescriptor, $optionalArgs = []) @@ -651,12 +645,10 @@ public function createMetricDescriptor($name, $metricDescriptor, $optionalArgs = $request->setMetricDescriptor($metricDescriptor); return $this->startCall( - new Call( - self::SERVICE_NAME.'/CreateMetricDescriptor', - MetricDescriptor::class, - $request - ), - $this->configureCallSettings('createMetricDescriptor', $optionalArgs) + 'CreateMetricDescriptor', + MetricDescriptor::class, + $optionalArgs, + $request )->wait(); } @@ -666,8 +658,8 @@ public function createMetricDescriptor($name, $metricDescriptor, $optionalArgs = * * Sample code: * ``` + * $metricServiceClient = new MetricServiceClient(); * try { - * $metricServiceClient = new MetricServiceClient(); * $formattedName = $metricServiceClient->metricDescriptorName('[PROJECT]', '[METRIC_DESCRIPTOR]'); * $metricServiceClient->deleteMetricDescriptor($formattedName); * } finally { @@ -682,14 +674,14 @@ public function createMetricDescriptor($name, $metricDescriptor, $optionalArgs = * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteMetricDescriptor($name, $optionalArgs = []) @@ -698,12 +690,10 @@ public function deleteMetricDescriptor($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteMetricDescriptor', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteMetricDescriptor', $optionalArgs) + 'DeleteMetricDescriptor', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -712,8 +702,8 @@ public function deleteMetricDescriptor($name, $optionalArgs = []) * * Sample code: * ``` + * $metricServiceClient = new MetricServiceClient(); * try { - * $metricServiceClient = new MetricServiceClient(); * $formattedName = $metricServiceClient->projectName('[PROJECT]'); * $filter = ''; * $interval = new TimeInterval(); @@ -770,7 +760,7 @@ public function deleteMetricDescriptor($name, $optionalArgs = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -779,7 +769,7 @@ public function deleteMetricDescriptor($name, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listTimeSeries($name, $filter, $interval, $view, $optionalArgs = []) @@ -803,13 +793,10 @@ public function listTimeSeries($name, $filter, $interval, $view, $optionalArgs = } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListTimeSeries', - ListTimeSeriesResponse::class, - $request - ), - $this->configureCallSettings('listTimeSeries', $optionalArgs), - $this->descriptors['listTimeSeries']['pageStreaming'] + 'ListTimeSeries', + $optionalArgs, + ListTimeSeriesResponse::class, + $request ); } @@ -821,8 +808,8 @@ public function listTimeSeries($name, $filter, $interval, $view, $optionalArgs = * * Sample code: * ``` + * $metricServiceClient = new MetricServiceClient(); * try { - * $metricServiceClient = new MetricServiceClient(); * $formattedName = $metricServiceClient->projectName('[PROJECT]'); * $timeSeries = []; * $metricServiceClient->createTimeSeries($formattedName, $timeSeries); @@ -841,14 +828,14 @@ public function listTimeSeries($name, $filter, $interval, $view, $optionalArgs = * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createTimeSeries($name, $timeSeries, $optionalArgs = []) @@ -858,23 +845,10 @@ public function createTimeSeries($name, $timeSeries, $optionalArgs = []) $request->setTimeSeries($timeSeries); return $this->startCall( - new Call( - self::SERVICE_NAME.'/CreateTimeSeries', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('createTimeSeries', $optionalArgs) + 'CreateTimeSeries', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php b/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php index 0fa43def1c0b..971e63e8ec01 100644 --- a/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php +++ b/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php @@ -1,12 +1,12 @@ projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $uptimeCheckServiceClient->listUptimeCheckConfigs($formattedParent); @@ -141,6 +145,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/uptime_check_service_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/uptime_check_service_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/uptime_check_service_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -259,10 +264,10 @@ public static function parseName($formattedName, $template = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'monitoring.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -273,9 +278,9 @@ public static function parseName($formattedName, $template = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Stackdriver Monitoring API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -293,12 +298,11 @@ public static function parseName($formattedName, $template = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -316,8 +320,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); * try { - * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); * $formattedParent = $uptimeCheckServiceClient->projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $uptimeCheckServiceClient->listUptimeCheckConfigs($formattedParent); @@ -352,7 +356,7 @@ public function __construct($options = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -361,7 +365,7 @@ public function __construct($options = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listUptimeCheckConfigs($parent, $optionalArgs = []) @@ -376,13 +380,10 @@ public function listUptimeCheckConfigs($parent, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListUptimeCheckConfigs', - ListUptimeCheckConfigsResponse::class, - $request - ), - $this->configureCallSettings('listUptimeCheckConfigs', $optionalArgs), - $this->descriptors['listUptimeCheckConfigs']['pageStreaming'] + 'ListUptimeCheckConfigs', + $optionalArgs, + ListUptimeCheckConfigsResponse::class, + $request ); } @@ -391,8 +392,8 @@ public function listUptimeCheckConfigs($parent, $optionalArgs = []) * * Sample code: * ``` + * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); * try { - * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); * $formattedName = $uptimeCheckServiceClient->uptimeCheckConfigName('[PROJECT]', '[UPTIME_CHECK_CONFIG]'); * $response = $uptimeCheckServiceClient->getUptimeCheckConfig($formattedName); * } finally { @@ -406,7 +407,7 @@ public function listUptimeCheckConfigs($parent, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -415,7 +416,7 @@ public function listUptimeCheckConfigs($parent, $optionalArgs = []) * * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getUptimeCheckConfig($name, $optionalArgs = []) @@ -424,12 +425,10 @@ public function getUptimeCheckConfig($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetUptimeCheckConfig', - UptimeCheckConfig::class, - $request - ), - $this->configureCallSettings('getUptimeCheckConfig', $optionalArgs) + 'GetUptimeCheckConfig', + UptimeCheckConfig::class, + $optionalArgs, + $request )->wait(); } @@ -438,8 +437,8 @@ public function getUptimeCheckConfig($name, $optionalArgs = []) * * Sample code: * ``` + * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); * try { - * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); * $formattedParent = $uptimeCheckServiceClient->projectName('[PROJECT]'); * $uptimeCheckConfig = new UptimeCheckConfig(); * $response = $uptimeCheckServiceClient->createUptimeCheckConfig($formattedParent, $uptimeCheckConfig); @@ -455,7 +454,7 @@ public function getUptimeCheckConfig($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -464,7 +463,7 @@ public function getUptimeCheckConfig($name, $optionalArgs = []) * * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createUptimeCheckConfig($parent, $uptimeCheckConfig, $optionalArgs = []) @@ -474,12 +473,10 @@ public function createUptimeCheckConfig($parent, $uptimeCheckConfig, $optionalAr $request->setUptimeCheckConfig($uptimeCheckConfig); return $this->startCall( - new Call( - self::SERVICE_NAME.'/CreateUptimeCheckConfig', - UptimeCheckConfig::class, - $request - ), - $this->configureCallSettings('createUptimeCheckConfig', $optionalArgs) + 'CreateUptimeCheckConfig', + UptimeCheckConfig::class, + $optionalArgs, + $request )->wait(); } @@ -491,8 +488,8 @@ public function createUptimeCheckConfig($parent, $uptimeCheckConfig, $optionalAr * * Sample code: * ``` + * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); * try { - * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); * $uptimeCheckConfig = new UptimeCheckConfig(); * $response = $uptimeCheckServiceClient->updateUptimeCheckConfig($uptimeCheckConfig); * } finally { @@ -515,7 +512,7 @@ public function createUptimeCheckConfig($parent, $uptimeCheckConfig, $optionalAr * configuration are updated with values from the new configuration. If this * field is empty, then the current configuration is completely replaced with * the new configuration. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -524,7 +521,7 @@ public function createUptimeCheckConfig($parent, $uptimeCheckConfig, $optionalAr * * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateUptimeCheckConfig($uptimeCheckConfig, $optionalArgs = []) @@ -536,12 +533,10 @@ public function updateUptimeCheckConfig($uptimeCheckConfig, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/UpdateUptimeCheckConfig', - UptimeCheckConfig::class, - $request - ), - $this->configureCallSettings('updateUptimeCheckConfig', $optionalArgs) + 'UpdateUptimeCheckConfig', + UptimeCheckConfig::class, + $optionalArgs, + $request )->wait(); } @@ -552,8 +547,8 @@ public function updateUptimeCheckConfig($uptimeCheckConfig, $optionalArgs = []) * * Sample code: * ``` + * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); * try { - * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); * $formattedName = $uptimeCheckServiceClient->uptimeCheckConfigName('[PROJECT]', '[UPTIME_CHECK_CONFIG]'); * $uptimeCheckServiceClient->deleteUptimeCheckConfig($formattedName); * } finally { @@ -567,14 +562,14 @@ public function updateUptimeCheckConfig($uptimeCheckConfig, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteUptimeCheckConfig($name, $optionalArgs = []) @@ -583,12 +578,10 @@ public function deleteUptimeCheckConfig($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteUptimeCheckConfig', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteUptimeCheckConfig', $optionalArgs) + 'DeleteUptimeCheckConfig', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -597,8 +590,8 @@ public function deleteUptimeCheckConfig($name, $optionalArgs = []) * * Sample code: * ``` + * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); * try { - * $uptimeCheckServiceClient = new UptimeCheckServiceClient(); * * // Iterate through all elements * $pagedResponse = $uptimeCheckServiceClient->listUptimeCheckIps(); @@ -630,7 +623,7 @@ public function deleteUptimeCheckConfig($name, $optionalArgs = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -639,7 +632,7 @@ public function deleteUptimeCheckConfig($name, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listUptimeCheckIps($optionalArgs = []) @@ -653,24 +646,10 @@ public function listUptimeCheckIps($optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListUptimeCheckIps', - ListUptimeCheckIpsResponse::class, - $request - ), - $this->configureCallSettings('listUptimeCheckIps', $optionalArgs), - $this->descriptors['listUptimeCheckIps']['pageStreaming'] + 'ListUptimeCheckIps', + $optionalArgs, + ListUptimeCheckIpsResponse::class, + $request ); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Monitoring/V3/GroupServiceClient.php b/src/Monitoring/V3/GroupServiceClient.php index 29d1062fdee6..72dc2a83fce0 100644 --- a/src/Monitoring/V3/GroupServiceClient.php +++ b/src/Monitoring/V3/GroupServiceClient.php @@ -1,12 +1,12 @@ [ 'google.monitoring.v3.GroupService' => [ - 'listGroups' => [ + 'ListGroups' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', @@ -13,7 +13,7 @@ 'resourcesGetMethod' => 'getGroup', ], ], - 'listGroupMembers' => [ + 'ListGroupMembers' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', diff --git a/src/Monitoring/V3/resources/group_service_rest_client_config.php b/src/Monitoring/V3/resources/group_service_rest_client_config.php index bc4eb32f9c31..19fdff918de8 100644 --- a/src/Monitoring/V3/resources/group_service_rest_client_config.php +++ b/src/Monitoring/V3/resources/group_service_rest_client_config.php @@ -5,58 +5,70 @@ 'google.monitoring.v3.GroupService' => [ 'ListGroups' => [ 'method' => 'get', - 'uri' => '/v3/{name=projects/*}/groups', + 'uriTemplate' => '/v3/{name=projects/*}/groups', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'GetGroup' => [ 'method' => 'get', - 'uri' => '/v3/{name=projects/*/groups/*}', + 'uriTemplate' => '/v3/{name=projects/*/groups/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'CreateGroup' => [ 'method' => 'post', - 'uri' => '/v3/{name=projects/*}/groups', + 'uriTemplate' => '/v3/{name=projects/*}/groups', 'body' => 'group', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'UpdateGroup' => [ 'method' => 'put', - 'uri' => '/v3/{group.name=projects/*/groups/*}', + 'uriTemplate' => '/v3/{group.name=projects/*/groups/*}', 'body' => 'group', 'placeholders' => [ 'group.name' => [ - 'getGroup', - 'getName', + 'getters' => [ + 'getGroup', + 'getName', + ], ], ], ], 'DeleteGroup' => [ 'method' => 'delete', - 'uri' => '/v3/{name=projects/*/groups/*}', + 'uriTemplate' => '/v3/{name=projects/*/groups/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'ListGroupMembers' => [ 'method' => 'get', - 'uri' => '/v3/{name=projects/*/groups/*}/members', + 'uriTemplate' => '/v3/{name=projects/*/groups/*}/members', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], diff --git a/src/Monitoring/V3/resources/metric_service_descriptor_config.php b/src/Monitoring/V3/resources/metric_service_descriptor_config.php index 57f8e2202a05..8e94f30dfabc 100644 --- a/src/Monitoring/V3/resources/metric_service_descriptor_config.php +++ b/src/Monitoring/V3/resources/metric_service_descriptor_config.php @@ -3,7 +3,7 @@ return [ 'interfaces' => [ 'google.monitoring.v3.MetricService' => [ - 'listMonitoredResourceDescriptors' => [ + 'ListMonitoredResourceDescriptors' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', @@ -13,7 +13,7 @@ 'resourcesGetMethod' => 'getResourceDescriptors', ], ], - 'listMetricDescriptors' => [ + 'ListMetricDescriptors' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', @@ -23,7 +23,7 @@ 'resourcesGetMethod' => 'getMetricDescriptors', ], ], - 'listTimeSeries' => [ + 'ListTimeSeries' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', diff --git a/src/Monitoring/V3/resources/metric_service_rest_client_config.php b/src/Monitoring/V3/resources/metric_service_rest_client_config.php index 3ad982f52a4e..27583d8738cc 100644 --- a/src/Monitoring/V3/resources/metric_service_rest_client_config.php +++ b/src/Monitoring/V3/resources/metric_service_rest_client_config.php @@ -5,75 +5,91 @@ 'google.monitoring.v3.MetricService' => [ 'ListMonitoredResourceDescriptors' => [ 'method' => 'get', - 'uri' => '/v3/{name=projects/*}/monitoredResourceDescriptors', + 'uriTemplate' => '/v3/{name=projects/*}/monitoredResourceDescriptors', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'GetMonitoredResourceDescriptor' => [ 'method' => 'get', - 'uri' => '/v3/{name=projects/*/monitoredResourceDescriptors/*}', + 'uriTemplate' => '/v3/{name=projects/*/monitoredResourceDescriptors/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'ListMetricDescriptors' => [ 'method' => 'get', - 'uri' => '/v3/{name=projects/*}/metricDescriptors', + 'uriTemplate' => '/v3/{name=projects/*}/metricDescriptors', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'GetMetricDescriptor' => [ 'method' => 'get', - 'uri' => '/v3/{name=projects/*/metricDescriptors/**}', + 'uriTemplate' => '/v3/{name=projects/*/metricDescriptors/**}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'CreateMetricDescriptor' => [ 'method' => 'post', - 'uri' => '/v3/{name=projects/*}/metricDescriptors', + 'uriTemplate' => '/v3/{name=projects/*}/metricDescriptors', 'body' => 'metric_descriptor', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'DeleteMetricDescriptor' => [ 'method' => 'delete', - 'uri' => '/v3/{name=projects/*/metricDescriptors/**}', + 'uriTemplate' => '/v3/{name=projects/*/metricDescriptors/**}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'ListTimeSeries' => [ 'method' => 'get', - 'uri' => '/v3/{name=projects/*}/timeSeries', + 'uriTemplate' => '/v3/{name=projects/*}/timeSeries', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'CreateTimeSeries' => [ 'method' => 'post', - 'uri' => '/v3/{name=projects/*}/timeSeries', + 'uriTemplate' => '/v3/{name=projects/*}/timeSeries', 'body' => '*', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], diff --git a/src/Monitoring/V3/resources/uptime_check_service_descriptor_config.php b/src/Monitoring/V3/resources/uptime_check_service_descriptor_config.php index 71a8aa121be0..04c912eeb82c 100644 --- a/src/Monitoring/V3/resources/uptime_check_service_descriptor_config.php +++ b/src/Monitoring/V3/resources/uptime_check_service_descriptor_config.php @@ -3,7 +3,7 @@ return [ 'interfaces' => [ 'google.monitoring.v3.UptimeCheckService' => [ - 'listUptimeCheckConfigs' => [ + 'ListUptimeCheckConfigs' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', @@ -13,7 +13,7 @@ 'resourcesGetMethod' => 'getUptimeCheckConfigs', ], ], - 'listUptimeCheckIps' => [ + 'ListUptimeCheckIps' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', diff --git a/src/Monitoring/V3/resources/uptime_check_service_rest_client_config.php b/src/Monitoring/V3/resources/uptime_check_service_rest_client_config.php index a3c94384128a..fdef0614f2d9 100644 --- a/src/Monitoring/V3/resources/uptime_check_service_rest_client_config.php +++ b/src/Monitoring/V3/resources/uptime_check_service_rest_client_config.php @@ -5,55 +5,65 @@ 'google.monitoring.v3.UptimeCheckService' => [ 'ListUptimeCheckConfigs' => [ 'method' => 'get', - 'uri' => '/v3/{parent=projects/*}/uptimeCheckConfigs', + 'uriTemplate' => '/v3/{parent=projects/*}/uptimeCheckConfigs', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'GetUptimeCheckConfig' => [ 'method' => 'get', - 'uri' => '/v3/{name=projects/*/uptimeCheckConfigs/*}', + 'uriTemplate' => '/v3/{name=projects/*/uptimeCheckConfigs/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'CreateUptimeCheckConfig' => [ 'method' => 'post', - 'uri' => '/v3/{parent=projects/*}/uptimeCheckConfigs', + 'uriTemplate' => '/v3/{parent=projects/*}/uptimeCheckConfigs', 'body' => 'uptime_check_config', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'UpdateUptimeCheckConfig' => [ 'method' => 'patch', - 'uri' => '/v3/{uptime_check_config.name=projects/*/uptimeCheckConfigs/*}', + 'uriTemplate' => '/v3/{uptime_check_config.name=projects/*/uptimeCheckConfigs/*}', 'body' => 'uptime_check_config', 'placeholders' => [ 'uptime_check_config.name' => [ - 'getUptimeCheckConfig', - 'getName', + 'getters' => [ + 'getUptimeCheckConfig', + 'getName', + ], ], ], ], 'DeleteUptimeCheckConfig' => [ 'method' => 'delete', - 'uri' => '/v3/{name=projects/*/uptimeCheckConfigs/*}', + 'uriTemplate' => '/v3/{name=projects/*/uptimeCheckConfigs/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'ListUptimeCheckIps' => [ 'method' => 'get', - 'uri' => '/v3/uptimeCheckIps', + 'uriTemplate' => '/v3/uptimeCheckIps', ], ], ], diff --git a/src/PubSub/V1/Gapic/PublisherGapicClient.php b/src/PubSub/V1/Gapic/PublisherGapicClient.php index d0d4b6e63153..be6ce80578fc 100644 --- a/src/PubSub/V1/Gapic/PublisherGapicClient.php +++ b/src/PubSub/V1/Gapic/PublisherGapicClient.php @@ -1,12 +1,12 @@ topicName('[PROJECT]', '[TOPIC]'); * $response = $publisherClient->createTopic($formattedName); * } finally { @@ -128,6 +132,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/publisher_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/publisher_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/publisher_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -246,10 +251,10 @@ public static function parseName($formattedName, $template = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'pubsub.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -260,9 +265,9 @@ public static function parseName($formattedName, $template = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Google Cloud Pub/Sub API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -280,12 +285,11 @@ public static function parseName($formattedName, $template = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -302,8 +306,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $publisherClient = new PublisherClient(); * try { - * $publisherClient = new PublisherClient(); * $formattedName = $publisherClient->topicName('[PROJECT]', '[TOPIC]'); * $response = $publisherClient->createTopic($formattedName); * } finally { @@ -322,7 +326,7 @@ public function __construct($options = []) * * @type array $labels * User labels. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -331,7 +335,7 @@ public function __construct($options = []) * * @return \Google\Cloud\PubSub\V1\Topic * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createTopic($name, $optionalArgs = []) @@ -343,12 +347,10 @@ public function createTopic($name, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/CreateTopic', - Topic::class, - $request - ), - $this->configureCallSettings('createTopic', $optionalArgs) + 'CreateTopic', + Topic::class, + $optionalArgs, + $request )->wait(); } @@ -362,8 +364,8 @@ public function createTopic($name, $optionalArgs = []) * * Sample code: * ``` + * $publisherClient = new PublisherClient(); * try { - * $publisherClient = new PublisherClient(); * $topic = new Topic(); * $updateMask = new FieldMask(); * $response = $publisherClient->updateTopic($topic, $updateMask); @@ -378,7 +380,7 @@ public function createTopic($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -387,7 +389,7 @@ public function createTopic($name, $optionalArgs = []) * * @return \Google\Cloud\PubSub\V1\Topic * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateTopic($topic, $updateMask, $optionalArgs = []) @@ -397,12 +399,10 @@ public function updateTopic($topic, $updateMask, $optionalArgs = []) $request->setUpdateMask($updateMask); return $this->startCall( - new Call( - self::SERVICE_NAME.'/UpdateTopic', - Topic::class, - $request - ), - $this->configureCallSettings('updateTopic', $optionalArgs) + 'UpdateTopic', + Topic::class, + $optionalArgs, + $request )->wait(); } @@ -413,8 +413,8 @@ public function updateTopic($topic, $updateMask, $optionalArgs = []) * * Sample code: * ``` + * $publisherClient = new PublisherClient(); * try { - * $publisherClient = new PublisherClient(); * $formattedTopic = $publisherClient->topicName('[PROJECT]', '[TOPIC]'); * $data = ''; * $messagesElement = new PubsubMessage(); @@ -432,7 +432,7 @@ public function updateTopic($topic, $updateMask, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -441,7 +441,7 @@ public function updateTopic($topic, $updateMask, $optionalArgs = []) * * @return \Google\Cloud\PubSub\V1\PublishResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function publish($topic, $messages, $optionalArgs = []) @@ -451,12 +451,10 @@ public function publish($topic, $messages, $optionalArgs = []) $request->setMessages($messages); return $this->startCall( - new Call( - self::SERVICE_NAME.'/Publish', - PublishResponse::class, - $request - ), - $this->configureCallSettings('publish', $optionalArgs) + 'Publish', + PublishResponse::class, + $optionalArgs, + $request )->wait(); } @@ -465,8 +463,8 @@ public function publish($topic, $messages, $optionalArgs = []) * * Sample code: * ``` + * $publisherClient = new PublisherClient(); * try { - * $publisherClient = new PublisherClient(); * $formattedTopic = $publisherClient->topicName('[PROJECT]', '[TOPIC]'); * $response = $publisherClient->getTopic($formattedTopic); * } finally { @@ -479,7 +477,7 @@ public function publish($topic, $messages, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -488,7 +486,7 @@ public function publish($topic, $messages, $optionalArgs = []) * * @return \Google\Cloud\PubSub\V1\Topic * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getTopic($topic, $optionalArgs = []) @@ -497,12 +495,10 @@ public function getTopic($topic, $optionalArgs = []) $request->setTopic($topic); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetTopic', - Topic::class, - $request - ), - $this->configureCallSettings('getTopic', $optionalArgs) + 'GetTopic', + Topic::class, + $optionalArgs, + $request )->wait(); } @@ -511,8 +507,8 @@ public function getTopic($topic, $optionalArgs = []) * * Sample code: * ``` + * $publisherClient = new PublisherClient(); * try { - * $publisherClient = new PublisherClient(); * $formattedProject = $publisherClient->projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $publisherClient->listTopics($formattedProject); @@ -546,7 +542,7 @@ public function getTopic($topic, $optionalArgs = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -555,7 +551,7 @@ public function getTopic($topic, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listTopics($project, $optionalArgs = []) @@ -570,13 +566,10 @@ public function listTopics($project, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListTopics', - ListTopicsResponse::class, - $request - ), - $this->configureCallSettings('listTopics', $optionalArgs), - $this->descriptors['listTopics']['pageStreaming'] + 'ListTopics', + $optionalArgs, + ListTopicsResponse::class, + $request ); } @@ -585,8 +578,8 @@ public function listTopics($project, $optionalArgs = []) * * Sample code: * ``` + * $publisherClient = new PublisherClient(); * try { - * $publisherClient = new PublisherClient(); * $formattedTopic = $publisherClient->topicName('[PROJECT]', '[TOPIC]'); * // Iterate through all elements * $pagedResponse = $publisherClient->listTopicSubscriptions($formattedTopic); @@ -620,7 +613,7 @@ public function listTopics($project, $optionalArgs = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -629,7 +622,7 @@ public function listTopics($project, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listTopicSubscriptions($topic, $optionalArgs = []) @@ -644,13 +637,10 @@ public function listTopicSubscriptions($topic, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListTopicSubscriptions', - ListTopicSubscriptionsResponse::class, - $request - ), - $this->configureCallSettings('listTopicSubscriptions', $optionalArgs), - $this->descriptors['listTopicSubscriptions']['pageStreaming'] + 'ListTopicSubscriptions', + $optionalArgs, + ListTopicSubscriptionsResponse::class, + $request ); } @@ -663,8 +653,8 @@ public function listTopicSubscriptions($topic, $optionalArgs = []) * * Sample code: * ``` + * $publisherClient = new PublisherClient(); * try { - * $publisherClient = new PublisherClient(); * $formattedTopic = $publisherClient->topicName('[PROJECT]', '[TOPIC]'); * $publisherClient->deleteTopic($formattedTopic); * } finally { @@ -677,14 +667,14 @@ public function listTopicSubscriptions($topic, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteTopic($topic, $optionalArgs = []) @@ -693,12 +683,10 @@ public function deleteTopic($topic, $optionalArgs = []) $request->setTopic($topic); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteTopic', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteTopic', $optionalArgs) + 'DeleteTopic', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -708,8 +696,8 @@ public function deleteTopic($topic, $optionalArgs = []) * * Sample code: * ``` + * $publisherClient = new PublisherClient(); * try { - * $publisherClient = new PublisherClient(); * $formattedResource = $publisherClient->topicName('[PROJECT]', '[TOPIC]'); * $policy = new Policy(); * $response = $publisherClient->setIamPolicy($formattedResource, $policy); @@ -728,7 +716,7 @@ public function deleteTopic($topic, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -737,7 +725,7 @@ public function deleteTopic($topic, $optionalArgs = []) * * @return \Google\Cloud\Iam\V1\Policy * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setIamPolicy($resource, $policy, $optionalArgs = []) @@ -747,12 +735,10 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) $request->setPolicy($policy); return $this->startCall( - new Call( - self::SERVICE_NAME.'/SetIamPolicy', - Policy::class, - $request - ), - $this->configureCallSettings('setIamPolicy', $optionalArgs) + 'SetIamPolicy', + Policy::class, + $optionalArgs, + $request )->wait(); } @@ -763,8 +749,8 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) * * Sample code: * ``` + * $publisherClient = new PublisherClient(); * try { - * $publisherClient = new PublisherClient(); * $formattedResource = $publisherClient->topicName('[PROJECT]', '[TOPIC]'); * $response = $publisherClient->getIamPolicy($formattedResource); * } finally { @@ -778,7 +764,7 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -787,7 +773,7 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) * * @return \Google\Cloud\Iam\V1\Policy * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getIamPolicy($resource, $optionalArgs = []) @@ -796,12 +782,10 @@ public function getIamPolicy($resource, $optionalArgs = []) $request->setResource($resource); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetIamPolicy', - Policy::class, - $request - ), - $this->configureCallSettings('getIamPolicy', $optionalArgs) + 'GetIamPolicy', + Policy::class, + $optionalArgs, + $request )->wait(); } @@ -812,8 +796,8 @@ public function getIamPolicy($resource, $optionalArgs = []) * * Sample code: * ``` + * $publisherClient = new PublisherClient(); * try { - * $publisherClient = new PublisherClient(); * $formattedResource = $publisherClient->topicName('[PROJECT]', '[TOPIC]'); * $permissions = []; * $response = $publisherClient->testIamPermissions($formattedResource, $permissions); @@ -832,7 +816,7 @@ public function getIamPolicy($resource, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -841,7 +825,7 @@ public function getIamPolicy($resource, $optionalArgs = []) * * @return \Google\Cloud\Iam\V1\TestIamPermissionsResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function testIamPermissions($resource, $permissions, $optionalArgs = []) @@ -851,23 +835,10 @@ public function testIamPermissions($resource, $permissions, $optionalArgs = []) $request->setPermissions($permissions); return $this->startCall( - new Call( - self::SERVICE_NAME.'/TestIamPermissions', - TestIamPermissionsResponse::class, - $request - ), - $this->configureCallSettings('testIamPermissions', $optionalArgs) + 'TestIamPermissions', + TestIamPermissionsResponse::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/PubSub/V1/Gapic/SubscriberGapicClient.php b/src/PubSub/V1/Gapic/SubscriberGapicClient.php index eaf8a92f0e15..f013fd9d7fe2 100644 --- a/src/PubSub/V1/Gapic/SubscriberGapicClient.php +++ b/src/PubSub/V1/Gapic/SubscriberGapicClient.php @@ -1,12 +1,12 @@ subscriptionName('[PROJECT]', '[SUBSCRIPTION]'); * $formattedTopic = $subscriberClient->topicName('[PROJECT]', '[TOPIC]'); * $response = $subscriberClient->createSubscription($formattedName, $formattedTopic); @@ -144,6 +149,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/subscriber_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/subscriber_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/subscriber_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -320,10 +326,10 @@ public static function parseName($formattedName, $template = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'pubsub.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -334,9 +340,9 @@ public static function parseName($formattedName, $template = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Google Cloud Pub/Sub API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -354,12 +360,11 @@ public static function parseName($formattedName, $template = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -385,8 +390,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $formattedName = $subscriberClient->subscriptionName('[PROJECT]', '[SUBSCRIPTION]'); * $formattedTopic = $subscriberClient->topicName('[PROJECT]', '[TOPIC]'); * $response = $subscriberClient->createSubscription($formattedName, $formattedTopic); @@ -446,7 +451,7 @@ public function __construct($options = []) * minutes. * @type array $labels * User labels. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -455,7 +460,7 @@ public function __construct($options = []) * * @return \Google\Cloud\PubSub\V1\Subscription * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createSubscription($name, $topic, $optionalArgs = []) @@ -480,12 +485,10 @@ public function createSubscription($name, $topic, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/CreateSubscription', - Subscription::class, - $request - ), - $this->configureCallSettings('createSubscription', $optionalArgs) + 'CreateSubscription', + Subscription::class, + $optionalArgs, + $request )->wait(); } @@ -494,8 +497,8 @@ public function createSubscription($name, $topic, $optionalArgs = []) * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $formattedSubscription = $subscriberClient->subscriptionName('[PROJECT]', '[SUBSCRIPTION]'); * $response = $subscriberClient->getSubscription($formattedSubscription); * } finally { @@ -508,7 +511,7 @@ public function createSubscription($name, $topic, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -517,7 +520,7 @@ public function createSubscription($name, $topic, $optionalArgs = []) * * @return \Google\Cloud\PubSub\V1\Subscription * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getSubscription($subscription, $optionalArgs = []) @@ -526,12 +529,10 @@ public function getSubscription($subscription, $optionalArgs = []) $request->setSubscription($subscription); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetSubscription', - Subscription::class, - $request - ), - $this->configureCallSettings('getSubscription', $optionalArgs) + 'GetSubscription', + Subscription::class, + $optionalArgs, + $request )->wait(); } @@ -545,8 +546,8 @@ public function getSubscription($subscription, $optionalArgs = []) * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $ackDeadlineSeconds = 42; * $subscription = new Subscription(); * $subscription->setAckDeadlineSeconds($ackDeadlineSeconds); @@ -566,7 +567,7 @@ public function getSubscription($subscription, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -575,7 +576,7 @@ public function getSubscription($subscription, $optionalArgs = []) * * @return \Google\Cloud\PubSub\V1\Subscription * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateSubscription($subscription, $updateMask, $optionalArgs = []) @@ -585,12 +586,10 @@ public function updateSubscription($subscription, $updateMask, $optionalArgs = [ $request->setUpdateMask($updateMask); return $this->startCall( - new Call( - self::SERVICE_NAME.'/UpdateSubscription', - Subscription::class, - $request - ), - $this->configureCallSettings('updateSubscription', $optionalArgs) + 'UpdateSubscription', + Subscription::class, + $optionalArgs, + $request )->wait(); } @@ -599,8 +598,8 @@ public function updateSubscription($subscription, $updateMask, $optionalArgs = [ * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $formattedProject = $subscriberClient->projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $subscriberClient->listSubscriptions($formattedProject); @@ -634,7 +633,7 @@ public function updateSubscription($subscription, $updateMask, $optionalArgs = [ * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -643,7 +642,7 @@ public function updateSubscription($subscription, $updateMask, $optionalArgs = [ * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listSubscriptions($project, $optionalArgs = []) @@ -658,13 +657,10 @@ public function listSubscriptions($project, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListSubscriptions', - ListSubscriptionsResponse::class, - $request - ), - $this->configureCallSettings('listSubscriptions', $optionalArgs), - $this->descriptors['listSubscriptions']['pageStreaming'] + 'ListSubscriptions', + $optionalArgs, + ListSubscriptionsResponse::class, + $request ); } @@ -677,8 +673,8 @@ public function listSubscriptions($project, $optionalArgs = []) * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $formattedSubscription = $subscriberClient->subscriptionName('[PROJECT]', '[SUBSCRIPTION]'); * $subscriberClient->deleteSubscription($formattedSubscription); * } finally { @@ -691,14 +687,14 @@ public function listSubscriptions($project, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteSubscription($subscription, $optionalArgs = []) @@ -707,12 +703,10 @@ public function deleteSubscription($subscription, $optionalArgs = []) $request->setSubscription($subscription); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteSubscription', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteSubscription', $optionalArgs) + 'DeleteSubscription', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -725,8 +719,8 @@ public function deleteSubscription($subscription, $optionalArgs = []) * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $formattedSubscription = $subscriberClient->subscriptionName('[PROJECT]', '[SUBSCRIPTION]'); * $ackIds = []; * $ackDeadlineSeconds = 0; @@ -749,14 +743,14 @@ public function deleteSubscription($subscription, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function modifyAckDeadline($subscription, $ackIds, $ackDeadlineSeconds, $optionalArgs = []) @@ -767,12 +761,10 @@ public function modifyAckDeadline($subscription, $ackIds, $ackDeadlineSeconds, $ $request->setAckDeadlineSeconds($ackDeadlineSeconds); return $this->startCall( - new Call( - self::SERVICE_NAME.'/ModifyAckDeadline', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('modifyAckDeadline', $optionalArgs) + 'ModifyAckDeadline', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -787,8 +779,8 @@ public function modifyAckDeadline($subscription, $ackIds, $ackDeadlineSeconds, $ * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $formattedSubscription = $subscriberClient->subscriptionName('[PROJECT]', '[SUBSCRIPTION]'); * $ackIds = []; * $subscriberClient->acknowledge($formattedSubscription, $ackIds); @@ -804,14 +796,14 @@ public function modifyAckDeadline($subscription, $ackIds, $ackDeadlineSeconds, $ * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function acknowledge($subscription, $ackIds, $optionalArgs = []) @@ -821,12 +813,10 @@ public function acknowledge($subscription, $ackIds, $optionalArgs = []) $request->setAckIds($ackIds); return $this->startCall( - new Call( - self::SERVICE_NAME.'/Acknowledge', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('acknowledge', $optionalArgs) + 'Acknowledge', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -838,8 +828,8 @@ public function acknowledge($subscription, $ackIds, $optionalArgs = []) * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $formattedSubscription = $subscriberClient->subscriptionName('[PROJECT]', '[SUBSCRIPTION]'); * $maxMessages = 0; * $response = $subscriberClient->pull($formattedSubscription, $maxMessages); @@ -862,7 +852,7 @@ public function acknowledge($subscription, $ackIds, $optionalArgs = []) * least one message is available, rather than returning no messages. The * client may cancel the request if it does not wish to wait any longer for * the response. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -871,7 +861,7 @@ public function acknowledge($subscription, $ackIds, $optionalArgs = []) * * @return \Google\Cloud\PubSub\V1\PullResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function pull($subscription, $maxMessages, $optionalArgs = []) @@ -884,12 +874,10 @@ public function pull($subscription, $maxMessages, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/Pull', - PullResponse::class, - $request - ), - $this->configureCallSettings('pull', $optionalArgs) + 'Pull', + PullResponse::class, + $optionalArgs, + $request )->wait(); } @@ -909,8 +897,8 @@ public function pull($subscription, $maxMessages, $optionalArgs = []) * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $formattedSubscription = $subscriberClient->subscriptionName('[PROJECT]', '[SUBSCRIPTION]'); * $streamAckDeadlineSeconds = 0; * $request = new StreamingPullRequest(); @@ -956,18 +944,17 @@ public function pull($subscription, $maxMessages, $optionalArgs = []) * * @return \Google\ApiCore\BidiStream * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function streamingPull($optionalArgs = []) { - return $this->transport->startBidiStreamingCall( - new Call( - self::SERVICE_NAME.'/StreamingPull', - StreamingPullResponse::class - ), - $this->configureCallSettings('streamingPull', $optionalArgs), - $this->descriptors['streamingPull']['grpcStreaming'] + return $this->startCall( + 'StreamingPull', + StreamingPullResponse::class, + $optionalArgs, + null, + Call::BIDI_STREAMING_CALL ); } @@ -981,8 +968,8 @@ public function streamingPull($optionalArgs = []) * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $formattedSubscription = $subscriberClient->subscriptionName('[PROJECT]', '[SUBSCRIPTION]'); * $pushConfig = new PushConfig(); * $subscriberClient->modifyPushConfig($formattedSubscription, $pushConfig); @@ -1002,14 +989,14 @@ public function streamingPull($optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function modifyPushConfig($subscription, $pushConfig, $optionalArgs = []) @@ -1019,12 +1006,10 @@ public function modifyPushConfig($subscription, $pushConfig, $optionalArgs = []) $request->setPushConfig($pushConfig); return $this->startCall( - new Call( - self::SERVICE_NAME.'/ModifyPushConfig', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('modifyPushConfig', $optionalArgs) + 'ModifyPushConfig', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -1033,8 +1018,8 @@ public function modifyPushConfig($subscription, $pushConfig, $optionalArgs = []) * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $formattedProject = $subscriberClient->projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $subscriberClient->listSnapshots($formattedProject); @@ -1068,7 +1053,7 @@ public function modifyPushConfig($subscription, $pushConfig, $optionalArgs = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1077,7 +1062,7 @@ public function modifyPushConfig($subscription, $pushConfig, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listSnapshots($project, $optionalArgs = []) @@ -1092,13 +1077,10 @@ public function listSnapshots($project, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListSnapshots', - ListSnapshotsResponse::class, - $request - ), - $this->configureCallSettings('listSnapshots', $optionalArgs), - $this->descriptors['listSnapshots']['pageStreaming'] + 'ListSnapshots', + $optionalArgs, + ListSnapshotsResponse::class, + $request ); } @@ -1116,8 +1098,8 @@ public function listSnapshots($project, $optionalArgs = []) * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $formattedName = $subscriberClient->snapshotName('[PROJECT]', '[SNAPSHOT]'); * $formattedSubscription = $subscriberClient->subscriptionName('[PROJECT]', '[SUBSCRIPTION]'); * $response = $subscriberClient->createSnapshot($formattedName, $formattedSubscription); @@ -1143,7 +1125,7 @@ public function listSnapshots($project, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1152,7 +1134,7 @@ public function listSnapshots($project, $optionalArgs = []) * * @return \Google\Cloud\PubSub\V1\Snapshot * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createSnapshot($name, $subscription, $optionalArgs = []) @@ -1162,12 +1144,10 @@ public function createSnapshot($name, $subscription, $optionalArgs = []) $request->setSubscription($subscription); return $this->startCall( - new Call( - self::SERVICE_NAME.'/CreateSnapshot', - Snapshot::class, - $request - ), - $this->configureCallSettings('createSnapshot', $optionalArgs) + 'CreateSnapshot', + Snapshot::class, + $optionalArgs, + $request )->wait(); } @@ -1181,8 +1161,8 @@ public function createSnapshot($name, $subscription, $optionalArgs = []) * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $seconds = 123456; * $expireTime = new Timestamp(); * $expireTime->setSeconds($seconds); @@ -1204,7 +1184,7 @@ public function createSnapshot($name, $subscription, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1213,7 +1193,7 @@ public function createSnapshot($name, $subscription, $optionalArgs = []) * * @return \Google\Cloud\PubSub\V1\Snapshot * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateSnapshot($snapshot, $updateMask, $optionalArgs = []) @@ -1223,12 +1203,10 @@ public function updateSnapshot($snapshot, $updateMask, $optionalArgs = []) $request->setUpdateMask($updateMask); return $this->startCall( - new Call( - self::SERVICE_NAME.'/UpdateSnapshot', - Snapshot::class, - $request - ), - $this->configureCallSettings('updateSnapshot', $optionalArgs) + 'UpdateSnapshot', + Snapshot::class, + $optionalArgs, + $request )->wait(); } @@ -1240,8 +1218,8 @@ public function updateSnapshot($snapshot, $updateMask, $optionalArgs = []) * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $formattedSnapshot = $subscriberClient->snapshotName('[PROJECT]', '[SNAPSHOT]'); * $subscriberClient->deleteSnapshot($formattedSnapshot); * } finally { @@ -1254,14 +1232,14 @@ public function updateSnapshot($snapshot, $updateMask, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteSnapshot($snapshot, $optionalArgs = []) @@ -1270,12 +1248,10 @@ public function deleteSnapshot($snapshot, $optionalArgs = []) $request->setSnapshot($snapshot); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteSnapshot', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteSnapshot', $optionalArgs) + 'DeleteSnapshot', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -1285,8 +1261,8 @@ public function deleteSnapshot($snapshot, $optionalArgs = []) * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $formattedSubscription = $subscriberClient->subscriptionName('[PROJECT]', '[SUBSCRIPTION]'); * $response = $subscriberClient->seek($formattedSubscription); * } finally { @@ -1314,7 +1290,7 @@ public function deleteSnapshot($snapshot, $optionalArgs = []) * The snapshot to seek to. The snapshot's topic must be the same as that of * the provided subscription. * Format is `projects/{project}/snapshots/{snap}`. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1323,7 +1299,7 @@ public function deleteSnapshot($snapshot, $optionalArgs = []) * * @return \Google\Cloud\PubSub\V1\SeekResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function seek($subscription, $optionalArgs = []) @@ -1338,12 +1314,10 @@ public function seek($subscription, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/Seek', - SeekResponse::class, - $request - ), - $this->configureCallSettings('seek', $optionalArgs) + 'Seek', + SeekResponse::class, + $optionalArgs, + $request )->wait(); } @@ -1353,8 +1327,8 @@ public function seek($subscription, $optionalArgs = []) * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $formattedResource = $subscriberClient->subscriptionName('[PROJECT]', '[SUBSCRIPTION]'); * $policy = new Policy(); * $response = $subscriberClient->setIamPolicy($formattedResource, $policy); @@ -1373,7 +1347,7 @@ public function seek($subscription, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1382,7 +1356,7 @@ public function seek($subscription, $optionalArgs = []) * * @return \Google\Cloud\Iam\V1\Policy * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setIamPolicy($resource, $policy, $optionalArgs = []) @@ -1392,12 +1366,10 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) $request->setPolicy($policy); return $this->startCall( - new Call( - self::SERVICE_NAME.'/SetIamPolicy', - Policy::class, - $request - ), - $this->configureCallSettings('setIamPolicy', $optionalArgs) + 'SetIamPolicy', + Policy::class, + $optionalArgs, + $request )->wait(); } @@ -1408,8 +1380,8 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $formattedResource = $subscriberClient->subscriptionName('[PROJECT]', '[SUBSCRIPTION]'); * $response = $subscriberClient->getIamPolicy($formattedResource); * } finally { @@ -1423,7 +1395,7 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1432,7 +1404,7 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) * * @return \Google\Cloud\Iam\V1\Policy * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getIamPolicy($resource, $optionalArgs = []) @@ -1441,12 +1413,10 @@ public function getIamPolicy($resource, $optionalArgs = []) $request->setResource($resource); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetIamPolicy', - Policy::class, - $request - ), - $this->configureCallSettings('getIamPolicy', $optionalArgs) + 'GetIamPolicy', + Policy::class, + $optionalArgs, + $request )->wait(); } @@ -1457,8 +1427,8 @@ public function getIamPolicy($resource, $optionalArgs = []) * * Sample code: * ``` + * $subscriberClient = new SubscriberClient(); * try { - * $subscriberClient = new SubscriberClient(); * $formattedResource = $subscriberClient->subscriptionName('[PROJECT]', '[SUBSCRIPTION]'); * $permissions = []; * $response = $subscriberClient->testIamPermissions($formattedResource, $permissions); @@ -1477,7 +1447,7 @@ public function getIamPolicy($resource, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1486,7 +1456,7 @@ public function getIamPolicy($resource, $optionalArgs = []) * * @return \Google\Cloud\Iam\V1\TestIamPermissionsResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function testIamPermissions($resource, $permissions, $optionalArgs = []) @@ -1496,23 +1466,10 @@ public function testIamPermissions($resource, $permissions, $optionalArgs = []) $request->setPermissions($permissions); return $this->startCall( - new Call( - self::SERVICE_NAME.'/TestIamPermissions', - TestIamPermissionsResponse::class, - $request - ), - $this->configureCallSettings('testIamPermissions', $optionalArgs) + 'TestIamPermissions', + TestIamPermissionsResponse::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/PubSub/V1/PublisherClient.php b/src/PubSub/V1/PublisherClient.php index a96a3f0bf724..e10bb2799a12 100644 --- a/src/PubSub/V1/PublisherClient.php +++ b/src/PubSub/V1/PublisherClient.php @@ -1,12 +1,12 @@ [ 'google.pubsub.v1.Publisher' => [ - 'listTopics' => [ + 'ListTopics' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', @@ -13,7 +13,7 @@ 'resourcesGetMethod' => 'getTopics', ], ], - 'listTopicSubscriptions' => [ + 'ListTopicSubscriptions' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', diff --git a/src/PubSub/V1/resources/publisher_rest_client_config.php b/src/PubSub/V1/resources/publisher_rest_client_config.php index 0c68ef6bb188..155380b7ba38 100644 --- a/src/PubSub/V1/resources/publisher_rest_client_config.php +++ b/src/PubSub/V1/resources/publisher_rest_client_config.php @@ -5,98 +5,118 @@ 'google.pubsub.v1.Publisher' => [ 'CreateTopic' => [ 'method' => 'put', - 'uri' => '/v1/{name=projects/*/topics/*}', + 'uriTemplate' => '/v1/{name=projects/*/topics/*}', 'body' => '*', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'UpdateTopic' => [ 'method' => 'patch', - 'uri' => '/v1/{topic.name=projects/*/topics/*}', + 'uriTemplate' => '/v1/{topic.name=projects/*/topics/*}', 'body' => '*', 'placeholders' => [ 'topic.name' => [ - 'getTopic', - 'getName', + 'getters' => [ + 'getTopic', + 'getName', + ], ], ], ], 'Publish' => [ 'method' => 'post', - 'uri' => '/v1/{topic=projects/*/topics/*}:publish', + 'uriTemplate' => '/v1/{topic=projects/*/topics/*}:publish', 'body' => '*', 'placeholders' => [ 'topic' => [ - 'getTopic', + 'getters' => [ + 'getTopic', + ], ], ], ], 'GetTopic' => [ 'method' => 'get', - 'uri' => '/v1/{topic=projects/*/topics/*}', + 'uriTemplate' => '/v1/{topic=projects/*/topics/*}', 'placeholders' => [ 'topic' => [ - 'getTopic', + 'getters' => [ + 'getTopic', + ], ], ], ], 'ListTopics' => [ 'method' => 'get', - 'uri' => '/v1/{project=projects/*}/topics', + 'uriTemplate' => '/v1/{project=projects/*}/topics', 'placeholders' => [ 'project' => [ - 'getProject', + 'getters' => [ + 'getProject', + ], ], ], ], 'ListTopicSubscriptions' => [ 'method' => 'get', - 'uri' => '/v1/{topic=projects/*/topics/*}/subscriptions', + 'uriTemplate' => '/v1/{topic=projects/*/topics/*}/subscriptions', 'placeholders' => [ 'topic' => [ - 'getTopic', + 'getters' => [ + 'getTopic', + ], ], ], ], 'DeleteTopic' => [ 'method' => 'delete', - 'uri' => '/v1/{topic=projects/*/topics/*}', + 'uriTemplate' => '/v1/{topic=projects/*/topics/*}', 'placeholders' => [ 'topic' => [ - 'getTopic', + 'getters' => [ + 'getTopic', + ], ], ], ], 'SetIamPolicy' => [ 'method' => 'post', - 'uri' => '/v1/{resource=**}:setIamPolicy', + 'uriTemplate' => '/v1/{resource=**}:setIamPolicy', 'body' => '*', 'placeholders' => [ 'resource' => [ - 'getResource', + 'getters' => [ + 'getResource', + ], ], ], ], 'GetIamPolicy' => [ 'method' => 'post', - 'uri' => '/v1/{resource=**}:getIamPolicy', + 'uriTemplate' => '/v1/{resource=**}:getIamPolicy', 'body' => '*', 'placeholders' => [ 'resource' => [ - 'getResource', + 'getters' => [ + 'getResource', + ], ], ], ], 'TestIamPermissions' => [ 'method' => 'post', - 'uri' => '/v1/{resource=**}:testIamPermissions', + 'uriTemplate' => '/v1/{resource=**}:testIamPermissions', 'body' => '*', 'placeholders' => [ 'resource' => [ - 'getResource', + 'getters' => [ + 'getResource', + ], ], ], ], diff --git a/src/PubSub/V1/resources/subscriber_descriptor_config.php b/src/PubSub/V1/resources/subscriber_descriptor_config.php index 146b491ec59a..e21758eb176d 100644 --- a/src/PubSub/V1/resources/subscriber_descriptor_config.php +++ b/src/PubSub/V1/resources/subscriber_descriptor_config.php @@ -3,7 +3,7 @@ return [ 'interfaces' => [ 'google.pubsub.v1.Subscriber' => [ - 'listSubscriptions' => [ + 'ListSubscriptions' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', @@ -13,7 +13,7 @@ 'resourcesGetMethod' => 'getSubscriptions', ], ], - 'listSnapshots' => [ + 'ListSnapshots' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', @@ -23,7 +23,7 @@ 'resourcesGetMethod' => 'getSnapshots', ], ], - 'streamingPull' => [ + 'StreamingPull' => [ 'grpcStreaming' => [ 'grpcStreamingType' => 'BidiStreaming', 'resourcesGetMethod' => 'getReceivedMessages', diff --git a/src/PubSub/V1/resources/subscriber_rest_client_config.php b/src/PubSub/V1/resources/subscriber_rest_client_config.php index fac4f8339451..b7dd5dad9aaa 100644 --- a/src/PubSub/V1/resources/subscriber_rest_client_config.php +++ b/src/PubSub/V1/resources/subscriber_rest_client_config.php @@ -5,168 +5,202 @@ 'google.pubsub.v1.Subscriber' => [ 'CreateSubscription' => [ 'method' => 'put', - 'uri' => '/v1/{name=projects/*/subscriptions/*}', + 'uriTemplate' => '/v1/{name=projects/*/subscriptions/*}', 'body' => '*', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'GetSubscription' => [ 'method' => 'get', - 'uri' => '/v1/{subscription=projects/*/subscriptions/*}', + 'uriTemplate' => '/v1/{subscription=projects/*/subscriptions/*}', 'placeholders' => [ 'subscription' => [ - 'getSubscription', + 'getters' => [ + 'getSubscription', + ], ], ], ], 'UpdateSubscription' => [ 'method' => 'patch', - 'uri' => '/v1/{subscription.name=projects/*/subscriptions/*}', + 'uriTemplate' => '/v1/{subscription.name=projects/*/subscriptions/*}', 'body' => '*', 'placeholders' => [ 'subscription.name' => [ - 'getSubscription', - 'getName', + 'getters' => [ + 'getSubscription', + 'getName', + ], ], ], ], 'ListSubscriptions' => [ 'method' => 'get', - 'uri' => '/v1/{project=projects/*}/subscriptions', + 'uriTemplate' => '/v1/{project=projects/*}/subscriptions', 'placeholders' => [ 'project' => [ - 'getProject', + 'getters' => [ + 'getProject', + ], ], ], ], 'DeleteSubscription' => [ 'method' => 'delete', - 'uri' => '/v1/{subscription=projects/*/subscriptions/*}', + 'uriTemplate' => '/v1/{subscription=projects/*/subscriptions/*}', 'placeholders' => [ 'subscription' => [ - 'getSubscription', + 'getters' => [ + 'getSubscription', + ], ], ], ], 'ModifyAckDeadline' => [ 'method' => 'post', - 'uri' => '/v1/{subscription=projects/*/subscriptions/*}:modifyAckDeadline', + 'uriTemplate' => '/v1/{subscription=projects/*/subscriptions/*}:modifyAckDeadline', 'body' => '*', 'placeholders' => [ 'subscription' => [ - 'getSubscription', + 'getters' => [ + 'getSubscription', + ], ], ], ], 'Acknowledge' => [ 'method' => 'post', - 'uri' => '/v1/{subscription=projects/*/subscriptions/*}:acknowledge', + 'uriTemplate' => '/v1/{subscription=projects/*/subscriptions/*}:acknowledge', 'body' => '*', 'placeholders' => [ 'subscription' => [ - 'getSubscription', + 'getters' => [ + 'getSubscription', + ], ], ], ], 'Pull' => [ 'method' => 'post', - 'uri' => '/v1/{subscription=projects/*/subscriptions/*}:pull', + 'uriTemplate' => '/v1/{subscription=projects/*/subscriptions/*}:pull', 'body' => '*', 'placeholders' => [ 'subscription' => [ - 'getSubscription', + 'getters' => [ + 'getSubscription', + ], ], ], ], 'ModifyPushConfig' => [ 'method' => 'post', - 'uri' => '/v1/{subscription=projects/*/subscriptions/*}:modifyPushConfig', + 'uriTemplate' => '/v1/{subscription=projects/*/subscriptions/*}:modifyPushConfig', 'body' => '*', 'placeholders' => [ 'subscription' => [ - 'getSubscription', + 'getters' => [ + 'getSubscription', + ], ], ], ], 'ListSnapshots' => [ 'method' => 'get', - 'uri' => '/v1/{project=projects/*}/snapshots', + 'uriTemplate' => '/v1/{project=projects/*}/snapshots', 'placeholders' => [ 'project' => [ - 'getProject', + 'getters' => [ + 'getProject', + ], ], ], ], 'CreateSnapshot' => [ 'method' => 'put', - 'uri' => '/v1/{name=projects/*/snapshots/*}', + 'uriTemplate' => '/v1/{name=projects/*/snapshots/*}', 'body' => '*', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'UpdateSnapshot' => [ 'method' => 'patch', - 'uri' => '/v1/{snapshot.name=projects/*/snapshots/*}', + 'uriTemplate' => '/v1/{snapshot.name=projects/*/snapshots/*}', 'body' => '*', 'placeholders' => [ 'snapshot.name' => [ - 'getSnapshot', - 'getName', + 'getters' => [ + 'getSnapshot', + 'getName', + ], ], ], ], 'DeleteSnapshot' => [ 'method' => 'delete', - 'uri' => '/v1/{snapshot=projects/*/snapshots/*}', + 'uriTemplate' => '/v1/{snapshot=projects/*/snapshots/*}', 'placeholders' => [ 'snapshot' => [ - 'getSnapshot', + 'getters' => [ + 'getSnapshot', + ], ], ], ], 'Seek' => [ 'method' => 'post', - 'uri' => '/v1/{subscription=projects/*/subscriptions/*}:seek', + 'uriTemplate' => '/v1/{subscription=projects/*/subscriptions/*}:seek', 'body' => '*', 'placeholders' => [ 'subscription' => [ - 'getSubscription', + 'getters' => [ + 'getSubscription', + ], ], ], ], 'SetIamPolicy' => [ 'method' => 'post', - 'uri' => '/v1/{resource=**}:setIamPolicy', + 'uriTemplate' => '/v1/{resource=**}:setIamPolicy', 'body' => '*', 'placeholders' => [ 'resource' => [ - 'getResource', + 'getters' => [ + 'getResource', + ], ], ], ], 'GetIamPolicy' => [ 'method' => 'post', - 'uri' => '/v1/{resource=**}:getIamPolicy', + 'uriTemplate' => '/v1/{resource=**}:getIamPolicy', 'body' => '*', 'placeholders' => [ 'resource' => [ - 'getResource', + 'getters' => [ + 'getResource', + ], ], ], ], 'TestIamPermissions' => [ 'method' => 'post', - 'uri' => '/v1/{resource=**}:testIamPermissions', + 'uriTemplate' => '/v1/{resource=**}:testIamPermissions', 'body' => '*', 'placeholders' => [ 'resource' => [ - 'getResource', + 'getters' => [ + 'getResource', + ], ], ], ], diff --git a/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php b/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php index f8968f1d4e89..fb33c021a42d 100644 --- a/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php +++ b/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php @@ -1,12 +1,12 @@ instanceName('[PROJECT]', '[INSTANCE]'); * // Iterate through all elements * $pagedResponse = $databaseAdminClient->listDatabases($formattedParent); @@ -147,6 +151,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/database_admin_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/database_admin_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/database_admin_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -263,7 +268,7 @@ public static function parseName($formattedName, $template = null) /** * Return an OperationsClient object with the same endpoint as $this. * - * @return \Google\ApiCore\LongRunning\OperationsClient + * @return OperationsClient * @experimental */ public function getOperationsClient() @@ -281,7 +286,7 @@ public function getOperationsClient() * @param string $operationName The name of the long running operation * @param string $methodName The name of the method used to start the operation * - * @return \Google\ApiCore\OperationResponse + * @return OperationResponse * @experimental */ public function resumeOperation($operationName, $methodName = null) @@ -304,10 +309,10 @@ public function resumeOperation($operationName, $methodName = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'spanner.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -318,9 +323,9 @@ public function resumeOperation($operationName, $methodName = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Cloud Spanner Database Admin API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -338,12 +343,11 @@ public function resumeOperation($operationName, $methodName = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -368,8 +372,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $databaseAdminClient = new DatabaseAdminClient(); * try { - * $databaseAdminClient = new DatabaseAdminClient(); * $formattedParent = $databaseAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * // Iterate through all elements * $pagedResponse = $databaseAdminClient->listDatabases($formattedParent); @@ -403,7 +407,7 @@ public function __construct($options = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -412,7 +416,7 @@ public function __construct($options = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listDatabases($parent, $optionalArgs = []) @@ -427,13 +431,10 @@ public function listDatabases($parent, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListDatabases', - ListDatabasesResponse::class, - $request - ), - $this->configureCallSettings('listDatabases', $optionalArgs), - $this->descriptors['listDatabases']['pageStreaming'] + 'ListDatabases', + $optionalArgs, + ListDatabasesResponse::class, + $request ); } @@ -449,8 +450,8 @@ public function listDatabases($parent, $optionalArgs = []) * * Sample code: * ``` + * $databaseAdminClient = new DatabaseAdminClient(); * try { - * $databaseAdminClient = new DatabaseAdminClient(); * $formattedParent = $databaseAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $createStatement = ''; * $operationResponse = $databaseAdminClient->createDatabase($formattedParent, $createStatement); @@ -499,7 +500,7 @@ public function listDatabases($parent, $optionalArgs = []) * database. Statements can create tables, indexes, etc. These * statements execute atomically with the creation of the database: * if there is an error in any statement, the database is not created. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -508,7 +509,7 @@ public function listDatabases($parent, $optionalArgs = []) * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createDatabase($parent, $createStatement, $optionalArgs = []) @@ -521,14 +522,10 @@ public function createDatabase($parent, $createStatement, $optionalArgs = []) } return $this->startOperationsCall( - new Call( - self::SERVICE_NAME.'/CreateDatabase', - Operation::class, - $request - ), - $this->configureCallSettings('createDatabase', $optionalArgs), - $this->getOperationsClient(), - $this->descriptors['createDatabase']['longRunning'] + 'CreateDatabase', + $optionalArgs, + $request, + $this->getOperationsClient() )->wait(); } @@ -537,8 +534,8 @@ public function createDatabase($parent, $createStatement, $optionalArgs = []) * * Sample code: * ``` + * $databaseAdminClient = new DatabaseAdminClient(); * try { - * $databaseAdminClient = new DatabaseAdminClient(); * $formattedName = $databaseAdminClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); * $response = $databaseAdminClient->getDatabase($formattedName); * } finally { @@ -551,7 +548,7 @@ public function createDatabase($parent, $createStatement, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -560,7 +557,7 @@ public function createDatabase($parent, $createStatement, $optionalArgs = []) * * @return \Google\Cloud\Spanner\Admin\Database\V1\Database * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getDatabase($name, $optionalArgs = []) @@ -569,12 +566,10 @@ public function getDatabase($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetDatabase', - Database::class, - $request - ), - $this->configureCallSettings('getDatabase', $optionalArgs) + 'GetDatabase', + Database::class, + $optionalArgs, + $request )->wait(); } @@ -589,8 +584,8 @@ public function getDatabase($name, $optionalArgs = []) * * Sample code: * ``` + * $databaseAdminClient = new DatabaseAdminClient(); * try { - * $databaseAdminClient = new DatabaseAdminClient(); * $formattedDatabase = $databaseAdminClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); * $statements = []; * $operationResponse = $databaseAdminClient->updateDatabaseDdl($formattedDatabase, $statements); @@ -647,7 +642,7 @@ public function getDatabase($name, $optionalArgs = []) * underscore. If the named operation already exists, * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] returns * `ALREADY_EXISTS`. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -656,7 +651,7 @@ public function getDatabase($name, $optionalArgs = []) * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateDatabaseDdl($database, $statements, $optionalArgs = []) @@ -669,14 +664,10 @@ public function updateDatabaseDdl($database, $statements, $optionalArgs = []) } return $this->startOperationsCall( - new Call( - self::SERVICE_NAME.'/UpdateDatabaseDdl', - Operation::class, - $request - ), - $this->configureCallSettings('updateDatabaseDdl', $optionalArgs), - $this->getOperationsClient(), - $this->descriptors['updateDatabaseDdl']['longRunning'] + 'UpdateDatabaseDdl', + $optionalArgs, + $request, + $this->getOperationsClient() )->wait(); } @@ -685,8 +676,8 @@ public function updateDatabaseDdl($database, $statements, $optionalArgs = []) * * Sample code: * ``` + * $databaseAdminClient = new DatabaseAdminClient(); * try { - * $databaseAdminClient = new DatabaseAdminClient(); * $formattedDatabase = $databaseAdminClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); * $databaseAdminClient->dropDatabase($formattedDatabase); * } finally { @@ -698,14 +689,14 @@ public function updateDatabaseDdl($database, $statements, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function dropDatabase($database, $optionalArgs = []) @@ -714,12 +705,10 @@ public function dropDatabase($database, $optionalArgs = []) $request->setDatabase($database); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DropDatabase', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('dropDatabase', $optionalArgs) + 'DropDatabase', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -730,8 +719,8 @@ public function dropDatabase($database, $optionalArgs = []) * * Sample code: * ``` + * $databaseAdminClient = new DatabaseAdminClient(); * try { - * $databaseAdminClient = new DatabaseAdminClient(); * $formattedDatabase = $databaseAdminClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); * $response = $databaseAdminClient->getDatabaseDdl($formattedDatabase); * } finally { @@ -743,7 +732,7 @@ public function dropDatabase($database, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -752,7 +741,7 @@ public function dropDatabase($database, $optionalArgs = []) * * @return \Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseDdlResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getDatabaseDdl($database, $optionalArgs = []) @@ -761,12 +750,10 @@ public function getDatabaseDdl($database, $optionalArgs = []) $request->setDatabase($database); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetDatabaseDdl', - GetDatabaseDdlResponse::class, - $request - ), - $this->configureCallSettings('getDatabaseDdl', $optionalArgs) + 'GetDatabaseDdl', + GetDatabaseDdlResponse::class, + $optionalArgs, + $request )->wait(); } @@ -779,8 +766,8 @@ public function getDatabaseDdl($database, $optionalArgs = []) * * Sample code: * ``` + * $databaseAdminClient = new DatabaseAdminClient(); * try { - * $databaseAdminClient = new DatabaseAdminClient(); * $formattedResource = $databaseAdminClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); * $policy = new Policy(); * $response = $databaseAdminClient->setIamPolicy($formattedResource, $policy); @@ -799,7 +786,7 @@ public function getDatabaseDdl($database, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -808,7 +795,7 @@ public function getDatabaseDdl($database, $optionalArgs = []) * * @return \Google\Cloud\Iam\V1\Policy * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setIamPolicy($resource, $policy, $optionalArgs = []) @@ -818,12 +805,10 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) $request->setPolicy($policy); return $this->startCall( - new Call( - self::SERVICE_NAME.'/SetIamPolicy', - Policy::class, - $request - ), - $this->configureCallSettings('setIamPolicy', $optionalArgs) + 'SetIamPolicy', + Policy::class, + $optionalArgs, + $request )->wait(); } @@ -836,8 +821,8 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) * * Sample code: * ``` + * $databaseAdminClient = new DatabaseAdminClient(); * try { - * $databaseAdminClient = new DatabaseAdminClient(); * $formattedResource = $databaseAdminClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); * $response = $databaseAdminClient->getIamPolicy($formattedResource); * } finally { @@ -851,7 +836,7 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -860,7 +845,7 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) * * @return \Google\Cloud\Iam\V1\Policy * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getIamPolicy($resource, $optionalArgs = []) @@ -869,12 +854,10 @@ public function getIamPolicy($resource, $optionalArgs = []) $request->setResource($resource); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetIamPolicy', - Policy::class, - $request - ), - $this->configureCallSettings('getIamPolicy', $optionalArgs) + 'GetIamPolicy', + Policy::class, + $optionalArgs, + $request )->wait(); } @@ -888,8 +871,8 @@ public function getIamPolicy($resource, $optionalArgs = []) * * Sample code: * ``` + * $databaseAdminClient = new DatabaseAdminClient(); * try { - * $databaseAdminClient = new DatabaseAdminClient(); * $formattedResource = $databaseAdminClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); * $permissions = []; * $response = $databaseAdminClient->testIamPermissions($formattedResource, $permissions); @@ -908,7 +891,7 @@ public function getIamPolicy($resource, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -917,7 +900,7 @@ public function getIamPolicy($resource, $optionalArgs = []) * * @return \Google\Cloud\Iam\V1\TestIamPermissionsResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function testIamPermissions($resource, $permissions, $optionalArgs = []) @@ -927,23 +910,10 @@ public function testIamPermissions($resource, $permissions, $optionalArgs = []) $request->setPermissions($permissions); return $this->startCall( - new Call( - self::SERVICE_NAME.'/TestIamPermissions', - TestIamPermissionsResponse::class, - $request - ), - $this->configureCallSettings('testIamPermissions', $optionalArgs) + 'TestIamPermissions', + TestIamPermissionsResponse::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Spanner/Admin/Database/V1/resources/database_admin_descriptor_config.php b/src/Spanner/Admin/Database/V1/resources/database_admin_descriptor_config.php index 3e4bf8b5f071..038af90e382f 100644 --- a/src/Spanner/Admin/Database/V1/resources/database_admin_descriptor_config.php +++ b/src/Spanner/Admin/Database/V1/resources/database_admin_descriptor_config.php @@ -3,19 +3,19 @@ return [ 'interfaces' => [ 'google.spanner.admin.database.v1.DatabaseAdmin' => [ - 'createDatabase' => [ + 'CreateDatabase' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\Database', 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\CreateDatabaseMetadata', ], ], - 'updateDatabaseDdl' => [ + 'UpdateDatabaseDdl' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Protobuf\GPBEmpty', 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseDdlMetadata', ], ], - 'listDatabases' => [ + 'ListDatabases' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', diff --git a/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php b/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php index 638e8fb6391e..76359b7725bd 100644 --- a/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php +++ b/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php @@ -5,87 +5,105 @@ 'google.spanner.admin.database.v1.DatabaseAdmin' => [ 'ListDatabases' => [ 'method' => 'get', - 'uri' => '/v1/{parent=projects/*/instances/*}/databases', + 'uriTemplate' => '/v1/{parent=projects/*/instances/*}/databases', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'CreateDatabase' => [ 'method' => 'post', - 'uri' => '/v1/{parent=projects/*/instances/*}/databases', + 'uriTemplate' => '/v1/{parent=projects/*/instances/*}/databases', 'body' => '*', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'GetDatabase' => [ 'method' => 'get', - 'uri' => '/v1/{name=projects/*/instances/*/databases/*}', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'UpdateDatabaseDdl' => [ 'method' => 'patch', - 'uri' => '/v1/{database=projects/*/instances/*/databases/*}/ddl', + 'uriTemplate' => '/v1/{database=projects/*/instances/*/databases/*}/ddl', 'body' => '*', 'placeholders' => [ 'database' => [ - 'getDatabase', + 'getters' => [ + 'getDatabase', + ], ], ], ], 'DropDatabase' => [ 'method' => 'delete', - 'uri' => '/v1/{database=projects/*/instances/*/databases/*}', + 'uriTemplate' => '/v1/{database=projects/*/instances/*/databases/*}', 'placeholders' => [ 'database' => [ - 'getDatabase', + 'getters' => [ + 'getDatabase', + ], ], ], ], 'GetDatabaseDdl' => [ 'method' => 'get', - 'uri' => '/v1/{database=projects/*/instances/*/databases/*}/ddl', + 'uriTemplate' => '/v1/{database=projects/*/instances/*/databases/*}/ddl', 'placeholders' => [ 'database' => [ - 'getDatabase', + 'getters' => [ + 'getDatabase', + ], ], ], ], 'SetIamPolicy' => [ 'method' => 'post', - 'uri' => '/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy', 'body' => '*', 'placeholders' => [ 'resource' => [ - 'getResource', + 'getters' => [ + 'getResource', + ], ], ], ], 'GetIamPolicy' => [ 'method' => 'post', - 'uri' => '/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy', 'body' => '*', 'placeholders' => [ 'resource' => [ - 'getResource', + 'getters' => [ + 'getResource', + ], ], ], ], 'TestIamPermissions' => [ 'method' => 'post', - 'uri' => '/v1/{resource=projects/*/instances/*/databases/*}:testIamPermissions', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*/databases/*}:testIamPermissions', 'body' => '*', 'placeholders' => [ 'resource' => [ - 'getResource', + 'getters' => [ + 'getResource', + ], ], ], ], diff --git a/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php b/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php index af653b4620de..918d5a8282dc 100644 --- a/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php +++ b/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php @@ -1,12 +1,12 @@ projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $instanceAdminClient->listInstanceConfigs($formattedParent); @@ -167,6 +171,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/instance_admin_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/instance_admin_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/instance_admin_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -308,7 +313,7 @@ public static function parseName($formattedName, $template = null) /** * Return an OperationsClient object with the same endpoint as $this. * - * @return \Google\ApiCore\LongRunning\OperationsClient + * @return OperationsClient * @experimental */ public function getOperationsClient() @@ -326,7 +331,7 @@ public function getOperationsClient() * @param string $operationName The name of the long running operation * @param string $methodName The name of the method used to start the operation * - * @return \Google\ApiCore\OperationResponse + * @return OperationResponse * @experimental */ public function resumeOperation($operationName, $methodName = null) @@ -349,10 +354,10 @@ public function resumeOperation($operationName, $methodName = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'spanner.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -363,9 +368,9 @@ public function resumeOperation($operationName, $methodName = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Cloud Spanner Instance Admin API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -383,12 +388,11 @@ public function resumeOperation($operationName, $methodName = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -413,8 +417,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $instanceAdminClient = new InstanceAdminClient(); * try { - * $instanceAdminClient = new InstanceAdminClient(); * $formattedParent = $instanceAdminClient->projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $instanceAdminClient->listInstanceConfigs($formattedParent); @@ -449,7 +453,7 @@ public function __construct($options = []) * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -458,7 +462,7 @@ public function __construct($options = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listInstanceConfigs($parent, $optionalArgs = []) @@ -473,13 +477,10 @@ public function listInstanceConfigs($parent, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListInstanceConfigs', - ListInstanceConfigsResponse::class, - $request - ), - $this->configureCallSettings('listInstanceConfigs', $optionalArgs), - $this->descriptors['listInstanceConfigs']['pageStreaming'] + 'ListInstanceConfigs', + $optionalArgs, + ListInstanceConfigsResponse::class, + $request ); } @@ -488,8 +489,8 @@ public function listInstanceConfigs($parent, $optionalArgs = []) * * Sample code: * ``` + * $instanceAdminClient = new InstanceAdminClient(); * try { - * $instanceAdminClient = new InstanceAdminClient(); * $formattedName = $instanceAdminClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); * $response = $instanceAdminClient->getInstanceConfig($formattedName); * } finally { @@ -502,7 +503,7 @@ public function listInstanceConfigs($parent, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -511,7 +512,7 @@ public function listInstanceConfigs($parent, $optionalArgs = []) * * @return \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getInstanceConfig($name, $optionalArgs = []) @@ -520,12 +521,10 @@ public function getInstanceConfig($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetInstanceConfig', - InstanceConfig::class, - $request - ), - $this->configureCallSettings('getInstanceConfig', $optionalArgs) + 'GetInstanceConfig', + InstanceConfig::class, + $optionalArgs, + $request )->wait(); } @@ -534,8 +533,8 @@ public function getInstanceConfig($name, $optionalArgs = []) * * Sample code: * ``` + * $instanceAdminClient = new InstanceAdminClient(); * try { - * $instanceAdminClient = new InstanceAdminClient(); * $formattedParent = $instanceAdminClient->projectName('[PROJECT]'); * // Iterate through all elements * $pagedResponse = $instanceAdminClient->listInstances($formattedParent); @@ -589,7 +588,7 @@ public function getInstanceConfig($name, $optionalArgs = []) * * `name:howl labels.env:dev` --> The instance's name contains "howl" and * it has the label "env" with its value * containing "dev". - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -598,7 +597,7 @@ public function getInstanceConfig($name, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listInstances($parent, $optionalArgs = []) @@ -616,13 +615,10 @@ public function listInstances($parent, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListInstances', - ListInstancesResponse::class, - $request - ), - $this->configureCallSettings('listInstances', $optionalArgs), - $this->descriptors['listInstances']['pageStreaming'] + 'ListInstances', + $optionalArgs, + ListInstancesResponse::class, + $request ); } @@ -631,8 +627,8 @@ public function listInstances($parent, $optionalArgs = []) * * Sample code: * ``` + * $instanceAdminClient = new InstanceAdminClient(); * try { - * $instanceAdminClient = new InstanceAdminClient(); * $formattedName = $instanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $response = $instanceAdminClient->getInstance($formattedName); * } finally { @@ -645,7 +641,7 @@ public function listInstances($parent, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -654,7 +650,7 @@ public function listInstances($parent, $optionalArgs = []) * * @return \Google\Cloud\Spanner\Admin\Instance\V1\Instance * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getInstance($name, $optionalArgs = []) @@ -663,12 +659,10 @@ public function getInstance($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetInstance', - Instance::class, - $request - ), - $this->configureCallSettings('getInstance', $optionalArgs) + 'GetInstance', + Instance::class, + $optionalArgs, + $request )->wait(); } @@ -710,8 +704,8 @@ public function getInstance($name, $optionalArgs = []) * * Sample code: * ``` + * $instanceAdminClient = new InstanceAdminClient(); * try { - * $instanceAdminClient = new InstanceAdminClient(); * $formattedParent = $instanceAdminClient->projectName('[PROJECT]'); * $instanceId = ''; * $instance = new Instance(); @@ -756,7 +750,7 @@ public function getInstance($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -765,7 +759,7 @@ public function getInstance($name, $optionalArgs = []) * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createInstance($parent, $instanceId, $instance, $optionalArgs = []) @@ -776,14 +770,10 @@ public function createInstance($parent, $instanceId, $instance, $optionalArgs = $request->setInstance($instance); return $this->startOperationsCall( - new Call( - self::SERVICE_NAME.'/CreateInstance', - Operation::class, - $request - ), - $this->configureCallSettings('createInstance', $optionalArgs), - $this->getOperationsClient(), - $this->descriptors['createInstance']['longRunning'] + 'CreateInstance', + $optionalArgs, + $request, + $this->getOperationsClient() )->wait(); } @@ -831,8 +821,8 @@ public function createInstance($parent, $instanceId, $instance, $optionalArgs = * * Sample code: * ``` + * $instanceAdminClient = new InstanceAdminClient(); * try { - * $instanceAdminClient = new InstanceAdminClient(); * $instance = new Instance(); * $fieldMask = new FieldMask(); * $operationResponse = $instanceAdminClient->updateInstance($instance, $fieldMask); @@ -875,7 +865,7 @@ public function createInstance($parent, $instanceId, $instance, $optionalArgs = * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -884,7 +874,7 @@ public function createInstance($parent, $instanceId, $instance, $optionalArgs = * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateInstance($instance, $fieldMask, $optionalArgs = []) @@ -894,14 +884,10 @@ public function updateInstance($instance, $fieldMask, $optionalArgs = []) $request->setFieldMask($fieldMask); return $this->startOperationsCall( - new Call( - self::SERVICE_NAME.'/UpdateInstance', - Operation::class, - $request - ), - $this->configureCallSettings('updateInstance', $optionalArgs), - $this->getOperationsClient(), - $this->descriptors['updateInstance']['longRunning'] + 'UpdateInstance', + $optionalArgs, + $request, + $this->getOperationsClient() )->wait(); } @@ -920,8 +906,8 @@ public function updateInstance($instance, $fieldMask, $optionalArgs = []) * * Sample code: * ``` + * $instanceAdminClient = new InstanceAdminClient(); * try { - * $instanceAdminClient = new InstanceAdminClient(); * $formattedName = $instanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $instanceAdminClient->deleteInstance($formattedName); * } finally { @@ -934,14 +920,14 @@ public function updateInstance($instance, $fieldMask, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteInstance($name, $optionalArgs = []) @@ -950,12 +936,10 @@ public function deleteInstance($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteInstance', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteInstance', $optionalArgs) + 'DeleteInstance', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -968,8 +952,8 @@ public function deleteInstance($name, $optionalArgs = []) * * Sample code: * ``` + * $instanceAdminClient = new InstanceAdminClient(); * try { - * $instanceAdminClient = new InstanceAdminClient(); * $formattedResource = $instanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $policy = new Policy(); * $response = $instanceAdminClient->setIamPolicy($formattedResource, $policy); @@ -988,7 +972,7 @@ public function deleteInstance($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -997,7 +981,7 @@ public function deleteInstance($name, $optionalArgs = []) * * @return \Google\Cloud\Iam\V1\Policy * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setIamPolicy($resource, $policy, $optionalArgs = []) @@ -1007,12 +991,10 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) $request->setPolicy($policy); return $this->startCall( - new Call( - self::SERVICE_NAME.'/SetIamPolicy', - Policy::class, - $request - ), - $this->configureCallSettings('setIamPolicy', $optionalArgs) + 'SetIamPolicy', + Policy::class, + $optionalArgs, + $request )->wait(); } @@ -1025,8 +1007,8 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) * * Sample code: * ``` + * $instanceAdminClient = new InstanceAdminClient(); * try { - * $instanceAdminClient = new InstanceAdminClient(); * $formattedResource = $instanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $response = $instanceAdminClient->getIamPolicy($formattedResource); * } finally { @@ -1040,7 +1022,7 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1049,7 +1031,7 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) * * @return \Google\Cloud\Iam\V1\Policy * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getIamPolicy($resource, $optionalArgs = []) @@ -1058,12 +1040,10 @@ public function getIamPolicy($resource, $optionalArgs = []) $request->setResource($resource); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetIamPolicy', - Policy::class, - $request - ), - $this->configureCallSettings('getIamPolicy', $optionalArgs) + 'GetIamPolicy', + Policy::class, + $optionalArgs, + $request )->wait(); } @@ -1077,8 +1057,8 @@ public function getIamPolicy($resource, $optionalArgs = []) * * Sample code: * ``` + * $instanceAdminClient = new InstanceAdminClient(); * try { - * $instanceAdminClient = new InstanceAdminClient(); * $formattedResource = $instanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); * $permissions = []; * $response = $instanceAdminClient->testIamPermissions($formattedResource, $permissions); @@ -1097,7 +1077,7 @@ public function getIamPolicy($resource, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1106,7 +1086,7 @@ public function getIamPolicy($resource, $optionalArgs = []) * * @return \Google\Cloud\Iam\V1\TestIamPermissionsResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function testIamPermissions($resource, $permissions, $optionalArgs = []) @@ -1116,23 +1096,10 @@ public function testIamPermissions($resource, $permissions, $optionalArgs = []) $request->setPermissions($permissions); return $this->startCall( - new Call( - self::SERVICE_NAME.'/TestIamPermissions', - TestIamPermissionsResponse::class, - $request - ), - $this->configureCallSettings('testIamPermissions', $optionalArgs) + 'TestIamPermissions', + TestIamPermissionsResponse::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php b/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php index 87a5fc06cc66..64f062cd4b98 100644 --- a/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php +++ b/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php @@ -1,12 +1,12 @@ [ 'google.spanner.admin.instance.v1.InstanceAdmin' => [ - 'createInstance' => [ + 'CreateInstance' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\Instance', 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\CreateInstanceMetadata', ], ], - 'updateInstance' => [ + 'UpdateInstance' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\Instance', 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceMetadata', ], ], - 'listInstanceConfigs' => [ + 'ListInstanceConfigs' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', @@ -25,7 +25,7 @@ 'resourcesGetMethod' => 'getInstanceConfigs', ], ], - 'listInstances' => [ + 'ListInstances' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', diff --git a/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php b/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php index f04652899b6b..a885fccf6e19 100644 --- a/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php +++ b/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php @@ -5,97 +5,117 @@ 'google.spanner.admin.instance.v1.InstanceAdmin' => [ 'ListInstanceConfigs' => [ 'method' => 'get', - 'uri' => '/v1/{parent=projects/*}/instanceConfigs', + 'uriTemplate' => '/v1/{parent=projects/*}/instanceConfigs', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'GetInstanceConfig' => [ 'method' => 'get', - 'uri' => '/v1/{name=projects/*/instanceConfigs/*}', + 'uriTemplate' => '/v1/{name=projects/*/instanceConfigs/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'ListInstances' => [ 'method' => 'get', - 'uri' => '/v1/{parent=projects/*}/instances', + 'uriTemplate' => '/v1/{parent=projects/*}/instances', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'GetInstance' => [ 'method' => 'get', - 'uri' => '/v1/{name=projects/*/instances/*}', + 'uriTemplate' => '/v1/{name=projects/*/instances/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'CreateInstance' => [ 'method' => 'post', - 'uri' => '/v1/{parent=projects/*}/instances', + 'uriTemplate' => '/v1/{parent=projects/*}/instances', 'body' => '*', 'placeholders' => [ 'parent' => [ - 'getParent', + 'getters' => [ + 'getParent', + ], ], ], ], 'UpdateInstance' => [ 'method' => 'patch', - 'uri' => '/v1/{instance.name=projects/*/instances/*}', + 'uriTemplate' => '/v1/{instance.name=projects/*/instances/*}', 'body' => '*', 'placeholders' => [ 'instance.name' => [ - 'getInstance', - 'getName', + 'getters' => [ + 'getInstance', + 'getName', + ], ], ], ], 'DeleteInstance' => [ 'method' => 'delete', - 'uri' => '/v1/{name=projects/*/instances/*}', + 'uriTemplate' => '/v1/{name=projects/*/instances/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'SetIamPolicy' => [ 'method' => 'post', - 'uri' => '/v1/{resource=projects/*/instances/*}:setIamPolicy', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*}:setIamPolicy', 'body' => '*', 'placeholders' => [ 'resource' => [ - 'getResource', + 'getters' => [ + 'getResource', + ], ], ], ], 'GetIamPolicy' => [ 'method' => 'post', - 'uri' => '/v1/{resource=projects/*/instances/*}:getIamPolicy', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*}:getIamPolicy', 'body' => '*', 'placeholders' => [ 'resource' => [ - 'getResource', + 'getters' => [ + 'getResource', + ], ], ], ], 'TestIamPermissions' => [ 'method' => 'post', - 'uri' => '/v1/{resource=projects/*/instances/*}:testIamPermissions', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*}:testIamPermissions', 'body' => '*', 'placeholders' => [ 'resource' => [ - 'getResource', + 'getters' => [ + 'getResource', + ], ], ], ], diff --git a/src/Spanner/V1/Gapic/SpannerGapicClient.php b/src/Spanner/V1/Gapic/SpannerGapicClient.php index 356cd015168b..8d9dddc4c56d 100644 --- a/src/Spanner/V1/Gapic/SpannerGapicClient.php +++ b/src/Spanner/V1/Gapic/SpannerGapicClient.php @@ -1,12 +1,12 @@ databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); * $response = $spannerClient->createSession($formattedDatabase); * } finally { @@ -134,6 +139,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/spanner_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/spanner_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/spanner_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -260,10 +266,10 @@ public static function parseName($formattedName, $template = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'spanner.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -274,9 +280,9 @@ public static function parseName($formattedName, $template = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Cloud Spanner API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -294,12 +300,11 @@ public static function parseName($formattedName, $template = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -334,8 +339,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $spannerClient = new SpannerClient(); * try { - * $spannerClient = new SpannerClient(); * $formattedDatabase = $spannerClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); * $response = $spannerClient->createSession($formattedDatabase); * } finally { @@ -349,7 +354,7 @@ public function __construct($options = []) * * @type Session $session * The session to create. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -358,7 +363,7 @@ public function __construct($options = []) * * @return \Google\Cloud\Spanner\V1\Session * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createSession($database, $optionalArgs = []) @@ -370,12 +375,10 @@ public function createSession($database, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/CreateSession', - Session::class, - $request - ), - $this->configureCallSettings('createSession', $optionalArgs) + 'CreateSession', + Session::class, + $optionalArgs, + $request )->wait(); } @@ -386,8 +389,8 @@ public function createSession($database, $optionalArgs = []) * * Sample code: * ``` + * $spannerClient = new SpannerClient(); * try { - * $spannerClient = new SpannerClient(); * $formattedName = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); * $response = $spannerClient->getSession($formattedName); * } finally { @@ -399,7 +402,7 @@ public function createSession($database, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -408,7 +411,7 @@ public function createSession($database, $optionalArgs = []) * * @return \Google\Cloud\Spanner\V1\Session * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getSession($name, $optionalArgs = []) @@ -417,12 +420,10 @@ public function getSession($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/GetSession', - Session::class, - $request - ), - $this->configureCallSettings('getSession', $optionalArgs) + 'GetSession', + Session::class, + $optionalArgs, + $request )->wait(); } @@ -431,8 +432,8 @@ public function getSession($name, $optionalArgs = []) * * Sample code: * ``` + * $spannerClient = new SpannerClient(); * try { - * $spannerClient = new SpannerClient(); * $formattedDatabase = $spannerClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); * // Iterate through all elements * $pagedResponse = $spannerClient->listSessions($formattedDatabase); @@ -476,7 +477,7 @@ public function getSession($name, $optionalArgs = []) * * `labels.env:*` --> The session has the label "env". * * `labels.env:dev` --> The session has the label "env" and the value of * the label contains the string "dev". - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -485,7 +486,7 @@ public function getSession($name, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listSessions($database, $optionalArgs = []) @@ -503,13 +504,10 @@ public function listSessions($database, $optionalArgs = []) } return $this->getPagedListResponse( - new Call( - self::SERVICE_NAME.'/ListSessions', - ListSessionsResponse::class, - $request - ), - $this->configureCallSettings('listSessions', $optionalArgs), - $this->descriptors['listSessions']['pageStreaming'] + 'ListSessions', + $optionalArgs, + ListSessionsResponse::class, + $request ); } @@ -518,8 +516,8 @@ public function listSessions($database, $optionalArgs = []) * * Sample code: * ``` + * $spannerClient = new SpannerClient(); * try { - * $spannerClient = new SpannerClient(); * $formattedName = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); * $spannerClient->deleteSession($formattedName); * } finally { @@ -531,14 +529,14 @@ public function listSessions($database, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteSession($name, $optionalArgs = []) @@ -547,12 +545,10 @@ public function deleteSession($name, $optionalArgs = []) $request->setName($name); return $this->startCall( - new Call( - self::SERVICE_NAME.'/DeleteSession', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('deleteSession', $optionalArgs) + 'DeleteSession', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } @@ -571,8 +567,8 @@ public function deleteSession($name, $optionalArgs = []) * * Sample code: * ``` + * $spannerClient = new SpannerClient(); * try { - * $spannerClient = new SpannerClient(); * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); * $sql = ''; * $response = $spannerClient->executeSql($formattedSession, $sql); @@ -624,7 +620,7 @@ public function deleteSession($name, $optionalArgs = []) * Used to control the amount of debugging information returned in * [ResultSetStats][google.spanner.v1.ResultSetStats]. * For allowed values, use constants defined on {@see \Google\Cloud\Spanner\V1\ExecuteSqlRequest_QueryMode} - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -633,7 +629,7 @@ public function deleteSession($name, $optionalArgs = []) * * @return \Google\Cloud\Spanner\V1\ResultSet * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function executeSql($session, $sql, $optionalArgs = []) @@ -658,12 +654,10 @@ public function executeSql($session, $sql, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/ExecuteSql', - ResultSet::class, - $request - ), - $this->configureCallSettings('executeSql', $optionalArgs) + 'ExecuteSql', + ResultSet::class, + $optionalArgs, + $request )->wait(); } @@ -676,8 +670,8 @@ public function executeSql($session, $sql, $optionalArgs = []) * * Sample code: * ``` + * $spannerClient = new SpannerClient(); * try { - * $spannerClient = new SpannerClient(); * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); * $sql = ''; * // Read all responses until the stream is complete @@ -739,7 +733,7 @@ public function executeSql($session, $sql, $optionalArgs = []) * * @return \Google\ApiCore\ServerStream * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function executeStreamingSql($session, $sql, $optionalArgs = []) @@ -763,14 +757,12 @@ public function executeStreamingSql($session, $sql, $optionalArgs = []) $request->setQueryMode($optionalArgs['queryMode']); } - return $this->transport->startServerStreamingCall( - new Call( - self::SERVICE_NAME.'/ExecuteStreamingSql', - PartialResultSet::class, - $request - ), - $this->configureCallSettings('executeStreamingSql', $optionalArgs), - $this->descriptors['executeStreamingSql']['grpcStreaming'] + return $this->startCall( + 'ExecuteStreamingSql', + PartialResultSet::class, + $optionalArgs, + $request, + Call::SERVER_STREAMING_CALL ); } @@ -791,8 +783,8 @@ public function executeStreamingSql($session, $sql, $optionalArgs = []) * * Sample code: * ``` + * $spannerClient = new SpannerClient(); * try { - * $spannerClient = new SpannerClient(); * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); * $table = ''; * $columns = []; @@ -837,7 +829,7 @@ public function executeStreamingSql($session, $sql, $optionalArgs = []) * enables the new read to resume where the last read left off. The * rest of the request parameters must exactly match the request * that yielded this token. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -846,7 +838,7 @@ public function executeStreamingSql($session, $sql, $optionalArgs = []) * * @return \Google\Cloud\Spanner\V1\ResultSet * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function read($session, $table, $columns, $keySet, $optionalArgs = []) @@ -870,12 +862,10 @@ public function read($session, $table, $columns, $keySet, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/Read', - ResultSet::class, - $request - ), - $this->configureCallSettings('read', $optionalArgs) + 'Read', + ResultSet::class, + $optionalArgs, + $request )->wait(); } @@ -888,8 +878,8 @@ public function read($session, $table, $columns, $keySet, $optionalArgs = []) * * Sample code: * ``` + * $spannerClient = new SpannerClient(); * try { - * $spannerClient = new SpannerClient(); * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); * $table = ''; * $columns = []; @@ -944,7 +934,7 @@ public function read($session, $table, $columns, $keySet, $optionalArgs = []) * * @return \Google\ApiCore\ServerStream * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function streamingRead($session, $table, $columns, $keySet, $optionalArgs = []) @@ -967,14 +957,12 @@ public function streamingRead($session, $table, $columns, $keySet, $optionalArgs $request->setResumeToken($optionalArgs['resumeToken']); } - return $this->transport->startServerStreamingCall( - new Call( - self::SERVICE_NAME.'/StreamingRead', - PartialResultSet::class, - $request - ), - $this->configureCallSettings('streamingRead', $optionalArgs), - $this->descriptors['streamingRead']['grpcStreaming'] + return $this->startCall( + 'StreamingRead', + PartialResultSet::class, + $optionalArgs, + $request, + Call::SERVER_STREAMING_CALL ); } @@ -986,8 +974,8 @@ public function streamingRead($session, $table, $columns, $keySet, $optionalArgs * * Sample code: * ``` + * $spannerClient = new SpannerClient(); * try { - * $spannerClient = new SpannerClient(); * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); * $options = new TransactionOptions(); * $response = $spannerClient->beginTransaction($formattedSession, $options); @@ -1001,7 +989,7 @@ public function streamingRead($session, $table, $columns, $keySet, $optionalArgs * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1010,7 +998,7 @@ public function streamingRead($session, $table, $columns, $keySet, $optionalArgs * * @return \Google\Cloud\Spanner\V1\Transaction * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function beginTransaction($session, $options, $optionalArgs = []) @@ -1020,12 +1008,10 @@ public function beginTransaction($session, $options, $optionalArgs = []) $request->setOptions($options); return $this->startCall( - new Call( - self::SERVICE_NAME.'/BeginTransaction', - Transaction::class, - $request - ), - $this->configureCallSettings('beginTransaction', $optionalArgs) + 'BeginTransaction', + Transaction::class, + $optionalArgs, + $request )->wait(); } @@ -1041,8 +1027,8 @@ public function beginTransaction($session, $options, $optionalArgs = []) * * Sample code: * ``` + * $spannerClient = new SpannerClient(); * try { - * $spannerClient = new SpannerClient(); * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); * $mutations = []; * $response = $spannerClient->commit($formattedSession, $mutations); @@ -1070,7 +1056,7 @@ public function beginTransaction($session, $options, $optionalArgs = []) * executed more than once. If this is undesirable, use * [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and * [Commit][google.spanner.v1.Spanner.Commit] instead. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1079,7 +1065,7 @@ public function beginTransaction($session, $options, $optionalArgs = []) * * @return \Google\Cloud\Spanner\V1\CommitResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function commit($session, $mutations, $optionalArgs = []) @@ -1095,12 +1081,10 @@ public function commit($session, $mutations, $optionalArgs = []) } return $this->startCall( - new Call( - self::SERVICE_NAME.'/Commit', - CommitResponse::class, - $request - ), - $this->configureCallSettings('commit', $optionalArgs) + 'Commit', + CommitResponse::class, + $optionalArgs, + $request )->wait(); } @@ -1116,8 +1100,8 @@ public function commit($session, $mutations, $optionalArgs = []) * * Sample code: * ``` + * $spannerClient = new SpannerClient(); * try { - * $spannerClient = new SpannerClient(); * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); * $transactionId = ''; * $spannerClient->rollback($formattedSession, $transactionId); @@ -1131,14 +1115,14 @@ public function commit($session, $mutations, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function rollback($session, $transactionId, $optionalArgs = []) @@ -1148,23 +1132,10 @@ public function rollback($session, $transactionId, $optionalArgs = []) $request->setTransactionId($transactionId); return $this->startCall( - new Call( - self::SERVICE_NAME.'/Rollback', - GPBEmpty::class, - $request - ), - $this->configureCallSettings('rollback', $optionalArgs) + 'Rollback', + GPBEmpty::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Spanner/V1/SpannerClient.php b/src/Spanner/V1/SpannerClient.php index c4dbdd2affbc..1450b95958a7 100644 --- a/src/Spanner/V1/SpannerClient.php +++ b/src/Spanner/V1/SpannerClient.php @@ -1,12 +1,12 @@ [ 'google.spanner.v1.Spanner' => [ - 'listSessions' => [ + 'ListSessions' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', @@ -13,12 +13,12 @@ 'resourcesGetMethod' => 'getSessions', ], ], - 'executeStreamingSql' => [ + 'ExecuteStreamingSql' => [ 'grpcStreaming' => [ 'grpcStreamingType' => 'ServerStreaming', ], ], - 'streamingRead' => [ + 'StreamingRead' => [ 'grpcStreaming' => [ 'grpcStreamingType' => 'ServerStreaming', ], diff --git a/src/Spanner/V1/resources/spanner_rest_client_config.php b/src/Spanner/V1/resources/spanner_rest_client_config.php index 35b11cb03a96..3a6202f27e9f 100644 --- a/src/Spanner/V1/resources/spanner_rest_client_config.php +++ b/src/Spanner/V1/resources/spanner_rest_client_config.php @@ -5,108 +5,106 @@ 'google.spanner.v1.Spanner' => [ 'CreateSession' => [ 'method' => 'post', - 'uri' => '/v1/{database=projects/*/instances/*/databases/*}/sessions', + 'uriTemplate' => '/v1/{database=projects/*/instances/*/databases/*}/sessions', 'body' => '*', 'placeholders' => [ 'database' => [ - 'getDatabase', + 'getters' => [ + 'getDatabase', + ], ], ], ], 'GetSession' => [ 'method' => 'get', - 'uri' => '/v1/{name=projects/*/instances/*/databases/*/sessions/*}', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/sessions/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'ListSessions' => [ 'method' => 'get', - 'uri' => '/v1/{database=projects/*/instances/*/databases/*}/sessions', + 'uriTemplate' => '/v1/{database=projects/*/instances/*/databases/*}/sessions', 'placeholders' => [ 'database' => [ - 'getDatabase', + 'getters' => [ + 'getDatabase', + ], ], ], ], 'DeleteSession' => [ 'method' => 'delete', - 'uri' => '/v1/{name=projects/*/instances/*/databases/*/sessions/*}', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/sessions/*}', 'placeholders' => [ 'name' => [ - 'getName', + 'getters' => [ + 'getName', + ], ], ], ], 'ExecuteSql' => [ 'method' => 'post', - 'uri' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeSql', + 'uriTemplate' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeSql', 'body' => '*', 'placeholders' => [ 'session' => [ - 'getSession', - ], - ], - ], - 'ExecuteStreamingSql' => [ - 'method' => 'post', - 'uri' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeStreamingSql', - 'body' => '*', - 'placeholders' => [ - 'session' => [ - 'getSession', + 'getters' => [ + 'getSession', + ], ], ], ], 'Read' => [ 'method' => 'post', - 'uri' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:read', - 'body' => '*', - 'placeholders' => [ - 'session' => [ - 'getSession', - ], - ], - ], - 'StreamingRead' => [ - 'method' => 'post', - 'uri' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:streamingRead', + 'uriTemplate' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:read', 'body' => '*', 'placeholders' => [ 'session' => [ - 'getSession', + 'getters' => [ + 'getSession', + ], ], ], ], 'BeginTransaction' => [ 'method' => 'post', - 'uri' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:beginTransaction', + 'uriTemplate' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:beginTransaction', 'body' => '*', 'placeholders' => [ 'session' => [ - 'getSession', + 'getters' => [ + 'getSession', + ], ], ], ], 'Commit' => [ 'method' => 'post', - 'uri' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:commit', + 'uriTemplate' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:commit', 'body' => '*', 'placeholders' => [ 'session' => [ - 'getSession', + 'getters' => [ + 'getSession', + ], ], ], ], 'Rollback' => [ 'method' => 'post', - 'uri' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:rollback', + 'uriTemplate' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:rollback', 'body' => '*', 'placeholders' => [ 'session' => [ - 'getSession', + 'getters' => [ + 'getSession', + ], ], ], ], diff --git a/src/Speech/V1/Gapic/SpeechGapicClient.php b/src/Speech/V1/Gapic/SpeechGapicClient.php index 642b1783863f..33fe47b23884 100644 --- a/src/Speech/V1/Gapic/SpeechGapicClient.php +++ b/src/Speech/V1/Gapic/SpeechGapicClient.php @@ -1,12 +1,12 @@ __DIR__.'/../resources/speech_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/speech_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/speech_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } /** * Return an OperationsClient object with the same endpoint as $this. * - * @return \Google\ApiCore\LongRunning\OperationsClient + * @return OperationsClient * @experimental */ public function getOperationsClient() @@ -143,7 +149,7 @@ public function getOperationsClient() * @param string $operationName The name of the long running operation * @param string $methodName The name of the method used to start the operation * - * @return \Google\ApiCore\OperationResponse + * @return OperationResponse * @experimental */ public function resumeOperation($operationName, $methodName = null) @@ -166,10 +172,10 @@ public function resumeOperation($operationName, $methodName = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'speech.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -180,9 +186,9 @@ public function resumeOperation($operationName, $methodName = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Google Cloud Speech API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -200,12 +206,11 @@ public function resumeOperation($operationName, $methodName = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -231,8 +236,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $speechClient = new SpeechClient(); * try { - * $speechClient = new SpeechClient(); * $encoding = AudioEncoding::FLAC; * $sampleRateHertz = 44100; * $languageCode = 'en-US'; @@ -255,7 +260,7 @@ public function __construct($options = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -264,7 +269,7 @@ public function __construct($options = []) * * @return \Google\Cloud\Speech\V1\RecognizeResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function recognize($config, $audio, $optionalArgs = []) @@ -274,12 +279,10 @@ public function recognize($config, $audio, $optionalArgs = []) $request->setAudio($audio); return $this->startCall( - new Call( - self::SERVICE_NAME.'/Recognize', - RecognizeResponse::class, - $request - ), - $this->configureCallSettings('recognize', $optionalArgs) + 'Recognize', + RecognizeResponse::class, + $optionalArgs, + $request )->wait(); } @@ -291,8 +294,8 @@ public function recognize($config, $audio, $optionalArgs = []) * * Sample code: * ``` + * $speechClient = new SpeechClient(); * try { - * $speechClient = new SpeechClient(); * $encoding = AudioEncoding::FLAC; * $sampleRateHertz = 44100; * $languageCode = 'en-US'; @@ -340,7 +343,7 @@ public function recognize($config, $audio, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -349,7 +352,7 @@ public function recognize($config, $audio, $optionalArgs = []) * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function longRunningRecognize($config, $audio, $optionalArgs = []) @@ -359,14 +362,10 @@ public function longRunningRecognize($config, $audio, $optionalArgs = []) $request->setAudio($audio); return $this->startOperationsCall( - new Call( - self::SERVICE_NAME.'/LongRunningRecognize', - Operation::class, - $request - ), - $this->configureCallSettings('longRunningRecognize', $optionalArgs), - $this->getOperationsClient(), - $this->descriptors['longRunningRecognize']['longRunning'] + 'LongRunningRecognize', + $optionalArgs, + $request, + $this->getOperationsClient() )->wait(); } @@ -376,8 +375,8 @@ public function longRunningRecognize($config, $audio, $optionalArgs = []) * * Sample code: * ``` + * $speechClient = new SpeechClient(); * try { - * $speechClient = new SpeechClient(); * $request = new StreamingRecognizeRequest(); * $requests = [$request]; * @@ -419,29 +418,17 @@ public function longRunningRecognize($config, $audio, $optionalArgs = []) * * @return \Google\ApiCore\BidiStream * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function streamingRecognize($optionalArgs = []) { - return $this->transport->startBidiStreamingCall( - new Call( - self::SERVICE_NAME.'/StreamingRecognize', - StreamingRecognizeResponse::class - ), - $this->configureCallSettings('streamingRecognize', $optionalArgs), - $this->descriptors['streamingRecognize']['grpcStreaming'] + return $this->startCall( + 'StreamingRecognize', + StreamingRecognizeResponse::class, + $optionalArgs, + null, + Call::BIDI_STREAMING_CALL ); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Speech/V1/SpeechClient.php b/src/Speech/V1/SpeechClient.php index 6d46e212fcb9..279af2ebf72d 100644 --- a/src/Speech/V1/SpeechClient.php +++ b/src/Speech/V1/SpeechClient.php @@ -1,12 +1,12 @@ [ 'google.cloud.speech.v1.Speech' => [ - 'longRunningRecognize' => [ + 'LongRunningRecognize' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\Speech\V1\LongRunningRecognizeResponse', 'metadataReturnType' => '\Google\Cloud\Speech\V1\LongRunningRecognizeMetadata', ], ], - 'streamingRecognize' => [ + 'StreamingRecognize' => [ 'grpcStreaming' => [ 'grpcStreamingType' => 'BidiStreaming', ], diff --git a/src/Speech/V1/resources/speech_rest_client_config.php b/src/Speech/V1/resources/speech_rest_client_config.php index dec8852a899b..4ccacaa52830 100644 --- a/src/Speech/V1/resources/speech_rest_client_config.php +++ b/src/Speech/V1/resources/speech_rest_client_config.php @@ -5,12 +5,12 @@ 'google.cloud.speech.v1.Speech' => [ 'Recognize' => [ 'method' => 'post', - 'uri' => '/v1/speech:recognize', + 'uriTemplate' => '/v1/speech:recognize', 'body' => '*', ], 'LongRunningRecognize' => [ 'method' => 'post', - 'uri' => '/v1/speech:longrunningrecognize', + 'uriTemplate' => '/v1/speech:longrunningrecognize', 'body' => '*', ], ], diff --git a/src/Speech/V1beta1/Gapic/SpeechGapicClient.php b/src/Speech/V1beta1/Gapic/SpeechGapicClient.php index e51f64e44c64..545c78408f12 100644 --- a/src/Speech/V1beta1/Gapic/SpeechGapicClient.php +++ b/src/Speech/V1beta1/Gapic/SpeechGapicClient.php @@ -1,12 +1,12 @@ __DIR__.'/../resources/speech_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/speech_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/speech_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } /** * Return an OperationsClient object with the same endpoint as $this. * - * @return \Google\ApiCore\LongRunning\OperationsClient + * @return OperationsClient * @experimental */ public function getOperationsClient() @@ -141,7 +147,7 @@ public function getOperationsClient() * @param string $operationName The name of the long running operation * @param string $methodName The name of the method used to start the operation * - * @return \Google\ApiCore\OperationResponse + * @return OperationResponse * @experimental */ public function resumeOperation($operationName, $methodName = null) @@ -164,10 +170,10 @@ public function resumeOperation($operationName, $methodName = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'speech.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -178,9 +184,9 @@ public function resumeOperation($operationName, $methodName = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Google Cloud Speech API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -198,12 +204,11 @@ public function resumeOperation($operationName, $methodName = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -229,8 +234,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $speechClient = new SpeechClient(); * try { - * $speechClient = new SpeechClient(); * $encoding = AudioEncoding::FLAC; * $sampleRate = 44100; * $config = new RecognitionConfig(); @@ -251,7 +256,7 @@ public function __construct($options = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -260,7 +265,7 @@ public function __construct($options = []) * * @return \Google\Cloud\Speech\V1beta1\SyncRecognizeResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function syncRecognize($config, $audio, $optionalArgs = []) @@ -270,12 +275,10 @@ public function syncRecognize($config, $audio, $optionalArgs = []) $request->setAudio($audio); return $this->startCall( - new Call( - self::SERVICE_NAME.'/SyncRecognize', - SyncRecognizeResponse::class, - $request - ), - $this->configureCallSettings('syncRecognize', $optionalArgs) + 'SyncRecognize', + SyncRecognizeResponse::class, + $optionalArgs, + $request )->wait(); } @@ -289,8 +292,8 @@ public function syncRecognize($config, $audio, $optionalArgs = []) * * Sample code: * ``` + * $speechClient = new SpeechClient(); * try { - * $speechClient = new SpeechClient(); * $encoding = AudioEncoding::FLAC; * $sampleRate = 44100; * $config = new RecognitionConfig(); @@ -336,7 +339,7 @@ public function syncRecognize($config, $audio, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -345,7 +348,7 @@ public function syncRecognize($config, $audio, $optionalArgs = []) * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function asyncRecognize($config, $audio, $optionalArgs = []) @@ -355,14 +358,10 @@ public function asyncRecognize($config, $audio, $optionalArgs = []) $request->setAudio($audio); return $this->startOperationsCall( - new Call( - self::SERVICE_NAME.'/AsyncRecognize', - Operation::class, - $request - ), - $this->configureCallSettings('asyncRecognize', $optionalArgs), - $this->getOperationsClient(), - $this->descriptors['asyncRecognize']['longRunning'] + 'AsyncRecognize', + $optionalArgs, + $request, + $this->getOperationsClient() )->wait(); } @@ -372,8 +371,8 @@ public function asyncRecognize($config, $audio, $optionalArgs = []) * * Sample code: * ``` + * $speechClient = new SpeechClient(); * try { - * $speechClient = new SpeechClient(); * $request = new StreamingRecognizeRequest(); * $requests = [$request]; * @@ -415,29 +414,17 @@ public function asyncRecognize($config, $audio, $optionalArgs = []) * * @return \Google\ApiCore\BidiStream * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function streamingRecognize($optionalArgs = []) { - return $this->transport->startBidiStreamingCall( - new Call( - self::SERVICE_NAME.'/StreamingRecognize', - StreamingRecognizeResponse::class - ), - $this->configureCallSettings('streamingRecognize', $optionalArgs), - $this->descriptors['streamingRecognize']['grpcStreaming'] + return $this->startCall( + 'StreamingRecognize', + StreamingRecognizeResponse::class, + $optionalArgs, + null, + Call::BIDI_STREAMING_CALL ); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Speech/V1beta1/SpeechClient.php b/src/Speech/V1beta1/SpeechClient.php index c1eb74c8520a..a854c92c47c9 100644 --- a/src/Speech/V1beta1/SpeechClient.php +++ b/src/Speech/V1beta1/SpeechClient.php @@ -1,12 +1,12 @@ [ 'google.cloud.speech.v1beta1.Speech' => [ - 'asyncRecognize' => [ + 'AsyncRecognize' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\Speech\V1beta1\AsyncRecognizeResponse', 'metadataReturnType' => '\Google\Cloud\Speech\V1beta1\AsyncRecognizeMetadata', ], ], - 'streamingRecognize' => [ + 'StreamingRecognize' => [ 'grpcStreaming' => [ 'grpcStreamingType' => 'BidiStreaming', ], diff --git a/src/Speech/V1beta1/resources/speech_rest_client_config.php b/src/Speech/V1beta1/resources/speech_rest_client_config.php index de00de4dc016..eb460e0d427b 100644 --- a/src/Speech/V1beta1/resources/speech_rest_client_config.php +++ b/src/Speech/V1beta1/resources/speech_rest_client_config.php @@ -5,12 +5,12 @@ 'google.cloud.speech.v1beta1.Speech' => [ 'SyncRecognize' => [ 'method' => 'post', - 'uri' => '/v1beta1/speech:syncrecognize', + 'uriTemplate' => '/v1beta1/speech:syncrecognize', 'body' => '*', ], 'AsyncRecognize' => [ 'method' => 'post', - 'uri' => '/v1beta1/speech:asyncrecognize', + 'uriTemplate' => '/v1beta1/speech:asyncrecognize', 'body' => '*', ], ], diff --git a/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php index d1c0e09d3364..422678e1bdaf 100644 --- a/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php @@ -1,12 +1,12 @@ annotateVideo(); + * $inputUri = 'gs://demomaker/cat.mp4'; + * $featuresElement = Feature::LABEL_DETECTION; + * $features = [$featuresElement]; + * $operationResponse = $videoIntelligenceServiceClient->annotateVideo(['inputUri' => $inputUri, 'features' => $features]); * $operationResponse->pollUntilComplete(); * if ($operationResponse->operationSucceeded()) { * $result = $operationResponse->getResult(); @@ -67,7 +73,7 @@ * } * * // OR start the operation, keep the operation name, and resume later - * $operationResponse = $videoIntelligenceServiceClient->annotateVideo(); + * $operationResponse = $videoIntelligenceServiceClient->annotateVideo(['inputUri' => $inputUri, 'features' => $features]); * $operationName = $operationResponse->getName(); * // ... do other work * $newOperationResponse = $videoIntelligenceServiceClient->resumeOperation($operationName, 'annotateVideo'); @@ -132,13 +138,14 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/video_intelligence_service_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/video_intelligence_service_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/video_intelligence_service_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } /** * Return an OperationsClient object with the same endpoint as $this. * - * @return \Google\ApiCore\LongRunning\OperationsClient + * @return OperationsClient * @experimental */ public function getOperationsClient() @@ -156,7 +163,7 @@ public function getOperationsClient() * @param string $operationName The name of the long running operation * @param string $methodName The name of the method used to start the operation * - * @return \Google\ApiCore\OperationResponse + * @return OperationResponse * @experimental */ public function resumeOperation($operationName, $methodName = null) @@ -179,10 +186,10 @@ public function resumeOperation($operationName, $methodName = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'videointelligence.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -193,9 +200,9 @@ public function resumeOperation($operationName, $methodName = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Cloud Video Intelligence API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -213,12 +220,11 @@ public function resumeOperation($operationName, $methodName = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -246,10 +252,12 @@ public function __construct($options = []) * * Sample code: * ``` + * $videoIntelligenceServiceClient = new VideoIntelligenceServiceClient(); * try { - * $videoIntelligenceServiceClient = new VideoIntelligenceServiceClient(); - * - * $operationResponse = $videoIntelligenceServiceClient->annotateVideo(); + * $inputUri = 'gs://demomaker/cat.mp4'; + * $featuresElement = Feature::LABEL_DETECTION; + * $features = [$featuresElement]; + * $operationResponse = $videoIntelligenceServiceClient->annotateVideo(['inputUri' => $inputUri, 'features' => $features]); * $operationResponse->pollUntilComplete(); * if ($operationResponse->operationSucceeded()) { * $result = $operationResponse->getResult(); @@ -260,7 +268,7 @@ public function __construct($options = []) * } * * // OR start the operation, keep the operation name, and resume later - * $operationResponse = $videoIntelligenceServiceClient->annotateVideo(); + * $operationResponse = $videoIntelligenceServiceClient->annotateVideo(['inputUri' => $inputUri, 'features' => $features]); * $operationName = $operationResponse->getName(); * // ... do other work * $newOperationResponse = $videoIntelligenceServiceClient->resumeOperation($operationName, 'annotateVideo'); @@ -314,7 +322,7 @@ public function __construct($options = []) * Optional cloud region where annotation should take place. Supported cloud * regions: `us-east1`, `us-west1`, `europe-west1`, `asia-east1`. If no region * is specified, a region will be determined based on video file location. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -323,7 +331,7 @@ public function __construct($options = []) * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function annotateVideo($optionalArgs = []) @@ -349,25 +357,10 @@ public function annotateVideo($optionalArgs = []) } return $this->startOperationsCall( - new Call( - self::SERVICE_NAME.'/AnnotateVideo', - Operation::class, - $request - ), - $this->configureCallSettings('annotateVideo', $optionalArgs), - $this->getOperationsClient(), - $this->descriptors['annotateVideo']['longRunning'] + 'AnnotateVideo', + $optionalArgs, + $request, + $this->getOperationsClient() )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/VideoIntelligence/V1/VideoIntelligenceServiceClient.php b/src/VideoIntelligence/V1/VideoIntelligenceServiceClient.php index 3bb7d4a9f111..39b980dcee72 100644 --- a/src/VideoIntelligence/V1/VideoIntelligenceServiceClient.php +++ b/src/VideoIntelligence/V1/VideoIntelligenceServiceClient.php @@ -1,12 +1,12 @@ [ 'google.cloud.videointelligence.v1.VideoIntelligenceService' => [ - 'annotateVideo' => [ + 'AnnotateVideo' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\VideoIntelligence\V1\AnnotateVideoResponse', 'metadataReturnType' => '\Google\Cloud\VideoIntelligence\V1\AnnotateVideoProgress', diff --git a/src/VideoIntelligence/V1/resources/video_intelligence_service_rest_client_config.php b/src/VideoIntelligence/V1/resources/video_intelligence_service_rest_client_config.php index 8497e3842aae..1de957680a93 100644 --- a/src/VideoIntelligence/V1/resources/video_intelligence_service_rest_client_config.php +++ b/src/VideoIntelligence/V1/resources/video_intelligence_service_rest_client_config.php @@ -5,7 +5,7 @@ 'google.cloud.videointelligence.v1.VideoIntelligenceService' => [ 'AnnotateVideo' => [ 'method' => 'post', - 'uri' => '/v1/videos:annotate', + 'uriTemplate' => '/v1/videos:annotate', 'body' => '*', ], ], diff --git a/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php index f845b7e1b71c..875e8377b922 100644 --- a/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php @@ -1,12 +1,12 @@ __DIR__.'/../resources/video_intelligence_service_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/video_intelligence_service_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/video_intelligence_service_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } /** * Return an OperationsClient object with the same endpoint as $this. * - * @return \Google\ApiCore\LongRunning\OperationsClient + * @return OperationsClient * @experimental */ public function getOperationsClient() @@ -158,7 +163,7 @@ public function getOperationsClient() * @param string $operationName The name of the long running operation * @param string $methodName The name of the method used to start the operation * - * @return \Google\ApiCore\OperationResponse + * @return OperationResponse * @experimental */ public function resumeOperation($operationName, $methodName = null) @@ -181,10 +186,10 @@ public function resumeOperation($operationName, $methodName = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'videointelligence.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -195,9 +200,9 @@ public function resumeOperation($operationName, $methodName = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Google Cloud Video Intelligence API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -215,12 +220,11 @@ public function resumeOperation($operationName, $methodName = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -248,8 +252,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $videoIntelligenceServiceClient = new VideoIntelligenceServiceClient(); * try { - * $videoIntelligenceServiceClient = new VideoIntelligenceServiceClient(); * $inputUri = 'gs://demomaker/cat.mp4'; * $featuresElement = Feature::LABEL_DETECTION; * $features = [$featuresElement]; @@ -315,7 +319,7 @@ public function __construct($options = []) * Optional cloud region where annotation should take place. Supported cloud * regions: `us-east1`, `us-west1`, `europe-west1`, `asia-east1`. If no region * is specified, a region will be determined based on video file location. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -324,7 +328,7 @@ public function __construct($options = []) * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function annotateVideo($inputUri, $features, $optionalArgs = []) @@ -346,25 +350,10 @@ public function annotateVideo($inputUri, $features, $optionalArgs = []) } return $this->startOperationsCall( - new Call( - self::SERVICE_NAME.'/AnnotateVideo', - Operation::class, - $request - ), - $this->configureCallSettings('annotateVideo', $optionalArgs), - $this->getOperationsClient(), - $this->descriptors['annotateVideo']['longRunning'] + 'AnnotateVideo', + $optionalArgs, + $request, + $this->getOperationsClient() )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php b/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php index 9f63ff684767..7791fcca4111 100644 --- a/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php +++ b/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php @@ -1,12 +1,12 @@ [ 'google.cloud.videointelligence.v1beta1.VideoIntelligenceService' => [ - 'annotateVideo' => [ + 'AnnotateVideo' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\VideoIntelligence\V1beta1\AnnotateVideoResponse', 'metadataReturnType' => '\Google\Cloud\VideoIntelligence\V1beta1\AnnotateVideoProgress', diff --git a/src/VideoIntelligence/V1beta1/resources/video_intelligence_service_rest_client_config.php b/src/VideoIntelligence/V1beta1/resources/video_intelligence_service_rest_client_config.php index 91da4a2d096b..4faf06c4e263 100644 --- a/src/VideoIntelligence/V1beta1/resources/video_intelligence_service_rest_client_config.php +++ b/src/VideoIntelligence/V1beta1/resources/video_intelligence_service_rest_client_config.php @@ -5,7 +5,7 @@ 'google.cloud.videointelligence.v1beta1.VideoIntelligenceService' => [ 'AnnotateVideo' => [ 'method' => 'post', - 'uri' => '/v1beta1/videos:annotate', + 'uriTemplate' => '/v1beta1/videos:annotate', 'body' => '*', ], ], diff --git a/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php index 6af3dd7f06be..a41b415c2248 100644 --- a/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php @@ -1,12 +1,12 @@ annotateVideo(); + * $inputUri = 'gs://demomaker/cat.mp4'; + * $featuresElement = Feature::LABEL_DETECTION; + * $features = [$featuresElement]; + * $operationResponse = $videoIntelligenceServiceClient->annotateVideo(['inputUri' => $inputUri, 'features' => $features]); * $operationResponse->pollUntilComplete(); * if ($operationResponse->operationSucceeded()) { * $result = $operationResponse->getResult(); @@ -67,7 +73,7 @@ * } * * // OR start the operation, keep the operation name, and resume later - * $operationResponse = $videoIntelligenceServiceClient->annotateVideo(); + * $operationResponse = $videoIntelligenceServiceClient->annotateVideo(['inputUri' => $inputUri, 'features' => $features]); * $operationName = $operationResponse->getName(); * // ... do other work * $newOperationResponse = $videoIntelligenceServiceClient->resumeOperation($operationName, 'annotateVideo'); @@ -132,13 +138,14 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/video_intelligence_service_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/video_intelligence_service_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/video_intelligence_service_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } /** * Return an OperationsClient object with the same endpoint as $this. * - * @return \Google\ApiCore\LongRunning\OperationsClient + * @return OperationsClient * @experimental */ public function getOperationsClient() @@ -156,7 +163,7 @@ public function getOperationsClient() * @param string $operationName The name of the long running operation * @param string $methodName The name of the method used to start the operation * - * @return \Google\ApiCore\OperationResponse + * @return OperationResponse * @experimental */ public function resumeOperation($operationName, $methodName = null) @@ -179,10 +186,10 @@ public function resumeOperation($operationName, $methodName = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'videointelligence.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -193,9 +200,9 @@ public function resumeOperation($operationName, $methodName = null) * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Google Cloud Video Intelligence API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -213,12 +220,11 @@ public function resumeOperation($operationName, $methodName = null) * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -246,10 +252,12 @@ public function __construct($options = []) * * Sample code: * ``` + * $videoIntelligenceServiceClient = new VideoIntelligenceServiceClient(); * try { - * $videoIntelligenceServiceClient = new VideoIntelligenceServiceClient(); - * - * $operationResponse = $videoIntelligenceServiceClient->annotateVideo(); + * $inputUri = 'gs://demomaker/cat.mp4'; + * $featuresElement = Feature::LABEL_DETECTION; + * $features = [$featuresElement]; + * $operationResponse = $videoIntelligenceServiceClient->annotateVideo(['inputUri' => $inputUri, 'features' => $features]); * $operationResponse->pollUntilComplete(); * if ($operationResponse->operationSucceeded()) { * $result = $operationResponse->getResult(); @@ -260,7 +268,7 @@ public function __construct($options = []) * } * * // OR start the operation, keep the operation name, and resume later - * $operationResponse = $videoIntelligenceServiceClient->annotateVideo(); + * $operationResponse = $videoIntelligenceServiceClient->annotateVideo(['inputUri' => $inputUri, 'features' => $features]); * $operationName = $operationResponse->getName(); * // ... do other work * $newOperationResponse = $videoIntelligenceServiceClient->resumeOperation($operationName, 'annotateVideo'); @@ -314,7 +322,7 @@ public function __construct($options = []) * Optional cloud region where annotation should take place. Supported cloud * regions: `us-east1`, `us-west1`, `europe-west1`, `asia-east1`. If no region * is specified, a region will be determined based on video file location. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -323,7 +331,7 @@ public function __construct($options = []) * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function annotateVideo($optionalArgs = []) @@ -349,25 +357,10 @@ public function annotateVideo($optionalArgs = []) } return $this->startOperationsCall( - new Call( - self::SERVICE_NAME.'/AnnotateVideo', - Operation::class, - $request - ), - $this->configureCallSettings('annotateVideo', $optionalArgs), - $this->getOperationsClient(), - $this->descriptors['annotateVideo']['longRunning'] + 'AnnotateVideo', + $optionalArgs, + $request, + $this->getOperationsClient() )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/VideoIntelligence/V1beta2/VideoIntelligenceServiceClient.php b/src/VideoIntelligence/V1beta2/VideoIntelligenceServiceClient.php index 206195c586a5..0149a377c7fc 100644 --- a/src/VideoIntelligence/V1beta2/VideoIntelligenceServiceClient.php +++ b/src/VideoIntelligence/V1beta2/VideoIntelligenceServiceClient.php @@ -1,12 +1,12 @@ [ 'google.cloud.videointelligence.v1beta2.VideoIntelligenceService' => [ - 'annotateVideo' => [ + 'AnnotateVideo' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\VideoIntelligence\V1beta2\AnnotateVideoResponse', 'metadataReturnType' => '\Google\Cloud\VideoIntelligence\V1beta2\AnnotateVideoProgress', diff --git a/src/VideoIntelligence/V1beta2/resources/video_intelligence_service_rest_client_config.php b/src/VideoIntelligence/V1beta2/resources/video_intelligence_service_rest_client_config.php index d7c73271fa4b..34b6e6635e0d 100644 --- a/src/VideoIntelligence/V1beta2/resources/video_intelligence_service_rest_client_config.php +++ b/src/VideoIntelligence/V1beta2/resources/video_intelligence_service_rest_client_config.php @@ -5,7 +5,7 @@ 'google.cloud.videointelligence.v1beta2.VideoIntelligenceService' => [ 'AnnotateVideo' => [ 'method' => 'post', - 'uri' => '/v1beta2/videos:annotate', + 'uriTemplate' => '/v1beta2/videos:annotate', 'body' => '*', ], ], diff --git a/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php b/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php index ee89d6c83a05..f2a4a4e24a8a 100644 --- a/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php +++ b/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php @@ -1,12 +1,12 @@ batchAnnotateImages($requests); * } finally { @@ -103,6 +107,7 @@ private static function getClientDefaults() 'clientConfigPath' => __DIR__.'/../resources/image_annotator_client_config.json', 'restClientConfigPath' => __DIR__.'/../resources/image_annotator_rest_client_config.php', 'descriptorsConfigPath' => __DIR__.'/../resources/image_annotator_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } @@ -115,10 +120,10 @@ private static function getClientDefaults() * @type string $serviceAddress The domain name of the API remote host. * Default 'vision.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel + * @type Channel $channel * A `Channel` object. If not specified, a channel will be constructed. * NOTE: This option is only valid when utilizing the gRPC transport. - * @type \Grpc\ChannelCredentials $sslCreds + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from * \Grpc\ChannelCredentials::createSsl(). @@ -129,9 +134,9 @@ private static function getClientDefaults() * Defaults to false. * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel * optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Google Cloud Vision API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -149,12 +154,11 @@ private static function getClientDefaults() * settings in $clientConfigPath. * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically * for authentication. Should match a signature of - * `function (RequestInterface $request, array $options) : ResponseInterface` - * NOTE: This option is only valid when utilizing the REST transport. + * `function (RequestInterface $request, array $options) : ResponseInterface`. * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a - * signature of `function (RequestInterface $request, array $options) : PromiseInterface` + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. * NOTE: This option is only valid when utilizing the REST transport. - * @type string|ApiTransportInterface $transport The transport used for executing network + * @type string|TransportInterface $transport The transport used for executing network * requests. May be either the string `rest` or `grpc`. Additionally, it is possible * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is * detected on the system. @@ -171,8 +175,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $imageAnnotatorClient = new ImageAnnotatorClient(); * try { - * $imageAnnotatorClient = new ImageAnnotatorClient(); * $requests = []; * $response = $imageAnnotatorClient->batchAnnotateImages($requests); * } finally { @@ -184,7 +188,7 @@ public function __construct($options = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -193,7 +197,7 @@ public function __construct($options = []) * * @return \Google\Cloud\Vision\V1\BatchAnnotateImagesResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function batchAnnotateImages($requests, $optionalArgs = []) @@ -202,23 +206,10 @@ public function batchAnnotateImages($requests, $optionalArgs = []) $request->setRequests($requests); return $this->startCall( - new Call( - self::SERVICE_NAME.'/BatchAnnotateImages', - BatchAnnotateImagesResponse::class, - $request - ), - $this->configureCallSettings('batchAnnotateImages', $optionalArgs) + 'BatchAnnotateImages', + BatchAnnotateImagesResponse::class, + $optionalArgs, + $request )->wait(); } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->transport->close(); - } } diff --git a/src/Vision/V1/ImageAnnotatorClient.php b/src/Vision/V1/ImageAnnotatorClient.php index 96780348023e..70b4c4fba066 100644 --- a/src/Vision/V1/ImageAnnotatorClient.php +++ b/src/Vision/V1/ImageAnnotatorClient.php @@ -1,12 +1,12 @@ [ 'BatchAnnotateImages' => [ 'method' => 'post', - 'uri' => '/v1/images:annotate', + 'uriTemplate' => '/v1/images:annotate', 'body' => '*', ], ], From a05ebf5e9cf7b3d389d4b16816ada06905f7379a Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Tue, 16 Jan 2018 13:56:48 -0500 Subject: [PATCH 08/21] refresh gapics --- .../BigtableInstanceAdminGapicClient.php | 4 +- .../Gapic/BigtableTableAdminGapicClient.php | 4 +- ...able_instance_admin_rest_client_config.php | 46 ++++++++++++ ...igtable_table_admin_rest_client_config.php | 46 ++++++++++++ .../V2beta1/Gapic/DlpServiceGapicClient.php | 4 +- .../dlp_service_rest_client_config.php | 47 ++++++++++++ src/PubSub/V1/Gapic/PublisherGapicClient.php | 12 ++- src/PubSub/V1/Gapic/SubscriberGapicClient.php | 12 ++- .../publisher_rest_client_config.php | 74 ++++++++++--------- .../subscriber_rest_client_config.php | 74 ++++++++++--------- .../V1/Gapic/DatabaseAdminGapicClient.php | 4 +- .../database_admin_rest_client_config.php | 46 ++++++++++++ .../V1/Gapic/InstanceAdminGapicClient.php | 4 +- .../instance_admin_rest_client_config.php | 46 ++++++++++++ .../resources/spanner_rest_client_config.php | 46 ++++++++++++ src/Speech/V1/Gapic/SpeechGapicClient.php | 4 +- .../V1beta1/Gapic/SpeechGapicClient.php | 4 +- .../resources/speech_rest_client_config.php | 40 ++++++++++ .../VideoIntelligenceServiceGapicClient.php | 4 +- ...ntelligence_service_rest_client_config.php | 40 ++++++++++ .../VideoIntelligenceServiceGapicClient.php | 4 +- ...ntelligence_service_rest_client_config.php | 40 ++++++++++ .../VideoIntelligenceServiceGapicClient.php | 4 +- ...ntelligence_service_rest_client_config.php | 40 ++++++++++ 24 files changed, 551 insertions(+), 98 deletions(-) diff --git a/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php b/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php index 6439687fd5c1..ba150f27637a 100644 --- a/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php +++ b/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php @@ -484,10 +484,10 @@ public function __construct($options = []) $this->pluckArray([ 'serviceName', 'clientConfigPath', - 'restClientConfigPath', 'descriptorsConfigPath', ], $options); - $this->operationsClient = new OperationsClient($options); + $this->operationsClient = $this->pluck('operationsClient', $options, false) + ?: new OperationsClient($options); } /** diff --git a/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php b/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php index e382acb2c46f..3a7e4c5afc1d 100644 --- a/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php +++ b/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php @@ -431,10 +431,10 @@ public function __construct($options = []) $this->pluckArray([ 'serviceName', 'clientConfigPath', - 'restClientConfigPath', 'descriptorsConfigPath', ], $options); - $this->operationsClient = new OperationsClient($options); + $this->operationsClient = $this->pluck('operationsClient', $options, false) + ?: new OperationsClient($options); } /** diff --git a/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_rest_client_config.php b/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_rest_client_config.php index 6fe9405c3708..5967d4f11dc5 100644 --- a/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_rest_client_config.php +++ b/src/Bigtable/Admin/V2/resources/bigtable_instance_admin_rest_client_config.php @@ -225,5 +225,51 @@ ], ], ], + 'google.longrunning.Operations' => [ + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{name=operations/projects/**}/operations', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{name=operations/**}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=operations/**}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{name=operations/**}:cancel', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], ], ]; diff --git a/src/Bigtable/Admin/V2/resources/bigtable_table_admin_rest_client_config.php b/src/Bigtable/Admin/V2/resources/bigtable_table_admin_rest_client_config.php index a5c9314a9e82..90fae8976bf4 100644 --- a/src/Bigtable/Admin/V2/resources/bigtable_table_admin_rest_client_config.php +++ b/src/Bigtable/Admin/V2/resources/bigtable_table_admin_rest_client_config.php @@ -154,5 +154,51 @@ ], ], ], + 'google.longrunning.Operations' => [ + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{name=operations/projects/**}/operations', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{name=operations/**}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=operations/**}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{name=operations/**}:cancel', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], ], ]; diff --git a/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php b/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php index 1bb14d56717e..b103d3fc8515 100644 --- a/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php +++ b/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php @@ -333,10 +333,10 @@ public function __construct($options = []) $this->pluckArray([ 'serviceName', 'clientConfigPath', - 'restClientConfigPath', 'descriptorsConfigPath', ], $options); - $this->operationsClient = new OperationsClient($options); + $this->operationsClient = $this->pluck('operationsClient', $options, false) + ?: new OperationsClient($options); } /** diff --git a/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php b/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php index 810de5139b2c..17704750e165 100644 --- a/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php +++ b/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php @@ -2,6 +2,53 @@ return [ 'interfaces' => [ + 'google.longrunning.Operations' => [ + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=inspect/operations}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=inspect/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=inspect/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=inspect/operations/*}:cancel', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], 'google.privacy.dlp.v2beta1.DlpService' => [ 'InspectContent' => [ 'method' => 'post', diff --git a/src/PubSub/V1/Gapic/PublisherGapicClient.php b/src/PubSub/V1/Gapic/PublisherGapicClient.php index be6ce80578fc..78f281ccb8fd 100644 --- a/src/PubSub/V1/Gapic/PublisherGapicClient.php +++ b/src/PubSub/V1/Gapic/PublisherGapicClient.php @@ -738,7 +738,9 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) 'SetIamPolicy', Policy::class, $optionalArgs, - $request + $request, + Call::UNARY_CALL, + 'google.iam.v1.IAMPolicy' )->wait(); } @@ -785,7 +787,9 @@ public function getIamPolicy($resource, $optionalArgs = []) 'GetIamPolicy', Policy::class, $optionalArgs, - $request + $request, + Call::UNARY_CALL, + 'google.iam.v1.IAMPolicy' )->wait(); } @@ -838,7 +842,9 @@ public function testIamPermissions($resource, $permissions, $optionalArgs = []) 'TestIamPermissions', TestIamPermissionsResponse::class, $optionalArgs, - $request + $request, + Call::UNARY_CALL, + 'google.iam.v1.IAMPolicy' )->wait(); } } diff --git a/src/PubSub/V1/Gapic/SubscriberGapicClient.php b/src/PubSub/V1/Gapic/SubscriberGapicClient.php index f013fd9d7fe2..e3b12b92f3f2 100644 --- a/src/PubSub/V1/Gapic/SubscriberGapicClient.php +++ b/src/PubSub/V1/Gapic/SubscriberGapicClient.php @@ -1369,7 +1369,9 @@ public function setIamPolicy($resource, $policy, $optionalArgs = []) 'SetIamPolicy', Policy::class, $optionalArgs, - $request + $request, + Call::UNARY_CALL, + 'google.iam.v1.IAMPolicy' )->wait(); } @@ -1416,7 +1418,9 @@ public function getIamPolicy($resource, $optionalArgs = []) 'GetIamPolicy', Policy::class, $optionalArgs, - $request + $request, + Call::UNARY_CALL, + 'google.iam.v1.IAMPolicy' )->wait(); } @@ -1469,7 +1473,9 @@ public function testIamPermissions($resource, $permissions, $optionalArgs = []) 'TestIamPermissions', TestIamPermissionsResponse::class, $optionalArgs, - $request + $request, + Call::UNARY_CALL, + 'google.iam.v1.IAMPolicy' )->wait(); } } diff --git a/src/PubSub/V1/resources/publisher_rest_client_config.php b/src/PubSub/V1/resources/publisher_rest_client_config.php index 155380b7ba38..5cf325a18651 100644 --- a/src/PubSub/V1/resources/publisher_rest_client_config.php +++ b/src/PubSub/V1/resources/publisher_rest_client_config.php @@ -2,6 +2,44 @@ return [ 'interfaces' => [ + 'google.iam.v1.IAMPolicy' => [ + 'SetIamPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=**}:setIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'GetIamPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=**}:getIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'TestIamPermissions' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=**}:testIamPermissions', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + ], 'google.pubsub.v1.Publisher' => [ 'CreateTopic' => [ 'method' => 'put', @@ -84,42 +122,6 @@ ], ], ], - 'SetIamPolicy' => [ - 'method' => 'post', - 'uriTemplate' => '/v1/{resource=**}:setIamPolicy', - 'body' => '*', - 'placeholders' => [ - 'resource' => [ - 'getters' => [ - 'getResource', - ], - ], - ], - ], - 'GetIamPolicy' => [ - 'method' => 'post', - 'uriTemplate' => '/v1/{resource=**}:getIamPolicy', - 'body' => '*', - 'placeholders' => [ - 'resource' => [ - 'getters' => [ - 'getResource', - ], - ], - ], - ], - 'TestIamPermissions' => [ - 'method' => 'post', - 'uriTemplate' => '/v1/{resource=**}:testIamPermissions', - 'body' => '*', - 'placeholders' => [ - 'resource' => [ - 'getters' => [ - 'getResource', - ], - ], - ], - ], ], ], ]; diff --git a/src/PubSub/V1/resources/subscriber_rest_client_config.php b/src/PubSub/V1/resources/subscriber_rest_client_config.php index b7dd5dad9aaa..3dda774bc059 100644 --- a/src/PubSub/V1/resources/subscriber_rest_client_config.php +++ b/src/PubSub/V1/resources/subscriber_rest_client_config.php @@ -2,6 +2,44 @@ return [ 'interfaces' => [ + 'google.iam.v1.IAMPolicy' => [ + 'SetIamPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=**}:setIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'GetIamPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=**}:getIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'TestIamPermissions' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=**}:testIamPermissions', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + ], 'google.pubsub.v1.Subscriber' => [ 'CreateSubscription' => [ 'method' => 'put', @@ -168,42 +206,6 @@ ], ], ], - 'SetIamPolicy' => [ - 'method' => 'post', - 'uriTemplate' => '/v1/{resource=**}:setIamPolicy', - 'body' => '*', - 'placeholders' => [ - 'resource' => [ - 'getters' => [ - 'getResource', - ], - ], - ], - ], - 'GetIamPolicy' => [ - 'method' => 'post', - 'uriTemplate' => '/v1/{resource=**}:getIamPolicy', - 'body' => '*', - 'placeholders' => [ - 'resource' => [ - 'getters' => [ - 'getResource', - ], - ], - ], - ], - 'TestIamPermissions' => [ - 'method' => 'post', - 'uriTemplate' => '/v1/{resource=**}:testIamPermissions', - 'body' => '*', - 'placeholders' => [ - 'resource' => [ - 'getters' => [ - 'getResource', - ], - ], - ], - ], ], ], ]; diff --git a/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php b/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php index 10c4bfa3d1f5..9c33b79ea36f 100644 --- a/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php +++ b/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php @@ -361,10 +361,10 @@ public function __construct($options = []) $this->pluckArray([ 'serviceName', 'clientConfigPath', - 'restClientConfigPath', 'descriptorsConfigPath', ], $options); - $this->operationsClient = new OperationsClient($options); + $this->operationsClient = $this->pluck('operationsClient', $options, false) + ?: new OperationsClient($options); } /** diff --git a/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php b/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php index 76359b7725bd..a8b15776f79f 100644 --- a/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php +++ b/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php @@ -2,6 +2,52 @@ return [ 'interfaces' => [ + 'google.longrunning.Operations' => [ + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}:cancel', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], 'google.spanner.admin.database.v1.DatabaseAdmin' => [ 'ListDatabases' => [ 'method' => 'get', diff --git a/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php b/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php index 918d5a8282dc..7a17154f860c 100644 --- a/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php +++ b/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php @@ -406,10 +406,10 @@ public function __construct($options = []) $this->pluckArray([ 'serviceName', 'clientConfigPath', - 'restClientConfigPath', 'descriptorsConfigPath', ], $options); - $this->operationsClient = new OperationsClient($options); + $this->operationsClient = $this->pluck('operationsClient', $options, false) + ?: new OperationsClient($options); } /** diff --git a/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php b/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php index a885fccf6e19..9a08fb14e162 100644 --- a/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php +++ b/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php @@ -2,6 +2,52 @@ return [ 'interfaces' => [ + 'google.longrunning.Operations' => [ + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}:cancel', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], 'google.spanner.admin.instance.v1.InstanceAdmin' => [ 'ListInstanceConfigs' => [ 'method' => 'get', diff --git a/src/Spanner/V1/resources/spanner_rest_client_config.php b/src/Spanner/V1/resources/spanner_rest_client_config.php index 3a6202f27e9f..1b426818b989 100644 --- a/src/Spanner/V1/resources/spanner_rest_client_config.php +++ b/src/Spanner/V1/resources/spanner_rest_client_config.php @@ -2,6 +2,52 @@ return [ 'interfaces' => [ + 'google.longrunning.Operations' => [ + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}:cancel', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], 'google.spanner.v1.Spanner' => [ 'CreateSession' => [ 'method' => 'post', diff --git a/src/Speech/V1/Gapic/SpeechGapicClient.php b/src/Speech/V1/Gapic/SpeechGapicClient.php index 33fe47b23884..97c5ff2a0158 100644 --- a/src/Speech/V1/Gapic/SpeechGapicClient.php +++ b/src/Speech/V1/Gapic/SpeechGapicClient.php @@ -224,10 +224,10 @@ public function __construct($options = []) $this->pluckArray([ 'serviceName', 'clientConfigPath', - 'restClientConfigPath', 'descriptorsConfigPath', ], $options); - $this->operationsClient = new OperationsClient($options); + $this->operationsClient = $this->pluck('operationsClient', $options, false) + ?: new OperationsClient($options); } /** diff --git a/src/Speech/V1beta1/Gapic/SpeechGapicClient.php b/src/Speech/V1beta1/Gapic/SpeechGapicClient.php index 545c78408f12..c64606f01385 100644 --- a/src/Speech/V1beta1/Gapic/SpeechGapicClient.php +++ b/src/Speech/V1beta1/Gapic/SpeechGapicClient.php @@ -222,10 +222,10 @@ public function __construct($options = []) $this->pluckArray([ 'serviceName', 'clientConfigPath', - 'restClientConfigPath', 'descriptorsConfigPath', ], $options); - $this->operationsClient = new OperationsClient($options); + $this->operationsClient = $this->pluck('operationsClient', $options, false) + ?: new OperationsClient($options); } /** diff --git a/src/Speech/V1beta1/resources/speech_rest_client_config.php b/src/Speech/V1beta1/resources/speech_rest_client_config.php index eb460e0d427b..4bdd0cbc5cc2 100644 --- a/src/Speech/V1beta1/resources/speech_rest_client_config.php +++ b/src/Speech/V1beta1/resources/speech_rest_client_config.php @@ -14,5 +14,45 @@ 'body' => '*', ], ], + 'google.longrunning.Operations' => [ + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/operations', + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/operations/{name=*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/operations/{name=*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/operations/{name=*}:cancel', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], ], ]; diff --git a/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php index 422678e1bdaf..f2f645643c0e 100644 --- a/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php @@ -238,10 +238,10 @@ public function __construct($options = []) $this->pluckArray([ 'serviceName', 'clientConfigPath', - 'restClientConfigPath', 'descriptorsConfigPath', ], $options); - $this->operationsClient = new OperationsClient($options); + $this->operationsClient = $this->pluck('operationsClient', $options, false) + ?: new OperationsClient($options); } /** diff --git a/src/VideoIntelligence/V1/resources/video_intelligence_service_rest_client_config.php b/src/VideoIntelligence/V1/resources/video_intelligence_service_rest_client_config.php index 1de957680a93..de74a210d133 100644 --- a/src/VideoIntelligence/V1/resources/video_intelligence_service_rest_client_config.php +++ b/src/VideoIntelligence/V1/resources/video_intelligence_service_rest_client_config.php @@ -9,5 +9,45 @@ 'body' => '*', ], ], + 'google.longrunning.Operations' => [ + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/operations', + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/operations/{name=*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/operations/{name=*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/operations/{name=*}:cancel', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], ], ]; diff --git a/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php index 875e8377b922..be1ad30cd2d3 100644 --- a/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php @@ -238,10 +238,10 @@ public function __construct($options = []) $this->pluckArray([ 'serviceName', 'clientConfigPath', - 'restClientConfigPath', 'descriptorsConfigPath', ], $options); - $this->operationsClient = new OperationsClient($options); + $this->operationsClient = $this->pluck('operationsClient', $options, false) + ?: new OperationsClient($options); } /** diff --git a/src/VideoIntelligence/V1beta1/resources/video_intelligence_service_rest_client_config.php b/src/VideoIntelligence/V1beta1/resources/video_intelligence_service_rest_client_config.php index 4faf06c4e263..c2be1bda08c2 100644 --- a/src/VideoIntelligence/V1beta1/resources/video_intelligence_service_rest_client_config.php +++ b/src/VideoIntelligence/V1beta1/resources/video_intelligence_service_rest_client_config.php @@ -9,5 +9,45 @@ 'body' => '*', ], ], + 'google.longrunning.Operations' => [ + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/operations/{name=*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/operations', + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/operations/{name=*}:cancel', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/operations/{name=*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], ], ]; diff --git a/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php index a41b415c2248..a199d982d7a2 100644 --- a/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php @@ -238,10 +238,10 @@ public function __construct($options = []) $this->pluckArray([ 'serviceName', 'clientConfigPath', - 'restClientConfigPath', 'descriptorsConfigPath', ], $options); - $this->operationsClient = new OperationsClient($options); + $this->operationsClient = $this->pluck('operationsClient', $options, false) + ?: new OperationsClient($options); } /** diff --git a/src/VideoIntelligence/V1beta2/resources/video_intelligence_service_rest_client_config.php b/src/VideoIntelligence/V1beta2/resources/video_intelligence_service_rest_client_config.php index 34b6e6635e0d..eb3a35908b1c 100644 --- a/src/VideoIntelligence/V1beta2/resources/video_intelligence_service_rest_client_config.php +++ b/src/VideoIntelligence/V1beta2/resources/video_intelligence_service_rest_client_config.php @@ -9,5 +9,45 @@ 'body' => '*', ], ], + 'google.longrunning.Operations' => [ + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/operations/{name=*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/operations', + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/operations/{name=*}:cancel', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/operations/{name=*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], ], ]; From 31d6760e7dcd3a5eb07a6fe6cdafa541324fca59 Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Tue, 16 Jan 2018 17:19:04 -0500 Subject: [PATCH 09/21] gapic refresh --- .../Admin/V2/BigtableInstanceAdminClient.php | 2 +- .../Admin/V2/BigtableTableAdminClient.php | 2 +- .../BigtableInstanceAdminGapicClient.php | 8 ++-- .../Gapic/BigtableTableAdminGapicClient.php | 28 ++++++------- src/Bigtable/V2/BigtableClient.php | 2 +- src/Bigtable/V2/Gapic/BigtableGapicClient.php | 20 +++++----- src/Dlp/V2beta1/DlpServiceClient.php | 2 +- .../V2beta1/Gapic/DlpServiceGapicClient.php | 27 +++++++------ .../dlp_service_rest_client_config.php | 8 ++-- .../V1beta1/ErrorGroupServiceClient.php | 2 +- .../V1beta1/ErrorStatsServiceClient.php | 2 +- .../Gapic/ErrorGroupServiceGapicClient.php | 15 +++---- .../Gapic/ErrorStatsServiceGapicClient.php | 15 +++---- .../Gapic/ReportErrorsServiceGapicClient.php | 15 +++---- .../V1beta1/ReportErrorsServiceClient.php | 2 +- src/Firestore/V1beta1/FirestoreClient.php | 2 +- .../V1beta1/Gapic/FirestoreGapicClient.php | 2 +- .../Gapic/LanguageServiceGapicClient.php | 15 +++---- .../V1beta2/LanguageServiceClient.php | 2 +- src/Logging/V2/ConfigServiceV2Client.php | 2 +- .../V2/Gapic/ConfigServiceV2GapicClient.php | 3 +- .../V2/Gapic/LoggingServiceV2GapicClient.php | 3 +- .../V2/Gapic/MetricsServiceV2GapicClient.php | 3 +- src/Logging/V2/LoggingServiceV2Client.php | 2 +- src/Logging/V2/MetricsServiceV2Client.php | 2 +- .../V3/Gapic/GroupServiceGapicClient.php | 15 +++---- .../V3/Gapic/MetricServiceGapicClient.php | 19 ++++----- .../Gapic/UptimeCheckServiceGapicClient.php | 15 +++---- src/Monitoring/V3/GroupServiceClient.php | 2 +- src/Monitoring/V3/MetricServiceClient.php | 2 +- .../V3/UptimeCheckServiceClient.php | 2 +- src/PubSub/V1/Gapic/PublisherGapicClient.php | 3 +- src/PubSub/V1/Gapic/SubscriberGapicClient.php | 2 +- src/PubSub/V1/PublisherClient.php | 2 +- src/PubSub/V1/SubscriberClient.php | 2 +- .../publisher_rest_client_config.php | 3 +- .../subscriber_rest_client_config.php | 3 +- .../Admin/Database/V1/DatabaseAdminClient.php | 2 +- .../V1/Gapic/DatabaseAdminGapicClient.php | 3 +- .../V1/Gapic/InstanceAdminGapicClient.php | 3 +- .../Admin/Instance/V1/InstanceAdminClient.php | 2 +- src/Spanner/V1/Gapic/SpannerGapicClient.php | 3 +- src/Speech/V1/Gapic/SpeechGapicClient.php | 8 ++-- src/Speech/V1/SpeechClient.php | 2 +- .../resources/speech_rest_client_config.php | 40 +++++++++++++++++++ .../V1beta1/Gapic/SpeechGapicClient.php | 8 ++-- src/Speech/V1beta1/SpeechClient.php | 2 +- .../VideoIntelligenceServiceGapicClient.php | 15 +++---- .../V1/VideoIntelligenceServiceClient.php | 2 +- .../VideoIntelligenceServiceGapicClient.php | 15 +++---- .../VideoIntelligenceServiceClient.php | 2 +- ...ntelligence_service_rest_client_config.php | 8 ++-- .../VideoIntelligenceServiceGapicClient.php | 15 +++---- .../VideoIntelligenceServiceClient.php | 2 +- .../V1/Gapic/ImageAnnotatorGapicClient.php | 3 +- src/Vision/V1/ImageAnnotatorClient.php | 2 +- 56 files changed, 224 insertions(+), 169 deletions(-) diff --git a/src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php b/src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php index a2275c345903..85939465bebd 100644 --- a/src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php +++ b/src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php @@ -1,6 +1,6 @@ instanceName('[PROJECT]', '[INSTANCE]'); * $displayName = ''; - * $type = Type::TYPE_UNSPECIFIED; + * $type = Instance_Type::TYPE_UNSPECIFIED; * $labels = []; * $response = $bigtableInstanceAdminClient->updateInstance($formattedName, $displayName, $type, $labels); * } finally { diff --git a/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php b/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php index 3a7e4c5afc1d..76d4c7011d62 100644 --- a/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php +++ b/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php @@ -1,6 +1,6 @@ /instances//tables/
`. - * @param Modification[] $modifications Modifications to be atomically applied to the specified table's families. - * Entries are applied in order, meaning that earlier modifications can be - * masked by later ones (in the case of repeated updates to the same family, - * for example). - * @param array $optionalArgs { - * Optional. + * @param string $name The unique name of the table whose families should be modified. + * Values are of the form + * `projects//instances//tables/
`. + * @param ModifyColumnFamiliesRequest_Modification[] $modifications Modifications to be atomically applied to the specified table's families. + * Entries are applied in order, meaning that earlier modifications can be + * masked by later ones (in the case of repeated updates to the same family, + * for example). + * @param array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a diff --git a/src/Bigtable/V2/BigtableClient.php b/src/Bigtable/V2/BigtableClient.php index 3d460f7cfd21..120c18943345 100644 --- a/src/Bigtable/V2/BigtableClient.php +++ b/src/Bigtable/V2/BigtableClient.php @@ -1,6 +1,6 @@ setName($name2); * $replaceWith = 'REDACTED'; - * $replaceConfigsElement = new ReplaceConfig(); + * $replaceConfigsElement = new RedactContentRequest_ReplaceConfig(); * $replaceConfigsElement->setInfoType($infoType); * $replaceConfigsElement->setReplaceWith($replaceWith); * $replaceConfigs = [$replaceConfigsElement]; @@ -437,10 +438,10 @@ public function inspectContent($inspectConfig, $items, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type ReplaceConfig[] $replaceConfigs + * @type RedactContentRequest_ReplaceConfig[] $replaceConfigs * The strings to replace findings text findings with. Must specify at least * one of these or one ImageRedactionConfig if redacting images. - * @type ImageRedactionConfig[] $imageRedactionConfigs + * @type RedactContentRequest_ImageRedactionConfig[] $imageRedactionConfigs * The configuration for specifying what content to redact from images. * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a @@ -612,7 +613,7 @@ public function analyzeDataSourceRisk($privacyMetric, $sourceTable, $optionalArg * $inspectConfig = new InspectConfig(); * $inspectConfig->setInfoTypes($infoTypes); * $url = 'gs://example_bucket/example_file.png'; - * $fileSet = new FileSet(); + * $fileSet = new CloudStorageOptions_FileSet(); * $fileSet->setUrl($url); * $cloudStorageOptions = new CloudStorageOptions(); * $cloudStorageOptions->setFileSet($fileSet); diff --git a/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php b/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php index 17704750e165..f5bb6294e242 100644 --- a/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php +++ b/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php @@ -5,7 +5,7 @@ 'google.longrunning.Operations' => [ 'ListOperations' => [ 'method' => 'get', - 'uriTemplate' => '/v1/{name=inspect/operations}', + 'uriTemplate' => '/v2beta1/{name=inspect/operations}', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -16,7 +16,7 @@ ], 'GetOperation' => [ 'method' => 'get', - 'uriTemplate' => '/v1/{name=inspect/operations/*}', + 'uriTemplate' => '/v2beta1/{name=inspect/operations/*}', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -27,7 +27,7 @@ ], 'DeleteOperation' => [ 'method' => 'delete', - 'uriTemplate' => '/v1/{name=inspect/operations/*}', + 'uriTemplate' => '/v2beta1/{name=inspect/operations/*}', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -38,7 +38,7 @@ ], 'CancelOperation' => [ 'method' => 'post', - 'uriTemplate' => '/v1/{name=inspect/operations/*}:cancel', + 'uriTemplate' => '/v2beta1/{name=inspect/operations/*}:cancel', 'body' => '*', 'placeholders' => [ 'name' => [ diff --git a/src/ErrorReporting/V1beta1/ErrorGroupServiceClient.php b/src/ErrorReporting/V1beta1/ErrorGroupServiceClient.php index 9c9ad5f00d61..7326b7233cac 100644 --- a/src/ErrorReporting/V1beta1/ErrorGroupServiceClient.php +++ b/src/ErrorReporting/V1beta1/ErrorGroupServiceClient.php @@ -1,6 +1,6 @@ annotateText($document, $features); * } finally { * $languageServiceClient->close(); * } * ``` * - * @param Document $document Input document. - * @param Features $features The enabled features. - * @param array $optionalArgs { - * Optional. + * @param Document $document Input document. + * @param AnnotateTextRequest_Features $features The enabled features. + * @param array $optionalArgs { + * Optional. * * @type int $encodingType * The encoding type used by the API to calculate offsets. diff --git a/src/Language/V1beta2/LanguageServiceClient.php b/src/Language/V1beta2/LanguageServiceClient.php index 9a9907a91ac8..51c3a32808e2 100644 --- a/src/Language/V1beta2/LanguageServiceClient.php +++ b/src/Language/V1beta2/LanguageServiceClient.php @@ -1,6 +1,6 @@ projectName('[PROJECT]'); * $filter = ''; * $interval = new TimeInterval(); - * $view = TimeSeriesView::FULL; + * $view = ListTimeSeriesRequest_TimeSeriesView::FULL; * // Iterate through all elements * $pagedResponse = $metricServiceClient->listTimeSeries($formattedName, $filter, $interval, $view); * foreach ($pagedResponse->iterateAllElements() as $element) { diff --git a/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php b/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php index 971e63e8ec01..42fc70466a6b 100644 --- a/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php +++ b/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php @@ -1,6 +1,6 @@ [ - 'method' => 'post', + 'method' => 'get', 'uriTemplate' => '/v1/{resource=**}:getIamPolicy', - 'body' => '*', 'placeholders' => [ 'resource' => [ 'getters' => [ diff --git a/src/PubSub/V1/resources/subscriber_rest_client_config.php b/src/PubSub/V1/resources/subscriber_rest_client_config.php index 3dda774bc059..838405111bb4 100644 --- a/src/PubSub/V1/resources/subscriber_rest_client_config.php +++ b/src/PubSub/V1/resources/subscriber_rest_client_config.php @@ -16,9 +16,8 @@ ], ], 'GetIamPolicy' => [ - 'method' => 'post', + 'method' => 'get', 'uriTemplate' => '/v1/{resource=**}:getIamPolicy', - 'body' => '*', 'placeholders' => [ 'resource' => [ 'getters' => [ diff --git a/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php b/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php index fb33c021a42d..8c5451de0256 100644 --- a/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php +++ b/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php @@ -1,6 +1,6 @@ '*', ], ], + 'google.longrunning.Operations' => [ + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/operations', + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/operations/{name=*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/operations/{name=*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/operations/{name=*}:cancel', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], ], ]; diff --git a/src/Speech/V1beta1/Gapic/SpeechGapicClient.php b/src/Speech/V1beta1/Gapic/SpeechGapicClient.php index c64606f01385..83d2875b194c 100644 --- a/src/Speech/V1beta1/Gapic/SpeechGapicClient.php +++ b/src/Speech/V1beta1/Gapic/SpeechGapicClient.php @@ -1,6 +1,6 @@ setEncoding($encoding); @@ -236,7 +236,7 @@ public function __construct($options = []) * ``` * $speechClient = new SpeechClient(); * try { - * $encoding = AudioEncoding::FLAC; + * $encoding = RecognitionConfig_AudioEncoding::FLAC; * $sampleRate = 44100; * $config = new RecognitionConfig(); * $config->setEncoding($encoding); @@ -294,7 +294,7 @@ public function syncRecognize($config, $audio, $optionalArgs = []) * ``` * $speechClient = new SpeechClient(); * try { - * $encoding = AudioEncoding::FLAC; + * $encoding = RecognitionConfig_AudioEncoding::FLAC; * $sampleRate = 44100; * $config = new RecognitionConfig(); * $config->setEncoding($encoding); diff --git a/src/Speech/V1beta1/SpeechClient.php b/src/Speech/V1beta1/SpeechClient.php index a854c92c47c9..d330b229c4b5 100644 --- a/src/Speech/V1beta1/SpeechClient.php +++ b/src/Speech/V1beta1/SpeechClient.php @@ -1,6 +1,6 @@ [ 'GetOperation' => [ 'method' => 'get', - 'uriTemplate' => '/v1/operations/{name=*}', + 'uriTemplate' => '/v1beta1/operations/{name=*}', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -23,11 +23,11 @@ ], 'ListOperations' => [ 'method' => 'get', - 'uriTemplate' => '/v1/operations', + 'uriTemplate' => '/v1beta1/operations', ], 'CancelOperation' => [ 'method' => 'post', - 'uriTemplate' => '/v1/operations/{name=*}:cancel', + 'uriTemplate' => '/v1beta1/operations/{name=*}:cancel', 'body' => '*', 'placeholders' => [ 'name' => [ @@ -39,7 +39,7 @@ ], 'DeleteOperation' => [ 'method' => 'delete', - 'uriTemplate' => '/v1/operations/{name=*}', + 'uriTemplate' => '/v1beta1/operations/{name=*}', 'placeholders' => [ 'name' => [ 'getters' => [ diff --git a/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php index a199d982d7a2..8f9074386226 100644 --- a/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php @@ -1,6 +1,6 @@ Date: Tue, 16 Jan 2018 17:57:25 -0500 Subject: [PATCH 10/21] gapic refresh --- .../Admin/V2/BigtableInstanceAdminClient.php | 4 +- .../Admin/V2/BigtableTableAdminClient.php | 4 +- .../BigtableInstanceAdminGapicClient.php | 4 +- .../Gapic/BigtableTableAdminGapicClient.php | 4 +- src/Bigtable/V2/BigtableClient.php | 4 +- src/Bigtable/V2/Gapic/BigtableGapicClient.php | 4 +- src/Container/V1/ClusterManagerClient.php | 8 +- .../V1/Gapic/ClusterManagerGapicClient.php | 1039 +++++------------ .../cluster_manager_descriptor_config.php | 8 + .../cluster_manager_rest_client_config.php | 674 +++++++++++ src/Dataproc/V1/ClusterControllerClient.php | 12 +- .../V1/Gapic/ClusterControllerGapicClient.php | 503 +++----- .../V1/Gapic/JobControllerGapicClient.php | 457 +++----- src/Dataproc/V1/JobControllerClient.php | 12 +- .../cluster_controller_descriptor_config.php | 42 + .../cluster_controller_rest_client_config.php | 173 +++ .../job_controller_descriptor_config.php | 18 + .../job_controller_rest_client_config.php | 173 +++ src/Dlp/V2beta1/DlpServiceClient.php | 4 +- .../V2beta1/Gapic/DlpServiceGapicClient.php | 4 +- .../V1beta1/ErrorGroupServiceClient.php | 4 +- .../V1beta1/ErrorStatsServiceClient.php | 4 +- .../Gapic/ErrorGroupServiceGapicClient.php | 4 +- .../Gapic/ErrorStatsServiceGapicClient.php | 4 +- .../Gapic/ReportErrorsServiceGapicClient.php | 4 +- .../V1beta1/ReportErrorsServiceClient.php | 4 +- src/Firestore/V1beta1/FirestoreClient.php | 4 +- .../V1beta1/Gapic/FirestoreGapicClient.php | 4 +- .../Gapic/LanguageServiceGapicClient.php | 4 +- .../V1beta2/LanguageServiceClient.php | 4 +- src/Logging/V2/ConfigServiceV2Client.php | 4 +- .../V2/Gapic/ConfigServiceV2GapicClient.php | 4 +- .../V2/Gapic/LoggingServiceV2GapicClient.php | 4 +- .../V2/Gapic/MetricsServiceV2GapicClient.php | 4 +- src/Logging/V2/LoggingServiceV2Client.php | 4 +- src/Logging/V2/MetricsServiceV2Client.php | 4 +- .../V3/Gapic/GroupServiceGapicClient.php | 4 +- .../V3/Gapic/MetricServiceGapicClient.php | 4 +- .../Gapic/UptimeCheckServiceGapicClient.php | 4 +- src/Monitoring/V3/GroupServiceClient.php | 4 +- src/Monitoring/V3/MetricServiceClient.php | 4 +- .../V3/UptimeCheckServiceClient.php | 6 +- src/PubSub/V1/Gapic/PublisherGapicClient.php | 4 +- src/PubSub/V1/Gapic/SubscriberGapicClient.php | 4 +- src/PubSub/V1/PublisherClient.php | 4 +- src/PubSub/V1/SubscriberClient.php | 4 +- .../Admin/Database/V1/DatabaseAdminClient.php | 4 +- .../V1/Gapic/DatabaseAdminGapicClient.php | 4 +- .../V1/Gapic/InstanceAdminGapicClient.php | 4 +- .../Admin/Instance/V1/InstanceAdminClient.php | 4 +- src/Spanner/V1/Gapic/SpannerGapicClient.php | 4 +- src/Speech/V1/Gapic/SpeechGapicClient.php | 4 +- src/Speech/V1/SpeechClient.php | 4 +- .../V1beta1/Gapic/SpeechGapicClient.php | 4 +- src/Speech/V1beta1/SpeechClient.php | 4 +- .../resources/speech_rest_client_config.php | 8 +- .../VideoIntelligenceServiceGapicClient.php | 4 +- .../V1/VideoIntelligenceServiceClient.php | 4 +- .../VideoIntelligenceServiceGapicClient.php | 4 +- .../VideoIntelligenceServiceClient.php | 4 +- .../VideoIntelligenceServiceGapicClient.php | 4 +- .../VideoIntelligenceServiceClient.php | 4 +- .../V1/Gapic/ImageAnnotatorGapicClient.php | 4 +- src/Vision/V1/ImageAnnotatorClient.php | 4 +- 64 files changed, 1835 insertions(+), 1498 deletions(-) create mode 100644 src/Container/V1/resources/cluster_manager_descriptor_config.php create mode 100644 src/Container/V1/resources/cluster_manager_rest_client_config.php create mode 100644 src/Dataproc/V1/resources/cluster_controller_descriptor_config.php create mode 100644 src/Dataproc/V1/resources/cluster_controller_rest_client_config.php create mode 100644 src/Dataproc/V1/resources/job_controller_descriptor_config.php create mode 100644 src/Dataproc/V1/resources/job_controller_rest_client_config.php diff --git a/src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php b/src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php index 85939465bebd..547029fba7cb 100644 --- a/src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php +++ b/src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/bigtable/admin/v2/bigtable_instance_admin.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Bigtable/Admin/V2/BigtableTableAdminClient.php b/src/Bigtable/Admin/V2/BigtableTableAdminClient.php index 51fa08e480b9..6e34126666e1 100644 --- a/src/Bigtable/Admin/V2/BigtableTableAdminClient.php +++ b/src/Bigtable/Admin/V2/BigtableTableAdminClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/bigtable/admin/v2/bigtable_table_admin.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php b/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php index b2b858db6d9c..8923884703de 100644 --- a/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php +++ b/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/bigtable/admin/v2/bigtable_instance_admin.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php b/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php index 76d4c7011d62..7011f5011951 100644 --- a/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php +++ b/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/bigtable/admin/v2/bigtable_table_admin.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Bigtable/V2/BigtableClient.php b/src/Bigtable/V2/BigtableClient.php index 120c18943345..9487104236eb 100644 --- a/src/Bigtable/V2/BigtableClient.php +++ b/src/Bigtable/V2/BigtableClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/bigtable/v2/bigtable.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Bigtable/V2/Gapic/BigtableGapicClient.php b/src/Bigtable/V2/Gapic/BigtableGapicClient.php index dd8e06735cf1..5c9e37459583 100644 --- a/src/Bigtable/V2/Gapic/BigtableGapicClient.php +++ b/src/Bigtable/V2/Gapic/BigtableGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/bigtable/v2/bigtable.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Container/V1/ClusterManagerClient.php b/src/Container/V1/ClusterManagerClient.php index 88fd90771b01..91f6da642f84 100644 --- a/src/Container/V1/ClusterManagerClient.php +++ b/src/Container/V1/ClusterManagerClient.php @@ -1,12 +1,12 @@ listClusters($projectId, $zone); @@ -102,6 +110,13 @@ */ class ClusterManagerGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.container.v1.ClusterManager'; + /** * The default address of the service. */ @@ -122,27 +137,20 @@ class ClusterManagerGapicClient */ const CODEGEN_VERSION = '0.0.5'; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - - protected $grpcCredentialsHelper; - protected $clusterManagerStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; - - private static function getGapicVersion() + private static function getClientDefaults() { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__.'/../resources/cluster_manager_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/cluster_manager_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/cluster_manager_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', + ]; } /** @@ -154,20 +162,23 @@ private static function getGapicVersion() * @type string $serviceAddress The domain name of the API remote host. * Default 'container.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. - * @type \Grpc\ChannelCredentials $sslCreds + * @type Channel $channel + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Google Container Engine API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -183,90 +194,22 @@ private static function getGapicVersion() * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface`. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|TransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/cluster_manager_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'listClusters' => $defaultDescriptors, - 'getCluster' => $defaultDescriptors, - 'createCluster' => $defaultDescriptors, - 'updateCluster' => $defaultDescriptors, - 'updateNodePool' => $defaultDescriptors, - 'setNodePoolAutoscaling' => $defaultDescriptors, - 'setLoggingService' => $defaultDescriptors, - 'setMonitoringService' => $defaultDescriptors, - 'setAddonsConfig' => $defaultDescriptors, - 'setLocations' => $defaultDescriptors, - 'updateMaster' => $defaultDescriptors, - 'setMasterAuth' => $defaultDescriptors, - 'deleteCluster' => $defaultDescriptors, - 'listOperations' => $defaultDescriptors, - 'getOperation' => $defaultDescriptors, - 'cancelOperation' => $defaultDescriptors, - 'getServerConfig' => $defaultDescriptors, - 'listNodePools' => $defaultDescriptors, - 'getNodePool' => $defaultDescriptors, - 'createNodePool' => $defaultDescriptors, - 'deleteNodePool' => $defaultDescriptors, - 'rollbackNodePoolUpgrade' => $defaultDescriptors, - 'setNodePoolManagement' => $defaultDescriptors, - 'setLabels' => $defaultDescriptors, - 'setLegacyAbac' => $defaultDescriptors, - 'startIPRotation' => $defaultDescriptors, - 'completeIPRotation' => $defaultDescriptors, - 'setNodePoolSize' => $defaultDescriptors, - 'setNetworkPolicy' => $defaultDescriptors, - 'setMaintenancePolicy' => $defaultDescriptors, - ]; - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.container.v1.ClusterManager', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createClusterManagerStubFunction = function ($hostname, $opts, $channel) { - return new ClusterManagerGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createClusterManagerStubFunction', $options)) { - $createClusterManagerStubFunction = $options['createClusterManagerStubFunction']; - } - $this->clusterManagerStub = $this->grpcCredentialsHelper->createStub($createClusterManagerStubFunction); + $this->setClientOptions($options + self::getClientDefaults()); } /** @@ -275,8 +218,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $response = $clusterManagerClient->listClusters($projectId, $zone); @@ -293,7 +236,7 @@ public function __construct($options = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -302,7 +245,7 @@ public function __construct($options = []) * * @return \Google\Cloud\Container\V1\ListClustersResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listClusters($projectId, $zone, $optionalArgs = []) @@ -311,24 +254,12 @@ public function listClusters($projectId, $zone, $optionalArgs = []) $request->setProjectId($projectId); $request->setZone($zone); - $defaultCallSettings = $this->defaultCallSettings['listClusters']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'ListClusters', - $mergedSettings, - $this->descriptors['listClusters'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + ListClustersResponse::class, + $optionalArgs, + $request + )->wait(); } /** @@ -336,8 +267,8 @@ public function listClusters($projectId, $zone, $optionalArgs = []) * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -356,7 +287,7 @@ public function listClusters($projectId, $zone, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -365,7 +296,7 @@ public function listClusters($projectId, $zone, $optionalArgs = []) * * @return \Google\Cloud\Container\V1\Cluster * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getCluster($projectId, $zone, $clusterId, $optionalArgs = []) @@ -375,24 +306,12 @@ public function getCluster($projectId, $zone, $clusterId, $optionalArgs = []) $request->setZone($zone); $request->setClusterId($clusterId); - $defaultCallSettings = $this->defaultCallSettings['getCluster']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'GetCluster', - $mergedSettings, - $this->descriptors['getCluster'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Cluster::class, + $optionalArgs, + $request + )->wait(); } /** @@ -412,8 +331,8 @@ public function getCluster($projectId, $zone, $clusterId, $optionalArgs = []) * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $cluster = new Cluster(); @@ -433,7 +352,7 @@ public function getCluster($projectId, $zone, $clusterId, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -442,7 +361,7 @@ public function getCluster($projectId, $zone, $clusterId, $optionalArgs = []) * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createCluster($projectId, $zone, $cluster, $optionalArgs = []) @@ -452,24 +371,12 @@ public function createCluster($projectId, $zone, $cluster, $optionalArgs = []) $request->setZone($zone); $request->setCluster($cluster); - $defaultCallSettings = $this->defaultCallSettings['createCluster']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'CreateCluster', - $mergedSettings, - $this->descriptors['createCluster'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -477,8 +384,8 @@ public function createCluster($projectId, $zone, $cluster, $optionalArgs = []) * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -499,7 +406,7 @@ public function createCluster($projectId, $zone, $cluster, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -508,7 +415,7 @@ public function createCluster($projectId, $zone, $cluster, $optionalArgs = []) * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateCluster($projectId, $zone, $clusterId, $update, $optionalArgs = []) @@ -519,24 +426,12 @@ public function updateCluster($projectId, $zone, $clusterId, $update, $optionalA $request->setClusterId($clusterId); $request->setUpdate($update); - $defaultCallSettings = $this->defaultCallSettings['updateCluster']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'UpdateCluster', - $mergedSettings, - $this->descriptors['updateCluster'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -544,8 +439,8 @@ public function updateCluster($projectId, $zone, $clusterId, $update, $optionalA * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -572,7 +467,7 @@ public function updateCluster($projectId, $zone, $clusterId, $update, $optionalA * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -581,7 +476,7 @@ public function updateCluster($projectId, $zone, $clusterId, $update, $optionalA * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateNodePool($projectId, $zone, $clusterId, $nodePoolId, $nodeVersion, $imageType, $optionalArgs = []) @@ -594,24 +489,12 @@ public function updateNodePool($projectId, $zone, $clusterId, $nodePoolId, $node $request->setNodeVersion($nodeVersion); $request->setImageType($imageType); - $defaultCallSettings = $this->defaultCallSettings['updateNodePool']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'UpdateNodePool', - $mergedSettings, - $this->descriptors['updateNodePool'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -619,8 +502,8 @@ public function updateNodePool($projectId, $zone, $clusterId, $nodePoolId, $node * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -643,7 +526,7 @@ public function updateNodePool($projectId, $zone, $clusterId, $nodePoolId, $node * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -652,7 +535,7 @@ public function updateNodePool($projectId, $zone, $clusterId, $nodePoolId, $node * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setNodePoolAutoscaling($projectId, $zone, $clusterId, $nodePoolId, $autoscaling, $optionalArgs = []) @@ -664,24 +547,12 @@ public function setNodePoolAutoscaling($projectId, $zone, $clusterId, $nodePoolI $request->setNodePoolId($nodePoolId); $request->setAutoscaling($autoscaling); - $defaultCallSettings = $this->defaultCallSettings['setNodePoolAutoscaling']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'SetNodePoolAutoscaling', - $mergedSettings, - $this->descriptors['setNodePoolAutoscaling'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -689,8 +560,8 @@ public function setNodePoolAutoscaling($projectId, $zone, $clusterId, $nodePoolI * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -715,7 +586,7 @@ public function setNodePoolAutoscaling($projectId, $zone, $clusterId, $nodePoolI * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -724,7 +595,7 @@ public function setNodePoolAutoscaling($projectId, $zone, $clusterId, $nodePoolI * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setLoggingService($projectId, $zone, $clusterId, $loggingService, $optionalArgs = []) @@ -735,24 +606,12 @@ public function setLoggingService($projectId, $zone, $clusterId, $loggingService $request->setClusterId($clusterId); $request->setLoggingService($loggingService); - $defaultCallSettings = $this->defaultCallSettings['setLoggingService']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'SetLoggingService', - $mergedSettings, - $this->descriptors['setLoggingService'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -760,8 +619,8 @@ public function setLoggingService($projectId, $zone, $clusterId, $loggingService * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -786,7 +645,7 @@ public function setLoggingService($projectId, $zone, $clusterId, $loggingService * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -795,7 +654,7 @@ public function setLoggingService($projectId, $zone, $clusterId, $loggingService * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setMonitoringService($projectId, $zone, $clusterId, $monitoringService, $optionalArgs = []) @@ -806,24 +665,12 @@ public function setMonitoringService($projectId, $zone, $clusterId, $monitoringS $request->setClusterId($clusterId); $request->setMonitoringService($monitoringService); - $defaultCallSettings = $this->defaultCallSettings['setMonitoringService']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'SetMonitoringService', - $mergedSettings, - $this->descriptors['setMonitoringService'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -831,8 +678,8 @@ public function setMonitoringService($projectId, $zone, $clusterId, $monitoringS * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -854,7 +701,7 @@ public function setMonitoringService($projectId, $zone, $clusterId, $monitoringS * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -863,7 +710,7 @@ public function setMonitoringService($projectId, $zone, $clusterId, $monitoringS * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setAddonsConfig($projectId, $zone, $clusterId, $addonsConfig, $optionalArgs = []) @@ -874,24 +721,12 @@ public function setAddonsConfig($projectId, $zone, $clusterId, $addonsConfig, $o $request->setClusterId($clusterId); $request->setAddonsConfig($addonsConfig); - $defaultCallSettings = $this->defaultCallSettings['setAddonsConfig']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'SetAddonsConfig', - $mergedSettings, - $this->descriptors['setAddonsConfig'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -899,8 +734,8 @@ public function setAddonsConfig($projectId, $zone, $clusterId, $addonsConfig, $o * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -927,7 +762,7 @@ public function setAddonsConfig($projectId, $zone, $clusterId, $addonsConfig, $o * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -936,7 +771,7 @@ public function setAddonsConfig($projectId, $zone, $clusterId, $addonsConfig, $o * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setLocations($projectId, $zone, $clusterId, $locations, $optionalArgs = []) @@ -947,24 +782,12 @@ public function setLocations($projectId, $zone, $clusterId, $locations, $optiona $request->setClusterId($clusterId); $request->setLocations($locations); - $defaultCallSettings = $this->defaultCallSettings['setLocations']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'SetLocations', - $mergedSettings, - $this->descriptors['setLocations'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -972,8 +795,8 @@ public function setLocations($projectId, $zone, $clusterId, $locations, $optiona * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -996,7 +819,7 @@ public function setLocations($projectId, $zone, $clusterId, $locations, $optiona * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1005,7 +828,7 @@ public function setLocations($projectId, $zone, $clusterId, $locations, $optiona * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateMaster($projectId, $zone, $clusterId, $masterVersion, $optionalArgs = []) @@ -1016,24 +839,12 @@ public function updateMaster($projectId, $zone, $clusterId, $masterVersion, $opt $request->setClusterId($clusterId); $request->setMasterVersion($masterVersion); - $defaultCallSettings = $this->defaultCallSettings['updateMaster']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'UpdateMaster', - $mergedSettings, - $this->descriptors['updateMaster'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -1043,12 +854,12 @@ public function updateMaster($projectId, $zone, $clusterId, $masterVersion, $opt * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; - * $action = Action::UNKNOWN; + * $action = SetMasterAuthRequest_Action::UNKNOWN; * $update = new MasterAuth(); * $response = $clusterManagerClient->setMasterAuth($projectId, $zone, $clusterId, $action, $update); * } finally { @@ -1068,7 +879,7 @@ public function updateMaster($projectId, $zone, $clusterId, $masterVersion, $opt * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1077,7 +888,7 @@ public function updateMaster($projectId, $zone, $clusterId, $masterVersion, $opt * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setMasterAuth($projectId, $zone, $clusterId, $action, $update, $optionalArgs = []) @@ -1089,24 +900,12 @@ public function setMasterAuth($projectId, $zone, $clusterId, $action, $update, $ $request->setAction($action); $request->setUpdate($update); - $defaultCallSettings = $this->defaultCallSettings['setMasterAuth']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'SetMasterAuth', - $mergedSettings, - $this->descriptors['setMasterAuth'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -1122,8 +921,8 @@ public function setMasterAuth($projectId, $zone, $clusterId, $action, $update, $ * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -1142,7 +941,7 @@ public function setMasterAuth($projectId, $zone, $clusterId, $action, $update, $ * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1151,7 +950,7 @@ public function setMasterAuth($projectId, $zone, $clusterId, $action, $update, $ * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteCluster($projectId, $zone, $clusterId, $optionalArgs = []) @@ -1161,24 +960,12 @@ public function deleteCluster($projectId, $zone, $clusterId, $optionalArgs = []) $request->setZone($zone); $request->setClusterId($clusterId); - $defaultCallSettings = $this->defaultCallSettings['deleteCluster']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'DeleteCluster', - $mergedSettings, - $this->descriptors['deleteCluster'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -1186,8 +973,8 @@ public function deleteCluster($projectId, $zone, $clusterId, $optionalArgs = []) * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $response = $clusterManagerClient->listOperations($projectId, $zone); @@ -1203,7 +990,7 @@ public function deleteCluster($projectId, $zone, $clusterId, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1212,7 +999,7 @@ public function deleteCluster($projectId, $zone, $clusterId, $optionalArgs = []) * * @return \Google\Cloud\Container\V1\ListOperationsResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listOperations($projectId, $zone, $optionalArgs = []) @@ -1221,24 +1008,12 @@ public function listOperations($projectId, $zone, $optionalArgs = []) $request->setProjectId($projectId); $request->setZone($zone); - $defaultCallSettings = $this->defaultCallSettings['listOperations']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'ListOperations', - $mergedSettings, - $this->descriptors['listOperations'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + ListOperationsResponse::class, + $optionalArgs, + $request + )->wait(); } /** @@ -1246,8 +1021,8 @@ public function listOperations($projectId, $zone, $optionalArgs = []) * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $operationId = ''; @@ -1266,7 +1041,7 @@ public function listOperations($projectId, $zone, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1275,7 +1050,7 @@ public function listOperations($projectId, $zone, $optionalArgs = []) * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getOperation($projectId, $zone, $operationId, $optionalArgs = []) @@ -1285,24 +1060,12 @@ public function getOperation($projectId, $zone, $operationId, $optionalArgs = [] $request->setZone($zone); $request->setOperationId($operationId); - $defaultCallSettings = $this->defaultCallSettings['getOperation']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'GetOperation', - $mergedSettings, - $this->descriptors['getOperation'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -1310,8 +1073,8 @@ public function getOperation($projectId, $zone, $operationId, $optionalArgs = [] * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $operationId = ''; @@ -1329,14 +1092,14 @@ public function getOperation($projectId, $zone, $operationId, $optionalArgs = [] * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function cancelOperation($projectId, $zone, $operationId, $optionalArgs = []) @@ -1346,24 +1109,12 @@ public function cancelOperation($projectId, $zone, $operationId, $optionalArgs = $request->setZone($zone); $request->setOperationId($operationId); - $defaultCallSettings = $this->defaultCallSettings['cancelOperation']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'CancelOperation', - $mergedSettings, - $this->descriptors['cancelOperation'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + GPBEmpty::class, + $optionalArgs, + $request + )->wait(); } /** @@ -1371,8 +1122,8 @@ public function cancelOperation($projectId, $zone, $operationId, $optionalArgs = * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $response = $clusterManagerClient->getServerConfig($projectId, $zone); @@ -1388,7 +1139,7 @@ public function cancelOperation($projectId, $zone, $operationId, $optionalArgs = * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1397,7 +1148,7 @@ public function cancelOperation($projectId, $zone, $operationId, $optionalArgs = * * @return \Google\Cloud\Container\V1\ServerConfig * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getServerConfig($projectId, $zone, $optionalArgs = []) @@ -1406,24 +1157,12 @@ public function getServerConfig($projectId, $zone, $optionalArgs = []) $request->setProjectId($projectId); $request->setZone($zone); - $defaultCallSettings = $this->defaultCallSettings['getServerConfig']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'GetServerConfig', - $mergedSettings, - $this->descriptors['getServerConfig'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + ServerConfig::class, + $optionalArgs, + $request + )->wait(); } /** @@ -1431,8 +1170,8 @@ public function getServerConfig($projectId, $zone, $optionalArgs = []) * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -1451,7 +1190,7 @@ public function getServerConfig($projectId, $zone, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1460,7 +1199,7 @@ public function getServerConfig($projectId, $zone, $optionalArgs = []) * * @return \Google\Cloud\Container\V1\ListNodePoolsResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listNodePools($projectId, $zone, $clusterId, $optionalArgs = []) @@ -1470,24 +1209,12 @@ public function listNodePools($projectId, $zone, $clusterId, $optionalArgs = []) $request->setZone($zone); $request->setClusterId($clusterId); - $defaultCallSettings = $this->defaultCallSettings['listNodePools']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'ListNodePools', - $mergedSettings, - $this->descriptors['listNodePools'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + ListNodePoolsResponse::class, + $optionalArgs, + $request + )->wait(); } /** @@ -1495,8 +1222,8 @@ public function listNodePools($projectId, $zone, $clusterId, $optionalArgs = []) * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -1517,7 +1244,7 @@ public function listNodePools($projectId, $zone, $clusterId, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1526,7 +1253,7 @@ public function listNodePools($projectId, $zone, $clusterId, $optionalArgs = []) * * @return \Google\Cloud\Container\V1\NodePool * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getNodePool($projectId, $zone, $clusterId, $nodePoolId, $optionalArgs = []) @@ -1537,24 +1264,12 @@ public function getNodePool($projectId, $zone, $clusterId, $nodePoolId, $optiona $request->setClusterId($clusterId); $request->setNodePoolId($nodePoolId); - $defaultCallSettings = $this->defaultCallSettings['getNodePool']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'GetNodePool', - $mergedSettings, - $this->descriptors['getNodePool'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + NodePool::class, + $optionalArgs, + $request + )->wait(); } /** @@ -1562,8 +1277,8 @@ public function getNodePool($projectId, $zone, $clusterId, $nodePoolId, $optiona * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -1584,7 +1299,7 @@ public function getNodePool($projectId, $zone, $clusterId, $nodePoolId, $optiona * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1593,7 +1308,7 @@ public function getNodePool($projectId, $zone, $clusterId, $nodePoolId, $optiona * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createNodePool($projectId, $zone, $clusterId, $nodePool, $optionalArgs = []) @@ -1604,24 +1319,12 @@ public function createNodePool($projectId, $zone, $clusterId, $nodePool, $option $request->setClusterId($clusterId); $request->setNodePool($nodePool); - $defaultCallSettings = $this->defaultCallSettings['createNodePool']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'CreateNodePool', - $mergedSettings, - $this->descriptors['createNodePool'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -1629,8 +1332,8 @@ public function createNodePool($projectId, $zone, $clusterId, $nodePool, $option * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -1651,7 +1354,7 @@ public function createNodePool($projectId, $zone, $clusterId, $nodePool, $option * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1660,7 +1363,7 @@ public function createNodePool($projectId, $zone, $clusterId, $nodePool, $option * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteNodePool($projectId, $zone, $clusterId, $nodePoolId, $optionalArgs = []) @@ -1671,24 +1374,12 @@ public function deleteNodePool($projectId, $zone, $clusterId, $nodePoolId, $opti $request->setClusterId($clusterId); $request->setNodePoolId($nodePoolId); - $defaultCallSettings = $this->defaultCallSettings['deleteNodePool']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'DeleteNodePool', - $mergedSettings, - $this->descriptors['deleteNodePool'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -1697,8 +1388,8 @@ public function deleteNodePool($projectId, $zone, $clusterId, $nodePoolId, $opti * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -1719,7 +1410,7 @@ public function deleteNodePool($projectId, $zone, $clusterId, $nodePoolId, $opti * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1728,7 +1419,7 @@ public function deleteNodePool($projectId, $zone, $clusterId, $nodePoolId, $opti * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function rollbackNodePoolUpgrade($projectId, $zone, $clusterId, $nodePoolId, $optionalArgs = []) @@ -1739,24 +1430,12 @@ public function rollbackNodePoolUpgrade($projectId, $zone, $clusterId, $nodePool $request->setClusterId($clusterId); $request->setNodePoolId($nodePoolId); - $defaultCallSettings = $this->defaultCallSettings['rollbackNodePoolUpgrade']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'RollbackNodePoolUpgrade', - $mergedSettings, - $this->descriptors['rollbackNodePoolUpgrade'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -1764,8 +1443,8 @@ public function rollbackNodePoolUpgrade($projectId, $zone, $clusterId, $nodePool * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -1788,7 +1467,7 @@ public function rollbackNodePoolUpgrade($projectId, $zone, $clusterId, $nodePool * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1797,7 +1476,7 @@ public function rollbackNodePoolUpgrade($projectId, $zone, $clusterId, $nodePool * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setNodePoolManagement($projectId, $zone, $clusterId, $nodePoolId, $management, $optionalArgs = []) @@ -1809,24 +1488,12 @@ public function setNodePoolManagement($projectId, $zone, $clusterId, $nodePoolId $request->setNodePoolId($nodePoolId); $request->setManagement($management); - $defaultCallSettings = $this->defaultCallSettings['setNodePoolManagement']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'SetNodePoolManagement', - $mergedSettings, - $this->descriptors['setNodePoolManagement'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -1834,8 +1501,8 @@ public function setNodePoolManagement($projectId, $zone, $clusterId, $nodePoolId * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -1863,7 +1530,7 @@ public function setNodePoolManagement($projectId, $zone, $clusterId, $nodePoolId * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1872,7 +1539,7 @@ public function setNodePoolManagement($projectId, $zone, $clusterId, $nodePoolId * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setLabels($projectId, $zone, $clusterId, $resourceLabels, $labelFingerprint, $optionalArgs = []) @@ -1884,24 +1551,12 @@ public function setLabels($projectId, $zone, $clusterId, $resourceLabels, $label $request->setResourceLabels($resourceLabels); $request->setLabelFingerprint($labelFingerprint); - $defaultCallSettings = $this->defaultCallSettings['setLabels']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'SetLabels', - $mergedSettings, - $this->descriptors['setLabels'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -1909,8 +1564,8 @@ public function setLabels($projectId, $zone, $clusterId, $resourceLabels, $label * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -1931,7 +1586,7 @@ public function setLabels($projectId, $zone, $clusterId, $resourceLabels, $label * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -1940,7 +1595,7 @@ public function setLabels($projectId, $zone, $clusterId, $resourceLabels, $label * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setLegacyAbac($projectId, $zone, $clusterId, $enabled, $optionalArgs = []) @@ -1951,24 +1606,12 @@ public function setLegacyAbac($projectId, $zone, $clusterId, $enabled, $optional $request->setClusterId($clusterId); $request->setEnabled($enabled); - $defaultCallSettings = $this->defaultCallSettings['setLegacyAbac']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'SetLegacyAbac', - $mergedSettings, - $this->descriptors['setLegacyAbac'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -1976,8 +1619,8 @@ public function setLegacyAbac($projectId, $zone, $clusterId, $enabled, $optional * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -1996,7 +1639,7 @@ public function setLegacyAbac($projectId, $zone, $clusterId, $enabled, $optional * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -2005,7 +1648,7 @@ public function setLegacyAbac($projectId, $zone, $clusterId, $enabled, $optional * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function startIPRotation($projectId, $zone, $clusterId, $optionalArgs = []) @@ -2015,24 +1658,12 @@ public function startIPRotation($projectId, $zone, $clusterId, $optionalArgs = [ $request->setZone($zone); $request->setClusterId($clusterId); - $defaultCallSettings = $this->defaultCallSettings['startIPRotation']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'StartIPRotation', - $mergedSettings, - $this->descriptors['startIPRotation'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -2040,8 +1671,8 @@ public function startIPRotation($projectId, $zone, $clusterId, $optionalArgs = [ * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -2060,7 +1691,7 @@ public function startIPRotation($projectId, $zone, $clusterId, $optionalArgs = [ * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -2069,7 +1700,7 @@ public function startIPRotation($projectId, $zone, $clusterId, $optionalArgs = [ * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function completeIPRotation($projectId, $zone, $clusterId, $optionalArgs = []) @@ -2079,24 +1710,12 @@ public function completeIPRotation($projectId, $zone, $clusterId, $optionalArgs $request->setZone($zone); $request->setClusterId($clusterId); - $defaultCallSettings = $this->defaultCallSettings['completeIPRotation']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'CompleteIPRotation', - $mergedSettings, - $this->descriptors['completeIPRotation'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -2104,8 +1723,8 @@ public function completeIPRotation($projectId, $zone, $clusterId, $optionalArgs * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -2128,7 +1747,7 @@ public function completeIPRotation($projectId, $zone, $clusterId, $optionalArgs * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -2137,7 +1756,7 @@ public function completeIPRotation($projectId, $zone, $clusterId, $optionalArgs * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setNodePoolSize($projectId, $zone, $clusterId, $nodePoolId, $nodeCount, $optionalArgs = []) @@ -2149,24 +1768,12 @@ public function setNodePoolSize($projectId, $zone, $clusterId, $nodePoolId, $nod $request->setNodePoolId($nodePoolId); $request->setNodeCount($nodeCount); - $defaultCallSettings = $this->defaultCallSettings['setNodePoolSize']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'SetNodePoolSize', - $mergedSettings, - $this->descriptors['setNodePoolSize'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -2174,8 +1781,8 @@ public function setNodePoolSize($projectId, $zone, $clusterId, $nodePoolId, $nod * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -2196,7 +1803,7 @@ public function setNodePoolSize($projectId, $zone, $clusterId, $nodePoolId, $nod * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -2205,7 +1812,7 @@ public function setNodePoolSize($projectId, $zone, $clusterId, $nodePoolId, $nod * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setNetworkPolicy($projectId, $zone, $clusterId, $networkPolicy, $optionalArgs = []) @@ -2216,24 +1823,12 @@ public function setNetworkPolicy($projectId, $zone, $clusterId, $networkPolicy, $request->setClusterId($clusterId); $request->setNetworkPolicy($networkPolicy); - $defaultCallSettings = $this->defaultCallSettings['setNetworkPolicy']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'SetNetworkPolicy', - $mergedSettings, - $this->descriptors['setNetworkPolicy'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Operation::class, + $optionalArgs, + $request + )->wait(); } /** @@ -2241,8 +1836,8 @@ public function setNetworkPolicy($projectId, $zone, $clusterId, $networkPolicy, * * Sample code: * ``` + * $clusterManagerClient = new ClusterManagerClient(); * try { - * $clusterManagerClient = new ClusterManagerClient(); * $projectId = ''; * $zone = ''; * $clusterId = ''; @@ -2264,7 +1859,7 @@ public function setNetworkPolicy($projectId, $zone, $clusterId, $networkPolicy, * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -2273,7 +1868,7 @@ public function setNetworkPolicy($projectId, $zone, $clusterId, $networkPolicy, * * @return \Google\Cloud\Container\V1\Operation * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setMaintenancePolicy($projectId, $zone, $clusterId, $maintenancePolicy, $optionalArgs = []) @@ -2284,39 +1879,11 @@ public function setMaintenancePolicy($projectId, $zone, $clusterId, $maintenance $request->setClusterId($clusterId); $request->setMaintenancePolicy($maintenancePolicy); - $defaultCallSettings = $this->defaultCallSettings['setMaintenancePolicy']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterManagerStub, + return $this->startCall( 'SetMaintenancePolicy', - $mergedSettings, - $this->descriptors['setMaintenancePolicy'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); - } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->clusterManagerStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + Operation::class, + $optionalArgs, + $request + )->wait(); } } diff --git a/src/Container/V1/resources/cluster_manager_descriptor_config.php b/src/Container/V1/resources/cluster_manager_descriptor_config.php new file mode 100644 index 000000000000..1d663bfaf0a9 --- /dev/null +++ b/src/Container/V1/resources/cluster_manager_descriptor_config.php @@ -0,0 +1,8 @@ + [ + 'google.container.v1.ClusterManager' => [ + ], + ], +]; diff --git a/src/Container/V1/resources/cluster_manager_rest_client_config.php b/src/Container/V1/resources/cluster_manager_rest_client_config.php new file mode 100644 index 000000000000..ec1397b50a14 --- /dev/null +++ b/src/Container/V1/resources/cluster_manager_rest_client_config.php @@ -0,0 +1,674 @@ + [ + 'google.container.v1.ClusterManager' => [ + 'ListClusters' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + ], + ], + 'GetCluster' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + 'CreateCluster' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + ], + ], + 'UpdateCluster' => [ + 'method' => 'put', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + 'UpdateNodePool' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}/nodePools/{node_pool_id}/update', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + 'node_pool_id' => [ + 'getters' => [ + 'getNodePoolId', + ], + ], + ], + ], + 'SetNodePoolAutoscaling' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}/nodePools/{node_pool_id}/autoscaling', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + 'node_pool_id' => [ + 'getters' => [ + 'getNodePoolId', + ], + ], + ], + ], + 'SetLoggingService' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}/logging', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + 'SetMonitoringService' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}/monitoring', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + 'SetAddonsConfig' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}/addons', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + 'SetLocations' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}/locations', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + 'UpdateMaster' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}/master', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + 'SetMasterAuth' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}:setMasterAuth', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + 'DeleteCluster' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/operations', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + ], + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/operations/{operation_id}', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'operation_id' => [ + 'getters' => [ + 'getOperationId', + ], + ], + ], + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/operations/{operation_id}:cancel', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'operation_id' => [ + 'getters' => [ + 'getOperationId', + ], + ], + ], + ], + 'GetServerConfig' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/serverconfig', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + ], + ], + 'ListNodePools' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}/nodePools', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + 'GetNodePool' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}/nodePools/{node_pool_id}', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + 'node_pool_id' => [ + 'getters' => [ + 'getNodePoolId', + ], + ], + ], + ], + 'CreateNodePool' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}/nodePools', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + 'DeleteNodePool' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}/nodePools/{node_pool_id}', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + 'node_pool_id' => [ + 'getters' => [ + 'getNodePoolId', + ], + ], + ], + ], + 'RollbackNodePoolUpgrade' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}/nodePools/{node_pool_id}:rollback', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + 'node_pool_id' => [ + 'getters' => [ + 'getNodePoolId', + ], + ], + ], + ], + 'SetNodePoolManagement' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}/nodePools/{node_pool_id}/setManagement', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + 'node_pool_id' => [ + 'getters' => [ + 'getNodePoolId', + ], + ], + ], + ], + 'SetLabels' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}/resourceLabels', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + 'SetLegacyAbac' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}/legacyAbac', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + 'StartIPRotation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}:startIpRotation', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + 'CompleteIPRotation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}:completeIpRotation', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + 'SetNodePoolSize' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}/nodePools/{node_pool_id}/setSize', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + 'node_pool_id' => [ + 'getters' => [ + 'getNodePoolId', + ], + ], + ], + ], + 'SetNetworkPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}:setNetworkPolicy', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + 'SetMaintenancePolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/zones/{zone}/clusters/{cluster_id}:setMaintenancePolicy', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'zone' => [ + 'getters' => [ + 'getZone', + ], + ], + 'cluster_id' => [ + 'getters' => [ + 'getClusterId', + ], + ], + ], + ], + ], + ], +]; diff --git a/src/Dataproc/V1/ClusterControllerClient.php b/src/Dataproc/V1/ClusterControllerClient.php index 1c2cd8040deb..36bbe77a7417 100644 --- a/src/Dataproc/V1/ClusterControllerClient.php +++ b/src/Dataproc/V1/ClusterControllerClient.php @@ -1,12 +1,12 @@ 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getClusters', - ]); - - $pageStreamingDescriptors = [ - 'listClusters' => $listClustersPageStreamingDescriptor, - ]; - return $pageStreamingDescriptors; - } - private static function getLongRunningDescriptors() + private $operationsClient; + private static function getClientDefaults() { return [ - 'createCluster' => [ - 'operationReturnType' => '\Google\Cloud\Dataproc\V1\Cluster', - 'metadataReturnType' => '\Google\Cloud\Dataproc\V1\ClusterOperationMetadata', - ], - 'updateCluster' => [ - 'operationReturnType' => '\Google\Cloud\Dataproc\V1\Cluster', - 'metadataReturnType' => '\Google\Cloud\Dataproc\V1\ClusterOperationMetadata', - ], - 'deleteCluster' => [ - 'operationReturnType' => '\Google\Protobuf\GPBEmpty', - 'metadataReturnType' => '\Google\Cloud\Dataproc\V1\ClusterOperationMetadata', - ], - 'diagnoseCluster' => [ - 'operationReturnType' => '\Google\Protobuf\GPBEmpty', - 'metadataReturnType' => '\Google\Cloud\Dataproc\V1\DiagnoseClusterResults', + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', ], + 'clientConfigPath' => __DIR__ . '/../resources/cluster_controller_client_config.json', + 'restClientConfigPath' => __DIR__ . '/../resources/cluster_controller_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__ . '/../resources/cluster_controller_descriptor_config.php', + 'versionFile' => __DIR__ . '/../../VERSION' ]; } - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - return self::$gapicVersion; - } /** * Return an OperationsClient object with the same endpoint as $this. * - * @return \Google\ApiCore\LongRunning\OperationsClient + * @return OperationsClient * @experimental */ public function getOperationsClient() @@ -204,22 +177,17 @@ public function getOperationsClient() * 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 \Google\ApiCore\OperationResponse + * @param string $methodName The name of the method used to start the operation + * @return OperationResponse * @experimental */ public function resumeOperation($operationName, $methodName = null) { - $lroDescriptors = self::getLongRunningDescriptors(); - if (!is_null($methodName) && array_key_exists($methodName, $lroDescriptors)) { - $options = $lroDescriptors[$methodName]; - } else { - $options = []; - } + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); - return $operation; } @@ -227,25 +195,28 @@ public function resumeOperation($operationName, $methodName = null) * Constructor. * * @param array $options { - * Optional. Options for configuring the service API wrapper. + * Optional. Options for configuring the service API wrapper. * * @type string $serviceAddress The domain name of the API remote host. * Default 'dataproc.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. - * @type \Grpc\ChannelCredentials $sslCreds + * @type Channel $channel + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Google Cloud Dataproc API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -261,83 +232,30 @@ public function resumeOperation($operationName, $methodName = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface`. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|TransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/cluster_controller_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - if (array_key_exists('operationsClient', $options)) { - $this->operationsClient = $options['operationsClient']; - } else { - $operationsClientOptions = $options; - unset($operationsClientOptions['retryingOverride']); - unset($operationsClientOptions['clientConfigPath']); - $this->operationsClient = new OperationsClient($operationsClientOptions); - } - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'createCluster' => $defaultDescriptors, - 'updateCluster' => $defaultDescriptors, - 'deleteCluster' => $defaultDescriptors, - 'getCluster' => $defaultDescriptors, - 'listClusters' => $defaultDescriptors, - 'diagnoseCluster' => $defaultDescriptors, - ]; - $pageStreamingDescriptors = self::getPageStreamingDescriptors(); - foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { - $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; - } - $longRunningDescriptors = self::getLongRunningDescriptors(); - foreach ($longRunningDescriptors as $method => $longRunningDescriptor) { - $this->descriptors[$method]['longRunningDescriptor'] = $longRunningDescriptor + ['operationsClient' => $this->operationsClient]; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.cloud.dataproc.v1.ClusterController', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createClusterControllerStubFunction = function ($hostname, $opts, $channel) { - return new ClusterControllerGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createClusterControllerStubFunction', $options)) { - $createClusterControllerStubFunction = $options['createClusterControllerStubFunction']; - } - $this->clusterControllerStub = $this->grpcCredentialsHelper->createStub($createClusterControllerStubFunction); + $options += self::getClientDefaults(); + $this->setClientOptions($options); + $this->pluckArray([ + 'serviceName', + 'clientConfigPath', + 'restClientConfigPath', + 'descriptorsConfigPath' + ], $options); + $this->operationsClient = new OperationsClient($options); } /** @@ -345,8 +263,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $clusterControllerClient = new ClusterControllerClient(); * try { - * $clusterControllerClient = new ClusterControllerClient(); * $projectId = ''; * $region = ''; * $cluster = new Cluster(); @@ -381,14 +299,13 @@ public function __construct($options = []) * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param Cluster $cluster Required. The cluster to create. - * @param array $optionalArgs { - * Optional. - * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param Cluster $cluster Required. The cluster to create. + * @param array $optionalArgs { + * Optional. + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -397,7 +314,7 @@ public function __construct($options = []) * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createCluster($projectId, $region, $cluster, $optionalArgs = []) @@ -407,24 +324,12 @@ public function createCluster($projectId, $region, $cluster, $optionalArgs = []) $request->setRegion($region); $request->setCluster($cluster); - $defaultCallSettings = $this->defaultCallSettings['createCluster']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterControllerStub, + return $this->startOperationsCall( 'CreateCluster', - $mergedSettings, - $this->descriptors['createCluster'] - ); - - return $callable( + $optionalArgs, $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + $this->getOperationsClient() + )->wait(); } /** @@ -432,8 +337,8 @@ public function createCluster($projectId, $region, $cluster, $optionalArgs = []) * * Sample code: * ``` + * $clusterControllerClient = new ClusterControllerClient(); * try { - * $clusterControllerClient = new ClusterControllerClient(); * $projectId = ''; * $region = ''; * $clusterName = ''; @@ -470,16 +375,16 @@ public function createCluster($projectId, $region, $cluster, $optionalArgs = []) * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project the - * cluster belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param string $clusterName Required. The cluster name. - * @param Cluster $cluster Required. The changes to the cluster. - * @param FieldMask $updateMask Required. Specifies the path, relative to `Cluster`, of - * the field to update. For example, to change the number of workers - * in a cluster to 5, the `update_mask` parameter would be - * specified as `config.worker_config.num_instances`, - * and the `PATCH` request body would specify the new value, as follows: + * @param string $projectId Required. The ID of the Google Cloud Platform project the + * cluster belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param string $clusterName Required. The cluster name. + * @param Cluster $cluster Required. The changes to the cluster. + * @param FieldMask $updateMask Required. Specifies the path, relative to `Cluster`, of + * the field to update. For example, to change the number of workers + * in a cluster to 5, the `update_mask` parameter would be + * specified as `config.worker_config.num_instances`, + * and the `PATCH` request body would specify the new value, as follows: * * { * "config":{ @@ -523,9 +428,8 @@ public function createCluster($projectId, $region, $cluster, $optionalArgs = []) * *
* @param array $optionalArgs { - * Optional. - * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * Optional. + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -534,7 +438,7 @@ public function createCluster($projectId, $region, $cluster, $optionalArgs = []) * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateCluster($projectId, $region, $clusterName, $cluster, $updateMask, $optionalArgs = []) @@ -546,24 +450,12 @@ public function updateCluster($projectId, $region, $clusterName, $cluster, $upda $request->setCluster($cluster); $request->setUpdateMask($updateMask); - $defaultCallSettings = $this->defaultCallSettings['updateCluster']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterControllerStub, + return $this->startOperationsCall( 'UpdateCluster', - $mergedSettings, - $this->descriptors['updateCluster'] - ); - - return $callable( + $optionalArgs, $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + $this->getOperationsClient() + )->wait(); } /** @@ -571,8 +463,8 @@ public function updateCluster($projectId, $region, $clusterName, $cluster, $upda * * Sample code: * ``` + * $clusterControllerClient = new ClusterControllerClient(); * try { - * $clusterControllerClient = new ClusterControllerClient(); * $projectId = ''; * $region = ''; * $clusterName = ''; @@ -605,14 +497,13 @@ public function updateCluster($projectId, $region, $clusterName, $cluster, $upda * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param string $clusterName Required. The cluster name. - * @param array $optionalArgs { - * Optional. - * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param string $clusterName Required. The cluster name. + * @param array $optionalArgs { + * Optional. + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -621,7 +512,7 @@ public function updateCluster($projectId, $region, $clusterName, $cluster, $upda * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteCluster($projectId, $region, $clusterName, $optionalArgs = []) @@ -631,24 +522,12 @@ public function deleteCluster($projectId, $region, $clusterName, $optionalArgs = $request->setRegion($region); $request->setClusterName($clusterName); - $defaultCallSettings = $this->defaultCallSettings['deleteCluster']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterControllerStub, + return $this->startOperationsCall( 'DeleteCluster', - $mergedSettings, - $this->descriptors['deleteCluster'] - ); - - return $callable( + $optionalArgs, $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + $this->getOperationsClient() + )->wait(); } /** @@ -656,8 +535,8 @@ public function deleteCluster($projectId, $region, $clusterName, $optionalArgs = * * Sample code: * ``` + * $clusterControllerClient = new ClusterControllerClient(); * try { - * $clusterControllerClient = new ClusterControllerClient(); * $projectId = ''; * $region = ''; * $clusterName = ''; @@ -667,14 +546,13 @@ public function deleteCluster($projectId, $region, $clusterName, $optionalArgs = * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param string $clusterName Required. The cluster name. - * @param array $optionalArgs { - * Optional. - * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param string $clusterName Required. The cluster name. + * @param array $optionalArgs { + * Optional. + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -683,7 +561,7 @@ public function deleteCluster($projectId, $region, $clusterName, $optionalArgs = * * @return \Google\Cloud\Dataproc\V1\Cluster * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getCluster($projectId, $region, $clusterName, $optionalArgs = []) @@ -693,24 +571,12 @@ public function getCluster($projectId, $region, $clusterName, $optionalArgs = [] $request->setRegion($region); $request->setClusterName($clusterName); - $defaultCallSettings = $this->defaultCallSettings['getCluster']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterControllerStub, + return $this->startCall( 'GetCluster', - $mergedSettings, - $this->descriptors['getCluster'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Cluster::class, + $optionalArgs, + $request + )->wait(); } /** @@ -718,8 +584,8 @@ public function getCluster($projectId, $region, $clusterName, $optionalArgs = [] * * Sample code: * ``` + * $clusterControllerClient = new ClusterControllerClient(); * try { - * $clusterControllerClient = new ClusterControllerClient(); * $projectId = ''; * $region = ''; * // Iterate through all elements @@ -740,12 +606,11 @@ public function getCluster($projectId, $region, $clusterName, $optionalArgs = [] * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param array $optionalArgs { - * Optional. - * + * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param array $optionalArgs { + * Optional. * @type string $filter * Optional. A filter constraining the clusters to list. Filters are * case-sensitive and have the following syntax: @@ -775,7 +640,7 @@ public function getCluster($projectId, $region, $clusterName, $optionalArgs = [] * 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 \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -784,7 +649,7 @@ public function getCluster($projectId, $region, $clusterName, $optionalArgs = [] * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listClusters($projectId, $region, $optionalArgs = []) @@ -802,24 +667,12 @@ public function listClusters($projectId, $region, $optionalArgs = []) $request->setPageToken($optionalArgs['pageToken']); } - $defaultCallSettings = $this->defaultCallSettings['listClusters']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterControllerStub, + return $this->getPagedListResponse( 'ListClusters', - $mergedSettings, - $this->descriptors['listClusters'] + $optionalArgs, + ListClustersResponse::class, + $request ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -829,8 +682,8 @@ public function listClusters($projectId, $region, $optionalArgs = []) * * Sample code: * ``` + * $clusterControllerClient = new ClusterControllerClient(); * try { - * $clusterControllerClient = new ClusterControllerClient(); * $projectId = ''; * $region = ''; * $clusterName = ''; @@ -863,14 +716,13 @@ public function listClusters($projectId, $region, $optionalArgs = []) * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param string $clusterName Required. The cluster name. - * @param array $optionalArgs { - * Optional. - * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param string $clusterName Required. The cluster name. + * @param array $optionalArgs { + * Optional. + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -879,7 +731,7 @@ public function listClusters($projectId, $region, $optionalArgs = []) * * @return \Google\ApiCore\OperationResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function diagnoseCluster($projectId, $region, $clusterName, $optionalArgs = []) @@ -889,39 +741,12 @@ public function diagnoseCluster($projectId, $region, $clusterName, $optionalArgs $request->setRegion($region); $request->setClusterName($clusterName); - $defaultCallSettings = $this->defaultCallSettings['diagnoseCluster']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->clusterControllerStub, + return $this->startOperationsCall( 'DiagnoseCluster', - $mergedSettings, - $this->descriptors['diagnoseCluster'] - ); - - return $callable( + $optionalArgs, $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); - } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->clusterControllerStub->close(); + $this->getOperationsClient() + )->wait(); } - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); - } -} +} \ No newline at end of file diff --git a/src/Dataproc/V1/Gapic/JobControllerGapicClient.php b/src/Dataproc/V1/Gapic/JobControllerGapicClient.php index 7e273960eaee..0a3464eaba5b 100644 --- a/src/Dataproc/V1/Gapic/JobControllerGapicClient.php +++ b/src/Dataproc/V1/Gapic/JobControllerGapicClient.php @@ -1,12 +1,12 @@ 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getJobs', - ]); - - $pageStreamingDescriptors = [ - 'listJobs' => $listJobsPageStreamingDescriptor, + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + ], + 'clientConfigPath' => __DIR__ . '/../resources/job_controller_client_config.json', + 'restClientConfigPath' => __DIR__ . '/../resources/job_controller_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__ . '/../resources/job_controller_descriptor_config.php', + 'versionFile' => __DIR__ . '/../../VERSION' ]; - - return $pageStreamingDescriptors; } - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - return self::$gapicVersion; - } + + /** * Constructor. * * @param array $options { - * Optional. Options for configuring the service API wrapper. + * Optional. Options for configuring the service API wrapper. * * @type string $serviceAddress The domain name of the API remote host. * Default 'dataproc.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. - * @type \Grpc\ChannelCredentials $sslCreds + * @type Channel $channel + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Google Cloud Dataproc API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -173,70 +171,22 @@ private static function getGapicVersion() * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface`. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|TransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/job_controller_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'submitJob' => $defaultDescriptors, - 'getJob' => $defaultDescriptors, - 'listJobs' => $defaultDescriptors, - 'updateJob' => $defaultDescriptors, - 'cancelJob' => $defaultDescriptors, - 'deleteJob' => $defaultDescriptors, - ]; - $pageStreamingDescriptors = self::getPageStreamingDescriptors(); - foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { - $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; - } - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.cloud.dataproc.v1.JobController', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createJobControllerStubFunction = function ($hostname, $opts, $channel) { - return new JobControllerGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createJobControllerStubFunction', $options)) { - $createJobControllerStubFunction = $options['createJobControllerStubFunction']; - } - $this->jobControllerStub = $this->grpcCredentialsHelper->createStub($createJobControllerStubFunction); + $this->setClientOptions($options + self::getClientDefaults()); } /** @@ -244,8 +194,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $jobControllerClient = new JobControllerClient(); * try { - * $jobControllerClient = new JobControllerClient(); * $projectId = ''; * $region = ''; * $job = new Job(); @@ -255,14 +205,13 @@ public function __construct($options = []) * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the job - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param Job $job Required. The job resource. - * @param array $optionalArgs { - * Optional. - * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @param string $projectId Required. The ID of the Google Cloud Platform project that the job + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param Job $job Required. The job resource. + * @param array $optionalArgs { + * Optional. + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -271,7 +220,7 @@ public function __construct($options = []) * * @return \Google\Cloud\Dataproc\V1\Job * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function submitJob($projectId, $region, $job, $optionalArgs = []) @@ -281,24 +230,12 @@ public function submitJob($projectId, $region, $job, $optionalArgs = []) $request->setRegion($region); $request->setJob($job); - $defaultCallSettings = $this->defaultCallSettings['submitJob']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->jobControllerStub, + return $this->startCall( 'SubmitJob', - $mergedSettings, - $this->descriptors['submitJob'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Job::class, + $optionalArgs, + $request + )->wait(); } /** @@ -306,8 +243,8 @@ public function submitJob($projectId, $region, $job, $optionalArgs = []) * * Sample code: * ``` + * $jobControllerClient = new JobControllerClient(); * try { - * $jobControllerClient = new JobControllerClient(); * $projectId = ''; * $region = ''; * $jobId = ''; @@ -317,14 +254,13 @@ public function submitJob($projectId, $region, $job, $optionalArgs = []) * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the job - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param string $jobId Required. The job ID. - * @param array $optionalArgs { - * Optional. - * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @param string $projectId Required. The ID of the Google Cloud Platform project that the job + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param string $jobId Required. The job ID. + * @param array $optionalArgs { + * Optional. + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -333,7 +269,7 @@ public function submitJob($projectId, $region, $job, $optionalArgs = []) * * @return \Google\Cloud\Dataproc\V1\Job * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getJob($projectId, $region, $jobId, $optionalArgs = []) @@ -343,24 +279,12 @@ public function getJob($projectId, $region, $jobId, $optionalArgs = []) $request->setRegion($region); $request->setJobId($jobId); - $defaultCallSettings = $this->defaultCallSettings['getJob']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->jobControllerStub, + return $this->startCall( 'GetJob', - $mergedSettings, - $this->descriptors['getJob'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Job::class, + $optionalArgs, + $request + )->wait(); } /** @@ -368,8 +292,8 @@ public function getJob($projectId, $region, $jobId, $optionalArgs = []) * * Sample code: * ``` + * $jobControllerClient = new JobControllerClient(); * try { - * $jobControllerClient = new JobControllerClient(); * $projectId = ''; * $region = ''; * // Iterate through all elements @@ -390,12 +314,11 @@ public function getJob($projectId, $region, $jobId, $optionalArgs = []) * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the job - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param array $optionalArgs { - * Optional. - * + * @param string $projectId Required. The ID of the Google Cloud Platform project that the job + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @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 @@ -429,7 +352,7 @@ public function getJob($projectId, $region, $jobId, $optionalArgs = []) * Example filter: * * status.state = ACTIVE AND labels.env = staging AND labels.starred = * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -438,7 +361,7 @@ public function getJob($projectId, $region, $jobId, $optionalArgs = []) * * @return \Google\ApiCore\PagedListResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listJobs($projectId, $region, $optionalArgs = []) @@ -462,24 +385,12 @@ public function listJobs($projectId, $region, $optionalArgs = []) $request->setFilter($optionalArgs['filter']); } - $defaultCallSettings = $this->defaultCallSettings['listJobs']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->jobControllerStub, + return $this->getPagedListResponse( 'ListJobs', - $mergedSettings, - $this->descriptors['listJobs'] + $optionalArgs, + ListJobsResponse::class, + $request ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); } /** @@ -487,8 +398,8 @@ public function listJobs($projectId, $region, $optionalArgs = []) * * Sample code: * ``` + * $jobControllerClient = new JobControllerClient(); * try { - * $jobControllerClient = new JobControllerClient(); * $projectId = ''; * $region = ''; * $jobId = ''; @@ -500,21 +411,20 @@ public function listJobs($projectId, $region, $optionalArgs = []) * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the job - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param string $jobId Required. The job ID. - * @param Job $job Required. The changes to the job. - * @param FieldMask $updateMask Required. Specifies the path, relative to Job, of - * the field to update. For example, to update the labels of a Job the - * update_mask parameter would be specified as - * labels, and the `PATCH` request body would specify the new - * value. Note: Currently, labels is the only - * field that can be updated. - * @param array $optionalArgs { - * Optional. - * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @param string $projectId Required. The ID of the Google Cloud Platform project that the job + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param string $jobId Required. The job ID. + * @param Job $job Required. The changes to the job. + * @param FieldMask $updateMask Required. Specifies the path, relative to Job, of + * the field to update. For example, to update the labels of a Job the + * update_mask parameter would be specified as + * labels, and the `PATCH` request body would specify the new + * value. Note: Currently, labels is the only + * field that can be updated. + * @param array $optionalArgs { + * Optional. + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -523,7 +433,7 @@ public function listJobs($projectId, $region, $optionalArgs = []) * * @return \Google\Cloud\Dataproc\V1\Job * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateJob($projectId, $region, $jobId, $job, $updateMask, $optionalArgs = []) @@ -535,24 +445,12 @@ public function updateJob($projectId, $region, $jobId, $job, $updateMask, $optio $request->setJob($job); $request->setUpdateMask($updateMask); - $defaultCallSettings = $this->defaultCallSettings['updateJob']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->jobControllerStub, + return $this->startCall( 'UpdateJob', - $mergedSettings, - $this->descriptors['updateJob'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Job::class, + $optionalArgs, + $request + )->wait(); } /** @@ -563,8 +461,8 @@ public function updateJob($projectId, $region, $jobId, $job, $updateMask, $optio * * Sample code: * ``` + * $jobControllerClient = new JobControllerClient(); * try { - * $jobControllerClient = new JobControllerClient(); * $projectId = ''; * $region = ''; * $jobId = ''; @@ -574,14 +472,13 @@ public function updateJob($projectId, $region, $jobId, $job, $updateMask, $optio * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the job - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param string $jobId Required. The job ID. - * @param array $optionalArgs { - * Optional. - * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @param string $projectId Required. The ID of the Google Cloud Platform project that the job + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param string $jobId Required. The job ID. + * @param array $optionalArgs { + * Optional. + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -590,7 +487,7 @@ public function updateJob($projectId, $region, $jobId, $job, $updateMask, $optio * * @return \Google\Cloud\Dataproc\V1\Job * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function cancelJob($projectId, $region, $jobId, $optionalArgs = []) @@ -600,24 +497,12 @@ public function cancelJob($projectId, $region, $jobId, $optionalArgs = []) $request->setRegion($region); $request->setJobId($jobId); - $defaultCallSettings = $this->defaultCallSettings['cancelJob']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->jobControllerStub, + return $this->startCall( 'CancelJob', - $mergedSettings, - $this->descriptors['cancelJob'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + Job::class, + $optionalArgs, + $request + )->wait(); } /** @@ -626,8 +511,8 @@ public function cancelJob($projectId, $region, $jobId, $optionalArgs = []) * * Sample code: * ``` + * $jobControllerClient = new JobControllerClient(); * try { - * $jobControllerClient = new JobControllerClient(); * $projectId = ''; * $region = ''; * $jobId = ''; @@ -637,21 +522,20 @@ public function cancelJob($projectId, $region, $jobId, $optionalArgs = []) * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the job - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param string $jobId Required. The job ID. - * @param array $optionalArgs { - * Optional. - * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @param string $projectId Required. The ID of the Google Cloud Platform project that the job + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param string $jobId Required. The job ID. + * @param array $optionalArgs { + * Optional. + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteJob($projectId, $region, $jobId, $optionalArgs = []) @@ -661,39 +545,12 @@ public function deleteJob($projectId, $region, $jobId, $optionalArgs = []) $request->setRegion($region); $request->setJobId($jobId); - $defaultCallSettings = $this->defaultCallSettings['deleteJob']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->jobControllerStub, + return $this->startCall( 'DeleteJob', - $mergedSettings, - $this->descriptors['deleteJob'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + GPBEmpty::class, + $optionalArgs, + $request + )->wait(); } - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->jobControllerStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); - } -} +} \ No newline at end of file diff --git a/src/Dataproc/V1/JobControllerClient.php b/src/Dataproc/V1/JobControllerClient.php index bbb6e225b22f..0091c2c75a0c 100644 --- a/src/Dataproc/V1/JobControllerClient.php +++ b/src/Dataproc/V1/JobControllerClient.php @@ -1,12 +1,12 @@ [ + 'google.cloud.dataproc.v1.ClusterController' => [ + 'CreateCluster' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Dataproc\V1\Cluster', + 'metadataReturnType' => '\Google\Cloud\Dataproc\V1\ClusterOperationMetadata', + ] + ], + 'UpdateCluster' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Dataproc\V1\Cluster', + 'metadataReturnType' => '\Google\Cloud\Dataproc\V1\ClusterOperationMetadata', + ] + ], + 'DeleteCluster' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Protobuf\GPBEmpty', + 'metadataReturnType' => '\Google\Cloud\Dataproc\V1\ClusterOperationMetadata', + ] + ], + 'DiagnoseCluster' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Protobuf\GPBEmpty', + 'metadataReturnType' => '\Google\Cloud\Dataproc\V1\DiagnoseClusterResults', + ] + ], + 'ListClusters' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getClusters' + ] + ], + ] + ] +]; \ No newline at end of file diff --git a/src/Dataproc/V1/resources/cluster_controller_rest_client_config.php b/src/Dataproc/V1/resources/cluster_controller_rest_client_config.php new file mode 100644 index 000000000000..18bd4cad591b --- /dev/null +++ b/src/Dataproc/V1/resources/cluster_controller_rest_client_config.php @@ -0,0 +1,173 @@ + [ + 'google.cloud.dataproc.v1.ClusterController' => [ + 'CreateCluster' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/regions/{region}/clusters', + 'body' => 'cluster', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'region' => [ + 'getters' => [ + 'getRegion', + ], + ], + ] + ], + 'UpdateCluster' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/projects/{project_id}/regions/{region}/clusters/{cluster_name}', + 'body' => 'cluster', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'region' => [ + 'getters' => [ + 'getRegion', + ], + ], + 'cluster_name' => [ + 'getters' => [ + 'getClusterName', + ], + ], + ] + ], + 'DeleteCluster' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/projects/{project_id}/regions/{region}/clusters/{cluster_name}', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'region' => [ + 'getters' => [ + 'getRegion', + ], + ], + 'cluster_name' => [ + 'getters' => [ + 'getClusterName', + ], + ], + ] + ], + 'GetCluster' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/projects/{project_id}/regions/{region}/clusters/{cluster_name}', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'region' => [ + 'getters' => [ + 'getRegion', + ], + ], + 'cluster_name' => [ + 'getters' => [ + 'getClusterName', + ], + ], + ] + ], + 'ListClusters' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/projects/{project_id}/regions/{region}/clusters', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'region' => [ + 'getters' => [ + 'getRegion', + ], + ], + ] + ], + 'DiagnoseCluster' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/regions/{region}/clusters/{cluster_name}:diagnose', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'region' => [ + 'getters' => [ + 'getRegion', + ], + ], + 'cluster_name' => [ + 'getters' => [ + 'getClusterName', + ], + ], + ] + ], + ], + 'google.longrunning.Operations' => [ + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/regions/*/operations}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ] + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/regions/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ] + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/regions/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ] + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/regions/*/operations/*}:cancel', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ] + ], + ], + ] +]; \ No newline at end of file diff --git a/src/Dataproc/V1/resources/job_controller_descriptor_config.php b/src/Dataproc/V1/resources/job_controller_descriptor_config.php new file mode 100644 index 000000000000..7236a63d47d9 --- /dev/null +++ b/src/Dataproc/V1/resources/job_controller_descriptor_config.php @@ -0,0 +1,18 @@ + [ + 'google.cloud.dataproc.v1.JobController' => [ + 'ListJobs' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getJobs' + ] + ], + ] + ] +]; \ No newline at end of file diff --git a/src/Dataproc/V1/resources/job_controller_rest_client_config.php b/src/Dataproc/V1/resources/job_controller_rest_client_config.php new file mode 100644 index 000000000000..ab3bb4ad836b --- /dev/null +++ b/src/Dataproc/V1/resources/job_controller_rest_client_config.php @@ -0,0 +1,173 @@ + [ + 'google.cloud.dataproc.v1.JobController' => [ + 'SubmitJob' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/regions/{region}/jobs:submit', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'region' => [ + 'getters' => [ + 'getRegion', + ], + ], + ] + ], + 'GetJob' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/projects/{project_id}/regions/{region}/jobs/{job_id}', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'region' => [ + 'getters' => [ + 'getRegion', + ], + ], + 'job_id' => [ + 'getters' => [ + 'getJobId', + ], + ], + ] + ], + 'ListJobs' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/projects/{project_id}/regions/{region}/jobs', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'region' => [ + 'getters' => [ + 'getRegion', + ], + ], + ] + ], + 'UpdateJob' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/projects/{project_id}/regions/{region}/jobs/{job_id}', + 'body' => 'job', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'region' => [ + 'getters' => [ + 'getRegion', + ], + ], + 'job_id' => [ + 'getters' => [ + 'getJobId', + ], + ], + ] + ], + 'CancelJob' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/projects/{project_id}/regions/{region}/jobs/{job_id}:cancel', + 'body' => '*', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'region' => [ + 'getters' => [ + 'getRegion', + ], + ], + 'job_id' => [ + 'getters' => [ + 'getJobId', + ], + ], + ] + ], + 'DeleteJob' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/projects/{project_id}/regions/{region}/jobs/{job_id}', + 'placeholders' => [ + 'project_id' => [ + 'getters' => [ + 'getProjectId', + ], + ], + 'region' => [ + 'getters' => [ + 'getRegion', + ], + ], + 'job_id' => [ + 'getters' => [ + 'getJobId', + ], + ], + ] + ], + ], + 'google.longrunning.Operations' => [ + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/regions/*/operations}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ] + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/regions/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ] + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/regions/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ] + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/regions/*/operations/*}:cancel', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ] + ], + ], + ] +]; \ No newline at end of file diff --git a/src/Dlp/V2beta1/DlpServiceClient.php b/src/Dlp/V2beta1/DlpServiceClient.php index 7af9f64c454b..9cc5b66a6cf9 100644 --- a/src/Dlp/V2beta1/DlpServiceClient.php +++ b/src/Dlp/V2beta1/DlpServiceClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/privacy/dlp/v2beta1/dlp.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php b/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php index 134889f97e57..f1079f15769d 100644 --- a/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php +++ b/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/privacy/dlp/v2beta1/dlp.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/ErrorReporting/V1beta1/ErrorGroupServiceClient.php b/src/ErrorReporting/V1beta1/ErrorGroupServiceClient.php index 7326b7233cac..e72aa5705c07 100644 --- a/src/ErrorReporting/V1beta1/ErrorGroupServiceClient.php +++ b/src/ErrorReporting/V1beta1/ErrorGroupServiceClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/devtools/clouderrorreporting/v1beta1/error_group_service.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/ErrorReporting/V1beta1/ErrorStatsServiceClient.php b/src/ErrorReporting/V1beta1/ErrorStatsServiceClient.php index 3ad3a8833635..cd4781b833da 100644 --- a/src/ErrorReporting/V1beta1/ErrorStatsServiceClient.php +++ b/src/ErrorReporting/V1beta1/ErrorStatsServiceClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/devtools/clouderrorreporting/v1beta1/error_stats_service.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/ErrorReporting/V1beta1/Gapic/ErrorGroupServiceGapicClient.php b/src/ErrorReporting/V1beta1/Gapic/ErrorGroupServiceGapicClient.php index cae20d8f4ae3..e475f0ee5675 100644 --- a/src/ErrorReporting/V1beta1/Gapic/ErrorGroupServiceGapicClient.php +++ b/src/ErrorReporting/V1beta1/Gapic/ErrorGroupServiceGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/devtools/clouderrorreporting/v1beta1/error_group_service.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php b/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php index 22c6fb4cf673..8496402fa8b7 100644 --- a/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php +++ b/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/devtools/clouderrorreporting/v1beta1/error_stats_service.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php b/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php index 93cf906d14cc..9c65a63a1ec8 100644 --- a/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php +++ b/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/devtools/clouderrorreporting/v1beta1/report_errors_service.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/ErrorReporting/V1beta1/ReportErrorsServiceClient.php b/src/ErrorReporting/V1beta1/ReportErrorsServiceClient.php index e09a1c2416e4..f2afe5e5d782 100644 --- a/src/ErrorReporting/V1beta1/ReportErrorsServiceClient.php +++ b/src/ErrorReporting/V1beta1/ReportErrorsServiceClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/devtools/clouderrorreporting/v1beta1/report_errors_service.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Firestore/V1beta1/FirestoreClient.php b/src/Firestore/V1beta1/FirestoreClient.php index 9dd25bdda2b1..8b9da3824c0f 100644 --- a/src/Firestore/V1beta1/FirestoreClient.php +++ b/src/Firestore/V1beta1/FirestoreClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/firestore/v1beta1/firestore.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php b/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php index 1b64c440ce3f..774531bff1ca 100644 --- a/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php +++ b/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/firestore/v1beta1/firestore.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php b/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php index 2b9e80c26680..310f959d2d4e 100644 --- a/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php +++ b/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/cloud/language/v1beta2/language_service.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Language/V1beta2/LanguageServiceClient.php b/src/Language/V1beta2/LanguageServiceClient.php index 51c3a32808e2..82e162e287be 100644 --- a/src/Language/V1beta2/LanguageServiceClient.php +++ b/src/Language/V1beta2/LanguageServiceClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/cloud/language/v1beta2/language_service.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Logging/V2/ConfigServiceV2Client.php b/src/Logging/V2/ConfigServiceV2Client.php index 6d6859a4c259..747d3a96e15b 100644 --- a/src/Logging/V2/ConfigServiceV2Client.php +++ b/src/Logging/V2/ConfigServiceV2Client.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/logging/v2/logging_config.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php b/src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php index 82bfe8e16241..0877df49b487 100644 --- a/src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php +++ b/src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/logging/v2/logging_config.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php b/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php index 60fb2cedc661..f39a2f063df1 100644 --- a/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php +++ b/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/logging/v2/logging.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php b/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php index 1e73532fa9db..5aa00d533ddb 100644 --- a/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php +++ b/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/logging/v2/logging_metrics.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Logging/V2/LoggingServiceV2Client.php b/src/Logging/V2/LoggingServiceV2Client.php index 2169a04b9061..35ffb6c2c93f 100644 --- a/src/Logging/V2/LoggingServiceV2Client.php +++ b/src/Logging/V2/LoggingServiceV2Client.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/logging/v2/logging.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Logging/V2/MetricsServiceV2Client.php b/src/Logging/V2/MetricsServiceV2Client.php index 0c93ab707944..3147ea492f6c 100644 --- a/src/Logging/V2/MetricsServiceV2Client.php +++ b/src/Logging/V2/MetricsServiceV2Client.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/logging/v2/logging_metrics.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php b/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php index 607b48f23425..34eecb8c23b2 100644 --- a/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php +++ b/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/monitoring/v3/group_service.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php b/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php index 06fae931f291..1e4ec69c9815 100644 --- a/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php +++ b/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/monitoring/v3/metric_service.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php b/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php index 42fc70466a6b..b3399b2f2908 100644 --- a/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php +++ b/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/monitoring/v3/uptime_service.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Monitoring/V3/GroupServiceClient.php b/src/Monitoring/V3/GroupServiceClient.php index 0ff2216114d8..ca821aa1aa16 100644 --- a/src/Monitoring/V3/GroupServiceClient.php +++ b/src/Monitoring/V3/GroupServiceClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/monitoring/v3/group_service.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Monitoring/V3/MetricServiceClient.php b/src/Monitoring/V3/MetricServiceClient.php index dc308e399e0d..5e86f0e074e9 100644 --- a/src/Monitoring/V3/MetricServiceClient.php +++ b/src/Monitoring/V3/MetricServiceClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/monitoring/v3/metric_service.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Monitoring/V3/UptimeCheckServiceClient.php b/src/Monitoring/V3/UptimeCheckServiceClient.php index b18512f058ba..9504643761af 100644 --- a/src/Monitoring/V3/UptimeCheckServiceClient.php +++ b/src/Monitoring/V3/UptimeCheckServiceClient.php @@ -21,9 +21,9 @@ * https://github.com/google/googleapis/blob/master/google/monitoring/v3/uptime_service.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared beta. This class may change - * more frequently than those which have been declared beta or 1.0, including changes which break - * backwards compatibility. + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes + * if necessary. * * @experimental */ diff --git a/src/PubSub/V1/Gapic/PublisherGapicClient.php b/src/PubSub/V1/Gapic/PublisherGapicClient.php index 305f15dbd598..b4ec9ba6fdaf 100644 --- a/src/PubSub/V1/Gapic/PublisherGapicClient.php +++ b/src/PubSub/V1/Gapic/PublisherGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/pubsub/v1/pubsub.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/PubSub/V1/Gapic/SubscriberGapicClient.php b/src/PubSub/V1/Gapic/SubscriberGapicClient.php index 8c05bbae373b..e208b83021eb 100644 --- a/src/PubSub/V1/Gapic/SubscriberGapicClient.php +++ b/src/PubSub/V1/Gapic/SubscriberGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/pubsub/v1/pubsub.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/PubSub/V1/PublisherClient.php b/src/PubSub/V1/PublisherClient.php index c29388b876d9..49d9f9733084 100644 --- a/src/PubSub/V1/PublisherClient.php +++ b/src/PubSub/V1/PublisherClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/pubsub/v1/pubsub.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/PubSub/V1/SubscriberClient.php b/src/PubSub/V1/SubscriberClient.php index 914519da6473..5179b177b803 100644 --- a/src/PubSub/V1/SubscriberClient.php +++ b/src/PubSub/V1/SubscriberClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/pubsub/v1/pubsub.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php b/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php index 8c5451de0256..18abd2d5b4bb 100644 --- a/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php +++ b/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/spanner/admin/database/v1/spanner_database_admin.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php b/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php index 1bea76abdaea..117dede76c9f 100644 --- a/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php +++ b/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/spanner/admin/database/v1/spanner_database_admin.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php b/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php index c3fc061467da..b8c8b9c480b7 100644 --- a/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php +++ b/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/spanner/admin/instance/v1/spanner_instance_admin.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php b/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php index 8acad43bf338..5e90a09d6549 100644 --- a/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php +++ b/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/spanner/admin/instance/v1/spanner_instance_admin.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Spanner/V1/Gapic/SpannerGapicClient.php b/src/Spanner/V1/Gapic/SpannerGapicClient.php index 50029912ff1c..dd746b5ca524 100644 --- a/src/Spanner/V1/Gapic/SpannerGapicClient.php +++ b/src/Spanner/V1/Gapic/SpannerGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/spanner/v1/spanner.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Speech/V1/Gapic/SpeechGapicClient.php b/src/Speech/V1/Gapic/SpeechGapicClient.php index 21f5f509899d..48a7bbaabafb 100644 --- a/src/Speech/V1/Gapic/SpeechGapicClient.php +++ b/src/Speech/V1/Gapic/SpeechGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/cloud/speech/v1/cloud_speech.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Speech/V1/SpeechClient.php b/src/Speech/V1/SpeechClient.php index df0ecfbb8e3c..eae73bec6254 100644 --- a/src/Speech/V1/SpeechClient.php +++ b/src/Speech/V1/SpeechClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/cloud/speech/v1/cloud_speech.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Speech/V1beta1/Gapic/SpeechGapicClient.php b/src/Speech/V1beta1/Gapic/SpeechGapicClient.php index 83d2875b194c..12f835f88046 100644 --- a/src/Speech/V1beta1/Gapic/SpeechGapicClient.php +++ b/src/Speech/V1beta1/Gapic/SpeechGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/cloud/speech/v1beta1/cloud_speech.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Speech/V1beta1/SpeechClient.php b/src/Speech/V1beta1/SpeechClient.php index d330b229c4b5..bb86ed50d810 100644 --- a/src/Speech/V1beta1/SpeechClient.php +++ b/src/Speech/V1beta1/SpeechClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/cloud/speech/v1beta1/cloud_speech.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Speech/V1beta1/resources/speech_rest_client_config.php b/src/Speech/V1beta1/resources/speech_rest_client_config.php index 4bdd0cbc5cc2..4111bd52575c 100644 --- a/src/Speech/V1beta1/resources/speech_rest_client_config.php +++ b/src/Speech/V1beta1/resources/speech_rest_client_config.php @@ -17,11 +17,11 @@ 'google.longrunning.Operations' => [ 'ListOperations' => [ 'method' => 'get', - 'uriTemplate' => '/v1/operations', + 'uriTemplate' => '/v1beta1/operations', ], 'GetOperation' => [ 'method' => 'get', - 'uriTemplate' => '/v1/operations/{name=*}', + 'uriTemplate' => '/v1beta1/operations/{name=*}', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -32,7 +32,7 @@ ], 'DeleteOperation' => [ 'method' => 'delete', - 'uriTemplate' => '/v1/operations/{name=*}', + 'uriTemplate' => '/v1beta1/operations/{name=*}', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -43,7 +43,7 @@ ], 'CancelOperation' => [ 'method' => 'post', - 'uriTemplate' => '/v1/operations/{name=*}:cancel', + 'uriTemplate' => '/v1beta1/operations/{name=*}:cancel', 'body' => '*', 'placeholders' => [ 'name' => [ diff --git a/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php index 98e2b9af0947..af03a897370e 100644 --- a/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/cloud/videointelligence/v1/video_intelligence.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/VideoIntelligence/V1/VideoIntelligenceServiceClient.php b/src/VideoIntelligence/V1/VideoIntelligenceServiceClient.php index 5e42675cb652..b37ba3642706 100644 --- a/src/VideoIntelligence/V1/VideoIntelligenceServiceClient.php +++ b/src/VideoIntelligence/V1/VideoIntelligenceServiceClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/cloud/videointelligence/v1/video_intelligence.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php index 4476fb574f6a..b0be51c5442c 100644 --- a/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php b/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php index 848199755314..5554220e06f9 100644 --- a/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php +++ b/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php index 8f9074386226..78bebeaba282 100644 --- a/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/VideoIntelligence/V1beta2/VideoIntelligenceServiceClient.php b/src/VideoIntelligence/V1beta2/VideoIntelligenceServiceClient.php index dcbe92be8e99..59bd767d76f9 100644 --- a/src/VideoIntelligence/V1beta2/VideoIntelligenceServiceClient.php +++ b/src/VideoIntelligence/V1beta2/VideoIntelligenceServiceClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php b/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php index 18a7793d593d..05f0fcd61fae 100644 --- a/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php +++ b/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/cloud/vision/v1/image_annotator.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental diff --git a/src/Vision/V1/ImageAnnotatorClient.php b/src/Vision/V1/ImageAnnotatorClient.php index c83bdc1e02f7..7c14ee179b48 100644 --- a/src/Vision/V1/ImageAnnotatorClient.php +++ b/src/Vision/V1/ImageAnnotatorClient.php @@ -21,8 +21,8 @@ * https://github.com/google/googleapis/blob/master/google/cloud/vision/v1/image_annotator.proto * and updates to that file get reflected here through a refresh process. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * @experimental From fa67681eaaf44f5d84049f9ed23777b0a3519fdb Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 17 Jan 2018 13:46:18 -0800 Subject: [PATCH 11/21] removes grpc-extension constants in favor of native ones --- src/Core/GrpcRequestWrapper.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Core/GrpcRequestWrapper.php b/src/Core/GrpcRequestWrapper.php index c90c642c1fbe..b1eea621f9e7 100644 --- a/src/Core/GrpcRequestWrapper.php +++ b/src/Core/GrpcRequestWrapper.php @@ -27,6 +27,7 @@ use Google\ApiCore\ServerStream; use Google\Protobuf\Internal\Message; use Google\Rpc\BadRequest; +use Google\Rpc\Code; use Google\Rpc\RetryInfo; use Grpc; @@ -58,10 +59,10 @@ class GrpcRequestWrapper * @var array gRPC retry codes. */ private $grpcRetryCodes = [ - Grpc\STATUS_UNKNOWN, - Grpc\STATUS_INTERNAL, - Grpc\STATUS_UNAVAILABLE, - Grpc\STATUS_DATA_LOSS + Code::UNKNOWN, + Code::INTERNAL, + Code::UNAVAILABLE, + Code::DATA_LOSS ]; /** @@ -200,36 +201,36 @@ private function handleStream(ServerStream $response) private function convertToGoogleException(ApiException $ex) { switch ($ex->getCode()) { - case Grpc\STATUS_INVALID_ARGUMENT: + case Code::INVALID_ARGUMENT: $exception = Exception\BadRequestException::class; break; - case Grpc\STATUS_NOT_FOUND: - case Grpc\STATUS_UNIMPLEMENTED: + case Code::NOT_FOUND: + case Code::UNIMPLEMENTED: $exception = Exception\NotFoundException::class; break; - case Grpc\STATUS_ALREADY_EXISTS: + case Code::ALREADY_EXISTS: $exception = Exception\ConflictException::class; break; - case Grpc\STATUS_FAILED_PRECONDITION: + case Code::FAILED_PRECONDITION: $exception = Exception\FailedPreconditionException::class; break; - case Grpc\STATUS_UNKNOWN: + case Code::UNKNOWN: $exception = Exception\ServerException::class; break; - case Grpc\STATUS_INTERNAL: + case Code::INTERNAL: $exception = Exception\ServerException::class; break; - case Grpc\STATUS_ABORTED: + case Code::ABORTED: $exception = Exception\AbortedException::class; break; - case Grpc\STATUS_DEADLINE_EXCEEDED: + case Code::DEADLINE_EXCEEDED: $exception = Exception\DeadlineExceededException::class; break; From cb03b051f28d77ab0f81edde709e75cc47165ec7 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Fri, 19 Jan 2018 11:22:30 -0800 Subject: [PATCH 12/21] fixes tests for Grpc connections --- src/Spanner/Connection/Grpc.php | 8 +++----- tests/unit/Core/GrpcTraitTest.php | 3 ++- tests/unit/Firestore/Connection/GrpcTest.php | 1 - tests/unit/PubSub/Connection/GrpcTest.php | 1 - tests/unit/Spanner/Connection/GrpcTest.php | 18 ++++++++---------- 5 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/Spanner/Connection/Grpc.php b/src/Spanner/Connection/Grpc.php index b1db4ac349c1..e1e8c9b7c9c7 100644 --- a/src/Spanner/Connection/Grpc.php +++ b/src/Spanner/Connection/Grpc.php @@ -461,19 +461,17 @@ public function deleteSession(array $args) public function deleteSessionAsync(array $args) { $database = $this->pluck('database', $args); - $settings = new CallSettings($this->addResourcePrefixHeader($args, $database)); $request = new DeleteSessionRequest(); $request->setName($this->pluck('name', $args)); - $transport = $this->spannerClient->getTransport(); - $callable = $transport->getCallable($settings); - return $callable( + $transport = $this->spannerClient->getTransport(); + return $transport->startUnaryCall( new Call( 'google.spanner.v1.Spanner/DeleteSession', GPBEmpty::class, $request ), - $settings + $this->addResourcePrefixHeader([], $database) ); } diff --git a/tests/unit/Core/GrpcTraitTest.php b/tests/unit/Core/GrpcTraitTest.php index 78c9ff772599..e410d11437a7 100644 --- a/tests/unit/Core/GrpcTraitTest.php +++ b/tests/unit/Core/GrpcTraitTest.php @@ -151,7 +151,8 @@ public function testGetsGaxConfig() 'credentialsLoader' => $fetcher, 'enableCaching' => false, 'libName' => 'gccl', - 'libVersion' => $version + 'libVersion' => $version, + 'transport' => 'grpc', ]; $this->assertEquals($expected, $this->implementation->call('getGaxConfig', [$version])); diff --git a/tests/unit/Firestore/Connection/GrpcTest.php b/tests/unit/Firestore/Connection/GrpcTest.php index 12a2a4a7743d..8d07b3fa7408 100644 --- a/tests/unit/Firestore/Connection/GrpcTest.php +++ b/tests/unit/Firestore/Connection/GrpcTest.php @@ -45,7 +45,6 @@ class GrpcTest extends TestCase const PROJECT = 'example_project'; const DATABASE = '(default)'; - private $requestWrapper; private $successMessage; public function setUp() diff --git a/tests/unit/PubSub/Connection/GrpcTest.php b/tests/unit/PubSub/Connection/GrpcTest.php index 10092a16712f..7539f027036d 100644 --- a/tests/unit/PubSub/Connection/GrpcTest.php +++ b/tests/unit/PubSub/Connection/GrpcTest.php @@ -40,7 +40,6 @@ class GrpcTest extends TestCase use GrpcTestTrait; use GrpcTrait; - private $requestWrapper; private $successMessage; public function setUp() diff --git a/tests/unit/Spanner/Connection/GrpcTest.php b/tests/unit/Spanner/Connection/GrpcTest.php index 2a3322307472..2ddcaf76cf3c 100644 --- a/tests/unit/Spanner/Connection/GrpcTest.php +++ b/tests/unit/Spanner/Connection/GrpcTest.php @@ -18,10 +18,9 @@ namespace Google\Cloud\Tests\Unit\Spanner\Connection; use Google\ApiCore\Call; -use Google\ApiCore\CallSettings; use Google\ApiCore\OperationResponse; use Google\ApiCore\Serializer; -use Google\ApiCore\Transport\ApiTransportInterface; +use Google\ApiCore\Transport\TransportInterface; use Google\Cloud\Core\GrpcRequestWrapper; use Google\Cloud\Core\GrpcTrait; use Google\Cloud\Spanner\Connection\Grpc; @@ -56,7 +55,6 @@ class GrpcTest extends TestCase const PROJECT = 'projects/my-project'; - private $requestWrapper; private $successMessage; public function setUp() @@ -69,18 +67,18 @@ public function setUp() public function testDeleteSessionAsync() { - $cb = function (Call $call, CallSettings $settings) { - return $this->prophesize(PromiseInterface::class) - ->reveal(); - }; + $promise = $this->prophesize(PromiseInterface::class) + ->reveal(); $sessionName = 'session1'; $databaseName = 'database1'; $request = new DeleteSessionRequest(); $request->setName($sessionName); $client = $this->prophesize(SpannerClient::class); - $transport = $this->prophesize(ApiTransportInterface::class); - $transport->getCallable(Argument::type(CallSettings::class)) - ->willReturn($cb); + $transport = $this->prophesize(TransportInterface::class); + $transport->startUnaryCall( + Argument::type(Call::class), + Argument::type('array') + )->willReturn($promise); $client->getTransport() ->willReturn($transport->reveal()); $grpc = new Grpc(['gapicSpannerClient' => $client->reveal()]); From 394454eb6b3c10c4805f3ed30e6dab7ac1bb105f Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Fri, 19 Jan 2018 15:38:05 -0500 Subject: [PATCH 13/21] gapic refresh --- .../BigtableInstanceAdminGapicClient.php | 4 +- .../Gapic/BigtableTableAdminGapicClient.php | 4 +- src/Bigtable/V2/Gapic/BigtableGapicClient.php | 4 +- .../V1/Gapic/ClusterManagerGapicClient.php | 4 +- src/Dataproc/V1/ClusterControllerClient.php | 10 +- .../V1/Gapic/ClusterControllerGapicClient.php | 137 +++++++++--------- .../V1/Gapic/JobControllerGapicClient.php | 131 ++++++++--------- src/Dataproc/V1/JobControllerClient.php | 10 +- .../cluster_controller_descriptor_config.php | 18 +-- .../cluster_controller_rest_client_config.php | 24 +-- .../job_controller_descriptor_config.php | 10 +- .../job_controller_rest_client_config.php | 24 +-- .../V2beta1/Gapic/DlpServiceGapicClient.php | 4 +- .../dlp_service_rest_client_config.php | 41 +++++- .../Gapic/ErrorGroupServiceGapicClient.php | 4 +- .../Gapic/ErrorStatsServiceGapicClient.php | 4 +- .../Gapic/ReportErrorsServiceGapicClient.php | 4 +- .../V1beta1/Gapic/FirestoreGapicClient.php | 4 +- .../Gapic/LanguageServiceGapicClient.php | 4 +- .../V2/Gapic/ConfigServiceV2GapicClient.php | 4 +- .../V2/Gapic/LoggingServiceV2GapicClient.php | 4 +- .../V2/Gapic/MetricsServiceV2GapicClient.php | 4 +- .../V3/Gapic/GroupServiceGapicClient.php | 4 +- .../V3/Gapic/MetricServiceGapicClient.php | 4 +- .../Gapic/UptimeCheckServiceGapicClient.php | 4 +- src/PubSub/V1/Gapic/PublisherGapicClient.php | 4 +- src/PubSub/V1/Gapic/SubscriberGapicClient.php | 4 +- .../V1/Gapic/DatabaseAdminGapicClient.php | 4 +- .../database_admin_rest_client_config.php | 54 +++++-- .../V1/Gapic/InstanceAdminGapicClient.php | 4 +- .../instance_admin_rest_client_config.php | 56 +++++-- src/Spanner/V1/Gapic/SpannerGapicClient.php | 4 +- .../resources/spanner_rest_client_config.php | 54 +++++-- src/Speech/V1/Gapic/SpeechGapicClient.php | 4 +- .../V1beta1/Gapic/SpeechGapicClient.php | 4 +- .../VideoIntelligenceServiceGapicClient.php | 4 +- .../VideoIntelligenceServiceGapicClient.php | 4 +- .../VideoIntelligenceServiceGapicClient.php | 4 +- .../V1/Gapic/ImageAnnotatorGapicClient.php | 4 +- 39 files changed, 382 insertions(+), 295 deletions(-) diff --git a/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php b/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php index 8923884703de..a5891da5b825 100644 --- a/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php +++ b/src/Bigtable/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php @@ -77,8 +77,8 @@ * Clusters. Provides access to the Instance and Cluster schemas only, not the * tables' metadata or data stored in those tables. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php b/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php index 7011f5011951..9f5629c8e293 100644 --- a/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php +++ b/src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php @@ -74,8 +74,8 @@ * Provides access to the table schemas only, not the data stored within * the tables. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Bigtable/V2/Gapic/BigtableGapicClient.php b/src/Bigtable/V2/Gapic/BigtableGapicClient.php index 5c9e37459583..ab025a27ffa4 100644 --- a/src/Bigtable/V2/Gapic/BigtableGapicClient.php +++ b/src/Bigtable/V2/Gapic/BigtableGapicClient.php @@ -61,8 +61,8 @@ /** * Service Description: Service for reading from and writing to existing Bigtable tables. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Container/V1/Gapic/ClusterManagerGapicClient.php b/src/Container/V1/Gapic/ClusterManagerGapicClient.php index 2b2dc8478090..1c64ef467f16 100644 --- a/src/Container/V1/Gapic/ClusterManagerGapicClient.php +++ b/src/Container/V1/Gapic/ClusterManagerGapicClient.php @@ -88,8 +88,8 @@ /** * Service Description: Google Container Engine Cluster Manager v1. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Dataproc/V1/ClusterControllerClient.php b/src/Dataproc/V1/ClusterControllerClient.php index 36bbe77a7417..6d4e740b2174 100644 --- a/src/Dataproc/V1/ClusterControllerClient.php +++ b/src/Dataproc/V1/ClusterControllerClient.php @@ -1,6 +1,6 @@ [ 'https://www.googleapis.com/auth/cloud-platform', ], - 'clientConfigPath' => __DIR__ . '/../resources/cluster_controller_client_config.json', - 'restClientConfigPath' => __DIR__ . '/../resources/cluster_controller_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__ . '/../resources/cluster_controller_descriptor_config.php', - 'versionFile' => __DIR__ . '/../../VERSION' + 'clientConfigPath' => __DIR__.'/../resources/cluster_controller_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/cluster_controller_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/cluster_controller_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } - - /** * Return an OperationsClient object with the same endpoint as $this. * @@ -177,7 +167,8 @@ public function getOperationsClient() * 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 + * @param string $methodName The name of the method used to start the operation + * * @return OperationResponse * @experimental */ @@ -188,6 +179,7 @@ public function resumeOperation($operationName, $methodName = null) : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); + return $operation; } @@ -195,7 +187,7 @@ public function resumeOperation($operationName, $methodName = null) * Constructor. * * @param array $options { - * Optional. Options for configuring the service API wrapper. + * Optional. Options for configuring the service API wrapper. * * @type string $serviceAddress The domain name of the API remote host. * Default 'dataproc.googleapis.com'. @@ -252,10 +244,10 @@ public function __construct($options = []) $this->pluckArray([ 'serviceName', 'clientConfigPath', - 'restClientConfigPath', - 'descriptorsConfigPath' + 'descriptorsConfigPath', ], $options); - $this->operationsClient = new OperationsClient($options); + $this->operationsClient = $this->pluck('operationsClient', $options, false) + ?: new OperationsClient($options); } /** @@ -299,12 +291,13 @@ public function __construct($options = []) * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param Cluster $cluster Required. The cluster to create. - * @param array $optionalArgs { - * Optional. + * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param Cluster $cluster Required. The cluster to create. + * @param array $optionalArgs { + * Optional. + * * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array @@ -375,16 +368,16 @@ public function createCluster($projectId, $region, $cluster, $optionalArgs = []) * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project the - * cluster belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param string $clusterName Required. The cluster name. - * @param Cluster $cluster Required. The changes to the cluster. - * @param FieldMask $updateMask Required. Specifies the path, relative to `Cluster`, of - * the field to update. For example, to change the number of workers - * in a cluster to 5, the `update_mask` parameter would be - * specified as `config.worker_config.num_instances`, - * and the `PATCH` request body would specify the new value, as follows: + * @param string $projectId Required. The ID of the Google Cloud Platform project the + * cluster belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param string $clusterName Required. The cluster name. + * @param Cluster $cluster Required. The changes to the cluster. + * @param FieldMask $updateMask Required. Specifies the path, relative to `Cluster`, of + * the field to update. For example, to change the number of workers + * in a cluster to 5, the `update_mask` parameter would be + * specified as `config.worker_config.num_instances`, + * and the `PATCH` request body would specify the new value, as follows: * * { * "config":{ @@ -428,7 +421,8 @@ public function createCluster($projectId, $region, $cluster, $optionalArgs = []) * * * @param array $optionalArgs { - * Optional. + * Optional. + * * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array @@ -497,12 +491,13 @@ public function updateCluster($projectId, $region, $clusterName, $cluster, $upda * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param string $clusterName Required. The cluster name. - * @param array $optionalArgs { - * Optional. + * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param string $clusterName Required. The cluster name. + * @param array $optionalArgs { + * Optional. + * * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array @@ -546,12 +541,13 @@ public function deleteCluster($projectId, $region, $clusterName, $optionalArgs = * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param string $clusterName Required. The cluster name. - * @param array $optionalArgs { - * Optional. + * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param string $clusterName Required. The cluster name. + * @param array $optionalArgs { + * Optional. + * * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array @@ -606,11 +602,12 @@ public function getCluster($projectId, $region, $clusterName, $optionalArgs = [] * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param array $optionalArgs { - * Optional. + * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param array $optionalArgs { + * Optional. + * * @type string $filter * Optional. A filter constraining the clusters to list. Filters are * case-sensitive and have the following syntax: @@ -716,12 +713,13 @@ public function listClusters($projectId, $region, $optionalArgs = []) * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param string $clusterName Required. The cluster name. - * @param array $optionalArgs { - * Optional. + * @param string $projectId Required. The ID of the Google Cloud Platform project that the cluster + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param string $clusterName Required. The cluster name. + * @param array $optionalArgs { + * Optional. + * * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array @@ -748,5 +746,4 @@ public function diagnoseCluster($projectId, $region, $clusterName, $optionalArgs $this->getOperationsClient() )->wait(); } - -} \ No newline at end of file +} diff --git a/src/Dataproc/V1/Gapic/JobControllerGapicClient.php b/src/Dataproc/V1/Gapic/JobControllerGapicClient.php index 0a3464eaba5b..585567043f61 100644 --- a/src/Dataproc/V1/Gapic/JobControllerGapicClient.php +++ b/src/Dataproc/V1/Gapic/JobControllerGapicClient.php @@ -1,6 +1,6 @@ [ 'https://www.googleapis.com/auth/cloud-platform', ], - 'clientConfigPath' => __DIR__ . '/../resources/job_controller_client_config.json', - 'restClientConfigPath' => __DIR__ . '/../resources/job_controller_rest_client_config.php', - 'descriptorsConfigPath' => __DIR__ . '/../resources/job_controller_descriptor_config.php', - 'versionFile' => __DIR__ . '/../../VERSION' + 'clientConfigPath' => __DIR__.'/../resources/job_controller_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/job_controller_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/job_controller_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', ]; } - - - - /** * Constructor. * * @param array $options { - * Optional. Options for configuring the service API wrapper. + * Optional. Options for configuring the service API wrapper. * * @type string $serviceAddress The domain name of the API remote host. * Default 'dataproc.googleapis.com'. @@ -205,12 +193,13 @@ public function __construct($options = []) * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the job - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param Job $job Required. The job resource. - * @param array $optionalArgs { - * Optional. + * @param string $projectId Required. The ID of the Google Cloud Platform project that the job + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param Job $job Required. The job resource. + * @param array $optionalArgs { + * Optional. + * * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array @@ -254,12 +243,13 @@ public function submitJob($projectId, $region, $job, $optionalArgs = []) * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the job - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param string $jobId Required. The job ID. - * @param array $optionalArgs { - * Optional. + * @param string $projectId Required. The ID of the Google Cloud Platform project that the job + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param string $jobId Required. The job ID. + * @param array $optionalArgs { + * Optional. + * * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array @@ -314,11 +304,12 @@ public function getJob($projectId, $region, $jobId, $optionalArgs = []) * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the job - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param array $optionalArgs { - * Optional. + * @param string $projectId Required. The ID of the Google Cloud Platform project that the job + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @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 @@ -411,19 +402,20 @@ public function listJobs($projectId, $region, $optionalArgs = []) * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the job - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param string $jobId Required. The job ID. - * @param Job $job Required. The changes to the job. - * @param FieldMask $updateMask Required. Specifies the path, relative to Job, of - * the field to update. For example, to update the labels of a Job the - * update_mask parameter would be specified as - * labels, and the `PATCH` request body would specify the new - * value. Note: Currently, labels is the only - * field that can be updated. - * @param array $optionalArgs { - * Optional. + * @param string $projectId Required. The ID of the Google Cloud Platform project that the job + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param string $jobId Required. The job ID. + * @param Job $job Required. The changes to the job. + * @param FieldMask $updateMask Required. Specifies the path, relative to Job, of + * the field to update. For example, to update the labels of a Job the + * update_mask parameter would be specified as + * labels, and the `PATCH` request body would specify the new + * value. Note: Currently, labels is the only + * field that can be updated. + * @param array $optionalArgs { + * Optional. + * * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array @@ -472,12 +464,13 @@ public function updateJob($projectId, $region, $jobId, $job, $updateMask, $optio * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the job - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param string $jobId Required. The job ID. - * @param array $optionalArgs { - * Optional. + * @param string $projectId Required. The ID of the Google Cloud Platform project that the job + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param string $jobId Required. The job ID. + * @param array $optionalArgs { + * Optional. + * * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array @@ -522,12 +515,13 @@ public function cancelJob($projectId, $region, $jobId, $optionalArgs = []) * } * ``` * - * @param string $projectId Required. The ID of the Google Cloud Platform project that the job - * belongs to. - * @param string $region Required. The Cloud Dataproc region in which to handle the request. - * @param string $jobId Required. The job ID. - * @param array $optionalArgs { - * Optional. + * @param string $projectId Required. The ID of the Google Cloud Platform project that the job + * belongs to. + * @param string $region Required. The Cloud Dataproc region in which to handle the request. + * @param string $jobId Required. The job ID. + * @param array $optionalArgs { + * Optional. + * * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array @@ -552,5 +546,4 @@ public function deleteJob($projectId, $region, $jobId, $optionalArgs = []) $request )->wait(); } - -} \ No newline at end of file +} diff --git a/src/Dataproc/V1/JobControllerClient.php b/src/Dataproc/V1/JobControllerClient.php index 0091c2c75a0c..435a785b9602 100644 --- a/src/Dataproc/V1/JobControllerClient.php +++ b/src/Dataproc/V1/JobControllerClient.php @@ -1,6 +1,6 @@ [ 'operationReturnType' => '\Google\Cloud\Dataproc\V1\Cluster', 'metadataReturnType' => '\Google\Cloud\Dataproc\V1\ClusterOperationMetadata', - ] + ], ], 'UpdateCluster' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\Dataproc\V1\Cluster', 'metadataReturnType' => '\Google\Cloud\Dataproc\V1\ClusterOperationMetadata', - ] + ], ], 'DeleteCluster' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Protobuf\GPBEmpty', 'metadataReturnType' => '\Google\Cloud\Dataproc\V1\ClusterOperationMetadata', - ] + ], ], 'DiagnoseCluster' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Protobuf\GPBEmpty', 'metadataReturnType' => '\Google\Cloud\Dataproc\V1\DiagnoseClusterResults', - ] + ], ], 'ListClusters' => [ 'pageStreaming' => [ @@ -34,9 +34,9 @@ 'requestPageSizeGetMethod' => 'getPageSize', 'requestPageSizeSetMethod' => 'setPageSize', 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getClusters' - ] + 'resourcesGetMethod' => 'getClusters', + ], ], - ] - ] -]; \ No newline at end of file + ], + ], +]; diff --git a/src/Dataproc/V1/resources/cluster_controller_rest_client_config.php b/src/Dataproc/V1/resources/cluster_controller_rest_client_config.php index 18bd4cad591b..351cdcc937d7 100644 --- a/src/Dataproc/V1/resources/cluster_controller_rest_client_config.php +++ b/src/Dataproc/V1/resources/cluster_controller_rest_client_config.php @@ -18,7 +18,7 @@ 'getRegion', ], ], - ] + ], ], 'UpdateCluster' => [ 'method' => 'patch', @@ -40,7 +40,7 @@ 'getClusterName', ], ], - ] + ], ], 'DeleteCluster' => [ 'method' => 'delete', @@ -61,7 +61,7 @@ 'getClusterName', ], ], - ] + ], ], 'GetCluster' => [ 'method' => 'get', @@ -82,7 +82,7 @@ 'getClusterName', ], ], - ] + ], ], 'ListClusters' => [ 'method' => 'get', @@ -98,7 +98,7 @@ 'getRegion', ], ], - ] + ], ], 'DiagnoseCluster' => [ 'method' => 'post', @@ -120,7 +120,7 @@ 'getClusterName', ], ], - ] + ], ], ], 'google.longrunning.Operations' => [ @@ -133,7 +133,7 @@ 'getName', ], ], - ] + ], ], 'GetOperation' => [ 'method' => 'get', @@ -144,7 +144,7 @@ 'getName', ], ], - ] + ], ], 'DeleteOperation' => [ 'method' => 'delete', @@ -155,7 +155,7 @@ 'getName', ], ], - ] + ], ], 'CancelOperation' => [ 'method' => 'post', @@ -166,8 +166,8 @@ 'getName', ], ], - ] + ], ], ], - ] -]; \ No newline at end of file + ], +]; diff --git a/src/Dataproc/V1/resources/job_controller_descriptor_config.php b/src/Dataproc/V1/resources/job_controller_descriptor_config.php index 7236a63d47d9..2b3ecb8af290 100644 --- a/src/Dataproc/V1/resources/job_controller_descriptor_config.php +++ b/src/Dataproc/V1/resources/job_controller_descriptor_config.php @@ -10,9 +10,9 @@ 'requestPageSizeGetMethod' => 'getPageSize', 'requestPageSizeSetMethod' => 'setPageSize', 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getJobs' - ] + 'resourcesGetMethod' => 'getJobs', + ], ], - ] - ] -]; \ No newline at end of file + ], + ], +]; diff --git a/src/Dataproc/V1/resources/job_controller_rest_client_config.php b/src/Dataproc/V1/resources/job_controller_rest_client_config.php index ab3bb4ad836b..d37daeab7192 100644 --- a/src/Dataproc/V1/resources/job_controller_rest_client_config.php +++ b/src/Dataproc/V1/resources/job_controller_rest_client_config.php @@ -18,7 +18,7 @@ 'getRegion', ], ], - ] + ], ], 'GetJob' => [ 'method' => 'get', @@ -39,7 +39,7 @@ 'getJobId', ], ], - ] + ], ], 'ListJobs' => [ 'method' => 'get', @@ -55,7 +55,7 @@ 'getRegion', ], ], - ] + ], ], 'UpdateJob' => [ 'method' => 'patch', @@ -77,7 +77,7 @@ 'getJobId', ], ], - ] + ], ], 'CancelJob' => [ 'method' => 'post', @@ -99,7 +99,7 @@ 'getJobId', ], ], - ] + ], ], 'DeleteJob' => [ 'method' => 'delete', @@ -120,7 +120,7 @@ 'getJobId', ], ], - ] + ], ], ], 'google.longrunning.Operations' => [ @@ -133,7 +133,7 @@ 'getName', ], ], - ] + ], ], 'GetOperation' => [ 'method' => 'get', @@ -144,7 +144,7 @@ 'getName', ], ], - ] + ], ], 'DeleteOperation' => [ 'method' => 'delete', @@ -155,7 +155,7 @@ 'getName', ], ], - ] + ], ], 'CancelOperation' => [ 'method' => 'post', @@ -166,8 +166,8 @@ 'getName', ], ], - ] + ], ], ], - ] -]; \ No newline at end of file + ], +]; diff --git a/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php b/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php index f1079f15769d..751bbdf656a3 100644 --- a/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php +++ b/src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php @@ -76,8 +76,8 @@ * The service also includes methods for sensitive data redaction and * scheduling of data scans on Google Cloud Platform based data sets. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php b/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php index f5bb6294e242..9e8541440b67 100644 --- a/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php +++ b/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php @@ -6,47 +6,72 @@ 'ListOperations' => [ 'method' => 'get', 'uriTemplate' => '/v2beta1/{name=inspect/operations}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v2beta1/{name=riskAnalysis/operations}', + ], + ] 'placeholders' => [ 'name' => [ 'getters' => [ 'getName', ], ], - ], + ] ], 'GetOperation' => [ 'method' => 'get', 'uriTemplate' => '/v2beta1/{name=inspect/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v2beta1/{name=riskAnalysis/operations/*}', + ], + ] 'placeholders' => [ 'name' => [ 'getters' => [ 'getName', ], ], - ], + ] ], 'DeleteOperation' => [ 'method' => 'delete', 'uriTemplate' => '/v2beta1/{name=inspect/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'delete', + 'uriTemplate' => '/v2beta1/{name=riskAnalysis/operations/*}', + ], + ] 'placeholders' => [ 'name' => [ 'getters' => [ 'getName', ], ], - ], + ] ], 'CancelOperation' => [ 'method' => 'post', 'uriTemplate' => '/v2beta1/{name=inspect/operations/*}:cancel', 'body' => '*', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v2beta1/{name=riskAnalysis/operations/*}:cancel', + 'body' => '*', + ], + ] 'placeholders' => [ 'name' => [ 'getters' => [ 'getName', ], ], - ], + ] ], ], 'google.privacy.dlp.v2beta1.DlpService' => [ @@ -84,7 +109,7 @@ 'getName', ], ], - ], + ] ], 'ListInfoTypes' => [ 'method' => 'get', @@ -95,12 +120,12 @@ 'getCategory', ], ], - ], + ] ], 'ListRootCategories' => [ 'method' => 'get', 'uriTemplate' => '/v2beta1/rootCategories', ], ], - ], -]; + ] +]; \ No newline at end of file diff --git a/src/ErrorReporting/V1beta1/Gapic/ErrorGroupServiceGapicClient.php b/src/ErrorReporting/V1beta1/Gapic/ErrorGroupServiceGapicClient.php index e475f0ee5675..30507f3f039f 100644 --- a/src/ErrorReporting/V1beta1/Gapic/ErrorGroupServiceGapicClient.php +++ b/src/ErrorReporting/V1beta1/Gapic/ErrorGroupServiceGapicClient.php @@ -47,8 +47,8 @@ /** * Service Description: Service for retrieving and updating individual error groups. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php b/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php index 8496402fa8b7..02f1ca2ea9da 100644 --- a/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php +++ b/src/ErrorReporting/V1beta1/Gapic/ErrorStatsServiceGapicClient.php @@ -55,8 +55,8 @@ * Service Description: An API for retrieving and managing error statistics as well as data for * individual events. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php b/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php index 9c65a63a1ec8..a2b45af2e224 100644 --- a/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php +++ b/src/ErrorReporting/V1beta1/Gapic/ReportErrorsServiceGapicClient.php @@ -47,8 +47,8 @@ /** * Service Description: An API for reporting error events. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php b/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php index 774531bff1ca..3252111ca815 100644 --- a/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php +++ b/src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php @@ -89,8 +89,8 @@ * committed. Any read with an equal or greater `read_time` is guaranteed * to see the effects of the transaction. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php b/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php index 310f959d2d4e..01c3f74a5e73 100644 --- a/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php +++ b/src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php @@ -58,8 +58,8 @@ * Service Description: Provides text analysis operations such as sentiment analysis and entity * recognition. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php b/src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php index 0877df49b487..148272f8804f 100644 --- a/src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php +++ b/src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php @@ -61,8 +61,8 @@ * Service Description: Service for configuring sinks used to export log entries outside of * Stackdriver Logging. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php b/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php index f39a2f063df1..0530c932df3e 100644 --- a/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php +++ b/src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php @@ -56,8 +56,8 @@ /** * Service Description: Service for ingesting and querying logs. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php b/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php index 5aa00d533ddb..d4bb20216c9b 100644 --- a/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php +++ b/src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php @@ -52,8 +52,8 @@ /** * Service Description: Service for configuring logs-based metrics. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php b/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php index 34eecb8c23b2..8553577f71fe 100644 --- a/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php +++ b/src/Monitoring/V3/Gapic/GroupServiceGapicClient.php @@ -66,8 +66,8 @@ * updated automatically as monitored resources are added and removed * from the infrastructure. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php b/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php index 1e4ec69c9815..702d2796704b 100644 --- a/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php +++ b/src/Monitoring/V3/Gapic/MetricServiceGapicClient.php @@ -63,8 +63,8 @@ * Service Description: Manages metric descriptors, monitored resource descriptors, and * time series data. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php b/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php index b3399b2f2908..343927cf45f2 100644 --- a/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php +++ b/src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php @@ -62,8 +62,8 @@ * clicking on "Monitoring" on the left-hand side to navigate to Stackdriver, * and then clicking on "Uptime". * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/PubSub/V1/Gapic/PublisherGapicClient.php b/src/PubSub/V1/Gapic/PublisherGapicClient.php index b4ec9ba6fdaf..27db4253f477 100644 --- a/src/PubSub/V1/Gapic/PublisherGapicClient.php +++ b/src/PubSub/V1/Gapic/PublisherGapicClient.php @@ -63,8 +63,8 @@ * Service Description: The service that an application uses to manipulate topics, and to send * messages to a topic. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/PubSub/V1/Gapic/SubscriberGapicClient.php b/src/PubSub/V1/Gapic/SubscriberGapicClient.php index e208b83021eb..f73d5607e0d1 100644 --- a/src/PubSub/V1/Gapic/SubscriberGapicClient.php +++ b/src/PubSub/V1/Gapic/SubscriberGapicClient.php @@ -76,8 +76,8 @@ * Service Description: The service that an application uses to manipulate subscriptions and to * consume messages from a subscription via the `Pull` method. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php b/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php index 117dede76c9f..cf706d9a54c4 100644 --- a/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php +++ b/src/Spanner/Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php @@ -68,8 +68,8 @@ * list databases. It also enables updating the schema of pre-existing * databases. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php b/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php index a8b15776f79f..c2353a4a0e50 100644 --- a/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php +++ b/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php @@ -6,46 +6,70 @@ 'GetOperation' => [ 'method' => 'get', 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}', + ], + ] 'placeholders' => [ 'name' => [ 'getters' => [ 'getName', ], ], - ], + ] ], 'ListOperations' => [ 'method' => 'get', 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations}', + ], + ] 'placeholders' => [ 'name' => [ 'getters' => [ 'getName', ], ], - ], + ] ], 'CancelOperation' => [ 'method' => 'post', 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}:cancel', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}:cancel', + ], + ] 'placeholders' => [ 'name' => [ 'getters' => [ 'getName', ], ], - ], + ] ], 'DeleteOperation' => [ 'method' => 'delete', 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}', + ], + ] 'placeholders' => [ 'name' => [ 'getters' => [ 'getName', ], ], - ], + ] ], ], 'google.spanner.admin.database.v1.DatabaseAdmin' => [ @@ -58,7 +82,7 @@ 'getParent', ], ], - ], + ] ], 'CreateDatabase' => [ 'method' => 'post', @@ -70,7 +94,7 @@ 'getParent', ], ], - ], + ] ], 'GetDatabase' => [ 'method' => 'get', @@ -81,7 +105,7 @@ 'getName', ], ], - ], + ] ], 'UpdateDatabaseDdl' => [ 'method' => 'patch', @@ -93,7 +117,7 @@ 'getDatabase', ], ], - ], + ] ], 'DropDatabase' => [ 'method' => 'delete', @@ -104,7 +128,7 @@ 'getDatabase', ], ], - ], + ] ], 'GetDatabaseDdl' => [ 'method' => 'get', @@ -115,7 +139,7 @@ 'getDatabase', ], ], - ], + ] ], 'SetIamPolicy' => [ 'method' => 'post', @@ -127,7 +151,7 @@ 'getResource', ], ], - ], + ] ], 'GetIamPolicy' => [ 'method' => 'post', @@ -139,7 +163,7 @@ 'getResource', ], ], - ], + ] ], 'TestIamPermissions' => [ 'method' => 'post', @@ -151,8 +175,8 @@ 'getResource', ], ], - ], + ] ], ], - ], -]; + ] +]; \ No newline at end of file diff --git a/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php b/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php index b8c8b9c480b7..b9372ecd4ac6 100644 --- a/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php +++ b/src/Spanner/Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php @@ -87,8 +87,8 @@ * instance resources, fewer resources are available for other * databases in that instance, and their performance may suffer. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php b/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php index 9a08fb14e162..7b55dadb4c3c 100644 --- a/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php +++ b/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php @@ -6,46 +6,70 @@ 'GetOperation' => [ 'method' => 'get', 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}', + ], + ] 'placeholders' => [ 'name' => [ 'getters' => [ 'getName', ], ], - ], + ] ], 'ListOperations' => [ 'method' => 'get', 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations}', + ], + ] 'placeholders' => [ 'name' => [ 'getters' => [ 'getName', ], ], - ], + ] ], 'CancelOperation' => [ 'method' => 'post', 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}:cancel', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}:cancel', + ], + ] 'placeholders' => [ 'name' => [ 'getters' => [ 'getName', ], ], - ], + ] ], 'DeleteOperation' => [ 'method' => 'delete', 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}', + ], + ] 'placeholders' => [ 'name' => [ 'getters' => [ 'getName', ], ], - ], + ] ], ], 'google.spanner.admin.instance.v1.InstanceAdmin' => [ @@ -58,7 +82,7 @@ 'getParent', ], ], - ], + ] ], 'GetInstanceConfig' => [ 'method' => 'get', @@ -69,7 +93,7 @@ 'getName', ], ], - ], + ] ], 'ListInstances' => [ 'method' => 'get', @@ -80,7 +104,7 @@ 'getParent', ], ], - ], + ] ], 'GetInstance' => [ 'method' => 'get', @@ -91,7 +115,7 @@ 'getName', ], ], - ], + ] ], 'CreateInstance' => [ 'method' => 'post', @@ -103,7 +127,7 @@ 'getParent', ], ], - ], + ] ], 'UpdateInstance' => [ 'method' => 'patch', @@ -116,7 +140,7 @@ 'getName', ], ], - ], + ] ], 'DeleteInstance' => [ 'method' => 'delete', @@ -127,7 +151,7 @@ 'getName', ], ], - ], + ] ], 'SetIamPolicy' => [ 'method' => 'post', @@ -139,7 +163,7 @@ 'getResource', ], ], - ], + ] ], 'GetIamPolicy' => [ 'method' => 'post', @@ -151,7 +175,7 @@ 'getResource', ], ], - ], + ] ], 'TestIamPermissions' => [ 'method' => 'post', @@ -163,8 +187,8 @@ 'getResource', ], ], - ], + ] ], ], - ], -]; + ] +]; \ No newline at end of file diff --git a/src/Spanner/V1/Gapic/SpannerGapicClient.php b/src/Spanner/V1/Gapic/SpannerGapicClient.php index dd746b5ca524..38bcc3243032 100644 --- a/src/Spanner/V1/Gapic/SpannerGapicClient.php +++ b/src/Spanner/V1/Gapic/SpannerGapicClient.php @@ -68,8 +68,8 @@ * The Cloud Spanner API can be used to manage sessions and execute * transactions on data stored in Cloud Spanner databases. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Spanner/V1/resources/spanner_rest_client_config.php b/src/Spanner/V1/resources/spanner_rest_client_config.php index 1b426818b989..c0b54ac0f1fb 100644 --- a/src/Spanner/V1/resources/spanner_rest_client_config.php +++ b/src/Spanner/V1/resources/spanner_rest_client_config.php @@ -6,46 +6,70 @@ 'GetOperation' => [ 'method' => 'get', 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}', + ], + ] 'placeholders' => [ 'name' => [ 'getters' => [ 'getName', ], ], - ], + ] ], 'ListOperations' => [ 'method' => 'get', 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations}', + ], + ] 'placeholders' => [ 'name' => [ 'getters' => [ 'getName', ], ], - ], + ] ], 'CancelOperation' => [ 'method' => 'post', 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}:cancel', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}:cancel', + ], + ] 'placeholders' => [ 'name' => [ 'getters' => [ 'getName', ], ], - ], + ] ], 'DeleteOperation' => [ 'method' => 'delete', 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}', + ], + ] 'placeholders' => [ 'name' => [ 'getters' => [ 'getName', ], ], - ], + ] ], ], 'google.spanner.v1.Spanner' => [ @@ -59,7 +83,7 @@ 'getDatabase', ], ], - ], + ] ], 'GetSession' => [ 'method' => 'get', @@ -70,7 +94,7 @@ 'getName', ], ], - ], + ] ], 'ListSessions' => [ 'method' => 'get', @@ -81,7 +105,7 @@ 'getDatabase', ], ], - ], + ] ], 'DeleteSession' => [ 'method' => 'delete', @@ -92,7 +116,7 @@ 'getName', ], ], - ], + ] ], 'ExecuteSql' => [ 'method' => 'post', @@ -104,7 +128,7 @@ 'getSession', ], ], - ], + ] ], 'Read' => [ 'method' => 'post', @@ -116,7 +140,7 @@ 'getSession', ], ], - ], + ] ], 'BeginTransaction' => [ 'method' => 'post', @@ -128,7 +152,7 @@ 'getSession', ], ], - ], + ] ], 'Commit' => [ 'method' => 'post', @@ -140,7 +164,7 @@ 'getSession', ], ], - ], + ] ], 'Rollback' => [ 'method' => 'post', @@ -152,8 +176,8 @@ 'getSession', ], ], - ], + ] ], ], - ], -]; + ] +]; \ No newline at end of file diff --git a/src/Speech/V1/Gapic/SpeechGapicClient.php b/src/Speech/V1/Gapic/SpeechGapicClient.php index 48a7bbaabafb..37a0168ce8d3 100644 --- a/src/Speech/V1/Gapic/SpeechGapicClient.php +++ b/src/Speech/V1/Gapic/SpeechGapicClient.php @@ -53,8 +53,8 @@ /** * Service Description: Service that implements Google Cloud Speech API. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Speech/V1beta1/Gapic/SpeechGapicClient.php b/src/Speech/V1beta1/Gapic/SpeechGapicClient.php index 12f835f88046..b7c1b7be2231 100644 --- a/src/Speech/V1beta1/Gapic/SpeechGapicClient.php +++ b/src/Speech/V1beta1/Gapic/SpeechGapicClient.php @@ -53,8 +53,8 @@ /** * Service Description: Service that implements Google Cloud Speech API. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php index af03a897370e..9dd2dcede4f8 100644 --- a/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1/Gapic/VideoIntelligenceServiceGapicClient.php @@ -50,8 +50,8 @@ /** * Service Description: Service that implements Google Cloud Video Intelligence API. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php index b0be51c5442c..40a9979f569e 100644 --- a/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php @@ -50,8 +50,8 @@ /** * Service Description: Service that implements Google Cloud Video Intelligence API. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php b/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php index 78bebeaba282..f7fd0b771ece 100644 --- a/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php +++ b/src/VideoIntelligence/V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php @@ -50,8 +50,8 @@ /** * Service Description: Service that implements Google Cloud Video Intelligence API. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method diff --git a/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php b/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php index 05f0fcd61fae..3a72f3ab905f 100644 --- a/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php +++ b/src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php @@ -47,8 +47,8 @@ * images, such as face, landmark, logo, label, and text detection. The * ImageAnnotator service returns detected entities from the images. * - * EXPERIMENTAL: this client library class has not yet been declared GA (1.0). This means that - * even though we intent the surface to be stable, we may make backwards incompatible changes + * EXPERIMENTAL: This client library class has not yet been declared GA (1.0). This means that + * even though we intend the surface to be stable, we may make backwards incompatible changes * if necessary. * * This class provides the ability to make remote calls to the backing service through method From e74ec3080ddf4d357a3ab3b095bd506669a9a7bb Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Fri, 19 Jan 2018 16:30:54 -0500 Subject: [PATCH 14/21] add trace/oslogin --- .../Gapic/OsLoginServiceGapicClient.php | 357 ++++++------------ src/OsLogin/V1beta/OsLoginServiceClient.php | 8 +- .../os_login_service_descriptor_config.php | 8 + .../os_login_service_rest_client_config.php | 76 ++++ .../V2/Gapic/TraceServiceGapicClient.php | 247 +++++------- src/Trace/V2/TraceServiceClient.php | 8 +- .../trace_service_descriptor_config.php | 8 + .../trace_service_rest_client_config.php | 32 ++ 8 files changed, 336 insertions(+), 408 deletions(-) create mode 100644 src/OsLogin/V1beta/resources/os_login_service_descriptor_config.php create mode 100644 src/OsLogin/V1beta/resources/os_login_service_rest_client_config.php create mode 100644 src/Trace/V2/resources/trace_service_descriptor_config.php create mode 100644 src/Trace/V2/resources/trace_service_rest_client_config.php diff --git a/src/OsLogin/V1beta/Gapic/OsLoginServiceGapicClient.php b/src/OsLogin/V1beta/Gapic/OsLoginServiceGapicClient.php index 6b35e235da3c..bf9faaefee40 100644 --- a/src/OsLogin/V1beta/Gapic/OsLoginServiceGapicClient.php +++ b/src/OsLogin/V1beta/Gapic/OsLoginServiceGapicClient.php @@ -1,12 +1,12 @@ projectName('[USER]', '[PROJECT]'); * $osLoginServiceClient->deletePosixAccount($formattedName); * } finally { @@ -79,6 +84,13 @@ */ class OsLoginServiceGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.cloud.oslogin.v1beta.OsLoginService'; + /** * The default address of the service. */ @@ -103,18 +115,29 @@ class OsLoginServiceGapicClient private static $projectNameTemplate; private static $fingerprintNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - protected $grpcCredentialsHelper; - protected $osLoginServiceStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/compute.readonly', + ], + 'clientConfigPath' => __DIR__.'/../resources/os_login_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/os_login_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/os_login_service_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', + ]; + } private static function getUserNameTemplate() { - if (self::$userNameTemplate == null) { + if (null == self::$userNameTemplate) { self::$userNameTemplate = new PathTemplate('users/{user}'); } @@ -123,7 +146,7 @@ private static function getUserNameTemplate() private static function getProjectNameTemplate() { - if (self::$projectNameTemplate == null) { + if (null == self::$projectNameTemplate) { self::$projectNameTemplate = new PathTemplate('users/{user}/projects/{project}'); } @@ -132,7 +155,7 @@ private static function getProjectNameTemplate() private static function getFingerprintNameTemplate() { - if (self::$fingerprintNameTemplate == null) { + if (null == self::$fingerprintNameTemplate) { self::$fingerprintNameTemplate = new PathTemplate('users/{user}/sshPublicKeys/{fingerprint}'); } @@ -141,7 +164,7 @@ private static function getFingerprintNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'user' => self::getUserNameTemplate(), 'project' => self::getProjectNameTemplate(), @@ -152,20 +175,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a user resource. @@ -270,20 +279,23 @@ public static function parseName($formattedName, $template = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'oslogin.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. - * @type \Grpc\ChannelCredentials $sslCreds + * @type Channel $channel + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Google Cloud OS Login API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -299,69 +311,22 @@ public static function parseName($formattedName, $template = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface`. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|TransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - 'https://www.googleapis.com/auth/compute', - 'https://www.googleapis.com/auth/compute.readonly', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/os_login_service_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'deletePosixAccount' => $defaultDescriptors, - 'deleteSshPublicKey' => $defaultDescriptors, - 'getLoginProfile' => $defaultDescriptors, - 'getSshPublicKey' => $defaultDescriptors, - 'importSshPublicKey' => $defaultDescriptors, - 'updateSshPublicKey' => $defaultDescriptors, - ]; - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.cloud.oslogin.v1beta.OsLoginService', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createOsLoginServiceStubFunction = function ($hostname, $opts, $channel) { - return new OsLoginServiceGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createOsLoginServiceStubFunction', $options)) { - $createOsLoginServiceStubFunction = $options['createOsLoginServiceStubFunction']; - } - $this->osLoginServiceStub = $this->grpcCredentialsHelper->createStub($createOsLoginServiceStubFunction); + $this->setClientOptions($options + self::getClientDefaults()); } /** @@ -369,8 +334,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); * try { - * $osLoginServiceClient = new OsLoginServiceClient(); * $formattedName = $osLoginServiceClient->projectName('[USER]', '[PROJECT]'); * $osLoginServiceClient->deletePosixAccount($formattedName); * } finally { @@ -384,14 +349,14 @@ public function __construct($options = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deletePosixAccount($name, $optionalArgs = []) @@ -399,24 +364,12 @@ public function deletePosixAccount($name, $optionalArgs = []) $request = new DeletePosixAccountRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['deletePosixAccount']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->osLoginServiceStub, + return $this->startCall( 'DeletePosixAccount', - $mergedSettings, - $this->descriptors['deletePosixAccount'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + GPBEmpty::class, + $optionalArgs, + $request + )->wait(); } /** @@ -424,8 +377,8 @@ public function deletePosixAccount($name, $optionalArgs = []) * * Sample code: * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); * try { - * $osLoginServiceClient = new OsLoginServiceClient(); * $formattedName = $osLoginServiceClient->fingerprintName('[USER]', '[FINGERPRINT]'); * $osLoginServiceClient->deleteSshPublicKey($formattedName); * } finally { @@ -439,14 +392,14 @@ public function deletePosixAccount($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteSshPublicKey($name, $optionalArgs = []) @@ -454,24 +407,12 @@ public function deleteSshPublicKey($name, $optionalArgs = []) $request = new DeleteSshPublicKeyRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['deleteSshPublicKey']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->osLoginServiceStub, + return $this->startCall( 'DeleteSshPublicKey', - $mergedSettings, - $this->descriptors['deleteSshPublicKey'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + GPBEmpty::class, + $optionalArgs, + $request + )->wait(); } /** @@ -480,8 +421,8 @@ public function deleteSshPublicKey($name, $optionalArgs = []) * * Sample code: * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); * try { - * $osLoginServiceClient = new OsLoginServiceClient(); * $formattedName = $osLoginServiceClient->userName('[USER]'); * $response = $osLoginServiceClient->getLoginProfile($formattedName); * } finally { @@ -493,7 +434,7 @@ public function deleteSshPublicKey($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -502,7 +443,7 @@ public function deleteSshPublicKey($name, $optionalArgs = []) * * @return \Google\Cloud\OsLogin\V1beta\LoginProfile * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getLoginProfile($name, $optionalArgs = []) @@ -510,24 +451,12 @@ public function getLoginProfile($name, $optionalArgs = []) $request = new GetLoginProfileRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['getLoginProfile']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->osLoginServiceStub, + return $this->startCall( 'GetLoginProfile', - $mergedSettings, - $this->descriptors['getLoginProfile'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + LoginProfile::class, + $optionalArgs, + $request + )->wait(); } /** @@ -535,8 +464,8 @@ public function getLoginProfile($name, $optionalArgs = []) * * Sample code: * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); * try { - * $osLoginServiceClient = new OsLoginServiceClient(); * $formattedName = $osLoginServiceClient->fingerprintName('[USER]', '[FINGERPRINT]'); * $response = $osLoginServiceClient->getSshPublicKey($formattedName); * } finally { @@ -550,7 +479,7 @@ public function getLoginProfile($name, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -559,7 +488,7 @@ public function getLoginProfile($name, $optionalArgs = []) * * @return \Google\Cloud\OsLogin\Common\SshPublicKey * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getSshPublicKey($name, $optionalArgs = []) @@ -567,24 +496,12 @@ public function getSshPublicKey($name, $optionalArgs = []) $request = new GetSshPublicKeyRequest(); $request->setName($name); - $defaultCallSettings = $this->defaultCallSettings['getSshPublicKey']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->osLoginServiceStub, + return $this->startCall( 'GetSshPublicKey', - $mergedSettings, - $this->descriptors['getSshPublicKey'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + SshPublicKey::class, + $optionalArgs, + $request + )->wait(); } /** @@ -594,8 +511,8 @@ public function getSshPublicKey($name, $optionalArgs = []) * * Sample code: * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); * try { - * $osLoginServiceClient = new OsLoginServiceClient(); * $formattedParent = $osLoginServiceClient->userName('[USER]'); * $sshPublicKey = new SshPublicKey(); * $response = $osLoginServiceClient->importSshPublicKey($formattedParent, $sshPublicKey); @@ -611,7 +528,7 @@ public function getSshPublicKey($name, $optionalArgs = []) * * @type string $projectId * The project ID of the Google Cloud Platform project. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -620,7 +537,7 @@ public function getSshPublicKey($name, $optionalArgs = []) * * @return \Google\Cloud\OsLogin\V1beta\ImportSshPublicKeyResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function importSshPublicKey($parent, $sshPublicKey, $optionalArgs = []) @@ -632,24 +549,12 @@ public function importSshPublicKey($parent, $sshPublicKey, $optionalArgs = []) $request->setProjectId($optionalArgs['projectId']); } - $defaultCallSettings = $this->defaultCallSettings['importSshPublicKey']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->osLoginServiceStub, + return $this->startCall( 'ImportSshPublicKey', - $mergedSettings, - $this->descriptors['importSshPublicKey'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + ImportSshPublicKeyResponse::class, + $optionalArgs, + $request + )->wait(); } /** @@ -658,8 +563,8 @@ public function importSshPublicKey($parent, $sshPublicKey, $optionalArgs = []) * * Sample code: * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); * try { - * $osLoginServiceClient = new OsLoginServiceClient(); * $formattedName = $osLoginServiceClient->fingerprintName('[USER]', '[FINGERPRINT]'); * $sshPublicKey = new SshPublicKey(); * $response = $osLoginServiceClient->updateSshPublicKey($formattedName, $sshPublicKey); @@ -677,7 +582,7 @@ public function importSshPublicKey($parent, $sshPublicKey, $optionalArgs = []) * * @type FieldMask $updateMask * Mask to control which fields get updated. Updates all if not present. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -686,7 +591,7 @@ public function importSshPublicKey($parent, $sshPublicKey, $optionalArgs = []) * * @return \Google\Cloud\OsLogin\Common\SshPublicKey * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateSshPublicKey($name, $sshPublicKey, $optionalArgs = []) @@ -698,39 +603,11 @@ public function updateSshPublicKey($name, $sshPublicKey, $optionalArgs = []) $request->setUpdateMask($optionalArgs['updateMask']); } - $defaultCallSettings = $this->defaultCallSettings['updateSshPublicKey']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->osLoginServiceStub, + return $this->startCall( 'UpdateSshPublicKey', - $mergedSettings, - $this->descriptors['updateSshPublicKey'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); - } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->osLoginServiceStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + SshPublicKey::class, + $optionalArgs, + $request + )->wait(); } } diff --git a/src/OsLogin/V1beta/OsLoginServiceClient.php b/src/OsLogin/V1beta/OsLoginServiceClient.php index 22249a42feda..37200820884d 100644 --- a/src/OsLogin/V1beta/OsLoginServiceClient.php +++ b/src/OsLogin/V1beta/OsLoginServiceClient.php @@ -1,12 +1,12 @@ [ + 'google.cloud.oslogin.v1beta.OsLoginService' => [ + ], + ], +]; diff --git a/src/OsLogin/V1beta/resources/os_login_service_rest_client_config.php b/src/OsLogin/V1beta/resources/os_login_service_rest_client_config.php new file mode 100644 index 000000000000..529b34be69d4 --- /dev/null +++ b/src/OsLogin/V1beta/resources/os_login_service_rest_client_config.php @@ -0,0 +1,76 @@ + [ + 'google.cloud.oslogin.v1beta.OsLoginService' => [ + 'DeletePosixAccount' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1beta/{name=users/*/projects/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteSshPublicKey' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1beta/{name=users/*/sshPublicKeys/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetLoginProfile' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=users/*}/loginProfile', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetSshPublicKey' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=users/*/sshPublicKeys/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ImportSshPublicKey' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=users/*}:importSshPublicKey', + 'body' => 'ssh_public_key', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateSshPublicKey' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1beta/{name=users/*/sshPublicKeys/*}', + 'body' => 'ssh_public_key', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], +]; diff --git a/src/Trace/V2/Gapic/TraceServiceGapicClient.php b/src/Trace/V2/Gapic/TraceServiceGapicClient.php index c423cdf6af4b..4b27175dbfd3 100644 --- a/src/Trace/V2/Gapic/TraceServiceGapicClient.php +++ b/src/Trace/V2/Gapic/TraceServiceGapicClient.php @@ -1,12 +1,12 @@ projectName('[PROJECT]'); * $spans = []; * $traceServiceClient->batchWriteSpans($formattedName, $spans); @@ -84,6 +87,13 @@ */ class TraceServiceGapicClient { + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.devtools.cloudtrace.v2.TraceService'; + /** * The default address of the service. */ @@ -107,18 +117,27 @@ class TraceServiceGapicClient private static $projectNameTemplate; private static $spanNameTemplate; private static $pathTemplateMap; - private static $gapicVersion; - private static $gapicVersionLoaded = false; - protected $grpcCredentialsHelper; - protected $traceServiceStub; - private $scopes; - private $defaultCallSettings; - private $descriptors; + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/trace.append', + ], + 'clientConfigPath' => __DIR__.'/../resources/trace_service_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/trace_service_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/trace_service_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', + ]; + } private static function getProjectNameTemplate() { - if (self::$projectNameTemplate == null) { + if (null == self::$projectNameTemplate) { self::$projectNameTemplate = new PathTemplate('projects/{project}'); } @@ -127,7 +146,7 @@ private static function getProjectNameTemplate() private static function getSpanNameTemplate() { - if (self::$spanNameTemplate == null) { + if (null == self::$spanNameTemplate) { self::$spanNameTemplate = new PathTemplate('projects/{project}/traces/{trace}/spans/{span}'); } @@ -136,7 +155,7 @@ private static function getSpanNameTemplate() private static function getPathTemplateMap() { - if (self::$pathTemplateMap == null) { + if (null == self::$pathTemplateMap) { self::$pathTemplateMap = [ 'project' => self::getProjectNameTemplate(), 'span' => self::getSpanNameTemplate(), @@ -146,20 +165,6 @@ private static function getPathTemplateMap() return self::$pathTemplateMap; } - private static function getGapicVersion() - { - if (!self::$gapicVersionLoaded) { - if (file_exists(__DIR__.'/../VERSION')) { - self::$gapicVersion = trim(file_get_contents(__DIR__.'/../VERSION')); - } elseif (class_exists(Version::class)) { - self::$gapicVersion = Version::VERSION; - } - self::$gapicVersionLoaded = true; - } - - return self::$gapicVersion; - } - /** * Formats a string containing the fully-qualified path to represent * a project resource. @@ -247,20 +252,23 @@ public static function parseName($formattedName, $template = null) * @type string $serviceAddress The domain name of the API remote host. * Default 'cloudtrace.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. - * @type \Grpc\ChannelCredentials $sslCreds + * @type Channel $channel + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Stackdriver Trace API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -276,63 +284,22 @@ public static function parseName($formattedName, $template = null) * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface`. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|TransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/trace.append', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/trace_service_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'batchWriteSpans' => $defaultDescriptors, - 'createSpan' => $defaultDescriptors, - ]; - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.devtools.cloudtrace.v2.TraceService', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createTraceServiceStubFunction = function ($hostname, $opts, $channel) { - return new TraceServiceGrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createTraceServiceStubFunction', $options)) { - $createTraceServiceStubFunction = $options['createTraceServiceStubFunction']; - } - $this->traceServiceStub = $this->grpcCredentialsHelper->createStub($createTraceServiceStubFunction); + $this->setClientOptions($options + self::getClientDefaults()); } /** @@ -341,8 +308,8 @@ public function __construct($options = []) * * Sample code: * ``` + * $traceServiceClient = new TraceServiceClient(); * try { - * $traceServiceClient = new TraceServiceClient(); * $formattedName = $traceServiceClient->projectName('[PROJECT]'); * $spans = []; * $traceServiceClient->batchWriteSpans($formattedName, $spans); @@ -358,14 +325,14 @@ public function __construct($options = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function batchWriteSpans($name, $spans, $optionalArgs = []) @@ -374,24 +341,12 @@ public function batchWriteSpans($name, $spans, $optionalArgs = []) $request->setName($name); $request->setSpans($spans); - $defaultCallSettings = $this->defaultCallSettings['batchWriteSpans']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->traceServiceStub, + return $this->startCall( 'BatchWriteSpans', - $mergedSettings, - $this->descriptors['batchWriteSpans'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + GPBEmpty::class, + $optionalArgs, + $request + )->wait(); } /** @@ -399,8 +354,8 @@ public function batchWriteSpans($name, $spans, $optionalArgs = []) * * Sample code: * ``` + * $traceServiceClient = new TraceServiceClient(); * try { - * $traceServiceClient = new TraceServiceClient(); * $formattedName = $traceServiceClient->spanName('[PROJECT]', '[TRACE]', '[SPAN]'); * $spanId = ''; * $displayName = new TruncatableString(); @@ -424,7 +379,7 @@ public function batchWriteSpans($name, $spans, $optionalArgs = []) * @param string $spanId The [SPAN_ID] portion of the span's resource name. * @param TruncatableString $displayName A description of the span's operation (up to 128 bytes). * Stackdriver Trace displays the description in the - * Google Cloud Platform Console. + * {% dynamic print site_values.console_name %}. * For example, the display name can be a qualified method name or a file name * and a line number where the operation is called. A best practice is to use * the same display name within an application and at the same call point. @@ -441,15 +396,15 @@ public function batchWriteSpans($name, $spans, $optionalArgs = []) * @type string $parentSpanId * The [SPAN_ID] of this span's parent span. If this is a root span, * then this field must be empty. - * @type Attributes $attributes + * @type Span_Attributes $attributes * A set of attributes on the span. You can have up to 32 attributes per * span. * @type StackTrace $stackTrace * Stack trace captured at the start of the span. - * @type TimeEvents $timeEvents + * @type Span_TimeEvents $timeEvents * A set of time events. You can have up to 32 annotations and 128 message * events per span. - * @type Links $links + * @type Span_Links $links * Links associated with the span. You can have up to 128 links per Span. * @type Status $status * An optional final status for this span. @@ -461,7 +416,7 @@ public function batchWriteSpans($name, $spans, $optionalArgs = []) * @type Int32Value $childSpanCount * An optional number of child spans that were generated while this span * was active. If set, allows implementation to detect missing child spans. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -470,7 +425,7 @@ public function batchWriteSpans($name, $spans, $optionalArgs = []) * * @return \Google\Cloud\Trace\V2\Span * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function createSpan($name, $spanId, $displayName, $startTime, $endTime, $optionalArgs = []) @@ -506,39 +461,11 @@ public function createSpan($name, $spanId, $displayName, $startTime, $endTime, $ $request->setChildSpanCount($optionalArgs['childSpanCount']); } - $defaultCallSettings = $this->defaultCallSettings['createSpan']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->traceServiceStub, + return $this->startCall( 'CreateSpan', - $mergedSettings, - $this->descriptors['createSpan'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); - } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->traceServiceStub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + Span::class, + $optionalArgs, + $request + )->wait(); } } diff --git a/src/Trace/V2/TraceServiceClient.php b/src/Trace/V2/TraceServiceClient.php index 0321a46c9f20..63232e4eb8ec 100644 --- a/src/Trace/V2/TraceServiceClient.php +++ b/src/Trace/V2/TraceServiceClient.php @@ -1,12 +1,12 @@ [ + 'google.devtools.cloudtrace.v2.TraceService' => [ + ], + ], +]; diff --git a/src/Trace/V2/resources/trace_service_rest_client_config.php b/src/Trace/V2/resources/trace_service_rest_client_config.php new file mode 100644 index 000000000000..5e01d0e13c7f --- /dev/null +++ b/src/Trace/V2/resources/trace_service_rest_client_config.php @@ -0,0 +1,32 @@ + [ + 'google.devtools.cloudtrace.v2.TraceService' => [ + 'BatchWriteSpans' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{name=projects/*}/traces:batchWrite', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'CreateSpan' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{name=projects/*/traces/*}/spans', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], +]; From d81f925ea781837abc66c68aca0e8812634de605 Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Fri, 19 Jan 2018 17:15:00 -0500 Subject: [PATCH 15/21] refresh gapics --- .../dlp_service_rest_client_config.php | 2 +- .../database_admin_rest_client_config.php | 2 +- .../instance_admin_rest_client_config.php | 2 +- src/Spanner/V1/SpannerClient.php | 20 +++++-------------- .../resources/spanner_rest_client_config.php | 2 +- 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php b/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php index 9e8541440b67..bb68d9bf6c48 100644 --- a/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php +++ b/src/Dlp/V2beta1/resources/dlp_service_rest_client_config.php @@ -128,4 +128,4 @@ ], ], ] -]; \ No newline at end of file +]; diff --git a/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php b/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php index c2353a4a0e50..7a168e4e939e 100644 --- a/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php +++ b/src/Spanner/Admin/Database/V1/resources/database_admin_rest_client_config.php @@ -179,4 +179,4 @@ ], ], ] -]; \ No newline at end of file +]; diff --git a/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php b/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php index 7b55dadb4c3c..34709e27316c 100644 --- a/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php +++ b/src/Spanner/Admin/Instance/V1/resources/instance_admin_rest_client_config.php @@ -191,4 +191,4 @@ ], ], ] -]; \ No newline at end of file +]; diff --git a/src/Spanner/V1/SpannerClient.php b/src/Spanner/V1/SpannerClient.php index 1450b95958a7..eaafa27ec474 100644 --- a/src/Spanner/V1/SpannerClient.php +++ b/src/Spanner/V1/SpannerClient.php @@ -1,6 +1,6 @@ transport; - } + // This class is intentionally empty, and is intended to hold manual + // additions to the generated {@see SpannerClientImpl} class. } diff --git a/src/Spanner/V1/resources/spanner_rest_client_config.php b/src/Spanner/V1/resources/spanner_rest_client_config.php index c0b54ac0f1fb..26445067905f 100644 --- a/src/Spanner/V1/resources/spanner_rest_client_config.php +++ b/src/Spanner/V1/resources/spanner_rest_client_config.php @@ -180,4 +180,4 @@ ], ], ] -]; \ No newline at end of file +]; From 2a1b5c2f45f2f3aaf37e739da0d38183c946d7b7 Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Fri, 19 Jan 2018 17:33:19 -0500 Subject: [PATCH 16/21] readd partial veneer --- src/Spanner/V1/SpannerClient.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Spanner/V1/SpannerClient.php b/src/Spanner/V1/SpannerClient.php index eaafa27ec474..7dffd70fc797 100644 --- a/src/Spanner/V1/SpannerClient.php +++ b/src/Spanner/V1/SpannerClient.php @@ -30,6 +30,7 @@ namespace Google\Cloud\Spanner\V1; +use Google\ApiCore\Transport\TransportInterface; use Google\Cloud\Spanner\V1\Gapic\SpannerGapicClient; /** @@ -37,6 +38,15 @@ */ class SpannerClient extends SpannerGapicClient { - // This class is intentionally empty, and is intended to hold manual - // additions to the generated {@see SpannerClientImpl} class. + /** + * Returns the underlying transport. + * + * @access private + * @return TransportInterface + * @experimental + */ + public function getTransport() + { + return $this->transport; + } } From 457709813b44f20b29599a66b528ac1383d68b9b Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Fri, 19 Jan 2018 20:45:33 -0500 Subject: [PATCH 17/21] gapic refresh --- src/Debugger/V2/Controller2Client.php | 6 +- src/Debugger/V2/Debugger2Client.php | 6 +- .../V2/Gapic/Controller2GapicClient.php | 245 +++++--------- .../V2/Gapic/Debugger2GapicClient.php | 305 ++++++------------ .../controller2_descriptor_config.php | 8 + .../controller2_rest_client_config.php | 42 +++ .../resources/debugger2_descriptor_config.php | 8 + .../debugger2_rest_client_config.php | 67 ++++ 8 files changed, 309 insertions(+), 378 deletions(-) create mode 100644 src/Debugger/V2/resources/controller2_descriptor_config.php create mode 100644 src/Debugger/V2/resources/controller2_rest_client_config.php create mode 100644 src/Debugger/V2/resources/debugger2_descriptor_config.php create mode 100644 src/Debugger/V2/resources/debugger2_rest_client_config.php diff --git a/src/Debugger/V2/Controller2Client.php b/src/Debugger/V2/Controller2Client.php index eca33a8817ca..d52b412bb8cb 100644 --- a/src/Debugger/V2/Controller2Client.php +++ b/src/Debugger/V2/Controller2Client.php @@ -1,6 +1,6 @@ self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud_debugger', + ], + 'clientConfigPath' => __DIR__.'/../resources/controller2_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/controller2_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/controller2_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', + ]; } /** @@ -137,20 +143,23 @@ private static function getGapicVersion() * @type string $serviceAddress The domain name of the API remote host. * Default 'clouddebugger.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. - * @type \Grpc\ChannelCredentials $sslCreds + * @type Channel $channel + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Stackdriver Debugger API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -166,64 +175,22 @@ private static function getGapicVersion() * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface`. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|TransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud_debugger', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/controller2_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'registerDebuggee' => $defaultDescriptors, - 'listActiveBreakpoints' => $defaultDescriptors, - 'updateActiveBreakpoint' => $defaultDescriptors, - ]; - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.devtools.clouddebugger.v2.Controller2', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createController2StubFunction = function ($hostname, $opts, $channel) { - return new Controller2GrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createController2StubFunction', $options)) { - $createController2StubFunction = $options['createController2StubFunction']; - } - $this->controller2Stub = $this->grpcCredentialsHelper->createStub($createController2StubFunction); + $this->setClientOptions($options + self::getClientDefaults()); } /** @@ -255,7 +222,7 @@ public function __construct($options = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -264,7 +231,7 @@ public function __construct($options = []) * * @return \Google\Cloud\Debugger\V2\RegisterDebuggeeResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function registerDebuggee($debuggee, $optionalArgs = []) @@ -272,24 +239,12 @@ public function registerDebuggee($debuggee, $optionalArgs = []) $request = new RegisterDebuggeeRequest(); $request->setDebuggee($debuggee); - $defaultCallSettings = $this->defaultCallSettings['registerDebuggee']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->controller2Stub, + return $this->startCall( 'RegisterDebuggee', - $mergedSettings, - $this->descriptors['registerDebuggee'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + RegisterDebuggeeResponse::class, + $optionalArgs, + $request + )->wait(); } /** @@ -334,7 +289,7 @@ public function registerDebuggee($debuggee, $optionalArgs = []) * * If set to `false` (deprecated), returns `google.rpc.Code.ABORTED` status * when the server-selected timeout has expired. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -343,7 +298,7 @@ public function registerDebuggee($debuggee, $optionalArgs = []) * * @return \Google\Cloud\Debugger\V2\ListActiveBreakpointsResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listActiveBreakpoints($debuggeeId, $optionalArgs = []) @@ -357,24 +312,12 @@ public function listActiveBreakpoints($debuggeeId, $optionalArgs = []) $request->setSuccessOnTimeout($optionalArgs['successOnTimeout']); } - $defaultCallSettings = $this->defaultCallSettings['listActiveBreakpoints']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->controller2Stub, + return $this->startCall( 'ListActiveBreakpoints', - $mergedSettings, - $this->descriptors['listActiveBreakpoints'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + ListActiveBreakpointsResponse::class, + $optionalArgs, + $request + )->wait(); } /** @@ -406,7 +349,7 @@ public function listActiveBreakpoints($debuggeeId, $optionalArgs = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -415,7 +358,7 @@ public function listActiveBreakpoints($debuggeeId, $optionalArgs = []) * * @return \Google\Cloud\Debugger\V2\UpdateActiveBreakpointResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function updateActiveBreakpoint($debuggeeId, $breakpoint, $optionalArgs = []) @@ -424,39 +367,11 @@ public function updateActiveBreakpoint($debuggeeId, $breakpoint, $optionalArgs = $request->setDebuggeeId($debuggeeId); $request->setBreakpoint($breakpoint); - $defaultCallSettings = $this->defaultCallSettings['updateActiveBreakpoint']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->controller2Stub, + return $this->startCall( 'UpdateActiveBreakpoint', - $mergedSettings, - $this->descriptors['updateActiveBreakpoint'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); - } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->controller2Stub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + UpdateActiveBreakpointResponse::class, + $optionalArgs, + $request + )->wait(); } } diff --git a/src/Debugger/V2/Gapic/Debugger2GapicClient.php b/src/Debugger/V2/Gapic/Debugger2GapicClient.php index 431618e21386..402bc523e35f 100644 --- a/src/Debugger/V2/Gapic/Debugger2GapicClient.php +++ b/src/Debugger/V2/Gapic/Debugger2GapicClient.php @@ -1,6 +1,6 @@ self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS, + 'port' => self::DEFAULT_SERVICE_PORT, + 'scopes' => [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud_debugger', + ], + 'clientConfigPath' => __DIR__.'/../resources/debugger2_client_config.json', + 'restClientConfigPath' => __DIR__.'/../resources/debugger2_rest_client_config.php', + 'descriptorsConfigPath' => __DIR__.'/../resources/debugger2_descriptor_config.php', + 'versionFile' => __DIR__.'/../../VERSION', + ]; } /** @@ -133,20 +141,23 @@ private static function getGapicVersion() * @type string $serviceAddress The domain name of the API remote host. * Default 'clouddebugger.googleapis.com'. * @type mixed $port The port on which to connect to the remote host. Default 443. - * @type \Grpc\Channel $channel - * A `Channel` object to be used by gRPC. If not specified, a channel will be constructed. - * @type \Grpc\ChannelCredentials $sslCreds + * @type Channel $channel + * A `Channel` object. If not specified, a channel will be constructed. + * NOTE: This option is only valid when utilizing the gRPC transport. + * @type ChannelCredentials $sslCreds * A `ChannelCredentials` object for use with an SSL-enabled channel. * Default: a credentials object returned from - * \Grpc\ChannelCredentials::createSsl() - * NOTE: if the $channel optional argument is specified, then this argument is unused. + * \Grpc\ChannelCredentials::createSsl(). + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this argument is unused. * @type bool $forceNewChannel * If true, this forces gRPC to create a new channel instead of using a persistent channel. * Defaults to false. - * NOTE: if the $channel optional argument is specified, then this option is unused. - * @type \Google\Auth\CredentialsLoader $credentialsLoader + * NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel + * optional argument is specified, then this option is unused. + * @type CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the Google\Auth library. - * @type array $scopes A string array of scopes to use when acquiring credentials. + * @type string[] $scopes A string array of scopes to use when acquiring credentials. * Defaults to the scopes for the Stackdriver Debugger API. * @type string $clientConfigPath * Path to a JSON file containing client method configuration, including retry settings. @@ -162,66 +173,22 @@ private static function getGapicVersion() * for example usage. Passing a value of null is equivalent to a value of * ['retriesEnabled' => false]. Retry settings provided in this setting override the * settings in $clientConfigPath. + * @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically + * for authentication. Should match a signature of + * `function (RequestInterface $request, array $options) : ResponseInterface`. + * @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a + * signature of `function (RequestInterface $request, array $options) : PromiseInterface`. + * NOTE: This option is only valid when utilizing the REST transport. + * @type string|TransportInterface $transport The transport used for executing network + * requests. May be either the string `rest` or `grpc`. Additionally, it is possible + * to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is + * detected on the system. * } * @experimental */ public function __construct($options = []) { - $defaultOptions = [ - 'serviceAddress' => self::SERVICE_ADDRESS, - 'port' => self::DEFAULT_SERVICE_PORT, - 'scopes' => [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud_debugger', - ], - 'retryingOverride' => null, - 'libName' => null, - 'libVersion' => null, - 'clientConfigPath' => __DIR__.'/../resources/debugger2_client_config.json', - ]; - $options = array_merge($defaultOptions, $options); - - $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); - - $headerDescriptor = new AgentHeaderDescriptor([ - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'gapicVersion' => $gapicVersion, - ]); - - $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; - $this->descriptors = [ - 'setBreakpoint' => $defaultDescriptors, - 'getBreakpoint' => $defaultDescriptors, - 'deleteBreakpoint' => $defaultDescriptors, - 'listBreakpoints' => $defaultDescriptors, - 'listDebuggees' => $defaultDescriptors, - ]; - - $clientConfigJsonString = file_get_contents($options['clientConfigPath']); - $clientConfig = json_decode($clientConfigJsonString, true); - $this->defaultCallSettings = - CallSettings::load( - 'google.devtools.clouddebugger.v2.Debugger2', - $clientConfig, - $options['retryingOverride'] - ); - - $this->scopes = $options['scopes']; - - $createStubOptions = []; - if (array_key_exists('sslCreds', $options)) { - $createStubOptions['sslCreds'] = $options['sslCreds']; - } - $this->grpcCredentialsHelper = new GrpcCredentialsHelper($options); - - $createDebugger2StubFunction = function ($hostname, $opts, $channel) { - return new Debugger2GrpcClient($hostname, $opts, $channel); - }; - if (array_key_exists('createDebugger2StubFunction', $options)) { - $createDebugger2StubFunction = $options['createDebugger2StubFunction']; - } - $this->debugger2Stub = $this->grpcCredentialsHelper->createStub($createDebugger2StubFunction); + $this->setClientOptions($options + self::getClientDefaults()); } /** @@ -248,7 +215,7 @@ public function __construct($options = []) * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -257,7 +224,7 @@ public function __construct($options = []) * * @return \Google\Cloud\Debugger\V2\SetBreakpointResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function setBreakpoint($debuggeeId, $breakpoint, $clientVersion, $optionalArgs = []) @@ -267,24 +234,12 @@ public function setBreakpoint($debuggeeId, $breakpoint, $clientVersion, $optiona $request->setBreakpoint($breakpoint); $request->setClientVersion($clientVersion); - $defaultCallSettings = $this->defaultCallSettings['setBreakpoint']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->debugger2Stub, + return $this->startCall( 'SetBreakpoint', - $mergedSettings, - $this->descriptors['setBreakpoint'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + SetBreakpointResponse::class, + $optionalArgs, + $request + )->wait(); } /** @@ -310,7 +265,7 @@ public function setBreakpoint($debuggeeId, $breakpoint, $clientVersion, $optiona * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -319,7 +274,7 @@ public function setBreakpoint($debuggeeId, $breakpoint, $clientVersion, $optiona * * @return \Google\Cloud\Debugger\V2\GetBreakpointResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function getBreakpoint($debuggeeId, $breakpointId, $clientVersion, $optionalArgs = []) @@ -329,24 +284,12 @@ public function getBreakpoint($debuggeeId, $breakpointId, $clientVersion, $optio $request->setBreakpointId($breakpointId); $request->setClientVersion($clientVersion); - $defaultCallSettings = $this->defaultCallSettings['getBreakpoint']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->debugger2Stub, + return $this->startCall( 'GetBreakpoint', - $mergedSettings, - $this->descriptors['getBreakpoint'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + GetBreakpointResponse::class, + $optionalArgs, + $request + )->wait(); } /** @@ -372,14 +315,14 @@ public function getBreakpoint($debuggeeId, $breakpointId, $clientVersion, $optio * @param array $optionalArgs { * Optional. * - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function deleteBreakpoint($debuggeeId, $breakpointId, $clientVersion, $optionalArgs = []) @@ -389,24 +332,12 @@ public function deleteBreakpoint($debuggeeId, $breakpointId, $clientVersion, $op $request->setBreakpointId($breakpointId); $request->setClientVersion($clientVersion); - $defaultCallSettings = $this->defaultCallSettings['deleteBreakpoint']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->debugger2Stub, + return $this->startCall( 'DeleteBreakpoint', - $mergedSettings, - $this->descriptors['deleteBreakpoint'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + GPBEmpty::class, + $optionalArgs, + $request + )->wait(); } /** @@ -436,7 +367,7 @@ public function deleteBreakpoint($debuggeeId, $breakpointId, $clientVersion, $op * @type bool $includeInactive * When set to `true`, the response includes active and inactive * breakpoints. Otherwise, it includes only active breakpoints. - * @type BreakpointActionValue $action + * @type ListBreakpointsRequest_BreakpointActionValue $action * When set, the response includes only breakpoints with the specified action. * @type bool $stripResults * This field is deprecated. The following fields are always stripped out of @@ -447,7 +378,7 @@ public function deleteBreakpoint($debuggeeId, $breakpointId, $clientVersion, $op * should be set from the last response. The error code * `google.rpc.Code.ABORTED` (RPC) is returned on wait timeout, which * should be called again with the same `wait_token`. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -456,7 +387,7 @@ public function deleteBreakpoint($debuggeeId, $breakpointId, $clientVersion, $op * * @return \Google\Cloud\Debugger\V2\ListBreakpointsResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listBreakpoints($debuggeeId, $clientVersion, $optionalArgs = []) @@ -480,24 +411,12 @@ public function listBreakpoints($debuggeeId, $clientVersion, $optionalArgs = []) $request->setWaitToken($optionalArgs['waitToken']); } - $defaultCallSettings = $this->defaultCallSettings['listBreakpoints']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->debugger2Stub, + return $this->startCall( 'ListBreakpoints', - $mergedSettings, - $this->descriptors['listBreakpoints'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); + ListBreakpointsResponse::class, + $optionalArgs, + $request + )->wait(); } /** @@ -524,7 +443,7 @@ public function listBreakpoints($debuggeeId, $clientVersion, $optionalArgs = []) * @type bool $includeInactive * When set to `true`, the result includes all debuggees. Otherwise, the * result includes only debuggees that are active. - * @type \Google\ApiCore\RetrySettings|array $retrySettings + * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a * {@see Google\ApiCore\RetrySettings} object, or an associative array * of retry settings parameters. See the documentation on @@ -533,7 +452,7 @@ public function listBreakpoints($debuggeeId, $clientVersion, $optionalArgs = []) * * @return \Google\Cloud\Debugger\V2\ListDebuggeesResponse * - * @throws \Google\ApiCore\ApiException if the remote call fails + * @throws ApiException if the remote call fails * @experimental */ public function listDebuggees($project, $clientVersion, $optionalArgs = []) @@ -545,39 +464,11 @@ public function listDebuggees($project, $clientVersion, $optionalArgs = []) $request->setIncludeInactive($optionalArgs['includeInactive']); } - $defaultCallSettings = $this->defaultCallSettings['listDebuggees']; - if (isset($optionalArgs['retrySettings']) && is_array($optionalArgs['retrySettings'])) { - $optionalArgs['retrySettings'] = $defaultCallSettings->getRetrySettings()->with( - $optionalArgs['retrySettings'] - ); - } - $mergedSettings = $defaultCallSettings->merge(new CallSettings($optionalArgs)); - $callable = ApiCallable::createApiCall( - $this->debugger2Stub, + return $this->startCall( 'ListDebuggees', - $mergedSettings, - $this->descriptors['listDebuggees'] - ); - - return $callable( - $request, - [], - ['call_credentials_callback' => $this->createCredentialsCallback()]); - } - - /** - * Initiates an orderly shutdown in which preexisting calls continue but new - * calls are immediately cancelled. - * - * @experimental - */ - public function close() - { - $this->debugger2Stub->close(); - } - - private function createCredentialsCallback() - { - return $this->grpcCredentialsHelper->createCallCredentialsCallback(); + ListDebuggeesResponse::class, + $optionalArgs, + $request + )->wait(); } } diff --git a/src/Debugger/V2/resources/controller2_descriptor_config.php b/src/Debugger/V2/resources/controller2_descriptor_config.php new file mode 100644 index 000000000000..c3678b97bcc0 --- /dev/null +++ b/src/Debugger/V2/resources/controller2_descriptor_config.php @@ -0,0 +1,8 @@ + [ + 'google.devtools.clouddebugger.v2.Controller2' => [ + ], + ], +]; diff --git a/src/Debugger/V2/resources/controller2_rest_client_config.php b/src/Debugger/V2/resources/controller2_rest_client_config.php new file mode 100644 index 000000000000..f426fc42d18e --- /dev/null +++ b/src/Debugger/V2/resources/controller2_rest_client_config.php @@ -0,0 +1,42 @@ + [ + 'google.devtools.clouddebugger.v2.Controller2' => [ + 'RegisterDebuggee' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/controller/debuggees/register', + 'body' => '*', + ], + 'ListActiveBreakpoints' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/controller/debuggees/{debuggee_id}/breakpoints', + 'placeholders' => [ + 'debuggee_id' => [ + 'getters' => [ + 'getDebuggeeId', + ], + ], + ], + ], + 'UpdateActiveBreakpoint' => [ + 'method' => 'put', + 'uriTemplate' => '/v2/controller/debuggees/{debuggee_id}/breakpoints/{breakpoint.id}', + 'body' => '*', + 'placeholders' => [ + 'debuggee_id' => [ + 'getters' => [ + 'getDebuggeeId', + ], + ], + 'breakpoint.id' => [ + 'getters' => [ + 'getBreakpoint', + 'getId', + ], + ], + ], + ], + ], + ], +]; diff --git a/src/Debugger/V2/resources/debugger2_descriptor_config.php b/src/Debugger/V2/resources/debugger2_descriptor_config.php new file mode 100644 index 000000000000..6aa6f538fd28 --- /dev/null +++ b/src/Debugger/V2/resources/debugger2_descriptor_config.php @@ -0,0 +1,8 @@ + [ + 'google.devtools.clouddebugger.v2.Debugger2' => [ + ], + ], +]; diff --git a/src/Debugger/V2/resources/debugger2_rest_client_config.php b/src/Debugger/V2/resources/debugger2_rest_client_config.php new file mode 100644 index 000000000000..a99fdf4c315a --- /dev/null +++ b/src/Debugger/V2/resources/debugger2_rest_client_config.php @@ -0,0 +1,67 @@ + [ + 'google.devtools.clouddebugger.v2.Debugger2' => [ + 'SetBreakpoint' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/debugger/debuggees/{debuggee_id}/breakpoints/set', + 'body' => 'breakpoint', + 'placeholders' => [ + 'debuggee_id' => [ + 'getters' => [ + 'getDebuggeeId', + ], + ], + ], + ], + 'GetBreakpoint' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/debugger/debuggees/{debuggee_id}/breakpoints/{breakpoint_id}', + 'placeholders' => [ + 'debuggee_id' => [ + 'getters' => [ + 'getDebuggeeId', + ], + ], + 'breakpoint_id' => [ + 'getters' => [ + 'getBreakpointId', + ], + ], + ], + ], + 'DeleteBreakpoint' => [ + 'method' => 'delete', + 'uriTemplate' => '/v2/debugger/debuggees/{debuggee_id}/breakpoints/{breakpoint_id}', + 'placeholders' => [ + 'debuggee_id' => [ + 'getters' => [ + 'getDebuggeeId', + ], + ], + 'breakpoint_id' => [ + 'getters' => [ + 'getBreakpointId', + ], + ], + ], + ], + 'ListBreakpoints' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/debugger/debuggees/{debuggee_id}/breakpoints', + 'placeholders' => [ + 'debuggee_id' => [ + 'getters' => [ + 'getDebuggeeId', + ], + ], + ], + ], + 'ListDebuggees' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/debugger/debuggees', + ], + ], + ], +]; From f5c9bb97e62753380a22079fb7d24ed30349511e Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Mon, 22 Jan 2018 09:13:36 -0500 Subject: [PATCH 18/21] remove auth dependency, as it is already required by GAX --- src/Core/composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Core/composer.json b/src/Core/composer.json index 82d2be0c5acb..c77b3e81db61 100644 --- a/src/Core/composer.json +++ b/src/Core/composer.json @@ -6,7 +6,6 @@ "require": { "php": ">=5.5", "rize/uri-template": "~0.3", - "google/auth": "~0.9|^1.0", "guzzlehttp/guzzle": "^5.3|^6.0", "guzzlehttp/psr7": "^1.2", "monolog/monolog": "~1", From 89158b1ffd7ed7a1fcf8357748fd2a86ddf11d26 Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Mon, 22 Jan 2018 15:23:36 -0500 Subject: [PATCH 19/21] rely on proto-client-php ^0.31 --- composer.json | 2 +- src/Bigtable/composer.json | 3 +-- src/Container/composer.json | 3 +-- src/Dataproc/composer.json | 3 +-- src/Dlp/composer.json | 3 +-- src/ErrorReporting/composer.json | 2 +- src/Firestore/composer.json | 2 +- src/Language/composer.json | 2 +- src/Logging/composer.json | 2 +- src/Monitoring/composer.json | 3 +-- src/OsLogin/composer.json | 3 +-- src/PubSub/composer.json | 2 +- src/Spanner/composer.json | 2 +- src/Speech/composer.json | 2 +- src/Trace/composer.json | 2 +- src/VideoIntelligence/composer.json | 3 +-- src/Vision/composer.json | 2 +- 17 files changed, 17 insertions(+), 24 deletions(-) diff --git a/composer.json b/composer.json index 75805922421b..939ad8bd3ce9 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "monolog/monolog": "~1", "psr/http-message": "1.0.*", "ramsey/uuid": "~3", - "google/proto-client": "^0.30.0", + "google/proto-client": "^0.31", "google/gax": "dev-json-transport" }, "require-dev": { diff --git a/src/Bigtable/composer.json b/src/Bigtable/composer.json index eb935053395a..a97ad62a9079 100644 --- a/src/Bigtable/composer.json +++ b/src/Bigtable/composer.json @@ -4,8 +4,7 @@ "license": "Apache-2.0", "minimum-stability": "stable", "require": { - "ext-grpc": "*", - "google/proto-client": "^0.30", + "google/proto-client": "^0.31", "google/gax": "^0.29" }, "suggest": { diff --git a/src/Container/composer.json b/src/Container/composer.json index 1f99885fa937..b3d2b1df831c 100644 --- a/src/Container/composer.json +++ b/src/Container/composer.json @@ -17,8 +17,7 @@ } }, "require": { - "ext-grpc": "*", - "google/proto-client": "^0.30.0", + "google/proto-client": "^0.31", "google/gax": "^0.29" } } diff --git a/src/Dataproc/composer.json b/src/Dataproc/composer.json index 1901c65133b7..58338bd1d355 100644 --- a/src/Dataproc/composer.json +++ b/src/Dataproc/composer.json @@ -17,8 +17,7 @@ } }, "require": { - "ext-grpc": "*", - "google/proto-client": "^0.30.0", + "google/proto-client": "^0.31", "google/gax": "^0.29" }, "suggest": { diff --git a/src/Dlp/composer.json b/src/Dlp/composer.json index 65cde528eb9e..710600e6bd1c 100644 --- a/src/Dlp/composer.json +++ b/src/Dlp/composer.json @@ -4,8 +4,7 @@ "license": "Apache-2.0", "minimum-stability": "stable", "require": { - "ext-grpc": "*", - "google/proto-client": "^0.30", + "google/proto-client": "^0.31", "google/gax": "^0.29" }, "suggest": { diff --git a/src/ErrorReporting/composer.json b/src/ErrorReporting/composer.json index abe76f5da3ac..729ea40cff71 100644 --- a/src/ErrorReporting/composer.json +++ b/src/ErrorReporting/composer.json @@ -5,7 +5,7 @@ "minimum-stability": "stable", "require": { "google/cloud-logging": "^1.5.0", - "google/proto-client": "^0.30", + "google/proto-client": "^0.31", "google/gax": "^0.29" }, "suggest": { diff --git a/src/Firestore/composer.json b/src/Firestore/composer.json index 1b9f9307da74..6c21e2ef88d5 100644 --- a/src/Firestore/composer.json +++ b/src/Firestore/composer.json @@ -7,7 +7,7 @@ "ext-grpc": "*", "google/cloud-core": "^1.14", "google/gax": "^0.29", - "google/proto-client": "^0.30", + "google/proto-client": "^0.31", "ramsey/uuid": "~3" }, "suggest": { diff --git a/src/Language/composer.json b/src/Language/composer.json index 21167bd8715a..af02dc0e7205 100644 --- a/src/Language/composer.json +++ b/src/Language/composer.json @@ -5,7 +5,7 @@ "minimum-stability": "stable", "require": { "google/cloud-core": "^1.14", - "google/proto-client": "^0.30", + "google/proto-client": "^0.31", "google/gax": "^0.29" }, "suggest": { diff --git a/src/Logging/composer.json b/src/Logging/composer.json index 93fb1f940e5f..6fe1cd0547f3 100644 --- a/src/Logging/composer.json +++ b/src/Logging/composer.json @@ -5,7 +5,7 @@ "minimum-stability": "stable", "require": { "google/cloud-core": "^1.14", - "google/proto-client": "^0.30", + "google/proto-client": "^0.31", "google/gax": "^0.29" }, "suggest": { diff --git a/src/Monitoring/composer.json b/src/Monitoring/composer.json index f03770643dd6..4905d8e42724 100644 --- a/src/Monitoring/composer.json +++ b/src/Monitoring/composer.json @@ -4,8 +4,7 @@ "license": "Apache-2.0", "minimum-stability": "stable", "require": { - "ext-grpc": "*", - "google/proto-client": "^0.30", + "google/proto-client": "^0.31", "google/gax": "^0.29" }, "suggest": { diff --git a/src/OsLogin/composer.json b/src/OsLogin/composer.json index f0c44dda68d0..62c4fab396a1 100644 --- a/src/OsLogin/composer.json +++ b/src/OsLogin/composer.json @@ -17,8 +17,7 @@ } }, "require": { - "ext-grpc": "*", - "google/proto-client": "^0.30.0", + "google/proto-client": "^0.31", "google/gax": "^0.29" }, "suggest": { diff --git a/src/PubSub/composer.json b/src/PubSub/composer.json index 70021118a53d..ce99ea6aca4f 100644 --- a/src/PubSub/composer.json +++ b/src/PubSub/composer.json @@ -5,7 +5,7 @@ "minimum-stability": "stable", "require": { "google/cloud-core": "^1.14", - "google/proto-client": "^0.30", + "google/proto-client": "^0.31", "google/gax": "^0.29" }, "suggest": { diff --git a/src/Spanner/composer.json b/src/Spanner/composer.json index b5feb17d3638..d17174a03cf0 100644 --- a/src/Spanner/composer.json +++ b/src/Spanner/composer.json @@ -7,7 +7,7 @@ "ext-grpc": "*", "google/cloud-core": "^1.14", "google/gax": "^0.29", - "google/proto-client": "^0.30" + "google/proto-client": "^0.31" }, "suggest": { "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." diff --git a/src/Speech/composer.json b/src/Speech/composer.json index e8e7f74049ee..3c367ec1e735 100644 --- a/src/Speech/composer.json +++ b/src/Speech/composer.json @@ -5,7 +5,7 @@ "minimum-stability": "stable", "require": { "google/cloud-core": "^1.14", - "google/proto-client": "^0.30", + "google/proto-client": "^0.31", "google/gax": "^0.29" }, "suggest": { diff --git a/src/Trace/composer.json b/src/Trace/composer.json index c161cf2f8330..9dd2b31ce7bd 100644 --- a/src/Trace/composer.json +++ b/src/Trace/composer.json @@ -7,7 +7,7 @@ "google/cloud-core": "^1.14", "ramsey/uuid": "~3", "google/gax": "^0.29", - "google/proto-client": "^0.30.0" + "google/proto-client": "^0.31" }, "suggest": { "ext-grpc": "The gRPC extension enables use of the performant gRPC transport", diff --git a/src/VideoIntelligence/composer.json b/src/VideoIntelligence/composer.json index 406737dff460..6d64b484f4a1 100644 --- a/src/VideoIntelligence/composer.json +++ b/src/VideoIntelligence/composer.json @@ -4,8 +4,7 @@ "license": "Apache-2.0", "minimum-stability": "stable", "require": { - "ext-grpc": "*", - "google/proto-client": "^0.30", + "google/proto-client": "^0.31", "google/gax": "^0.29" }, "suggest": { diff --git a/src/Vision/composer.json b/src/Vision/composer.json index f2b0f7f4df49..b52019740496 100644 --- a/src/Vision/composer.json +++ b/src/Vision/composer.json @@ -5,7 +5,7 @@ "minimum-stability": "stable", "require": { "google/cloud-core": "^1.14", - "google/proto-client": "^0.30", + "google/proto-client": "^0.31", "google/gax": "^0.29" }, "suggest": { From 2030219e3a8eedfc1194a20708bb070b3c9d5eba Mon Sep 17 00:00:00 2001 From: Dave Supplee Date: Mon, 22 Jan 2018 15:29:51 -0500 Subject: [PATCH 20/21] use correct copyright year --- src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php | 2 +- src/Bigtable/Admin/V2/BigtableTableAdminClient.php | 2 +- .../Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php | 2 +- src/Bigtable/Admin/V2/Gapic/BigtableTableAdminGapicClient.php | 2 +- src/Bigtable/V2/BigtableClient.php | 2 +- src/Bigtable/V2/Gapic/BigtableGapicClient.php | 2 +- src/Container/V1/ClusterManagerClient.php | 2 +- src/Container/V1/Gapic/ClusterManagerGapicClient.php | 2 +- src/Dataproc/V1/ClusterControllerClient.php | 2 +- src/Dataproc/V1/Gapic/ClusterControllerGapicClient.php | 2 +- src/Dataproc/V1/Gapic/JobControllerGapicClient.php | 2 +- src/Dataproc/V1/JobControllerClient.php | 2 +- src/Dlp/V2beta1/DlpServiceClient.php | 2 +- src/Dlp/V2beta1/Gapic/DlpServiceGapicClient.php | 2 +- src/ErrorReporting/V1beta1/ErrorGroupServiceClient.php | 2 +- src/ErrorReporting/V1beta1/ErrorStatsServiceClient.php | 2 +- .../V1beta1/Gapic/ErrorGroupServiceGapicClient.php | 2 +- .../V1beta1/Gapic/ErrorStatsServiceGapicClient.php | 2 +- .../V1beta1/Gapic/ReportErrorsServiceGapicClient.php | 2 +- src/ErrorReporting/V1beta1/ReportErrorsServiceClient.php | 2 +- src/Firestore/V1beta1/FirestoreClient.php | 2 +- src/Firestore/V1beta1/Gapic/FirestoreGapicClient.php | 2 +- src/Language/V1beta2/Gapic/LanguageServiceGapicClient.php | 2 +- src/Language/V1beta2/LanguageServiceClient.php | 2 +- src/Logging/V2/ConfigServiceV2Client.php | 2 +- src/Logging/V2/Gapic/ConfigServiceV2GapicClient.php | 2 +- src/Logging/V2/Gapic/LoggingServiceV2GapicClient.php | 2 +- src/Logging/V2/Gapic/MetricsServiceV2GapicClient.php | 2 +- src/Logging/V2/LoggingServiceV2Client.php | 2 +- src/Logging/V2/MetricsServiceV2Client.php | 2 +- src/Monitoring/V3/Gapic/GroupServiceGapicClient.php | 2 +- src/Monitoring/V3/Gapic/MetricServiceGapicClient.php | 2 +- src/Monitoring/V3/Gapic/UptimeCheckServiceGapicClient.php | 2 +- src/Monitoring/V3/GroupServiceClient.php | 2 +- src/Monitoring/V3/MetricServiceClient.php | 2 +- src/Monitoring/V3/UptimeCheckServiceClient.php | 2 +- src/OsLogin/V1beta/Gapic/OsLoginServiceGapicClient.php | 2 +- src/OsLogin/V1beta/OsLoginServiceClient.php | 2 +- src/PubSub/V1/Gapic/PublisherGapicClient.php | 2 +- src/PubSub/V1/Gapic/SubscriberGapicClient.php | 2 +- src/PubSub/V1/PublisherClient.php | 2 +- src/PubSub/V1/SubscriberClient.php | 2 +- src/Spanner/Admin/Database/V1/DatabaseAdminClient.php | 2 +- .../Admin/Database/V1/Gapic/DatabaseAdminGapicClient.php | 2 +- .../Admin/Instance/V1/Gapic/InstanceAdminGapicClient.php | 2 +- src/Spanner/Admin/Instance/V1/InstanceAdminClient.php | 2 +- src/Spanner/V1/Gapic/SpannerGapicClient.php | 2 +- src/Spanner/V1/SpannerClient.php | 2 +- src/Speech/V1/Gapic/SpeechGapicClient.php | 2 +- src/Speech/V1/SpeechClient.php | 2 +- src/Speech/V1beta1/Gapic/SpeechGapicClient.php | 2 +- src/Speech/V1beta1/SpeechClient.php | 2 +- src/Trace/V2/Gapic/TraceServiceGapicClient.php | 2 +- src/Trace/V2/TraceServiceClient.php | 2 +- .../V1/Gapic/VideoIntelligenceServiceGapicClient.php | 2 +- src/VideoIntelligence/V1/VideoIntelligenceServiceClient.php | 2 +- .../V1beta1/Gapic/VideoIntelligenceServiceGapicClient.php | 2 +- .../V1beta1/VideoIntelligenceServiceClient.php | 2 +- .../V1beta2/Gapic/VideoIntelligenceServiceGapicClient.php | 2 +- .../V1beta2/VideoIntelligenceServiceClient.php | 2 +- src/Vision/V1/Gapic/ImageAnnotatorGapicClient.php | 2 +- src/Vision/V1/ImageAnnotatorClient.php | 2 +- 62 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php b/src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php index 547029fba7cb..4c8c2a25793e 100644 --- a/src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php +++ b/src/Bigtable/Admin/V2/BigtableInstanceAdminClient.php @@ -1,6 +1,6 @@ Date: Mon, 22 Jan 2018 16:48:08 -0500 Subject: [PATCH 21/21] pin to gax 0.30 --- composer.json | 2 +- src/Bigtable/composer.json | 2 +- src/Container/composer.json | 2 +- src/Dataproc/composer.json | 2 +- src/Dlp/composer.json | 2 +- src/ErrorReporting/composer.json | 2 +- src/Firestore/composer.json | 2 +- src/Language/composer.json | 2 +- src/Logging/composer.json | 2 +- src/Monitoring/composer.json | 2 +- src/OsLogin/composer.json | 2 +- src/PubSub/composer.json | 2 +- src/Spanner/composer.json | 2 +- src/Speech/composer.json | 2 +- src/Trace/composer.json | 2 +- src/VideoIntelligence/composer.json | 2 +- src/Vision/composer.json | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index 939ad8bd3ce9..f50962d94428 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,7 @@ "psr/http-message": "1.0.*", "ramsey/uuid": "~3", "google/proto-client": "^0.31", - "google/gax": "dev-json-transport" + "google/gax": "^0.30" }, "require-dev": { "phpunit/phpunit": "^4.8|^5.0", diff --git a/src/Bigtable/composer.json b/src/Bigtable/composer.json index a97ad62a9079..6bf2bc202175 100644 --- a/src/Bigtable/composer.json +++ b/src/Bigtable/composer.json @@ -5,7 +5,7 @@ "minimum-stability": "stable", "require": { "google/proto-client": "^0.31", - "google/gax": "^0.29" + "google/gax": "^0.30" }, "suggest": { "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." diff --git a/src/Container/composer.json b/src/Container/composer.json index b3d2b1df831c..22320e31aab6 100644 --- a/src/Container/composer.json +++ b/src/Container/composer.json @@ -18,6 +18,6 @@ }, "require": { "google/proto-client": "^0.31", - "google/gax": "^0.29" + "google/gax": "^0.30" } } diff --git a/src/Dataproc/composer.json b/src/Dataproc/composer.json index 58338bd1d355..d447e7b54a77 100644 --- a/src/Dataproc/composer.json +++ b/src/Dataproc/composer.json @@ -18,7 +18,7 @@ }, "require": { "google/proto-client": "^0.31", - "google/gax": "^0.29" + "google/gax": "^0.30" }, "suggest": { "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." diff --git a/src/Dlp/composer.json b/src/Dlp/composer.json index 710600e6bd1c..ab21c4e3d350 100644 --- a/src/Dlp/composer.json +++ b/src/Dlp/composer.json @@ -5,7 +5,7 @@ "minimum-stability": "stable", "require": { "google/proto-client": "^0.31", - "google/gax": "^0.29" + "google/gax": "^0.30" }, "suggest": { "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." diff --git a/src/ErrorReporting/composer.json b/src/ErrorReporting/composer.json index 729ea40cff71..09948de5ac5f 100644 --- a/src/ErrorReporting/composer.json +++ b/src/ErrorReporting/composer.json @@ -6,7 +6,7 @@ "require": { "google/cloud-logging": "^1.5.0", "google/proto-client": "^0.31", - "google/gax": "^0.29" + "google/gax": "^0.30" }, "suggest": { "ext-grpc": "The gRPC extension allows more granular control over Error Reporting", diff --git a/src/Firestore/composer.json b/src/Firestore/composer.json index 6c21e2ef88d5..56574d0bb20b 100644 --- a/src/Firestore/composer.json +++ b/src/Firestore/composer.json @@ -6,7 +6,7 @@ "require": { "ext-grpc": "*", "google/cloud-core": "^1.14", - "google/gax": "^0.29", + "google/gax": "^0.30", "google/proto-client": "^0.31", "ramsey/uuid": "~3" }, diff --git a/src/Language/composer.json b/src/Language/composer.json index af02dc0e7205..93d28ef6ea6b 100644 --- a/src/Language/composer.json +++ b/src/Language/composer.json @@ -6,7 +6,7 @@ "require": { "google/cloud-core": "^1.14", "google/proto-client": "^0.31", - "google/gax": "^0.29" + "google/gax": "^0.30" }, "suggest": { "google/cloud-storage": "Analyze documents stored in Google Cloud Storage", diff --git a/src/Logging/composer.json b/src/Logging/composer.json index 6fe1cd0547f3..80b4274f9feb 100644 --- a/src/Logging/composer.json +++ b/src/Logging/composer.json @@ -6,7 +6,7 @@ "require": { "google/cloud-core": "^1.14", "google/proto-client": "^0.31", - "google/gax": "^0.29" + "google/gax": "^0.30" }, "suggest": { "ext-grpc": "The gRPC extension enables use of the performant gRPC transport", diff --git a/src/Monitoring/composer.json b/src/Monitoring/composer.json index 4905d8e42724..81942c72479e 100644 --- a/src/Monitoring/composer.json +++ b/src/Monitoring/composer.json @@ -5,7 +5,7 @@ "minimum-stability": "stable", "require": { "google/proto-client": "^0.31", - "google/gax": "^0.29" + "google/gax": "^0.30" }, "suggest": { "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." diff --git a/src/OsLogin/composer.json b/src/OsLogin/composer.json index 62c4fab396a1..3bdf479c23fb 100644 --- a/src/OsLogin/composer.json +++ b/src/OsLogin/composer.json @@ -18,7 +18,7 @@ }, "require": { "google/proto-client": "^0.31", - "google/gax": "^0.29" + "google/gax": "^0.30" }, "suggest": { "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." diff --git a/src/PubSub/composer.json b/src/PubSub/composer.json index ce99ea6aca4f..a405b40365c6 100644 --- a/src/PubSub/composer.json +++ b/src/PubSub/composer.json @@ -6,7 +6,7 @@ "require": { "google/cloud-core": "^1.14", "google/proto-client": "^0.31", - "google/gax": "^0.29" + "google/gax": "^0.30" }, "suggest": { "ext-grpc": "The gRPC extension enables use of the performant gRPC transport", diff --git a/src/Spanner/composer.json b/src/Spanner/composer.json index d17174a03cf0..2a54aea6a9f7 100644 --- a/src/Spanner/composer.json +++ b/src/Spanner/composer.json @@ -6,7 +6,7 @@ "require": { "ext-grpc": "*", "google/cloud-core": "^1.14", - "google/gax": "^0.29", + "google/gax": "^0.30", "google/proto-client": "^0.31" }, "suggest": { diff --git a/src/Speech/composer.json b/src/Speech/composer.json index 3c367ec1e735..3e174514f362 100644 --- a/src/Speech/composer.json +++ b/src/Speech/composer.json @@ -6,7 +6,7 @@ "require": { "google/cloud-core": "^1.14", "google/proto-client": "^0.31", - "google/gax": "^0.29" + "google/gax": "^0.30" }, "suggest": { "ext-grpc": "The gRPC extension enables use of the performant gRPC transport", diff --git a/src/Trace/composer.json b/src/Trace/composer.json index 9dd2b31ce7bd..6473ae722127 100644 --- a/src/Trace/composer.json +++ b/src/Trace/composer.json @@ -6,7 +6,7 @@ "require": { "google/cloud-core": "^1.14", "ramsey/uuid": "~3", - "google/gax": "^0.29", + "google/gax": "^0.30", "google/proto-client": "^0.31" }, "suggest": { diff --git a/src/VideoIntelligence/composer.json b/src/VideoIntelligence/composer.json index 6d64b484f4a1..5761c99e02e6 100644 --- a/src/VideoIntelligence/composer.json +++ b/src/VideoIntelligence/composer.json @@ -5,7 +5,7 @@ "minimum-stability": "stable", "require": { "google/proto-client": "^0.31", - "google/gax": "^0.29" + "google/gax": "^0.30" }, "suggest": { "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." diff --git a/src/Vision/composer.json b/src/Vision/composer.json index b52019740496..58890dadffab 100644 --- a/src/Vision/composer.json +++ b/src/Vision/composer.json @@ -6,7 +6,7 @@ "require": { "google/cloud-core": "^1.14", "google/proto-client": "^0.31", - "google/gax": "^0.29" + "google/gax": "^0.30" }, "suggest": { "ext-grpc": "The gRPC extension enables use of the performant gRPC transport",