Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
fix: proper fallback option handling (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation committed Jun 16, 2020
1 parent 7f74781 commit 52fe53d
Show file tree
Hide file tree
Showing 16 changed files with 122 additions and 68 deletions.
44 changes: 44 additions & 0 deletions .kokoro/populate-secrets.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .kokoro/publish.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions .kokoro/release/publish.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .kokoro/trampoline.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions protos/protos.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5083,6 +5083,9 @@ export namespace google {

/** FieldDescriptorProto options */
options?: (google.protobuf.IFieldOptions|null);

/** FieldDescriptorProto proto3Optional */
proto3Optional?: (boolean|null);
}

/** Represents a FieldDescriptorProto. */
Expand Down Expand Up @@ -5124,6 +5127,9 @@ export namespace google {
/** FieldDescriptorProto options. */
public options?: (google.protobuf.IFieldOptions|null);

/** FieldDescriptorProto proto3Optional. */
public proto3Optional: boolean;

/**
* Creates a new FieldDescriptorProto instance using the specified properties.
* @param [properties] Properties to set
Expand Down
28 changes: 25 additions & 3 deletions protos/protos.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;

// Exported root namespace
var $root = $protobuf.roots._google_cloud_recaptcha_enterprise_1_8_0_protos || ($protobuf.roots._google_cloud_recaptcha_enterprise_1_8_0_protos = {});
var $root = $protobuf.roots._google_cloud_recaptcha_enterprise_protos || ($protobuf.roots._google_cloud_recaptcha_enterprise_protos = {});

$root.google = (function() {

Expand Down Expand Up @@ -12382,6 +12382,7 @@
* @property {number|null} [oneofIndex] FieldDescriptorProto oneofIndex
* @property {string|null} [jsonName] FieldDescriptorProto jsonName
* @property {google.protobuf.IFieldOptions|null} [options] FieldDescriptorProto options
* @property {boolean|null} [proto3Optional] FieldDescriptorProto proto3Optional
*/

/**
Expand Down Expand Up @@ -12479,6 +12480,14 @@
*/
FieldDescriptorProto.prototype.options = null;

/**
* FieldDescriptorProto proto3Optional.
* @member {boolean} proto3Optional
* @memberof google.protobuf.FieldDescriptorProto
* @instance
*/
FieldDescriptorProto.prototype.proto3Optional = false;

/**
* Creates a new FieldDescriptorProto instance using the specified properties.
* @function create
Expand Down Expand Up @@ -12523,6 +12532,8 @@
writer.uint32(/* id 9, wireType 0 =*/72).int32(message.oneofIndex);
if (message.jsonName != null && Object.hasOwnProperty.call(message, "jsonName"))
writer.uint32(/* id 10, wireType 2 =*/82).string(message.jsonName);
if (message.proto3Optional != null && Object.hasOwnProperty.call(message, "proto3Optional"))
writer.uint32(/* id 17, wireType 0 =*/136).bool(message.proto3Optional);
return writer;
};

Expand Down Expand Up @@ -12587,6 +12598,9 @@
case 8:
message.options = $root.google.protobuf.FieldOptions.decode(reader, reader.uint32());
break;
case 17:
message.proto3Optional = reader.bool();
break;
default:
reader.skipType(tag & 7);
break;
Expand Down Expand Up @@ -12681,6 +12695,9 @@
if (error)
return "options." + error;
}
if (message.proto3Optional != null && message.hasOwnProperty("proto3Optional"))
if (typeof message.proto3Optional !== "boolean")
return "proto3Optional: boolean expected";
return null;
};

Expand Down Expand Up @@ -12803,6 +12820,8 @@
throw TypeError(".google.protobuf.FieldDescriptorProto.options: object expected");
message.options = $root.google.protobuf.FieldOptions.fromObject(object.options);
}
if (object.proto3Optional != null)
message.proto3Optional = Boolean(object.proto3Optional);
return message;
};

Expand Down Expand Up @@ -12830,6 +12849,7 @@
object.options = null;
object.oneofIndex = 0;
object.jsonName = "";
object.proto3Optional = false;
}
if (message.name != null && message.hasOwnProperty("name"))
object.name = message.name;
Expand All @@ -12851,6 +12871,8 @@
object.oneofIndex = message.oneofIndex;
if (message.jsonName != null && message.hasOwnProperty("jsonName"))
object.jsonName = message.jsonName;
if (message.proto3Optional != null && message.hasOwnProperty("proto3Optional"))
object.proto3Optional = message.proto3Optional;
return object;
};

Expand Down Expand Up @@ -14644,7 +14666,7 @@
* @memberof google.protobuf.FileOptions
* @instance
*/
FileOptions.prototype.ccEnableArenas = false;
FileOptions.prototype.ccEnableArenas = true;

