Skip to content

Commit

Permalink
fix: simplify logic for HTTP/1.1 REST fallback option (#1138)
Browse files Browse the repository at this point in the history
* docs: Update property requirement specifications

PiperOrigin-RevId: 557861399

Source-Link: googleapis/googleapis@3303b93

Source-Link: googleapis/googleapis-gen@fb0d0a4
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZmIwZDBhNDUzODVlYjBiZTU4NDIxMTFhZjc5YWY1ZDcxOWQzMjE2OCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* fix: simplify logic for HTTP/1.1 REST fallback option

For the `fallback` parameter, all values considered as `true`
in Boolean context will enable HTTP/1.1 REST fallback,
since the other fallback transport, proto over HTTP, is
removed from `google-gax` v4.

PiperOrigin-RevId: 559812260

Source-Link: googleapis/googleapis@6a6fd29

Source-Link: googleapis/googleapis-gen@56c1665
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTZjMTY2NTdlN2E1OTEyMmIxZGE5NDc3MWE5ZWY0MDk4OWMyODJjMCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: danieljbruce <danieljbruce@users.noreply.github.com>
  • Loading branch information
3 people committed Sep 7, 2023
1 parent b25537d commit 4cefaea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
9 changes: 7 additions & 2 deletions protos/google/datastore/v1/query.proto
Expand Up @@ -279,8 +279,13 @@ message KindExpression {

// A reference to a property relative to the kind expressions.
message PropertyReference {
// The name of the property.
// If name includes "."s, it may be interpreted as a property name path.
// A reference to a property.
//
// Requires:
//
// * MUST be a dot-delimited (`.`) string of segments, where each segment
// conforms to [entity property name][google.datastore.v1.Entity.properties]
// limitations.
string name = 2;
}

Expand Down
9 changes: 4 additions & 5 deletions src/v1/datastore_admin_client.ts
Expand Up @@ -138,16 +138,15 @@ export class DatastoreAdminClient {
* API remote host.
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
* Follows the structure of {@link gapicConfig}.
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
* @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
* For more information, please check the
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
* need to avoid loading the default gRPC version and want to use the fallback
* HTTP implementation. Load only fallback version and pass it to the constructor:
* ```
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
* const client = new DatastoreAdminClient({fallback: 'rest'}, gax);
* const client = new DatastoreAdminClient({fallback: true}, gax);
* ```
*/
constructor(
Expand Down Expand Up @@ -213,7 +212,7 @@ export class DatastoreAdminClient {
}
if (!opts.fallback) {
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
} else if (opts.fallback === 'rest') {
} else {
clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
}
if (opts.libName && opts.libVersion) {
Expand Down Expand Up @@ -241,7 +240,7 @@ export class DatastoreAdminClient {
auth: this.auth,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
};
if (opts.fallback === 'rest') {
if (opts.fallback) {
lroOptions.protoJson = protoFilesRoot;
lroOptions.httpRules = [
{
Expand Down
9 changes: 4 additions & 5 deletions src/v1/datastore_client.ts
Expand Up @@ -95,16 +95,15 @@ export class DatastoreClient {
* API remote host.
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
* Follows the structure of {@link gapicConfig}.
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
* @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
* For more information, please check the
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
* need to avoid loading the default gRPC version and want to use the fallback
* HTTP implementation. Load only fallback version and pass it to the constructor:
* ```
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
* const client = new DatastoreClient({fallback: 'rest'}, gax);
* const client = new DatastoreClient({fallback: true}, gax);
* ```
*/
constructor(
Expand Down Expand Up @@ -170,7 +169,7 @@ export class DatastoreClient {
}
if (!opts.fallback) {
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
} else if (opts.fallback === 'rest') {
} else {
clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
}
if (opts.libName && opts.libVersion) {
Expand All @@ -187,7 +186,7 @@ export class DatastoreClient {
auth: this.auth,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
};
if (opts.fallback === 'rest') {
if (opts.fallback) {
lroOptions.protoJson = protoFilesRoot;
lroOptions.httpRules = [
{
Expand Down

0 comments on commit 4cefaea

Please sign in to comment.