From d65cd6e5cbf8ee5b68e4b09a3700117889cc0584 Mon Sep 17 00:00:00 2001 From: Michael Bausor Date: Fri, 19 May 2017 09:26:05 -0700 Subject: [PATCH 1/4] Update spanner gapic --- .../Admin/Database/V1/DatabaseAdminClient.php | 39 +++++++++------- .../database_admin_client_config.json | 14 +++--- .../Admin/Instance/V1/InstanceAdminClient.php | 37 +++++++++------ .../instance_admin_client_config.json | 14 +++--- src/Spanner/V1/SpannerClient.php | 45 ++++++++++--------- .../V1/resources/spanner_client_config.json | 14 +++--- 6 files changed, 93 insertions(+), 70 deletions(-) diff --git a/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php b/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php index 332d10cc7728..a0eaf8ea8acb 100644 --- a/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php +++ b/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php @@ -1,6 +1,6 @@ RetryOptions, where the keys * are method names (e.g. 'createFoo'), that overrides default retrying @@ -310,9 +321,6 @@ public function resumeOperation($operationName, $methodName = null) * that don't use retries. For calls that use retries, * set the timeout in RetryOptions. * Default: 30000 (30 seconds) - * @type string $appName The codename of the calling service. Default 'gax'. - * @type string $appVersion The version of the calling service. - * Default: the current version of GAX. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the * Google\Auth library. @@ -329,8 +337,8 @@ public function __construct($options = []) ], 'retryingOverride' => null, 'timeoutMillis' => self::DEFAULT_TIMEOUT_MILLIS, - 'appName' => 'gax', - 'appVersion' => AgentHeaderDescriptor::getGaxVersion(), + 'libName' => null, + 'libVersion' => null, ]; $options = array_merge($defaultOptions, $options); @@ -340,16 +348,17 @@ public function __construct($options = []) $this->operationsClient = new OperationsClient([ 'serviceAddress' => $options['serviceAddress'], 'scopes' => $options['scopes'], + 'libName' => $options['libName'], + 'libVersion' => $options['libVersion'], ]); } + $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); + $headerDescriptor = new AgentHeaderDescriptor([ - 'clientName' => $options['appName'], - 'clientVersion' => $options['appVersion'], - 'codeGenName' => self::CODEGEN_NAME, - 'codeGenVersion' => self::CODEGEN_VERSION, - 'gaxVersion' => AgentHeaderDescriptor::getGaxVersion(), - 'phpVersion' => phpversion(), + 'libName' => $options['libName'], + 'libVersion' => $options['libVersion'], + 'gapicVersion' => $gapicVersion, ]); $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; @@ -701,7 +710,7 @@ public function getDatabase($name, $optionalArgs = []) * [longrunning.Operation][google.longrunning.Operation]: `/operations/`. * * `operation_id` should be unique within the database, and must be - * a valid identifier: `[a-zA-Z][a-zA-Z0-9_]*`. Note that + * a valid identifier: `[a-z][a-z0-9_]*`. Note that * automatically-generated operation IDs always begin with an * underscore. If the named operation already exists, * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] returns diff --git a/src/Spanner/Admin/Database/V1/resources/database_admin_client_config.json b/src/Spanner/Admin/Database/V1/resources/database_admin_client_config.json index efa919a0a7d8..bba6763e0100 100644 --- a/src/Spanner/Admin/Database/V1/resources/database_admin_client_config.json +++ b/src/Spanner/Admin/Database/V1/resources/database_admin_client_config.json @@ -2,13 +2,13 @@ "interfaces": { "google.spanner.admin.database.v1.DatabaseAdmin": { "retry_codes": { - "retry_codes_def": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "non_idempotent": [] - } + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [ + "UNAVAILABLE" + ] }, "retry_params": { "default": { diff --git a/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php b/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php index bb7d0a10b257..7cdcf173eef0 100644 --- a/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php +++ b/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php @@ -1,6 +1,6 @@ RetryOptions, where the keys * are method names (e.g. 'createFoo'), that overrides default retrying @@ -356,9 +367,6 @@ public function resumeOperation($operationName, $methodName = null) * that don't use retries. For calls that use retries, * set the timeout in RetryOptions. * Default: 30000 (30 seconds) - * @type string $appName The codename of the calling service. Default 'gax'. - * @type string $appVersion The version of the calling service. - * Default: the current version of GAX. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the * Google\Auth library. @@ -375,8 +383,8 @@ public function __construct($options = []) ], 'retryingOverride' => null, 'timeoutMillis' => self::DEFAULT_TIMEOUT_MILLIS, - 'appName' => 'gax', - 'appVersion' => AgentHeaderDescriptor::getGaxVersion(), + 'libName' => null, + 'libVersion' => null, ]; $options = array_merge($defaultOptions, $options); @@ -386,16 +394,17 @@ public function __construct($options = []) $this->operationsClient = new OperationsClient([ 'serviceAddress' => $options['serviceAddress'], 'scopes' => $options['scopes'], + 'libName' => $options['libName'], + 'libVersion' => $options['libVersion'], ]); } + $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); + $headerDescriptor = new AgentHeaderDescriptor([ - 'clientName' => $options['appName'], - 'clientVersion' => $options['appVersion'], - 'codeGenName' => self::CODEGEN_NAME, - 'codeGenVersion' => self::CODEGEN_VERSION, - 'gaxVersion' => AgentHeaderDescriptor::getGaxVersion(), - 'phpVersion' => phpversion(), + 'libName' => $options['libName'], + 'libVersion' => $options['libVersion'], + 'gapicVersion' => $gapicVersion, ]); $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; diff --git a/src/Spanner/Admin/Instance/V1/resources/instance_admin_client_config.json b/src/Spanner/Admin/Instance/V1/resources/instance_admin_client_config.json index 23dbca4fe655..c438b46bd79a 100644 --- a/src/Spanner/Admin/Instance/V1/resources/instance_admin_client_config.json +++ b/src/Spanner/Admin/Instance/V1/resources/instance_admin_client_config.json @@ -2,13 +2,13 @@ "interfaces": { "google.spanner.admin.instance.v1.InstanceAdmin": { "retry_codes": { - "retry_codes_def": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "non_idempotent": [] - } + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [ + "UNAVAILABLE" + ] }, "retry_params": { "default": { diff --git a/src/Spanner/V1/SpannerClient.php b/src/Spanner/V1/SpannerClient.php index 21f8dc2bdfbe..55417e52e6f6 100644 --- a/src/Spanner/V1/SpannerClient.php +++ b/src/Spanner/V1/SpannerClient.php @@ -1,6 +1,6 @@ RetryOptions, where the keys * are method names (e.g. 'createFoo'), that overrides default retrying @@ -261,9 +271,6 @@ private static function getGrpcStreamingDescriptors() * that don't use retries. For calls that use retries, * set the timeout in RetryOptions. * Default: 30000 (30 seconds) - * @type string $appName The codename of the calling service. Default 'gax'. - * @type string $appVersion The version of the calling service. - * Default: the current version of GAX. * @type \Google\Auth\CredentialsLoader $credentialsLoader * A CredentialsLoader object created using the * Google\Auth library. @@ -280,18 +287,17 @@ public function __construct($options = []) ], 'retryingOverride' => null, 'timeoutMillis' => self::DEFAULT_TIMEOUT_MILLIS, - 'appName' => 'gax', - 'appVersion' => AgentHeaderDescriptor::getGaxVersion(), + 'libName' => null, + 'libVersion' => null, ]; $options = array_merge($defaultOptions, $options); + $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); + $headerDescriptor = new AgentHeaderDescriptor([ - 'clientName' => $options['appName'], - 'clientVersion' => $options['appVersion'], - 'codeGenName' => self::CODEGEN_NAME, - 'codeGenVersion' => self::CODEGEN_VERSION, - 'gaxVersion' => AgentHeaderDescriptor::getGaxVersion(), - 'phpVersion' => phpversion(), + 'libName' => $options['libName'], + 'libVersion' => $options['libVersion'], + 'gapicVersion' => $gapicVersion, ]); $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; @@ -360,10 +366,9 @@ public function __construct($options = []) * * Cloud Spanner limits the number of sessions that can exist at any given * time; thus, it is a good idea to delete idle and/or unneeded sessions. - * Aside from explicit deletes, Cloud Spanner can delete sessions for - * which no operations are sent for more than an hour, or due to - * internal errors. If a session is deleted, requests to it - * return `NOT_FOUND`. + * Aside from explicit deletes, Cloud Spanner can delete sessions for which no + * operations are sent for more than an hour. If a session is deleted, + * requests to it return `NOT_FOUND`. * * Idle sessions can be kept alive by sending a trivial SQL query * periodically, e.g., `"SELECT 1"`. @@ -959,7 +964,7 @@ public function streamingRead($session, $table, $columns, $keySet, $optionalArgs $mergedSettings, $this->descriptors['streamingRead'] ); -// print_r($request->serialize(new PhpArray));exit; + return $callable( $request, [], diff --git a/src/Spanner/V1/resources/spanner_client_config.json b/src/Spanner/V1/resources/spanner_client_config.json index db4ced68c440..76c56b6880c7 100644 --- a/src/Spanner/V1/resources/spanner_client_config.json +++ b/src/Spanner/V1/resources/spanner_client_config.json @@ -2,13 +2,13 @@ "interfaces": { "google.spanner.v1.Spanner": { "retry_codes": { - "retry_codes_def": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "non_idempotent": [] - } + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [ + "UNAVAILABLE" + ] }, "retry_params": { "default": { From 89084f9e359d1ca02db181d045312875fd187ca1 Mon Sep 17 00:00:00 2001 From: Michael Bausor Date: Fri, 19 May 2017 09:46:12 -0700 Subject: [PATCH 2/4] Update video intelligence --- .../V1beta1/VideoIntelligenceServiceClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php b/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php index a283ef134b70..bbc28435eab1 100644 --- a/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php +++ b/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php @@ -339,7 +339,7 @@ public function __construct($options = []) * supported, which must be specified in the following format: * `gs://bucket-id/object-id` (other URI formats return * [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more information, see - * [Request URIs](/storage/docs/reference-uris). + * [Request URIs](https://cloud.google.com/storage/docs/reference-uris). * A video URI may include wildcards in `object-id`, and thus identify * multiple videos. Supported wildcards: '*' to match 0 or more characters; * '?' to match 1 character. If unset, the input video should be embedded @@ -360,7 +360,7 @@ public function __construct($options = []) * URIs are supported, which must be specified in the following format: * `gs://bucket-id/object-id` (other URI formats return * [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more information, see - * [Request URIs](/storage/docs/reference-uris). + * [Request URIs](https://cloud.google.com/storage/docs/reference-uris). * @type string $locationId * Optional cloud region where annotation should take place. Supported cloud * regions: `us-east1`, `us-west1`, `europe-west1`, `asia-east1`. If no region From d2410785ae2ef9c7c3ce6624aabf168b72356011 Mon Sep 17 00:00:00 2001 From: Michael Bausor Date: Fri, 19 May 2017 12:29:56 -0700 Subject: [PATCH 3/4] Update Spanner, VideoIntelligence and Speech --- .../Admin/Database/V1/DatabaseAdminClient.php | 2 ++ .../Admin/Instance/V1/InstanceAdminClient.php | 2 ++ src/Speech/V1beta1/SpeechClient.php | 24 +++++++++++-------- .../resources/speech_client_config.json | 4 ++-- .../VideoIntelligenceServiceClient.php | 2 ++ 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php b/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php index a0eaf8ea8acb..ac1a11f38988 100644 --- a/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php +++ b/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php @@ -350,6 +350,8 @@ public function __construct($options = []) 'scopes' => $options['scopes'], 'libName' => $options['libName'], 'libVersion' => $options['libVersion'], + 'sslCreds' => $options['sslCreds'], + 'credentialsLoader' => $options['credentialsLoader'], ]); } diff --git a/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php b/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php index 7cdcf173eef0..f91f974a114e 100644 --- a/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php +++ b/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php @@ -396,6 +396,8 @@ public function __construct($options = []) 'scopes' => $options['scopes'], 'libName' => $options['libName'], 'libVersion' => $options['libVersion'], + 'sslCreds' => $options['sslCreds'], + 'credentialsLoader' => $options['credentialsLoader'], ]); } diff --git a/src/Speech/V1beta1/SpeechClient.php b/src/Speech/V1beta1/SpeechClient.php index 2e2e7997c0d1..b854da878a4c 100644 --- a/src/Speech/V1beta1/SpeechClient.php +++ b/src/Speech/V1beta1/SpeechClient.php @@ -228,6 +228,8 @@ public function __construct($options = []) 'scopes' => $options['scopes'], 'libName' => $options['libName'], 'libVersion' => $options['libVersion'], + 'sslCreds' => $options['sslCreds'], + 'credentialsLoader' => $options['credentialsLoader'], ]); } @@ -289,7 +291,7 @@ public function __construct($options = []) } /** - * Perform synchronous speech-recognition: receive results after all audio + * Performs synchronous speech recognition: receive results after all audio * has been sent and processed. * * Sample code: @@ -310,9 +312,9 @@ public function __construct($options = []) * } * ``` * - * @param RecognitionConfig $config [Required] The `config` message provides information to the recognizer - * that specifies how to process the request. - * @param RecognitionAudio $audio [Required] The audio data to be recognized. + * @param RecognitionConfig $config *Required* Provides information to the recognizer that specifies how to + * process the request. + * @param RecognitionAudio $audio *Required* The audio data to be recognized. * @param array $optionalArgs { * Optional. * @@ -351,8 +353,10 @@ public function syncRecognize($config, $audio, $optionalArgs = []) } /** - * Perform asynchronous speech-recognition: receive results via the - * google.longrunning.Operations interface. Returns either an + * Performs asynchronous speech recognition: receive results via the + * [google.longrunning.Operations] + * (https://cloud.google.com/speech/reference/rest/v1beta1/operations#Operation) + * interface. Returns either an * `Operation.error` or an `Operation.response` which contains * an `AsyncRecognizeResponse` message. * @@ -399,9 +403,9 @@ public function syncRecognize($config, $audio, $optionalArgs = []) * } * ``` * - * @param RecognitionConfig $config [Required] The `config` message provides information to the recognizer - * that specifies how to process the request. - * @param RecognitionAudio $audio [Required] The audio data to be recognized. + * @param RecognitionConfig $config *Required* Provides information to the recognizer that specifies how to + * process the request. + * @param RecognitionAudio $audio *Required* The audio data to be recognized. * @param array $optionalArgs { * Optional. * @@ -440,7 +444,7 @@ public function asyncRecognize($config, $audio, $optionalArgs = []) } /** - * Perform bidirectional streaming speech-recognition: receive results while + * Performs bidirectional streaming speech recognition: receive results while * sending audio. This method is only available via the gRPC API (not REST). * * Sample code: diff --git a/src/Speech/V1beta1/resources/speech_client_config.json b/src/Speech/V1beta1/resources/speech_client_config.json index 5d11ce19e587..e1877f31ec57 100644 --- a/src/Speech/V1beta1/resources/speech_client_config.json +++ b/src/Speech/V1beta1/resources/speech_client_config.json @@ -15,9 +15,9 @@ "initial_retry_delay_millis": 100, "retry_delay_multiplier": 1.3, "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, + "initial_rpc_timeout_millis": 190000, "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 60000, + "max_rpc_timeout_millis": 190000, "total_timeout_millis": 600000 } }, diff --git a/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php b/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php index bbc28435eab1..46f4d5bfc729 100644 --- a/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php +++ b/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php @@ -237,6 +237,8 @@ public function __construct($options = []) 'scopes' => $options['scopes'], 'libName' => $options['libName'], 'libVersion' => $options['libVersion'], + 'sslCreds' => $options['sslCreds'], + 'credentialsLoader' => $options['credentialsLoader'], ]); } From 55884f7f288c0d11a12d8925863e3705d60f30fc Mon Sep 17 00:00:00 2001 From: Michael Bausor Date: Fri, 19 May 2017 13:50:42 -0700 Subject: [PATCH 4/4] Address PR feedback --- .../Admin/Database/V1/DatabaseAdminClient.php | 12 ++++-------- .../Admin/Instance/V1/InstanceAdminClient.php | 12 ++++-------- src/Speech/V1beta1/SpeechClient.php | 12 ++++-------- .../V1beta1/VideoIntelligenceServiceClient.php | 12 ++++-------- 4 files changed, 16 insertions(+), 32 deletions(-) diff --git a/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php b/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php index ac1a11f38988..baec24318a42 100644 --- a/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php +++ b/src/Spanner/Admin/Database/V1/DatabaseAdminClient.php @@ -345,14 +345,10 @@ public function __construct($options = []) if (array_key_exists('operationsClient', $options)) { $this->operationsClient = $options['operationsClient']; } else { - $this->operationsClient = new OperationsClient([ - 'serviceAddress' => $options['serviceAddress'], - 'scopes' => $options['scopes'], - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'sslCreds' => $options['sslCreds'], - 'credentialsLoader' => $options['credentialsLoader'], - ]); + $operationsClientOptions = $options; + unset($operationsClientOptions['timeoutMillis']); + unset($operationsClientOptions['retryingOverride']); + $this->operationsClient = new OperationsClient($operationsClientOptions); } $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); diff --git a/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php b/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php index f91f974a114e..8db5e5121850 100644 --- a/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php +++ b/src/Spanner/Admin/Instance/V1/InstanceAdminClient.php @@ -391,14 +391,10 @@ public function __construct($options = []) if (array_key_exists('operationsClient', $options)) { $this->operationsClient = $options['operationsClient']; } else { - $this->operationsClient = new OperationsClient([ - 'serviceAddress' => $options['serviceAddress'], - 'scopes' => $options['scopes'], - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'sslCreds' => $options['sslCreds'], - 'credentialsLoader' => $options['credentialsLoader'], - ]); + $operationsClientOptions = $options; + unset($operationsClientOptions['timeoutMillis']); + unset($operationsClientOptions['retryingOverride']); + $this->operationsClient = new OperationsClient($operationsClientOptions); } $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); diff --git a/src/Speech/V1beta1/SpeechClient.php b/src/Speech/V1beta1/SpeechClient.php index b854da878a4c..d4a0bca2086f 100644 --- a/src/Speech/V1beta1/SpeechClient.php +++ b/src/Speech/V1beta1/SpeechClient.php @@ -223,14 +223,10 @@ public function __construct($options = []) if (array_key_exists('operationsClient', $options)) { $this->operationsClient = $options['operationsClient']; } else { - $this->operationsClient = new OperationsClient([ - 'serviceAddress' => $options['serviceAddress'], - 'scopes' => $options['scopes'], - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'sslCreds' => $options['sslCreds'], - 'credentialsLoader' => $options['credentialsLoader'], - ]); + $operationsClientOptions = $options; + unset($operationsClientOptions['timeoutMillis']); + unset($operationsClientOptions['retryingOverride']); + $this->operationsClient = new OperationsClient($operationsClientOptions); } $gapicVersion = $options['libVersion'] ?: self::getGapicVersion(); diff --git a/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php b/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php index 46f4d5bfc729..5fcc8f8a66a5 100644 --- a/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php +++ b/src/VideoIntelligence/V1beta1/VideoIntelligenceServiceClient.php @@ -232,14 +232,10 @@ public function __construct($options = []) if (array_key_exists('operationsClient', $options)) { $this->operationsClient = $options['operationsClient']; } else { - $this->operationsClient = new OperationsClient([ - 'serviceAddress' => $options['serviceAddress'], - 'scopes' => $options['scopes'], - 'libName' => $options['libName'], - 'libVersion' => $options['libVersion'], - 'sslCreds' => $options['sslCreds'], - 'credentialsLoader' => $options['credentialsLoader'], - ]); + $operationsClientOptions = $options; + unset($operationsClientOptions['timeoutMillis']); + unset($operationsClientOptions['retryingOverride']); + $this->operationsClient = new OperationsClient($operationsClientOptions); } $gapicVersion = $options['libVersion'] ?: self::getGapicVersion();