diff --git a/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.create_policy.js b/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.create_policy.js index 8753742da8c..08d2c889751 100644 --- a/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.create_policy.js +++ b/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.create_policy.js @@ -23,6 +23,9 @@ function main(parent, policy) { // [START orgpolicy_v2_generated_OrgPolicy_CreatePolicy_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.delete_policy.js b/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.delete_policy.js index e0d0e4d4929..15c4c999560 100644 --- a/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.delete_policy.js +++ b/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.delete_policy.js @@ -23,6 +23,9 @@ function main(name) { // [START orgpolicy_v2_generated_OrgPolicy_DeletePolicy_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.get_effective_policy.js b/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.get_effective_policy.js index 1a353cb360a..864ee6d811e 100644 --- a/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.get_effective_policy.js +++ b/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.get_effective_policy.js @@ -23,6 +23,9 @@ function main(name) { // [START orgpolicy_v2_generated_OrgPolicy_GetEffectivePolicy_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.get_policy.js b/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.get_policy.js index 150b48d579c..1b813ee52c9 100644 --- a/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.get_policy.js +++ b/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.get_policy.js @@ -23,6 +23,9 @@ function main(name) { // [START orgpolicy_v2_generated_OrgPolicy_GetPolicy_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.list_constraints.js b/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.list_constraints.js index 6be7b59691c..010266ca4ec 100644 --- a/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.list_constraints.js +++ b/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.list_constraints.js @@ -23,6 +23,9 @@ function main(parent) { // [START orgpolicy_v2_generated_OrgPolicy_ListConstraints_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.list_policies.js b/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.list_policies.js index 20000f793e6..a9877c65ed6 100644 --- a/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.list_policies.js +++ b/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.list_policies.js @@ -23,6 +23,9 @@ function main(parent) { // [START orgpolicy_v2_generated_OrgPolicy_ListPolicies_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.update_policy.js b/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.update_policy.js index 76640ea81a4..34bb2615962 100644 --- a/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.update_policy.js +++ b/packages/google-cloud-orgpolicy/samples/generated/v2/org_policy.update_policy.js @@ -23,6 +23,9 @@ function main(policy) { // [START orgpolicy_v2_generated_OrgPolicy_UpdatePolicy_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-orgpolicy/samples/generated/v2/snippet_metadata.google.cloud.orgpolicy.v2.json b/packages/google-cloud-orgpolicy/samples/generated/v2/snippet_metadata.google.cloud.orgpolicy.v2.json index 17ce06ad723..afbf79be85d 100644 --- a/packages/google-cloud-orgpolicy/samples/generated/v2/snippet_metadata.google.cloud.orgpolicy.v2.json +++ b/packages/google-cloud-orgpolicy/samples/generated/v2/snippet_metadata.google.cloud.orgpolicy.v2.json @@ -22,7 +22,7 @@ "segments": [ { "start": 25, - "end": 68, + "end": 71, "type": "FULL" } ], @@ -70,7 +70,7 @@ "segments": [ { "start": 25, - "end": 69, + "end": 72, "type": "FULL" } ], @@ -118,7 +118,7 @@ "segments": [ { "start": 25, - "end": 50, + "end": 53, "type": "FULL" } ], @@ -158,7 +158,7 @@ "segments": [ { "start": 25, - "end": 50, + "end": 53, "type": "FULL" } ], @@ -198,7 +198,7 @@ "segments": [ { "start": 25, - "end": 60, + "end": 63, "type": "FULL" } ], @@ -242,7 +242,7 @@ "segments": [ { "start": 25, - "end": 50, + "end": 53, "type": "FULL" } ], @@ -282,7 +282,7 @@ "segments": [ { "start": 25, - "end": 51, + "end": 54, "type": "FULL" } ], diff --git a/packages/google-cloud-orgpolicy/src/v2/org_policy_client.ts b/packages/google-cloud-orgpolicy/src/v2/org_policy_client.ts index b1330169270..7fcf2034ea1 100644 --- a/packages/google-cloud-orgpolicy/src/v2/org_policy_client.ts +++ b/packages/google-cloud-orgpolicy/src/v2/org_policy_client.ts @@ -28,7 +28,6 @@ import { } from 'google-gax'; import {Transform} from 'stream'; -import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -298,7 +297,8 @@ export class OrgPolicyClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -976,7 +976,7 @@ export class OrgPolicyClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listConstraints.createStream( - this.innerApiCalls.listConstraints as gax.GaxCall, + this.innerApiCalls.listConstraints as GaxCall, request, callSettings ); @@ -1032,7 +1032,7 @@ export class OrgPolicyClient { this.initialize(); return this.descriptors.page.listConstraints.asyncIterate( this.innerApiCalls['listConstraints'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } @@ -1185,7 +1185,7 @@ export class OrgPolicyClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listPolicies.createStream( - this.innerApiCalls.listPolicies as gax.GaxCall, + this.innerApiCalls.listPolicies as GaxCall, request, callSettings ); @@ -1242,7 +1242,7 @@ export class OrgPolicyClient { this.initialize(); return this.descriptors.page.listPolicies.asyncIterate( this.innerApiCalls['listPolicies'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } diff --git a/packages/google-cloud-orgpolicy/test/gapic_org_policy_v2.ts b/packages/google-cloud-orgpolicy/test/gapic_org_policy_v2.ts index 24ab888508b..65ce8062d52 100644 --- a/packages/google-cloud-orgpolicy/test/gapic_org_policy_v2.ts +++ b/packages/google-cloud-orgpolicy/test/gapic_org_policy_v2.ts @@ -113,99 +113,101 @@ function stubAsyncIterationCall( } describe('v2.OrgPolicyClient', () => { - it('has servicePath', () => { - const servicePath = orgpolicyModule.v2.OrgPolicyClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = orgpolicyModule.v2.OrgPolicyClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = orgpolicyModule.v2.OrgPolicyClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new orgpolicyModule.v2.OrgPolicyClient(); - assert(client); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = orgpolicyModule.v2.OrgPolicyClient.servicePath; + assert(servicePath); + }); - it('should create a client with gRPC fallback', () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - fallback: true, + it('has apiEndpoint', () => { + const apiEndpoint = orgpolicyModule.v2.OrgPolicyClient.apiEndpoint; + assert(apiEndpoint); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has port', () => { + const port = orgpolicyModule.v2.OrgPolicyClient.port; + assert(port); + assert(typeof port === 'number'); }); - assert.strictEqual(client.orgPolicyStub, undefined); - await client.initialize(); - assert(client.orgPolicyStub); - }); - it('has close method for the initialized client', done => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with no option', () => { + const client = new orgpolicyModule.v2.OrgPolicyClient(); + assert(client); }); - client.initialize(); - assert(client.orgPolicyStub); - client.close().then(() => { - done(); + + it('should create a client with gRPC fallback', () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + fallback: true, + }); + assert(client); }); - }); - it('has close method for the non-initialized client', done => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has initialize method and supports deferred initialization', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.orgPolicyStub, undefined); + await client.initialize(); + assert(client.orgPolicyStub); }); - assert.strictEqual(client.orgPolicyStub, undefined); - client.close().then(() => { - done(); + + it('has close method for the initialized client', done => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.orgPolicyStub); + client.close().then(() => { + done(); + }); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the non-initialized client', done => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.orgPolicyStub, undefined); + client.close().then(() => { + done(); + }); }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); }); describe('getPolicy', () => {