/**
* FileOptions objcClassPrefix.
Expand Down Expand Up @@ -15130,7 +15152,7 @@
object.javaGenerateEqualsAndHash = false;
object.deprecated = false;
object.javaStringCheckUtf8 = false;
object.ccEnableArenas = false;
object.ccEnableArenas = true;
object.objcClassPrefix = "";
object.csharpNamespace = "";
object.swiftPrefix = "";
Expand Down
6 changes: 5 additions & 1 deletion protos/protos.json
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,10 @@
"options": {
"type": "FieldOptions",
"id": 8
},
"proto3Optional": {
"type": "bool",
"id": 17
}
},
"nested": {
Expand Down Expand Up @@ -1600,7 +1604,7 @@
"type": "bool",
"id": 31,
"options": {
"default": false
"default": true
}
},
"objcClassPrefix": {
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
// ** https://github.com/googleapis/synthtool **
// ** All changes to this file may be overwritten. **

import * as v1 from './v1';
import * as v1beta1 from './v1beta1';
import * as v1 from './v1';

const RecaptchaEnterpriseServiceClient = v1.RecaptchaEnterpriseServiceClient;

export {v1, v1beta1, RecaptchaEnterpriseServiceClient};
export default {v1, v1beta1, RecaptchaEnterpriseServiceClient};
export {v1beta1, v1, RecaptchaEnterpriseServiceClient};
export default {v1beta1, v1, RecaptchaEnterpriseServiceClient};
import * as protos from '../protos/protos';
export {protos};
20 changes: 12 additions & 8 deletions src/v1/recaptcha_enterprise_service_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,20 @@ export class RecaptchaEnterpriseServiceClient {
}
opts.servicePath = opts.servicePath || servicePath;
opts.port = opts.port || port;

// users can override the config from client side, like retry codes name.
// The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546
// The way to override client config for Showcase API:
//
// const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}}
// const showcaseClient = new showcaseClient({ projectId, customConfig });
opts.clientConfig = opts.clientConfig || {};

const isBrowser = typeof window !== 'undefined';
if (isBrowser) {
opts.fallback = true;
}
// If we are in browser, we are already using fallback because of the
// "browser" field in package.json.
// But if we were explicitly requested to use fallback, let's do it now.
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// If we're running in browser, it's OK to omit `fallback` since
// google-gax has `browser` field in its `package.json`.
// For Electron (which does not respect `browser` field),
// pass `{fallback: true}` to the RecaptchaEnterpriseServiceClient constructor.
this._gaxModule = opts.fallback ? gax.fallback : gax;

// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
Expand Down
20 changes: 12 additions & 8 deletions src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,20 @@ export class RecaptchaEnterpriseServiceV1Beta1Client {
}
opts.servicePath = opts.servicePath || servicePath;
opts.port = opts.port || port;

// users can override the config from client side, like retry codes name.
// The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546
// The way to override client config for Showcase API:
//
// const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}}
// const showcaseClient = new showcaseClient({ projectId, customConfig });
opts.clientConfig = opts.clientConfig || {};

const isBrowser = typeof window !== 'undefined';
if (isBrowser) {
opts.fallback = true;
}
// If we are in browser, we are already using fallback because of the
// "browser" field in package.json.
// But if we were explicitly requested to use fallback, let's do it now.
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// If we're running in browser, it's OK to omit `fallback` since
// google-gax has `browser` field in its `package.json`.
// For Electron (which does not respect `browser` field),
// pass `{fallback: true}` to the RecaptchaEnterpriseServiceV1Beta1Client constructor.
this._gaxModule = opts.fallback ? gax.fallback : gax;

// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
Expand Down
33 changes: 3 additions & 30 deletions synth.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,15 @@
"git": {
"name": ".",
"remote": "git@github.com:googleapis/nodejs-recaptcha-enterprise.git",
"sha": "05f1acabb9834dd291475598f343ecf7ae62b128"
"sha": "f548f0270d13a5195c345e209ffeb75a1d038344"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "aed11c01e52921613b9ee469c2d85f5f33175fb7",
"internalRef": "310660461"
}
},
{
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
"sha": "98c50772ec23295c64cf0d2ddf199ea52961fd4c"
}
}
],
"destinations": [
{
"client": {
"source": "googleapis",
"apiName": "recaptchaenterprise",
"apiVersion": "v1",
"language": "typescript",
"generator": "gapic-generator-typescript"
}
},
{
"client": {
"source": "googleapis",
"apiName": "recaptchaenterprise",
"apiVersion": "v1beta1",
"language": "typescript",
"generator": "gapic-generator-typescript"
"sha": "c1ba5ba3f24307ca5a6df350d0137c29d69983d5",
"internalRef": "316715576"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# run the gapic generator
gapic = gcp.GAPICMicrogenerator()
versions = ['v1', 'v1beta1']
versions = ['v1beta1', 'v1']
for version in versions:
library = gapic.typescript_library(
'recaptchaenterprise', version,
Expand Down
2 changes: 1 addition & 1 deletion system-test/fixtures/sample/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
const recaptchaenterprise = require('@google-cloud/recaptcha-enterprise');

function main() {
const recaptchaEnterpriseServiceV1Beta1Client = new recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client();
const recaptchaEnterpriseServiceClient = new recaptchaenterprise.RecaptchaEnterpriseServiceClient();
}

main();
4 changes: 2 additions & 2 deletions system-test/fixtures/sample/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **

import * as recaptchaenterprise from '@google-cloud/recaptcha-enterprise';
import {RecaptchaEnterpriseServiceClient} from '@google-cloud/recaptcha-enterprise';

function main() {
new recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client();
new RecaptchaEnterpriseServiceClient();
}

main();
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"outDir": "build",
"resolveJsonModule": true,
"lib": [
"es2016",
"es2018",
"dom"
]
},
Expand Down
4 changes: 2 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const path = require('path');
module.exports = {
entry: './src/index.ts',
output: {
library: 'RecaptchaEnterpriseServiceV1Beta1',
filename: './recaptcha-enterprise-service-v1-beta1.js',
library: 'RecaptchaEnterpriseService',
filename: './recaptcha-enterprise-service.js',
},
node: {
child_process: 'empty',
Expand Down

0 comments on commit 52fe53d

Please sign in to comment.