From fc9bd69fc0d57eff53b7a34a113e6824bc7c947f Mon Sep 17 00:00:00 2001 From: Shivanee Persaud Date: Tue, 31 Mar 2026 10:08:53 -0700 Subject: [PATCH 01/12] fix: add logic to check for IAM RPC methods within the service before adding mixin to avoid generating duplicate methods --- .../templates/cjs/typescript_gapic/_iam.njk | 10 +++++ .../cjs/typescript_gapic/_locations.njk | 7 +++ .../src/$version/$service_client.ts.njk | 41 ++++++++++++------ .../test/gapic_$service_$version.ts.njk | 14 +++++- .../templates/esm/typescript_gapic/_iam.njk | 10 +++++ .../esm/typescript_gapic/_locations.njk | 7 +++ .../esm/src/$version/$service_client.ts.njk | 43 +++++++++++++------ .../esm/test/gapic_$service_$version.ts.njk | 14 +++++- 8 files changed, 118 insertions(+), 28 deletions(-) diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_iam.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_iam.njk index 281ad5a33bc..967f24b8383 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_iam.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_iam.njk @@ -5,6 +5,12 @@ IamClient is created for the client in the constructor. [setIamPolicy, getIamPolicy, testIamPermission] methods are created which is calling the corresponding methods from IamClient in google-gax. -#} +{{ getIamPolicy() }} +{{ setIamPolicy() }} +{{ testIamPermissions() }} +{%- endmacro -%} + +{%- macro getIamPolicy() -%} /** * Gets the access control policy for a resource. Returns an empty policy * if the resource exists and does not have a policy set. @@ -47,7 +53,9 @@ ):Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } +{%- endmacro -%} +{%- macro setIamPolicy() -%} /** * Returns permissions that a caller has on the specified resource. If the * resource does not exist, this will return an empty set of @@ -94,7 +102,9 @@ ):Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } +{%- endmacro -%} +{%- macro testIamPermissions() -%} /** * Returns permissions that a caller has on the specified resource. If the * resource does not exist, this will return an empty set of diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_locations.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_locations.njk index 728b057d544..085a3db8965 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_locations.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_locations.njk @@ -6,6 +6,11 @@ [getLocation, listLocations] methods are created which is calling the corresponding methods from LocationsClient in google-gax. Note that since the listLocations method is a paginated method, we default to using listLocationsAsync for ease of use. -#} +{{ getLocation() }} +{{ listLocationsAsync() }} +{%- endmacro -%} + +{%- macro getLocation() -%} /** * Gets information about a location. * @@ -45,7 +50,9 @@ ): Promise { return this.locationsClient.getLocation(request, options, callback); } +{%- endmacro -%} +{%- macro listLocationsAsync() -%} /** * Lists information about the supported locations for this service. Returns an iterable object. * diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk index da67e250fe7..e95e95e6b63 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk @@ -27,18 +27,22 @@ limitations under the License. {% import "../../_namer.njk" as namer -%} {{- namer.initialize(id, service) -}} {%- set autoPopulated = false -%} +{%- set methodNamesStr = "|" -%} {%- for method in service.method -%} {%- if method.autoPopulatedFields|length !== 0 %} {%- set autoPopulated = true -%} {%- endif %} + {%- set methodNamesStr = methodNamesStr + method.name.toCamelCase() + "|" -%} {%- endfor -%} +{%- set generateIam = service.IAMPolicyMixin > 0 and ('|getIamPolicy|' not in methodNamesStr or '|setIamPolicy|' not in methodNamesStr or '|testIamPermissions|' not in methodNamesStr) -%} +{%- set generateLocation = service.LocationMixin > 0 and ('|getLocation|' not in methodNamesStr or '|listLocations|' not in methodNamesStr) -%} import {% if (not api.legacyProtoLoad) and (autoPopulated === false) %}type {% endif %}* as gax from 'google-gax'; import type {Callback, CallOptions, Descriptors, ClientOptions {%- if service.longRunning.length > 0 or service.LongRunningOperationsMixin > 0 %}, GrpcClientOptions{%- endif -%} {%- if service.longRunning.length > 0 or service.diregapicLRO.length > 0 %}, LROperation{%- endif -%} {%- if service.paging.length > 0 %}, PaginationCallback, GaxCall{%- endif -%} -{%- if service.IAMPolicyMixin > 0 %}, IamClient, IamProtos{%- endif -%} -{%- if service.LocationMixin > 0 %}, LocationsClient, LocationProtos{%- endif -%} +{%- if generateIam %}, IamClient, IamProtos{%- endif -%} +{%- if generateLocation %}, LocationsClient, LocationProtos{%- endif -%} } from 'google-gax'; {% if service.paging.length > 0 or service.streaming.length > 0 -%} {% set importStreamJoiner = joiner(', ') -%} @@ -93,10 +97,10 @@ export class {{ service.name }}Client { }; warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; - {%- if service.IAMPolicyMixin > 0 %} + {%- if generateIam %} iamClient: IamClient; {%- endif %} - {%- if service.LocationMixin > 0 %} + {%- if generateLocation %} locationsClient: LocationsClient; {%- endif -%} {%- if service.pathTemplates.length > 0 %} @@ -222,11 +226,11 @@ export class {{ service.name }}Client { if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.{{ id.get("scopes") }}; } - {%- if service.IAMPolicyMixin > 0 %} + {%- if generateIam %} this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); {% endif %} - {%- if service.LocationMixin > 0 %} + {%- if generateLocation %} this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, opts @@ -1102,11 +1106,24 @@ export class {{ service.name }}Client { } {%- endif %} {%- endfor %} -{%- if service.IAMPolicyMixin > 0 %} -{{ iam.iamServiceMethods()}} +{%- if generateIam %} + {%- if '|getIamPolicy|' not in methodNamesStr %} + {{ iam.getIamPolicy()}} + {%- endif %} + {%- if '|setIamPolicy|' not in methodNamesStr %} + {{ iam.setIamPolicy()}} + {%- endif %} + {%- if '|testIamPermissions|' not in methodNamesStr %} + {{ iam.testIamPermissions()}} + {%- endif %} {% endif -%} -{%- if service.LocationMixin > 0 %} -{{ location.locationServiceMethods()}} +{%- if generateLocation %} + {%- if '|getLocation|' not in methodNamesStr %} + {{ location.getLocation() }} + {%- endif %} + {%- if '|listLocations|' not in methodNamesStr %} + {{ location.listLocationsAsync() }} + {%- endif %} {% endif -%} {%- if service.LongRunningOperationsMixin > 0 %} {{ operations.operationsServiceMethods()}} @@ -1165,10 +1182,10 @@ export class {{ service.name }}Client { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - {%- if service.IAMPolicyMixin > 0 %} + {%- if generateIam %} this.iamClient.close().catch(err => {throw err}); {%- endif %} - {%- if service.LocationMixin > 0 %} + {%- if generateLocation %} this.locationsClient.close().catch(err => {throw err}); {%- endif %} {%- if service.longRunning.length > 0 or service.LongRunningOperationsMixin > 0 %} diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk index cb601868033..265d9de60c7 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk @@ -20,6 +20,10 @@ limitations under the License. {{license.license(commonParameters.copyrightYear)}} {% import "../_namer.njk" as namer -%} {{- namer.initialize(id, service) -}} +{%- set methodNamesStr = "|" -%} +{%- for method in service.method -%} + {%- set methodNamesStr = methodNamesStr + method.name.toCamelCase() + "|" -%} +{%- endfor -%} import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; @@ -1089,6 +1093,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { {%- if (service.IAMPolicyMixin) > 0 %} {%- set IAMmethods = ['getIamPolicy', 'setIamPolicy', 'testIamPermissions'] %} {%- for method in IAMmethods %} + {%- if ('|' + method + '|') not in methodNamesStr %} describe('{{ method }}', () => { it('invokes {{ method }} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client( @@ -1204,10 +1209,12 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { .getCall(0).calledWith(request, expectedOptions, undefined)); }); }); + {%- endif %} {%- endfor %} {%- endif %} {%- if service.LocationMixin > 0 %} -{%- set method = 'getLocation' %} + {%- if '|getLocation|' not in methodNamesStr %} + {%- set method = 'getLocation' %} describe('{{ method }}', () => { it('invokes {{ method }} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client( @@ -1314,7 +1321,9 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { .getCall(0).calledWith(request, expectedOptions, undefined)); }); }); -{%- set method = 'listLocations' %} + {%- endif %} + {%- if '|listLocations|' not in methodNamesStr %} + {%- set method = 'listLocations' %} describe('{{ method }}Async', () => { it('uses async iteration with {{method}} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({{- util.initClientOptions(api.rest) -}}); @@ -1395,6 +1404,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { ); }); }); + {%- endif %} {%- endif %} {%- if (service.LongRunningOperationsMixin) > 0 %} {%- set Operationsmethods = ['getOperation', 'cancelOperation', 'deleteOperation'] %} diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_iam.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_iam.njk index 281ad5a33bc..967f24b8383 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_iam.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_iam.njk @@ -5,6 +5,12 @@ IamClient is created for the client in the constructor. [setIamPolicy, getIamPolicy, testIamPermission] methods are created which is calling the corresponding methods from IamClient in google-gax. -#} +{{ getIamPolicy() }} +{{ setIamPolicy() }} +{{ testIamPermissions() }} +{%- endmacro -%} + +{%- macro getIamPolicy() -%} /** * Gets the access control policy for a resource. Returns an empty policy * if the resource exists and does not have a policy set. @@ -47,7 +53,9 @@ ):Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } +{%- endmacro -%} +{%- macro setIamPolicy() -%} /** * Returns permissions that a caller has on the specified resource. If the * resource does not exist, this will return an empty set of @@ -94,7 +102,9 @@ ):Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } +{%- endmacro -%} +{%- macro testIamPermissions() -%} /** * Returns permissions that a caller has on the specified resource. If the * resource does not exist, this will return an empty set of diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_locations.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_locations.njk index 728b057d544..085a3db8965 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_locations.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_locations.njk @@ -6,6 +6,11 @@ [getLocation, listLocations] methods are created which is calling the corresponding methods from LocationsClient in google-gax. Note that since the listLocations method is a paginated method, we default to using listLocationsAsync for ease of use. -#} +{{ getLocation() }} +{{ listLocationsAsync() }} +{%- endmacro -%} + +{%- macro getLocation() -%} /** * Gets information about a location. * @@ -45,7 +50,9 @@ ): Promise { return this.locationsClient.getLocation(request, options, callback); } +{%- endmacro -%} +{%- macro listLocationsAsync() -%} /** * Lists information about the supported locations for this service. Returns an iterable object. * diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk index 62d4d28e97d..cbe961430b2 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk @@ -26,13 +26,19 @@ limitations under the License. {% import "../../../_operations.njk" as operations -%} {% import "../../../_namer.njk" as namer -%} {{- namer.initialize(id, service) -}} +{%- set methodNamesStr = "|" -%} +{%- for method in service.method -%} + {%- set methodNamesStr = methodNamesStr + method.name.toCamelCase() + "|" -%} +{%- endfor -%} +{%- set generateIam = service.IAMPolicyMixin > 0 and ('|getIamPolicy|' not in methodNamesStr or '|setIamPolicy|' not in methodNamesStr or '|testIamPermissions|' not in methodNamesStr) -%} +{%- set generateLocation = service.LocationMixin > 0 and ('|getLocation|' not in methodNamesStr or '|listLocations|' not in methodNamesStr) -%} import * as gax from 'google-gax'; import type {Callback, CallOptions, Descriptors, ClientOptions {%- if service.longRunning.length > 0 or service.LongRunningOperationsMixin > 0 %}, GrpcClientOptions{%- endif -%} {%- if service.longRunning.length > 0 or service.diregapicLRO.length > 0 %}, LROperation{%- endif -%} {%- if service.paging.length > 0 %}, PaginationCallback, GaxCall{%- endif -%} -{%- if service.IAMPolicyMixin > 0 %}, IamClient, IamProtos{%- endif -%} -{%- if service.LocationMixin > 0 %}, LocationsClient, LocationProtos{%- endif -%} +{%- if generateIam %}, IamClient, IamProtos{%- endif -%} +{%- if generateLocation %}, LocationsClient, LocationProtos{%- endif -%} } from 'google-gax'; {% if service.paging.length > 0 or service.streaming.length > 0 -%} {% set importStreamJoiner = joiner(', ') -%} @@ -99,10 +105,10 @@ export class {{ service.name }}Client { }; warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; - {%- if service.IAMPolicyMixin > 0 %} + {%- if generateIam %} iamClient: IamClient; {%- endif %} - {%- if service.LocationMixin > 0 %} + {%- if generateLocation %} locationsClient: LocationsClient; {%- endif -%} {%- if service.pathTemplates.length > 0 %} @@ -229,11 +235,11 @@ export class {{ service.name }}Client { if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.{{ id.get("scopes") }}; } - {%- if service.IAMPolicyMixin > 0 %} + {%- if generateIam %} this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); {% endif %} - {%- if service.LocationMixin > 0 %} + {%- if generateLocation %} this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, opts @@ -1109,11 +1115,24 @@ export class {{ service.name }}Client { } {%- endif %} {%- endfor %} -{%- if service.IAMPolicyMixin > 0 %} -{{ iam.iamServiceMethods()}} +{%- if generateIam %} + {%- if '|getIamPolicy|' not in methodNamesStr %} + {{ iam.getIamPolicy()}} + {%- endif %} + {%- if '|setIamPolicy|' not in methodNamesStr %} + {{ iam.setIamPolicy()}} + {%- endif %} + {%- if '|testIamPermissions|' not in methodNamesStr %} + {{ iam.testIamPermissions()}} + {%- endif %} {% endif -%} -{%- if service.LocationMixin > 0 %} -{{ location.locationServiceMethods()}} +{%- if generateLocation %} + {%- if '|getLocation|' not in methodNamesStr %} + {{ location.getLocation() }} + {%- endif %} + {%- if '|listLocations|' not in methodNamesStr %} + {{ location.listLocationsAsync() }} + {%- endif %} {% endif -%} {%- if service.LongRunningOperationsMixin > 0 %} {{ operations.operationsServiceMethods()}} @@ -1172,10 +1191,10 @@ export class {{ service.name }}Client { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - {%- if service.IAMPolicyMixin > 0 %} + {%- if generateIam %} this.iamClient.close().catch(err => {throw err}); {%- endif %} - {%- if service.LocationMixin > 0 %} + {%- if generateLocation %} this.locationsClient.close().catch(err => {throw err}); {%- endif %} {%- if service.longRunning.length > 0 or service.LongRunningOperationsMixin > 0 %} diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk index 0d723c4e2ea..78301892fc7 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk @@ -20,6 +20,10 @@ limitations under the License. {{license.license(commonParameters.copyrightYear)}} {% import "../../_namer.njk" as namer -%} {{- namer.initialize(id, service) -}} +{%- set methodNamesStr = "|" -%} +{%- for method in service.method -%} + {%- set methodNamesStr = methodNamesStr + method.name.toCamelCase() + "|" -%} +{%- endfor -%} // @ts-ignore import * as protos from '../../protos/protos.js'; import assert from 'assert'; @@ -1095,6 +1099,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { {%- if (service.IAMPolicyMixin) > 0 %} {%- set IAMmethods = ['getIamPolicy', 'setIamPolicy', 'testIamPermissions'] %} {%- for method in IAMmethods %} + {%- if ('|' + method + '|') not in methodNamesStr %} describe('{{ method }}', () => { it('invokes {{ method }} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client( @@ -1210,10 +1215,12 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { .getCall(0).calledWith(request, expectedOptions, undefined)); }); }); + {%- endif %} {%- endfor %} {%- endif %} {%- if service.LocationMixin > 0 %} -{%- set method = 'getLocation' %} + {%- if '|getLocation|' not in methodNamesStr %} + {%- set method = 'getLocation' %} describe('{{ method }}', () => { it('invokes {{ method }} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client( @@ -1320,7 +1327,9 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { .getCall(0).calledWith(request, expectedOptions, undefined)); }); }); -{%- set method = 'listLocations' %} + {%- endif %} + {%- if '|listLocations|' not in methodNamesStr %} + {%- set method = 'listLocations' %} describe('{{ method }}Async', () => { it('uses async iteration with {{method}} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({{- util.initClientOptions(api.rest) -}}); @@ -1401,6 +1410,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { ); }); }); + {%- endif %} {%- endif %} {%- if (service.LongRunningOperationsMixin) > 0 %} {%- set Operationsmethods = ['getOperation', 'cancelOperation', 'deleteOperation'] %} From d75afb081277c2d3dee925d16c60f5733fed18b3 Mon Sep 17 00:00:00 2001 From: Shivanee Persaud Date: Tue, 31 Mar 2026 15:07:04 -0700 Subject: [PATCH 02/12] Revert "fix: add logic to check for IAM RPC methods within the service before adding mixin to avoid generating duplicate methods" This reverts commit 5759a4fcf661a64e8f13faa098e817ceb814bd93. --- .../templates/cjs/typescript_gapic/_iam.njk | 10 ----- .../cjs/typescript_gapic/_locations.njk | 7 --- .../src/$version/$service_client.ts.njk | 41 ++++++------------ .../test/gapic_$service_$version.ts.njk | 14 +----- .../templates/esm/typescript_gapic/_iam.njk | 10 ----- .../esm/typescript_gapic/_locations.njk | 7 --- .../esm/src/$version/$service_client.ts.njk | 43 ++++++------------- .../esm/test/gapic_$service_$version.ts.njk | 14 +----- 8 files changed, 28 insertions(+), 118 deletions(-) diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_iam.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_iam.njk index 967f24b8383..281ad5a33bc 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_iam.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_iam.njk @@ -5,12 +5,6 @@ IamClient is created for the client in the constructor. [setIamPolicy, getIamPolicy, testIamPermission] methods are created which is calling the corresponding methods from IamClient in google-gax. -#} -{{ getIamPolicy() }} -{{ setIamPolicy() }} -{{ testIamPermissions() }} -{%- endmacro -%} - -{%- macro getIamPolicy() -%} /** * Gets the access control policy for a resource. Returns an empty policy * if the resource exists and does not have a policy set. @@ -53,9 +47,7 @@ ):Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -{%- endmacro -%} -{%- macro setIamPolicy() -%} /** * Returns permissions that a caller has on the specified resource. If the * resource does not exist, this will return an empty set of @@ -102,9 +94,7 @@ ):Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -{%- endmacro -%} -{%- macro testIamPermissions() -%} /** * Returns permissions that a caller has on the specified resource. If the * resource does not exist, this will return an empty set of diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_locations.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_locations.njk index 085a3db8965..728b057d544 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_locations.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_locations.njk @@ -6,11 +6,6 @@ [getLocation, listLocations] methods are created which is calling the corresponding methods from LocationsClient in google-gax. Note that since the listLocations method is a paginated method, we default to using listLocationsAsync for ease of use. -#} -{{ getLocation() }} -{{ listLocationsAsync() }} -{%- endmacro -%} - -{%- macro getLocation() -%} /** * Gets information about a location. * @@ -50,9 +45,7 @@ ): Promise { return this.locationsClient.getLocation(request, options, callback); } -{%- endmacro -%} -{%- macro listLocationsAsync() -%} /** * Lists information about the supported locations for this service. Returns an iterable object. * diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk index e95e95e6b63..da67e250fe7 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk @@ -27,22 +27,18 @@ limitations under the License. {% import "../../_namer.njk" as namer -%} {{- namer.initialize(id, service) -}} {%- set autoPopulated = false -%} -{%- set methodNamesStr = "|" -%} {%- for method in service.method -%} {%- if method.autoPopulatedFields|length !== 0 %} {%- set autoPopulated = true -%} {%- endif %} - {%- set methodNamesStr = methodNamesStr + method.name.toCamelCase() + "|" -%} {%- endfor -%} -{%- set generateIam = service.IAMPolicyMixin > 0 and ('|getIamPolicy|' not in methodNamesStr or '|setIamPolicy|' not in methodNamesStr or '|testIamPermissions|' not in methodNamesStr) -%} -{%- set generateLocation = service.LocationMixin > 0 and ('|getLocation|' not in methodNamesStr or '|listLocations|' not in methodNamesStr) -%} import {% if (not api.legacyProtoLoad) and (autoPopulated === false) %}type {% endif %}* as gax from 'google-gax'; import type {Callback, CallOptions, Descriptors, ClientOptions {%- if service.longRunning.length > 0 or service.LongRunningOperationsMixin > 0 %}, GrpcClientOptions{%- endif -%} {%- if service.longRunning.length > 0 or service.diregapicLRO.length > 0 %}, LROperation{%- endif -%} {%- if service.paging.length > 0 %}, PaginationCallback, GaxCall{%- endif -%} -{%- if generateIam %}, IamClient, IamProtos{%- endif -%} -{%- if generateLocation %}, LocationsClient, LocationProtos{%- endif -%} +{%- if service.IAMPolicyMixin > 0 %}, IamClient, IamProtos{%- endif -%} +{%- if service.LocationMixin > 0 %}, LocationsClient, LocationProtos{%- endif -%} } from 'google-gax'; {% if service.paging.length > 0 or service.streaming.length > 0 -%} {% set importStreamJoiner = joiner(', ') -%} @@ -97,10 +93,10 @@ export class {{ service.name }}Client { }; warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; - {%- if generateIam %} + {%- if service.IAMPolicyMixin > 0 %} iamClient: IamClient; {%- endif %} - {%- if generateLocation %} + {%- if service.LocationMixin > 0 %} locationsClient: LocationsClient; {%- endif -%} {%- if service.pathTemplates.length > 0 %} @@ -226,11 +222,11 @@ export class {{ service.name }}Client { if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.{{ id.get("scopes") }}; } - {%- if generateIam %} + {%- if service.IAMPolicyMixin > 0 %} this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); {% endif %} - {%- if generateLocation %} + {%- if service.LocationMixin > 0 %} this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, opts @@ -1106,24 +1102,11 @@ export class {{ service.name }}Client { } {%- endif %} {%- endfor %} -{%- if generateIam %} - {%- if '|getIamPolicy|' not in methodNamesStr %} - {{ iam.getIamPolicy()}} - {%- endif %} - {%- if '|setIamPolicy|' not in methodNamesStr %} - {{ iam.setIamPolicy()}} - {%- endif %} - {%- if '|testIamPermissions|' not in methodNamesStr %} - {{ iam.testIamPermissions()}} - {%- endif %} +{%- if service.IAMPolicyMixin > 0 %} +{{ iam.iamServiceMethods()}} {% endif -%} -{%- if generateLocation %} - {%- if '|getLocation|' not in methodNamesStr %} - {{ location.getLocation() }} - {%- endif %} - {%- if '|listLocations|' not in methodNamesStr %} - {{ location.listLocationsAsync() }} - {%- endif %} +{%- if service.LocationMixin > 0 %} +{{ location.locationServiceMethods()}} {% endif -%} {%- if service.LongRunningOperationsMixin > 0 %} {{ operations.operationsServiceMethods()}} @@ -1182,10 +1165,10 @@ export class {{ service.name }}Client { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - {%- if generateIam %} + {%- if service.IAMPolicyMixin > 0 %} this.iamClient.close().catch(err => {throw err}); {%- endif %} - {%- if generateLocation %} + {%- if service.LocationMixin > 0 %} this.locationsClient.close().catch(err => {throw err}); {%- endif %} {%- if service.longRunning.length > 0 or service.LongRunningOperationsMixin > 0 %} diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk index 265d9de60c7..cb601868033 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk @@ -20,10 +20,6 @@ limitations under the License. {{license.license(commonParameters.copyrightYear)}} {% import "../_namer.njk" as namer -%} {{- namer.initialize(id, service) -}} -{%- set methodNamesStr = "|" -%} -{%- for method in service.method -%} - {%- set methodNamesStr = methodNamesStr + method.name.toCamelCase() + "|" -%} -{%- endfor -%} import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; @@ -1093,7 +1089,6 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { {%- if (service.IAMPolicyMixin) > 0 %} {%- set IAMmethods = ['getIamPolicy', 'setIamPolicy', 'testIamPermissions'] %} {%- for method in IAMmethods %} - {%- if ('|' + method + '|') not in methodNamesStr %} describe('{{ method }}', () => { it('invokes {{ method }} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client( @@ -1209,12 +1204,10 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { .getCall(0).calledWith(request, expectedOptions, undefined)); }); }); - {%- endif %} {%- endfor %} {%- endif %} {%- if service.LocationMixin > 0 %} - {%- if '|getLocation|' not in methodNamesStr %} - {%- set method = 'getLocation' %} +{%- set method = 'getLocation' %} describe('{{ method }}', () => { it('invokes {{ method }} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client( @@ -1321,9 +1314,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { .getCall(0).calledWith(request, expectedOptions, undefined)); }); }); - {%- endif %} - {%- if '|listLocations|' not in methodNamesStr %} - {%- set method = 'listLocations' %} +{%- set method = 'listLocations' %} describe('{{ method }}Async', () => { it('uses async iteration with {{method}} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({{- util.initClientOptions(api.rest) -}}); @@ -1404,7 +1395,6 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { ); }); }); - {%- endif %} {%- endif %} {%- if (service.LongRunningOperationsMixin) > 0 %} {%- set Operationsmethods = ['getOperation', 'cancelOperation', 'deleteOperation'] %} diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_iam.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_iam.njk index 967f24b8383..281ad5a33bc 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_iam.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_iam.njk @@ -5,12 +5,6 @@ IamClient is created for the client in the constructor. [setIamPolicy, getIamPolicy, testIamPermission] methods are created which is calling the corresponding methods from IamClient in google-gax. -#} -{{ getIamPolicy() }} -{{ setIamPolicy() }} -{{ testIamPermissions() }} -{%- endmacro -%} - -{%- macro getIamPolicy() -%} /** * Gets the access control policy for a resource. Returns an empty policy * if the resource exists and does not have a policy set. @@ -53,9 +47,7 @@ ):Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -{%- endmacro -%} -{%- macro setIamPolicy() -%} /** * Returns permissions that a caller has on the specified resource. If the * resource does not exist, this will return an empty set of @@ -102,9 +94,7 @@ ):Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -{%- endmacro -%} -{%- macro testIamPermissions() -%} /** * Returns permissions that a caller has on the specified resource. If the * resource does not exist, this will return an empty set of diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_locations.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_locations.njk index 085a3db8965..728b057d544 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_locations.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_locations.njk @@ -6,11 +6,6 @@ [getLocation, listLocations] methods are created which is calling the corresponding methods from LocationsClient in google-gax. Note that since the listLocations method is a paginated method, we default to using listLocationsAsync for ease of use. -#} -{{ getLocation() }} -{{ listLocationsAsync() }} -{%- endmacro -%} - -{%- macro getLocation() -%} /** * Gets information about a location. * @@ -50,9 +45,7 @@ ): Promise { return this.locationsClient.getLocation(request, options, callback); } -{%- endmacro -%} -{%- macro listLocationsAsync() -%} /** * Lists information about the supported locations for this service. Returns an iterable object. * diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk index cbe961430b2..62d4d28e97d 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk @@ -26,19 +26,13 @@ limitations under the License. {% import "../../../_operations.njk" as operations -%} {% import "../../../_namer.njk" as namer -%} {{- namer.initialize(id, service) -}} -{%- set methodNamesStr = "|" -%} -{%- for method in service.method -%} - {%- set methodNamesStr = methodNamesStr + method.name.toCamelCase() + "|" -%} -{%- endfor -%} -{%- set generateIam = service.IAMPolicyMixin > 0 and ('|getIamPolicy|' not in methodNamesStr or '|setIamPolicy|' not in methodNamesStr or '|testIamPermissions|' not in methodNamesStr) -%} -{%- set generateLocation = service.LocationMixin > 0 and ('|getLocation|' not in methodNamesStr or '|listLocations|' not in methodNamesStr) -%} import * as gax from 'google-gax'; import type {Callback, CallOptions, Descriptors, ClientOptions {%- if service.longRunning.length > 0 or service.LongRunningOperationsMixin > 0 %}, GrpcClientOptions{%- endif -%} {%- if service.longRunning.length > 0 or service.diregapicLRO.length > 0 %}, LROperation{%- endif -%} {%- if service.paging.length > 0 %}, PaginationCallback, GaxCall{%- endif -%} -{%- if generateIam %}, IamClient, IamProtos{%- endif -%} -{%- if generateLocation %}, LocationsClient, LocationProtos{%- endif -%} +{%- if service.IAMPolicyMixin > 0 %}, IamClient, IamProtos{%- endif -%} +{%- if service.LocationMixin > 0 %}, LocationsClient, LocationProtos{%- endif -%} } from 'google-gax'; {% if service.paging.length > 0 or service.streaming.length > 0 -%} {% set importStreamJoiner = joiner(', ') -%} @@ -105,10 +99,10 @@ export class {{ service.name }}Client { }; warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; - {%- if generateIam %} + {%- if service.IAMPolicyMixin > 0 %} iamClient: IamClient; {%- endif %} - {%- if generateLocation %} + {%- if service.LocationMixin > 0 %} locationsClient: LocationsClient; {%- endif -%} {%- if service.pathTemplates.length > 0 %} @@ -235,11 +229,11 @@ export class {{ service.name }}Client { if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.{{ id.get("scopes") }}; } - {%- if generateIam %} + {%- if service.IAMPolicyMixin > 0 %} this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); {% endif %} - {%- if generateLocation %} + {%- if service.LocationMixin > 0 %} this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, opts @@ -1115,24 +1109,11 @@ export class {{ service.name }}Client { } {%- endif %} {%- endfor %} -{%- if generateIam %} - {%- if '|getIamPolicy|' not in methodNamesStr %} - {{ iam.getIamPolicy()}} - {%- endif %} - {%- if '|setIamPolicy|' not in methodNamesStr %} - {{ iam.setIamPolicy()}} - {%- endif %} - {%- if '|testIamPermissions|' not in methodNamesStr %} - {{ iam.testIamPermissions()}} - {%- endif %} +{%- if service.IAMPolicyMixin > 0 %} +{{ iam.iamServiceMethods()}} {% endif -%} -{%- if generateLocation %} - {%- if '|getLocation|' not in methodNamesStr %} - {{ location.getLocation() }} - {%- endif %} - {%- if '|listLocations|' not in methodNamesStr %} - {{ location.listLocationsAsync() }} - {%- endif %} +{%- if service.LocationMixin > 0 %} +{{ location.locationServiceMethods()}} {% endif -%} {%- if service.LongRunningOperationsMixin > 0 %} {{ operations.operationsServiceMethods()}} @@ -1191,10 +1172,10 @@ export class {{ service.name }}Client { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - {%- if generateIam %} + {%- if service.IAMPolicyMixin > 0 %} this.iamClient.close().catch(err => {throw err}); {%- endif %} - {%- if generateLocation %} + {%- if service.LocationMixin > 0 %} this.locationsClient.close().catch(err => {throw err}); {%- endif %} {%- if service.longRunning.length > 0 or service.LongRunningOperationsMixin > 0 %} diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk index 78301892fc7..0d723c4e2ea 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk @@ -20,10 +20,6 @@ limitations under the License. {{license.license(commonParameters.copyrightYear)}} {% import "../../_namer.njk" as namer -%} {{- namer.initialize(id, service) -}} -{%- set methodNamesStr = "|" -%} -{%- for method in service.method -%} - {%- set methodNamesStr = methodNamesStr + method.name.toCamelCase() + "|" -%} -{%- endfor -%} // @ts-ignore import * as protos from '../../protos/protos.js'; import assert from 'assert'; @@ -1099,7 +1095,6 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { {%- if (service.IAMPolicyMixin) > 0 %} {%- set IAMmethods = ['getIamPolicy', 'setIamPolicy', 'testIamPermissions'] %} {%- for method in IAMmethods %} - {%- if ('|' + method + '|') not in methodNamesStr %} describe('{{ method }}', () => { it('invokes {{ method }} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client( @@ -1215,12 +1210,10 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { .getCall(0).calledWith(request, expectedOptions, undefined)); }); }); - {%- endif %} {%- endfor %} {%- endif %} {%- if service.LocationMixin > 0 %} - {%- if '|getLocation|' not in methodNamesStr %} - {%- set method = 'getLocation' %} +{%- set method = 'getLocation' %} describe('{{ method }}', () => { it('invokes {{ method }} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client( @@ -1327,9 +1320,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { .getCall(0).calledWith(request, expectedOptions, undefined)); }); }); - {%- endif %} - {%- if '|listLocations|' not in methodNamesStr %} - {%- set method = 'listLocations' %} +{%- set method = 'listLocations' %} describe('{{ method }}Async', () => { it('uses async iteration with {{method}} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({{- util.initClientOptions(api.rest) -}}); @@ -1410,7 +1401,6 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { ); }); }); - {%- endif %} {%- endif %} {%- if (service.LongRunningOperationsMixin) > 0 %} {%- set Operationsmethods = ['getOperation', 'cancelOperation', 'deleteOperation'] %} From b3ee7c3e61bc271f65dc583125b41e5f94d77c8c Mon Sep 17 00:00:00 2001 From: Shivanee Persaud Date: Tue, 31 Mar 2026 15:53:20 -0700 Subject: [PATCH 03/12] Update logic to be in the TypeScript layer --- .../templates/cjs/typescript_gapic/_iam.njk | 14 +++++--- .../cjs/typescript_gapic/_locations.njk | 6 +++- .../src/$version/$service_client.ts.njk | 4 +-- .../test/gapic_$service_$version.ts.njk | 6 ++++ .../templates/esm/typescript_gapic/_iam.njk | 14 +++++--- .../esm/typescript_gapic/_locations.njk | 5 ++- .../esm/src/$version/$service_client.ts.njk | 4 +-- .../esm/test/gapic_$service_$version.ts.njk | 6 ++++ .../typescript/src/schema/proto.ts | 32 +++++++++++++++++++ 9 files changed, 77 insertions(+), 14 deletions(-) diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_iam.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_iam.njk index 281ad5a33bc..2e3d3b938f5 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_iam.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_iam.njk @@ -1,4 +1,4 @@ -{%- macro iamServiceMethods() -%} +{%- macro iamServiceMethods(service) -%} {#- This part will be added into src/version/client.ts. If the --service-yaml contains "google.iam.v1.IAMPolicy", it means the client requires IAM methods [setIamPolicy, getIamPolicy, testIamPermission]. @@ -30,7 +30,8 @@ * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. * The promise has a method named "cancel" which cancels the ongoing API call. */ - getIamPolicy( +{%- if service.iamPolicyMixinFlags.getIamPolicy == true %} + /** request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: | gax.CallOptions @@ -47,6 +48,7 @@ ):Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } +{%- endif %} /** * Returns permissions that a caller has on the specified resource. If the @@ -77,7 +79,8 @@ * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. * The promise has a method named "cancel" which cancels the ongoing API call. */ - setIamPolicy( +{%- if service.iamPolicyMixinFlags.setIamPolicy %} + /** request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: | gax.CallOptions @@ -94,6 +97,7 @@ ):Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } +{%- endif %} /** * Returns permissions that a caller has on the specified resource. If the @@ -125,7 +129,8 @@ * The promise has a method named "cancel" which cancels the ongoing API call. * */ - testIamPermissions( +{%- if service.iamPolicyMixinFlags.testIamPermissions %} + /** request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: | gax.CallOptions @@ -142,4 +147,5 @@ ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } +{%- endif %} {%- endmacro -%} diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_locations.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_locations.njk index 728b057d544..1db7c0bbfc5 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_locations.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_locations.njk @@ -1,4 +1,4 @@ -{%- macro locationServiceMethods() -%} +{%- macro locationServiceMethods(service) -%} {#- This part will be added into src/version/client.ts. If the --service-yaml contains "google.cloud.location.Locations", it means the client requires Locations methods [getLocation, listLocations]. @@ -6,6 +6,7 @@ [getLocation, listLocations] methods are created which is calling the corresponding methods from LocationsClient in google-gax. Note that since the listLocations method is a paginated method, we default to using listLocationsAsync for ease of use. -#} +{%- if service.locationMixinFlags.getLocation %} /** * Gets information about a location. * @@ -45,7 +46,9 @@ ): Promise { return this.locationsClient.getLocation(request, options, callback); } +{%- endif %} +{%- if service.locationMixinFlags.listLocations %} /** * Lists information about the supported locations for this service. Returns an iterable object. * @@ -83,4 +86,5 @@ ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } +{%- endif %} {%- endmacro -%} diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk index da67e250fe7..e4a61222783 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk @@ -1103,10 +1103,10 @@ export class {{ service.name }}Client { {%- endif %} {%- endfor %} {%- if service.IAMPolicyMixin > 0 %} -{{ iam.iamServiceMethods()}} +{{ iam.iamServiceMethods(service)}} {% endif -%} {%- if service.LocationMixin > 0 %} -{{ location.locationServiceMethods()}} +{{ location.locationServiceMethods(service)}} {% endif -%} {%- if service.LongRunningOperationsMixin > 0 %} {{ operations.operationsServiceMethods()}} diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk index cb601868033..b23796cfb16 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk @@ -1089,6 +1089,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { {%- if (service.IAMPolicyMixin) > 0 %} {%- set IAMmethods = ['getIamPolicy', 'setIamPolicy', 'testIamPermissions'] %} {%- for method in IAMmethods %} +{%- if service.iamPolicyMixinFlags[method] %} describe('{{ method }}', () => { it('invokes {{ method }} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client( @@ -1204,10 +1205,12 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { .getCall(0).calledWith(request, expectedOptions, undefined)); }); }); +{%- endif %} {%- endfor %} {%- endif %} {%- if service.LocationMixin > 0 %} {%- set method = 'getLocation' %} +{%- if service.locationMixinFlags.getLocation %} describe('{{ method }}', () => { it('invokes {{ method }} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client( @@ -1314,7 +1317,9 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { .getCall(0).calledWith(request, expectedOptions, undefined)); }); }); +{%- endif %} {%- set method = 'listLocations' %} +{%- if service.locationMixinFlags.listLocations %} describe('{{ method }}Async', () => { it('uses async iteration with {{method}} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({{- util.initClientOptions(api.rest) -}}); @@ -1396,6 +1401,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { }); }); {%- endif %} +{%- endif %} {%- if (service.LongRunningOperationsMixin) > 0 %} {%- set Operationsmethods = ['getOperation', 'cancelOperation', 'deleteOperation'] %} {%- for method in Operationsmethods %} diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_iam.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_iam.njk index 281ad5a33bc..a756f6d798d 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_iam.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_iam.njk @@ -1,4 +1,4 @@ -{%- macro iamServiceMethods() -%} +{%- macro iamServiceMethods(service) -%} {#- This part will be added into src/version/client.ts. If the --service-yaml contains "google.iam.v1.IAMPolicy", it means the client requires IAM methods [setIamPolicy, getIamPolicy, testIamPermission]. @@ -30,7 +30,8 @@ * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. * The promise has a method named "cancel" which cancels the ongoing API call. */ - getIamPolicy( +{%- if service.iamPolicyMixinFlags.getIamPolicy %} + /** request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: | gax.CallOptions @@ -47,6 +48,7 @@ ):Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } +{%- endif %} /** * Returns permissions that a caller has on the specified resource. If the @@ -77,7 +79,8 @@ * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. * The promise has a method named "cancel" which cancels the ongoing API call. */ - setIamPolicy( +{%- if service.iamPolicyMixinFlags.setIamPolicy %} + /** request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: | gax.CallOptions @@ -94,6 +97,7 @@ ):Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } +{%- endif %} /** * Returns permissions that a caller has on the specified resource. If the @@ -125,7 +129,8 @@ * The promise has a method named "cancel" which cancels the ongoing API call. * */ - testIamPermissions( +{%- if service.iamPolicyMixinFlags.testIamPermissions %} + /** request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: | gax.CallOptions @@ -142,4 +147,5 @@ ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } +{%- endif %} {%- endmacro -%} diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_locations.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_locations.njk index 728b057d544..c147d8c8c04 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_locations.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_locations.njk @@ -1,4 +1,4 @@ -{%- macro locationServiceMethods() -%} +{%- macro locationServiceMethods(service) -%} {#- This part will be added into src/version/client.ts. If the --service-yaml contains "google.cloud.location.Locations", it means the client requires Locations methods [getLocation, listLocations]. @@ -6,6 +6,7 @@ [getLocation, listLocations] methods are created which is calling the corresponding methods from LocationsClient in google-gax. Note that since the listLocations method is a paginated method, we default to using listLocationsAsync for ease of use. -#} +{%- if service.locationMixinFlags.getLocation %} /** * Gets information about a location. * @@ -45,6 +46,7 @@ ): Promise { return this.locationsClient.getLocation(request, options, callback); } +{%- endif %} /** * Lists information about the supported locations for this service. Returns an iterable object. @@ -83,4 +85,5 @@ ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } +{%- endif %} {%- endmacro -%} diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk index 62d4d28e97d..ce28ddabb44 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk @@ -1110,10 +1110,10 @@ export class {{ service.name }}Client { {%- endif %} {%- endfor %} {%- if service.IAMPolicyMixin > 0 %} -{{ iam.iamServiceMethods()}} +{{ iam.iamServiceMethods(service)}} {% endif -%} {%- if service.LocationMixin > 0 %} -{{ location.locationServiceMethods()}} +{{ location.locationServiceMethods(service)}} {% endif -%} {%- if service.LongRunningOperationsMixin > 0 %} {{ operations.operationsServiceMethods()}} diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk index 0d723c4e2ea..bf5cc387e40 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk @@ -1095,6 +1095,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { {%- if (service.IAMPolicyMixin) > 0 %} {%- set IAMmethods = ['getIamPolicy', 'setIamPolicy', 'testIamPermissions'] %} {%- for method in IAMmethods %} +{%- if service.iamPolicyMixinFlags[method] %} describe('{{ method }}', () => { it('invokes {{ method }} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client( @@ -1210,10 +1211,12 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { .getCall(0).calledWith(request, expectedOptions, undefined)); }); }); +{%- endif %} {%- endfor %} {%- endif %} {%- if service.LocationMixin > 0 %} {%- set method = 'getLocation' %} +{%- if service.locationMixinFlags.getLocation %} describe('{{ method }}', () => { it('invokes {{ method }} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client( @@ -1320,7 +1323,9 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { .getCall(0).calledWith(request, expectedOptions, undefined)); }); }); +{%- endif %} {%- set method = 'listLocations' %} +{%- if service.locationMixinFlags.listLocations %} describe('{{ method }}Async', () => { it('uses async iteration with {{method}} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({{- util.initClientOptions(api.rest) -}}); @@ -1402,6 +1407,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { }); }); {%- endif %} +{%- endif %} {%- if (service.LongRunningOperationsMixin) > 0 %} {%- set Operationsmethods = ['getOperation', 'cancelOperation', 'deleteOperation'] %} {%- for method in Operationsmethods %} diff --git a/core/generator/gapic-generator-typescript/typescript/src/schema/proto.ts b/core/generator/gapic-generator-typescript/typescript/src/schema/proto.ts index dc3d4e20c48..d5c52199bf0 100644 --- a/core/generator/gapic-generator-typescript/typescript/src/schema/proto.ts +++ b/core/generator/gapic-generator-typescript/typescript/src/schema/proto.ts @@ -83,6 +83,21 @@ export interface MethodDescriptorProto maxResultsParameter?: boolean; } +export interface MixinConfig { + enabled: boolean; +} + +export interface IamPolicyMixinConfig extends MixinConfig { + getIamPolicy: boolean; + setIamPolicy: boolean; + testIamPermissions: boolean; +} + +export interface LocationMixinConfig extends MixinConfig { + getLocation: boolean; + listLocations: boolean; +} + export interface ServiceDescriptorProto extends protos.google.protobuf.IServiceDescriptorProto { internalMethods: MethodDescriptorProto[]; @@ -111,6 +126,8 @@ export interface ServiceDescriptorProto IAMPolicyMixin: number; LocationMixin: number; LongRunningOperationsMixin: number; + iamPolicyMixinFlags?: IamPolicyMixinConfig; + locationMixinFlags?: LocationMixinConfig; protoFile: string; diregapicLRO?: MethodDescriptorProto[]; httpRules?: protos.google.api.IHttpRule[]; @@ -1031,6 +1048,21 @@ export function augmentService(parameters: AugmentServiceParameters) { SelectiveGapicType.INTERNAL, ); + const nativeMethods = augmentedService.method || []; + const nativeMethodNames = nativeMethods.map(m => m.name); + augmentedService.iamPolicyMixinFlags = { + enabled: augmentedService.IAMPolicyMixin === 1, + getIamPolicy: !nativeMethodNames.includes('GetIamPolicy'), + setIamPolicy: !nativeMethodNames.includes('SetIamPolicy'), + testIamPermissions: !nativeMethodNames.includes('TestIamPermissions'), + }; + + augmentedService.locationMixinFlags = { + enabled: augmentedService.LocationMixin === 1, + getLocation: !nativeMethodNames.includes('GetLocation'), + listLocations: !nativeMethodNames.includes('ListLocations'), + }; + augmentedService.bundleConfigsMethods = augmentedService.method.filter( method => method.bundleConfig, ); From e6175e03f876dacf773a812b38cfdf93750c37e2 Mon Sep 17 00:00:00 2001 From: Shivanee Persaud Date: Tue, 31 Mar 2026 16:24:02 -0700 Subject: [PATCH 04/12] Add unit tests --- .../typescript/test/unit/proto.ts | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/core/generator/gapic-generator-typescript/typescript/test/unit/proto.ts b/core/generator/gapic-generator-typescript/typescript/test/unit/proto.ts index 26cc3a16793..1d274ec2893 100644 --- a/core/generator/gapic-generator-typescript/typescript/test/unit/proto.ts +++ b/core/generator/gapic-generator-typescript/typescript/test/unit/proto.ts @@ -420,6 +420,52 @@ describe('src/schema/proto.ts', () => { assert.strictEqual(proto.services[fd.service[0].name].protoFile, fd.name); }); + it('should calculate mixin flags accurately for duplicate methods', () => { + const fd = {} as protos.google.protobuf.FileDescriptorProto; + fd.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; + fd.service[0].name = 'TestService'; + fd.service[0].method = [ + {name: 'GetIamPolicy'}, + {name: 'ListLocations'}, + ] as protos.google.protobuf.MethodDescriptorProto[]; + + // Simulating mixins being enabled (non-zero value) + (fd.service[0] as any).IAMPolicyMixin = 1; + (fd.service[0] as any).LocationMixin = 1; + + const options: Options = { + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, + }; + + const augmentedService = augmentService({ + allMessages: {}, + localMessages: {}, + packageName: 'google.showcase.v1beta1', + service: fd.service[0], + commentsMap: new CommentsMap([fd]), + allResourceDatabase: new ResourceDatabase(), + resourceDatabase: new ResourceDatabase(), + options, + protoFile: 'fd', + }); + + assert.strictEqual( + augmentedService.iamPolicyMixinFlags?.getIamPolicy, + false + ); // Native GetIamPolicy exists + assert.strictEqual(augmentedService.iamPolicyMixinFlags?.setIamPolicy, true); + assert.strictEqual( + augmentedService.iamPolicyMixinFlags?.testIamPermissions, + true + ); + + assert.strictEqual(augmentedService.locationMixinFlags?.getLocation, true); + assert.strictEqual( + augmentedService.locationMixinFlags?.listLocations, + false + ); // Native ListLocations exists + }); + it('should return api version if it exists', () => { const fd = {} as protos.google.protobuf.FileDescriptorProto; fd.name = 'google/cloud/showcase/v1beta1/test.proto'; From e412b95f9c9040c70e0285131d759abd1e8faf88 Mon Sep 17 00:00:00 2001 From: Shivanee Persaud Date: Tue, 31 Mar 2026 17:08:44 -0700 Subject: [PATCH 05/12] Add files to test generated code. --- .../v1/duplicate_methods_test_v1.proto | 66 +++++++++++++++++++ .../v1/duplicate_methods_test_v1.yaml | 26 ++++++++ 2 files changed, 92 insertions(+) create mode 100644 core/generator/gapic-generator-typescript/test-fixtures/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto create mode 100644 core/generator/gapic-generator-typescript/test-fixtures/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.yaml diff --git a/core/generator/gapic-generator-typescript/test-fixtures/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto b/core/generator/gapic-generator-typescript/test-fixtures/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto new file mode 100644 index 00000000000..b91e79094ff --- /dev/null +++ b/core/generator/gapic-generator-typescript/test-fixtures/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto @@ -0,0 +1,66 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.duplicate_methods_test.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/cloud/location/locations.proto"; + +option csharp_namespace = "Google.DuplicateMethodsTest.V1"; +option go_package = "google.golang.org/genproto/googleapis/duplicate_methods_test/v1;duplicate_methods_test"; +option java_multiple_files = true; +option java_outer_classname = "DuplicateMethodsTestProto"; +option java_package = "com.google.duplicate_methods_test.v1"; +option php_namespace = "Google\\DuplicateMethodsTest\\V1"; +option ruby_package = "Google::DuplicateMethodsTest::V1"; + +service DuplicateMethodsTestService { + option (google.api.default_host) = "duplicatemethodstest.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Native GetIamPolicy method that conflicts with the IAMPolicy mixin. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + get: "/v1/{resource=projects/*}:getIamPolicy" + }; + } + + // Native ListLocations method that conflicts with the Locations mixin. + rpc ListLocations(google.cloud.location.ListLocationsRequest) returns (google.cloud.location.ListLocationsResponse) { + option (google.api.http) = { + get: "/v1/{name=projects/*}/locations" + }; + } + + // Another native method to ensure the service is valid and has other methods. + rpc Echo(EchoRequest) returns (EchoResponse) { + option (google.api.http) = { + post: "/v1/echo" + body: "*" + }; + } +} + +message EchoRequest { + string content = 1; +} + +message EchoResponse { + string content = 1; +} diff --git a/core/generator/gapic-generator-typescript/test-fixtures/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.yaml b/core/generator/gapic-generator-typescript/test-fixtures/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.yaml new file mode 100644 index 00000000000..2cacee59791 --- /dev/null +++ b/core/generator/gapic-generator-typescript/test-fixtures/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.yaml @@ -0,0 +1,26 @@ +type: google.api.Service +config_version: 3 +name: duplicatemethodstest.googleapis.com +title: Duplicate Methods Test Service API + +apis: +- name: google.duplicate_methods_test.v1.DuplicateMethodsTestService +- name: google.iam.v1.IAMPolicy +- name: google.cloud.location.Locations + +# We don't need to define HTTP rules for the native methods here if they are in the proto, +# but we can define standard ones if we want to ensure full coverage. +http: + rules: + - selector: google.iam.v1.IAMPolicy.SetIamPolicy + post: '/v1/{resource=projects/*}:setIamPolicy' + body: '*' + - selector: google.iam.v1.IAMPolicy.GetIamPolicy + get: '/v1/{resource=projects/*}:getIamPolicy' + - selector: google.iam.v1.IAMPolicy.TestIamPermissions + post: '/v1/{resource=projects/*}:testIamPermissions' + body: '*' + - selector: google.cloud.location.Locations.GetLocation + get: '/v1/{name=projects/*}/locations' + - selector: google.cloud.location.Locations.ListLocations + get: '/v1/{name=projects/*}/locations' From 0e754eea0823a07b429d1ad39c5729ecd485d4bc Mon Sep 17 00:00:00 2001 From: Shivanee Persaud Date: Tue, 31 Mar 2026 17:18:29 -0700 Subject: [PATCH 06/12] Add baseline files --- .../CODE_OF_CONDUCT.md | 94 ++ .../CONTRIBUTING.md | 76 ++ .../duplicate_methods_test-esm/LICENSE | 202 ++++ .../duplicate_methods_test-esm/README.md | 108 ++ .../esm/src/index.ts | 26 + .../esm/src/json-helper.cjs | 20 + .../duplicate_methods_test_service_client.ts | 917 ++++++++++++++++ ...te_methods_test_service_client_config.json | 38 + ...icate_methods_test_service_proto_list.json | 3 + .../esm/src/v1/index.ts | 19 + .../system-test/fixtures/sample/src/index.cjs | 27 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 33 + .../esm/system-test/install.ts | 55 + ...gapic_duplicate_methods_test_service_v1.ts | 977 ++++++++++++++++++ .../duplicate_methods_test-esm/package.json | 105 ++ .../v1/duplicate_methods_test_v1.proto | 66 ++ .../v1/duplicate_methods_test_service.echo.js | 59 ++ ...ate_methods_test_service.get_iam_policy.js | 67 ++ ...ate_methods_test_service.list_locations.js | 74 ++ ...data_google.duplicate_methods_test.v1.json | 151 +++ .../tsconfig.esm.json | 27 + .../duplicate_methods_test-esm/tsconfig.json | 32 + .../webpack.config.cjs | 64 ++ .../duplicate_methods_test/CODE_OF_CONDUCT.md | 94 ++ .../duplicate_methods_test/CONTRIBUTING.md | 76 ++ .../baselines/duplicate_methods_test/LICENSE | 202 ++++ .../duplicate_methods_test/README.md | 108 ++ .../duplicate_methods_test/package.json | 58 ++ .../v1/duplicate_methods_test_v1.proto | 66 ++ .../v1/duplicate_methods_test_service.echo.js | 59 ++ ...ate_methods_test_service.get_iam_policy.js | 67 ++ ...ate_methods_test_service.list_locations.js | 74 ++ ...data_google.duplicate_methods_test.v1.json | 151 +++ .../duplicate_methods_test/src/index.ts | 25 + .../duplicate_methods_test_service_client.ts | 899 ++++++++++++++++ ...te_methods_test_service_client_config.json | 38 + ...icate_methods_test_service_proto_list.json | 3 + .../duplicate_methods_test/src/v1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../system-test/install.ts | 49 + ...gapic_duplicate_methods_test_service_v1.ts | 968 +++++++++++++++++ .../duplicate_methods_test/tsconfig.json | 22 + .../duplicate_methods_test/webpack.config.js | 64 ++ .../esm/typescript_gapic/_locations.njk | 1 + .../typescript/test/unit/baselines-esm.ts | 8 + .../typescript/test/unit/baselines.ts | 7 + 48 files changed, 6384 insertions(+) create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/CODE_OF_CONDUCT.md create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/CONTRIBUTING.md create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/LICENSE create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/README.md create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/index.ts create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/json-helper.cjs create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client.ts create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client_config.json create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_proto_list.json create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/v1/index.ts create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.cjs create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.js create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.ts create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/system-test/install.ts create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/test/gapic_duplicate_methods_test_service_v1.ts create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/package.json create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.echo.js create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.list_locations.js create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/tsconfig.esm.json create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/tsconfig.json create mode 100644 core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/webpack.config.cjs create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/CODE_OF_CONDUCT.md create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/CONTRIBUTING.md create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/LICENSE create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/README.md create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/package.json create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.echo.js create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.list_locations.js create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/index.ts create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client.ts create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client_config.json create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_proto_list.json create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/index.ts create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.js create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.ts create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/install.ts create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/test/gapic_duplicate_methods_test_service_v1.ts create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/tsconfig.json create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/webpack.config.js diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/CODE_OF_CONDUCT.md b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..2add2547a81 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/CODE_OF_CONDUCT.md @@ -0,0 +1,94 @@ + +# Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of +experience, education, socio-economic status, nationality, personal appearance, +race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +This Code of Conduct also applies outside the project spaces when the Project +Steward has a reasonable belief that an individual's behavior may have a +negative impact on the project or its community. + +## Conflict Resolution + +We do not believe that all conflict is bad; healthy debate and disagreement +often yield positive results. However, it is never okay to be disrespectful or +to engage in behavior that violates the project’s code of conduct. + +If you see someone violating the code of conduct, you are encouraged to address +the behavior directly with those involved. Many issues can be resolved quickly +and easily, and this gives people more control over the outcome of their +dispute. If you are unable to resolve the matter for any reason, or if the +behavior is threatening or harassing, report it. We are dedicated to providing +an environment where participants feel welcome and safe. + +Reports should be directed to *googleapis-stewards@google.com*, the +Project Steward(s) for *Google Cloud Client Libraries*. It is the Project Steward’s duty to +receive and address reported violations of the code of conduct. They will then +work with a committee consisting of representatives from the Open Source +Programs Office and the Google Open Source Strategy team. If for any reason you +are uncomfortable reaching out to the Project Steward, please email +opensource@google.com. + +We will investigate every complaint, but you may not receive a direct response. +We will use our discretion in determining when and how to follow up on reported +incidents, which may range from not taking action to permanent expulsion from +the project and project-sponsored spaces. We will notify the accused of the +report and provide them an opportunity to discuss it before any action is taken. +The identity of the reporter will be omitted from the details of the report +supplied to the accused. In potentially harmful situations, such as ongoing +harassment or threats to anyone's safety, we may take action without notice. + +## Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, +available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/CONTRIBUTING.md b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/CONTRIBUTING.md new file mode 100644 index 00000000000..099d8bfb0e8 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/CONTRIBUTING.md @@ -0,0 +1,76 @@ +# How to become a contributor and submit your own code + +**Table of contents** + +* [Contributor License Agreements](#contributor-license-agreements) +* [Contributing a patch](#contributing-a-patch) +* [Running the tests](#running-the-tests) +* [Releasing the library](#releasing-the-library) + +## Contributor License Agreements + +We'd love to accept your sample apps and patches! Before we can take them, we +have to jump a couple of legal hurdles. + +Please fill out either the individual or corporate Contributor License Agreement +(CLA). + + * If you are an individual writing original source code and you're sure you + own the intellectual property, then you'll need to sign an [individual CLA](https://developers.google.com/open-source/cla/individual). + * If you work for a company that wants to allow you to contribute your work, + then you'll need to sign a [corporate CLA](https://developers.google.com/open-source/cla/corporate). + +Follow either of the two links above to access the appropriate CLA and +instructions for how to sign and return it. Once we receive it, we'll be able to +accept your pull requests. + +## Contributing A Patch + +1. Submit an issue describing your proposed change to the repo in question. +1. The repo owner will respond to your issue promptly. +1. If your proposed change is accepted, and you haven't already done so, sign a + Contributor License Agreement (see details above). +1. Fork the desired repo, develop and test your code changes. +1. Ensure that your code adheres to the existing style in the code to which + you are contributing. +1. Ensure that your code has an appropriate set of tests which all pass. +1. Title your pull request following [Conventional Commits](https://www.conventionalcommits.org/) styling. +1. Submit a pull request. + +### Before you begin + +1. [Select or create a Cloud Platform project][projects]. +1. [Enable billing for your project][billing]. +1. [Enable the Duplicate_methods_test API][enable_api]. +1. [Set up authentication with a service account][auth] so you can access the + API from your local workstation. + + +## Running the tests + +1. [Prepare your environment for Node.js setup][setup]. + +1. Install dependencies: + + npm install + +1. Run the tests: + + # Run unit tests. + npm test + + # Run sample integration tests. + npm run samples-test + + # Run all system tests. + npm run system-test + +1. Lint (and maybe fix) any changes: + + npm run fix + +[setup]: https://cloud.google.com/nodejs/docs/setup +[projects]: https://console.cloud.google.com/project +[billing]: https://support.google.com/cloud/answer/6293499#enable-billing +[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=duplicatemethodstest.googleapis.com +[auth]: https://cloud.google.com/docs/authentication/getting-started \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/LICENSE b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/README.md b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/README.md new file mode 100644 index 00000000000..2ad47e789f2 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/README.md @@ -0,0 +1,108 @@ +[//]: # "This README.md file is auto-generated, all changes to this file will be lost." +[//]: # "The comments you see below are used to generate those parts of the template in later states." +Google Cloud Platform logo + +# [Duplicate Methods Test Service API: Nodejs Client][homepage] + +[//]: # "releaseLevel" + +[![npm version](https://img.shields.io/npm/v/@google-cloud/duplicate_methods_test-esm.svg)](https://www.npmjs.org/package/@google-cloud/duplicate_methods_test-esm) + +Duplicate Methods Test Service API client for Node.js + +[//]: # "partials.introduction" + +A comprehensive list of changes in each version may be found in +[the CHANGELOG][homepage_changelog]. + +* [Duplicate Methods Test Service API Nodejs Client API Reference](https://cloud.google.com/nodejs/docs/reference/duplicate_methods_test/latest) + + +Read more about the client libraries for Cloud APIs, including the older +Google APIs Client Libraries, in [Client Libraries Explained][explained]. + +[explained]: https://cloud.google.com/apis/docs/client-libraries-explained + +**Table of contents:** + +* [Quickstart](#quickstart) + * [Before you begin](#before-you-begin) + * [Installing the client library](#installing-the-client-library) + +* [Versioning](#versioning) +* [Contributing](#contributing) +* [License](#license) + +## Quickstart +### Before you begin + +1. [Select or create a Cloud Platform project][projects]. +1. [Enable billing for your project][billing]. +1. [Enable the Duplicate Methods Test Service API API][enable_api]. +1. [Set up authentication][auth] so you can access the + API from your local workstation. +### Installing the client library + +```bash +npm install @google-cloud/duplicate_methods_test-esm +``` + +[//]: # "partials.body" + +## Samples + +Samples are in the [`samples/`][homepage_samples] directory. Each sample's `README.md` has instructions for running its sample. + +[//]: # "samples" + +## Supported Node.js Versions + +Our client libraries follow the [Node.js release schedule](https://github.com/nodejs/release#release-schedule). +Libraries are compatible with all current _active_ and _maintenance_ versions of +Node.js. +If you are using an end-of-life version of Node.js, we recommend that you update +as soon as possible to an actively supported LTS version. + +Google's client libraries support legacy versions of Node.js runtimes on a +best-efforts basis with the following warnings: + +* Legacy versions are not tested in continuous integration. +* Some security patches and features cannot be backported. +* Dependencies cannot be kept up-to-date. + +Client libraries targeting some end-of-life versions of Node.js are available, and +can be installed through npm [dist-tags](https://docs.npmjs.com/cli/dist-tag). +The dist-tags follow the naming convention `legacy-(version)`. +For example, `npm install @google-cloud/duplicate_methods_test-esm@legacy-8` installs client libraries +for versions compatible with Node.js 8. + +## Versioning + +This library follows [Semantic Versioning](http://semver.org/). + +More Information: [Google Cloud Platform Launch Stages][launch_stages] + +[launch_stages]: https://cloud.google.com/terms/launch-stages + +## Contributing + +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-duplicate_methods_test/CONTRIBUTING.md). + +Please note that this `README.md` +and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) +are generated from a central template. + +## License + +Apache Version 2.0 + +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-duplicate_methods_test/LICENSE) + +[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png +[projects]: https://console.cloud.google.com/project +[billing]: https://support.google.com/cloud/answer/6293499#enable-billing +[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=duplicatemethodstest.googleapis.com +[auth]: https://cloud.google.com/docs/authentication/external/set-up-adc-local +[homepage_samples]: https://github.com/googleapis/google-cloud-node/blob/main/packages/google-duplicate_methods_test/samples +[homepage_changelog]: https://github.com/googleapis/google-cloud-node/blob/main/packages/google-duplicate_methods_test/CHANGELOG.md +[homepage]: https://github.com/googleapis/google-cloud-node/blob/main/packages/google-duplicate_methods_test diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/index.ts b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/index.ts new file mode 100644 index 00000000000..2f77a606018 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/index.ts @@ -0,0 +1,26 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1/index.js'; +const DuplicateMethodsTestServiceClient = v1.DuplicateMethodsTestServiceClient; +type DuplicateMethodsTestServiceClient = v1.DuplicateMethodsTestServiceClient; +export {v1, DuplicateMethodsTestServiceClient}; +export default {v1, DuplicateMethodsTestServiceClient}; +// @ts-ignore +import * as protos from '../../protos/protos.js'; +export {protos} diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/json-helper.cjs b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/json-helper.cjs new file mode 100644 index 00000000000..3c1fc730201 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/json-helper.cjs @@ -0,0 +1,20 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* eslint-disable node/no-missing-require */ +function getJSON(path) { + return require(path); +} + +exports.getJSON = getJSON; diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client.ts b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client.ts new file mode 100644 index 00000000000..49a70fe1fe3 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client.ts @@ -0,0 +1,917 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +// @ts-ignore +import type * as protos from '../../../protos/protos.js'; +import * as duplicate_methods_test_service_client_config from './duplicate_methods_test_service_client_config.json'; +import fs from 'fs'; +import path from 'path'; +import {fileURLToPath} from 'url'; +import {getJSON} from '../json-helper.cjs'; +// @ts-ignore +const dirname = path.dirname(fileURLToPath(import.meta.url)); + +/** + * Client JSON configuration object, loaded from + * `src/v1/duplicate_methods_test_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +const gapicConfig = getJSON( + path.join(dirname, 'duplicate_methods_test_service_client_config.json') +); + +const jsonProtos = getJSON( + path.join(dirname, '..', '..', '..', 'protos/protos.json') +); +import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +const version = getJSON( + path.join(dirname, '..', '..', '..', '..', 'package.json') +).version; + +/** + * @class + * @memberof v1 + */ +export class DuplicateMethodsTestServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; + private _log = logging.log('duplicate_methods_test-esm'); + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + iamClient: IamClient; + locationsClient: LocationsClient; + duplicateMethodsTestServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DuplicateMethodsTestServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * 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. + * 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 DuplicateMethodsTestServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof DuplicateMethodsTestServiceClient; + if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { + throw new Error('Please set either universe_domain or universeDomain, but not both.'); + } + const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; + this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + this._servicePath = 'duplicatemethodstest.' + this._universeDomain; + const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== this._servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = gax as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = this._servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === this._servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); + + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Add ESM headers + const isEsm = true; + const isEsmString = isEsm ? '-esm' : '-cjs'; + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process === 'object' && 'versions' in process) { + clientHeader.push(`gl-node/{process.versions.node}${isEsmString}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos as gax.protobuf.INamespace); + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listLocations: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'locations') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.duplicate_methods_test.v1.DuplicateMethodsTestService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.duplicateMethodsTestServiceStub) { + return this.duplicateMethodsTestServiceStub; + } + + // Put together the "service stub" for + // google.duplicate_methods_test.v1.DuplicateMethodsTestService. + this.duplicateMethodsTestServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.duplicate_methods_test.v1.DuplicateMethodsTestService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.duplicate_methods_test.v1.DuplicateMethodsTestService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const duplicateMethodsTestServiceStubMethods = + ['getIamPolicy', 'listLocations', 'echo']; + for (const methodName of duplicateMethodsTestServiceStubMethods) { + const callPromise = this.duplicateMethodsTestServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.duplicateMethodsTestServiceStub; + } + + /** + * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + if (typeof process === 'object' && typeof process.emitWarning === 'function') { + process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + } + return 'duplicatemethodstest.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath, + * exists for compatibility reasons. + * @deprecated Use the apiEndpoint method of the client instance. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + if (typeof process === 'object' && typeof process.emitWarning === 'function') { + process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + } + return 'duplicatemethodstest.googleapis.com'; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Native GetIamPolicy method that conflicts with the IAMPolicy mixin. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js + * region_tag:duplicatemethodstest_v1_generated_DuplicateMethodsTestService_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize().catch(err => {throw err}); + this._log.info('getIamPolicy request %j', request); + const wrappedCallback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>|undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getIamPolicy response %j', response); + callback!(error, response, options, rawResponse); + } + : undefined; + return this.innerApiCalls.getIamPolicy(request, options, wrappedCallback) + ?.then(([response, options, rawResponse]: [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]) => { + this._log.info('getIamPolicy response %j', response); + return [response, options, rawResponse]; + }).catch((error: any) => { + if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { + const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + } + throw error; + }); + } +/** + * Another native method to ensure the service is valid and has other methods. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.content + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.duplicate_methods_test.v1.EchoResponse|EchoResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/duplicate_methods_test_service.echo.js + * region_tag:duplicatemethodstest_v1_generated_DuplicateMethodsTestService_Echo_async + */ + echo( + request?: protos.google.duplicate_methods_test.v1.IEchoRequest, + options?: CallOptions): + Promise<[ + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|undefined, {}|undefined + ]>; + echo( + request: protos.google.duplicate_methods_test.v1.IEchoRequest, + options: CallOptions, + callback: Callback< + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|null|undefined, + {}|null|undefined>): void; + echo( + request: protos.google.duplicate_methods_test.v1.IEchoRequest, + callback: Callback< + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|null|undefined, + {}|null|undefined>): void; + echo( + request?: protos.google.duplicate_methods_test.v1.IEchoRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize().catch(err => {throw err}); + this._log.info('echo request %j', request); + const wrappedCallback: Callback< + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|null|undefined, + {}|null|undefined>|undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('echo response %j', response); + callback!(error, response, options, rawResponse); + } + : undefined; + return this.innerApiCalls.echo(request, options, wrappedCallback) + ?.then(([response, options, rawResponse]: [ + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|undefined, {}|undefined + ]) => { + this._log.info('echo response %j', response); + return [response, options, rawResponse]; + }).catch((error: any) => { + if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { + const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + } + throw error; + }); + } + + /** + * Native ListLocations method that conflicts with the Locations mixin. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.location.Location|Location}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listLocationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listLocations( + request?: protos.google.cloud.location.IListLocationsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.location.ILocation[], + protos.google.cloud.location.IListLocationsRequest|null, + protos.google.cloud.location.IListLocationsResponse + ]>; + listLocations( + request: protos.google.cloud.location.IListLocationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.location.IListLocationsRequest, + protos.google.cloud.location.IListLocationsResponse|null|undefined, + protos.google.cloud.location.ILocation>): void; + listLocations( + request: protos.google.cloud.location.IListLocationsRequest, + callback: PaginationCallback< + protos.google.cloud.location.IListLocationsRequest, + protos.google.cloud.location.IListLocationsResponse|null|undefined, + protos.google.cloud.location.ILocation>): void; + listLocations( + request?: protos.google.cloud.location.IListLocationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.location.IListLocationsRequest, + protos.google.cloud.location.IListLocationsResponse|null|undefined, + protos.google.cloud.location.ILocation>, + callback?: PaginationCallback< + protos.google.cloud.location.IListLocationsRequest, + protos.google.cloud.location.IListLocationsResponse|null|undefined, + protos.google.cloud.location.ILocation>): + Promise<[ + protos.google.cloud.location.ILocation[], + protos.google.cloud.location.IListLocationsRequest|null, + protos.google.cloud.location.IListLocationsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize().catch(err => {throw err}); + const wrappedCallback: PaginationCallback< + protos.google.cloud.location.IListLocationsRequest, + protos.google.cloud.location.IListLocationsResponse|null|undefined, + protos.google.cloud.location.ILocation>|undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listLocations values %j', values); + callback!(error, values, nextPageRequest, rawResponse); + } + : undefined; + this._log.info('listLocations request %j', request); + return this.innerApiCalls + .listLocations(request, options, wrappedCallback) + ?.then(([response, input, output]: [ + protos.google.cloud.location.ILocation[], + protos.google.cloud.location.IListLocationsRequest|null, + protos.google.cloud.location.IListLocationsResponse + ]) => { + this._log.info('listLocations values %j', response); + return [response, input, output]; + }); + } + +/** + * Equivalent to `listLocations`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.location.Location|Location} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listLocationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listLocationsStream( + request?: protos.google.cloud.location.IListLocationsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listLocations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize().catch(err => {throw err}); + this._log.info('listLocations stream %j', request); + return this.descriptors.page.listLocations.createStream( + this.innerApiCalls.listLocations as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listLocations`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.location.Location|Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/duplicate_methods_test_service.list_locations.js + * region_tag:duplicatemethodstest_v1_generated_DuplicateMethodsTestService_ListLocations_async + */ + listLocationsAsync( + request?: protos.google.cloud.location.IListLocationsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listLocations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize().catch(err => {throw err}); + this._log.info('listLocations iterate %j', request); + return this.descriptors.page.listLocations.asyncIterate( + this.innerApiCalls['listLocations'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + /** + request: IamProtos.google.iam.v1.SetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.Policy]> { + return this.iamClient.setIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ + /** + request: IamProtos.google.iam.v1.TestIamPermissionsRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + return this.iamClient.testIamPermissions(request, options, callback); + } + + + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.duplicateMethodsTestServiceStub && !this._terminated) { + return this.duplicateMethodsTestServiceStub.then(stub => { + this._log.info('ending gRPC channel'); + this._terminated = true; + stub.close(); + this.iamClient.close().catch(err => {throw err}); + this.locationsClient.close().catch(err => {throw err}); + }); + } + return Promise.resolve(); + } +} \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client_config.json b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client_config.json new file mode 100644 index 00000000000..be7baac9386 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client_config.json @@ -0,0 +1,38 @@ +{ + "interfaces": { + "google.duplicate_methods_test.v1.DuplicateMethodsTestService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListLocations": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Echo": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_proto_list.json b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_proto_list.json new file mode 100644 index 00000000000..d3ee7abc5db --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto" +] diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/v1/index.ts b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/v1/index.ts new file mode 100644 index 00000000000..0104bde3222 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {DuplicateMethodsTestServiceClient} from './duplicate_methods_test_service_client.js'; diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.cjs b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.cjs new file mode 100644 index 00000000000..dc8c439b40a --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.cjs @@ -0,0 +1,27 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars, no-undef */ +const duplicate-methods-test = require('@google-cloud/duplicate_methods_test-esm'); + +function main() { + const duplicateMethodsTestServiceClient = new duplicate-methods-test.DuplicateMethodsTestServiceClient(); +} + +main(); diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.js b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..26d8bef5a41 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars, no-undef */ +import * as duplicate-methods-test from '@google-cloud/duplicate_methods_test-esm'; + +function main() { + const duplicateMethodsTestServiceClient = new duplicate-methods-test.DuplicateMethodsTestServiceClient(); +} + +main(); diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.ts b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..cf215c8b06c --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,33 @@ +/* eslint-disable node/no-missing-require, no-unused-vars, no-undef */ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {DuplicateMethodsTestServiceClient} from '@google-cloud/duplicate_methods_test-esm'; + +// check that the client class type name can be used +function doStuffWithDuplicateMethodsTestServiceClient(client: DuplicateMethodsTestServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const duplicateMethodsTestServiceClient = new DuplicateMethodsTestServiceClient(); + doStuffWithDuplicateMethodsTestServiceClient(duplicateMethodsTestServiceClient); +} + +main(); diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/system-test/install.ts b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/system-test/install.ts new file mode 100644 index 00000000000..e079c4fa110 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/system-test/install.ts @@ -0,0 +1,55 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + it('TypeScript', async function() { + this.timeout(300000); + await packNTest({ + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./esm/system-test/fixtures/sample/src/index.ts').toString() + } + }); + }); + + it('ESM module', async function() { + this.timeout(300000); + await packNTest({ + sample: { + description: 'Should be able to import using ESM', + esm: readFileSync('./esm/system-test/fixtures/sample/src/index.js').toString(), + }, + }); + }); + + it('CJS module', async function() { + this.timeout(300000); + await packNTest({ + sample: { + description: 'Should be able to import using CJS', + cjs: readFileSync('./esm/system-test/fixtures/sample/src/index.cjs').toString(), + }, + }); + }); + +}); diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/test/gapic_duplicate_methods_test_service_v1.ts b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/test/gapic_duplicate_methods_test_service_v1.ts new file mode 100644 index 00000000000..ad48c9cffc7 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/esm/test/gapic_duplicate_methods_test_service_v1.ts @@ -0,0 +1,977 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +// @ts-ignore +import * as protos from '../../protos/protos.js'; +import assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as duplicatemethodstestserviceModule from '../src/index.js'; + +import {PassThrough} from 'stream'; + +import {protobuf, IamProtos, LocationProtos} from 'google-gax'; +import fs from 'fs'; +import path from 'path'; +import {fileURLToPath} from 'url'; + +// @ts-ignore +const dirname = path.dirname(fileURLToPath(import.meta.url)); +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + JSON.parse( + fs.readFileSync(path.join(dirname, '..', '..', 'protos/protos.json'), 'utf8') + )) + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type?.fields[field]?.resolvedType as protobuf.Type; + } + return type?.fields[fields[fields.length - 1]]?.defaultValue ?? null; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.DuplicateMethodsTestServiceClient', () => { + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'duplicatemethodstest.googleapis.com'); + }); + + it('has universeDomain', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, "googleapis.com"); + }); + + if (typeof process === 'object' && typeof process.emitWarning === 'function') { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient.servicePath; + assert.strictEqual(servicePath, 'duplicatemethodstest.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'duplicatemethodstest.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({universeDomain: 'example.com'}); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'duplicatemethodstest.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({universe_domain: 'example.com'}); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'duplicatemethodstest.example.com'); + }); + + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'duplicatemethodstest.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({universeDomain: 'configured.example.com'}); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'duplicatemethodstest.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + }); + + it('has port', () => { + const port = duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.duplicateMethodsTestServiceStub, undefined); + await client.initialize(); + assert(client.duplicateMethodsTestServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize().catch(err => {throw err}); + assert(client.duplicateMethodsTestServiceStub); + client.close().then(() => { + done(); + }).catch(err => {throw err}); + }); + + it('has close method for the non-initialized client', done => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.duplicateMethodsTestServiceStub, undefined); + client.close().then(() => { + done(); + }).catch(err => {throw err}); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + 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()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + 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); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch(err => {throw err}); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('echo', () => { + it('invokes echo without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoResponse() + ); + client.innerApiCalls.echo = stubSimpleCall(expectedResponse); + const [response] = await client.echo(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes echo without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoResponse() + ); + client.innerApiCalls.echo = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.echo( + request, + (err?: Error|null, result?: protos.google.duplicate_methods_test.v1.IEchoResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes echo with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.echo = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.echo(request), expectedError); + }); + + it('invokes echo with closed client', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch(err => {throw err}); + await assert.rejects(client.echo(request), expectedError); + }); + }); + + describe('listLocations', () => { + it('invokes listLocations without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + ]; + client.innerApiCalls.listLocations = stubSimpleCall(expectedResponse); + const [response] = await client.listLocations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listLocations without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + ]; + client.innerApiCalls.listLocations = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listLocations( + request, + (err?: Error|null, result?: protos.google.cloud.location.ILocation[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listLocations with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedError = new Error('expected'); + client.innerApiCalls.listLocations = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listLocations(request), expectedError); + const actualRequest = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listLocationsStream without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + ]; + client.descriptors.page.listLocations.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listLocationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.location.Location[] = []; + stream.on('data', (response: protos.google.cloud.location.Location) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listLocations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listLocations, request)); + assert( + (client.descriptors.page.listLocations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listLocationsStream with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedError = new Error('expected'); + client.descriptors.page.listLocations.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listLocationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.location.Location[] = []; + stream.on('data', (response: protos.google.cloud.location.Location) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listLocations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listLocations, request)); + assert( + (client.descriptors.page.listLocations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listLocations without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + ]; + client.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listLocations with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedError = new Error('expected'); + client.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }).catch(err => {throw err}); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }).catch(err => {throw err}); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); +}); diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/package.json b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/package.json new file mode 100644 index 00000000000..276b80e372b --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/package.json @@ -0,0 +1,105 @@ +{ + "name": "@google-cloud/duplicate_methods_test-esm", + "version": "0.1.0", + "description": "Duplicate_methods_test client for Node.js", + "repository": "googleapis/nodejs-duplicate-methods-test", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "./build/cjs/src/index.cjs", + "types": "./build/cjs/src/index.d.ts", + "type": "module", + "exports": { + ".": { + "import": { + "types": "./build/esm/src/index.d.ts", + "default": "./build/esm/src/index.js" + }, + "require": { + "types": "./build/cjs/src/index.d.ts", + "default": "./build/cjs/src/index.cjs" + } + }, + "./build/protos/protos": { + "import": { + "types": "./build/protos/protos/protos.d.ts", + "default": "./build/protos/protos/protos.js" + }, + "require": { + "types": "./build/protos/protos/protos.d.ts", + "default": "./build/protos/protos/protos.cjs" + } + } + }, + "files": [ + "build/esm", + "build/cjs", + "build/protos", + "!build/esm/**/*.map", + "!build/cjs/**/*.map" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google duplicateMethodsTest", + "duplicateMethodsTest", + "duplicate methods test service" + ], + "scripts": { + "clean": "gts clean", + "compile-protos": "compileProtos esm/src --esm ", + "docs": "jsdoc -c .jsdoc.cjs", + "postpack": "minifyProtoJson build/cjs && minifyProtoJson build/esm", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test:cjs": "c8 mocha build/cjs/system-test", + "system-test:esm": "c8 mocha build/esm/system-test", + "system-test": "npm run system-test:esm && npm run system-test:cjs", + "test:cjs": "c8 mocha build/cjs/test", + "test:esm": "c8 mocha build/esm/test", + "test": "npm run test:cjs && npm run test:esm", + "compile:esm": "tsc -p ./tsconfig.esm.json && cp -r esm/src/json-helper.cjs build/esm/src/json-helper.cjs", + "babel": "babel esm --out-dir build/cjs --ignore \"esm/**/*.d.ts\" --extensions \".ts\" --out-file-extension .cjs --copy-files", + "compile:cjs": "tsc -p ./tsconfig.json && npm run babel", + "compile": "npm run compile:esm && rm -rf esm/src/json-helper.d.cts && npm run compile:cjs && rm -rf build/protos && cp -r protos build/protos", + "samples-test": "cd samples/ && npm link ../ && npm i && npm test" + }, + "dependencies": { + "google-gax": "^5.1.1-rc.1" + }, + "devDependencies": { + "@babel/cli": "^7.28.3", + "@babel/core": "^7.28.5", + "@babel/preset-env": "^7.28.5", + "@babel/preset-typescript": "^7.28.5", + "@types/mocha": "^10.0.10", + "@types/node": "^22.18.12", + "@types/sinon": "^17.0.4", + "babel-plugin-replace-import-extension": "^1.1.5", + "c8": "^10.1.3", + "gapic-tools": "^1.0.3", + "gts": "^6.0.2", + "jsdoc": "^4.0.5", + "jsdoc-region-tag": "^4.0.1", + "jsdoc-fresh": "^5.0.2", + "long": "^5.3.2", + "mocha": "^11.7.4", + "pack-n-play": "^4.2.1", + "typescript": "5.8.3", + "sinon": "^21.0.0", + "ts-loader": "^8.4.0", + "webpack": "^5.102.1", + "webpack-cli": "^6.0.1" + }, + "engines": { + "node": ">=v18" + } +} diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto new file mode 100644 index 00000000000..b91e79094ff --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto @@ -0,0 +1,66 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.duplicate_methods_test.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/cloud/location/locations.proto"; + +option csharp_namespace = "Google.DuplicateMethodsTest.V1"; +option go_package = "google.golang.org/genproto/googleapis/duplicate_methods_test/v1;duplicate_methods_test"; +option java_multiple_files = true; +option java_outer_classname = "DuplicateMethodsTestProto"; +option java_package = "com.google.duplicate_methods_test.v1"; +option php_namespace = "Google\\DuplicateMethodsTest\\V1"; +option ruby_package = "Google::DuplicateMethodsTest::V1"; + +service DuplicateMethodsTestService { + option (google.api.default_host) = "duplicatemethodstest.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Native GetIamPolicy method that conflicts with the IAMPolicy mixin. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + get: "/v1/{resource=projects/*}:getIamPolicy" + }; + } + + // Native ListLocations method that conflicts with the Locations mixin. + rpc ListLocations(google.cloud.location.ListLocationsRequest) returns (google.cloud.location.ListLocationsResponse) { + option (google.api.http) = { + get: "/v1/{name=projects/*}/locations" + }; + } + + // Another native method to ensure the service is valid and has other methods. + rpc Echo(EchoRequest) returns (EchoResponse) { + option (google.api.http) = { + post: "/v1/echo" + body: "*" + }; + } +} + +message EchoRequest { + string content = 1; +} + +message EchoResponse { + string content = 1; +} diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.echo.js b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.echo.js new file mode 100644 index 00000000000..64b901b97c4 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.echo.js @@ -0,0 +1,59 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START duplicatemethodstest_v1_generated_DuplicateMethodsTestService_Echo_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. + */ + /** + */ + // const content = 'abc123' + + // Imports the Duplicate_methods_test library + const {DuplicateMethodsTestServiceClient} = require('@google-cloud/duplicate_methods_test-esm').v1; + + // Instantiates a client + const duplicateMethodsTestClient = new DuplicateMethodsTestServiceClient(); + + async function callEcho() { + // Construct request + const request = { + }; + + // Run request + const response = await duplicateMethodsTestClient.echo(request); + console.log(response); + } + + callEcho(); + // [END duplicatemethodstest_v1_generated_DuplicateMethodsTestService_Echo_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js new file mode 100644 index 00000000000..caa51373b49 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js @@ -0,0 +1,67 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(resource) { + // [START duplicatemethodstest_v1_generated_DuplicateMethodsTestService_GetIamPolicy_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. + */ + /** + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + */ + // const options = {} + + // Imports the Duplicate_methods_test library + const {DuplicateMethodsTestServiceClient} = require('@google-cloud/duplicate_methods_test-esm').v1; + + // Instantiates a client + const duplicateMethodsTestClient = new DuplicateMethodsTestServiceClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await duplicateMethodsTestClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END duplicatemethodstest_v1_generated_DuplicateMethodsTestService_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.list_locations.js b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.list_locations.js new file mode 100644 index 00000000000..a6e028742d6 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.list_locations.js @@ -0,0 +1,74 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START duplicatemethodstest_v1_generated_DuplicateMethodsTestService_ListLocations_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. + */ + /** + * The resource that owns the locations collection, if applicable. + */ + // const name = 'abc123' + /** + * The standard list filter. + */ + // const filter = 'abc123' + /** + * The standard list page size. + */ + // const pageSize = 1234 + /** + * The standard list page token. + */ + // const pageToken = 'abc123' + + // Imports the Duplicate_methods_test library + const {DuplicateMethodsTestServiceClient} = require('@google-cloud/duplicate_methods_test-esm').v1; + + // Instantiates a client + const duplicateMethodsTestClient = new DuplicateMethodsTestServiceClient(); + + async function callListLocations() { + // Construct request + const request = { + }; + + // Run request + const iterable = duplicateMethodsTestClient.listLocationsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListLocations(); + // [END duplicatemethodstest_v1_generated_DuplicateMethodsTestService_ListLocations_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json new file mode 100644 index 00000000000..5e881b6e29b --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json @@ -0,0 +1,151 @@ +{ + "clientLibrary": { + "name": "nodejs-duplicate-methods-test", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.duplicate_methods_test.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "duplicatemethodstest_v1_generated_DuplicateMethodsTestService_GetIamPolicy_async", + "title": "DuplicateMethodsTestService getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Native GetIamPolicy method that conflicts with the IAMPolicy mixin.", + "canonical": true, + "file": "duplicate_methods_test_service.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "DuplicateMethodsTestServiceClient", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestServiceClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.GetIamPolicy", + "service": { + "shortName": "DuplicateMethodsTestService", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService" + } + } + } + }, + { + "regionTag": "duplicatemethodstest_v1_generated_DuplicateMethodsTestService_ListLocations_async", + "title": "DuplicateMethodsTestService listLocations Sample", + "origin": "API_DEFINITION", + "description": " Native ListLocations method that conflicts with the Locations mixin.", + "canonical": true, + "file": "duplicate_methods_test_service.list_locations.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListLocations", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.ListLocations", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.location.ListLocationsResponse", + "client": { + "shortName": "DuplicateMethodsTestServiceClient", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestServiceClient" + }, + "method": { + "shortName": "ListLocations", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.ListLocations", + "service": { + "shortName": "DuplicateMethodsTestService", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService" + } + } + } + }, + { + "regionTag": "duplicatemethodstest_v1_generated_DuplicateMethodsTestService_Echo_async", + "title": "DuplicateMethodsTestService echo Sample", + "origin": "API_DEFINITION", + "description": " Another native method to ensure the service is valid and has other methods.", + "canonical": true, + "file": "duplicate_methods_test_service.echo.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Echo", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.Echo", + "async": true, + "parameters": [ + { + "name": "content", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.duplicate_methods_test.v1.EchoResponse", + "client": { + "shortName": "DuplicateMethodsTestServiceClient", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestServiceClient" + }, + "method": { + "shortName": "Echo", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.Echo", + "service": { + "shortName": "DuplicateMethodsTestService", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService" + } + } + } + } + ] +} diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/tsconfig.esm.json b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/tsconfig.esm.json new file mode 100644 index 00000000000..9ea46f074fa --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/tsconfig.esm.json @@ -0,0 +1,27 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "module": "es2020", + "moduleResolution": "node", + "esModuleInterop": true, + "sourceMap": false, + "allowJs": true, + "lib": [ + "es2020", + "DOM" + ] + }, + "include": [ + "esm/src/*.ts", + "esm/src/**/*.ts", + "esm/test/*.ts", + "esm/test/**/*.ts", + "esm/system-test/*.ts", + "esm/src/**/*.json", + "protos/protos.json", + "esm/src/*.cjs" + ] +} diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/tsconfig.json b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/tsconfig.json new file mode 100644 index 00000000000..110f6eccd41 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/tsconfig.json @@ -0,0 +1,32 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "resolveJsonModule": true, + "moduleResolution": "node", + "allowJs": true, + "esModuleInterop": true, + "sourceMap": false, + "target": "esnext", + "module": "CommonJS", + "declaration": true, + "strict": true, + "isolatedModules": false, + "emitDeclarationOnly": true, + "lib": [ + "es2023", + "dom" + ] + }, + "include": [ + "esm/src/*.ts", + "esm/src/**/*.ts", + "esm/test/*.ts", + "esm/test/**/*.ts", + "esm/src/**/*.json", + "esm/system-test/*.ts", + "esm/src/*.cjs", + "samples/**/*.json", + "protos/protos.json" + ] +} diff --git a/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/webpack.config.cjs b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/webpack.config.cjs new file mode 100644 index 00000000000..59e373662ce --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines-esm/duplicate_methods_test-esm/webpack.config.cjs @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'DuplicateMethodsTestService', + filename: './duplicate-methods-test-service.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/CODE_OF_CONDUCT.md b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..2add2547a81 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/CODE_OF_CONDUCT.md @@ -0,0 +1,94 @@ + +# Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of +experience, education, socio-economic status, nationality, personal appearance, +race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +This Code of Conduct also applies outside the project spaces when the Project +Steward has a reasonable belief that an individual's behavior may have a +negative impact on the project or its community. + +## Conflict Resolution + +We do not believe that all conflict is bad; healthy debate and disagreement +often yield positive results. However, it is never okay to be disrespectful or +to engage in behavior that violates the project’s code of conduct. + +If you see someone violating the code of conduct, you are encouraged to address +the behavior directly with those involved. Many issues can be resolved quickly +and easily, and this gives people more control over the outcome of their +dispute. If you are unable to resolve the matter for any reason, or if the +behavior is threatening or harassing, report it. We are dedicated to providing +an environment where participants feel welcome and safe. + +Reports should be directed to *googleapis-stewards@google.com*, the +Project Steward(s) for *Google Cloud Client Libraries*. It is the Project Steward’s duty to +receive and address reported violations of the code of conduct. They will then +work with a committee consisting of representatives from the Open Source +Programs Office and the Google Open Source Strategy team. If for any reason you +are uncomfortable reaching out to the Project Steward, please email +opensource@google.com. + +We will investigate every complaint, but you may not receive a direct response. +We will use our discretion in determining when and how to follow up on reported +incidents, which may range from not taking action to permanent expulsion from +the project and project-sponsored spaces. We will notify the accused of the +report and provide them an opportunity to discuss it before any action is taken. +The identity of the reporter will be omitted from the details of the report +supplied to the accused. In potentially harmful situations, such as ongoing +harassment or threats to anyone's safety, we may take action without notice. + +## Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, +available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/CONTRIBUTING.md b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/CONTRIBUTING.md new file mode 100644 index 00000000000..099d8bfb0e8 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/CONTRIBUTING.md @@ -0,0 +1,76 @@ +# How to become a contributor and submit your own code + +**Table of contents** + +* [Contributor License Agreements](#contributor-license-agreements) +* [Contributing a patch](#contributing-a-patch) +* [Running the tests](#running-the-tests) +* [Releasing the library](#releasing-the-library) + +## Contributor License Agreements + +We'd love to accept your sample apps and patches! Before we can take them, we +have to jump a couple of legal hurdles. + +Please fill out either the individual or corporate Contributor License Agreement +(CLA). + + * If you are an individual writing original source code and you're sure you + own the intellectual property, then you'll need to sign an [individual CLA](https://developers.google.com/open-source/cla/individual). + * If you work for a company that wants to allow you to contribute your work, + then you'll need to sign a [corporate CLA](https://developers.google.com/open-source/cla/corporate). + +Follow either of the two links above to access the appropriate CLA and +instructions for how to sign and return it. Once we receive it, we'll be able to +accept your pull requests. + +## Contributing A Patch + +1. Submit an issue describing your proposed change to the repo in question. +1. The repo owner will respond to your issue promptly. +1. If your proposed change is accepted, and you haven't already done so, sign a + Contributor License Agreement (see details above). +1. Fork the desired repo, develop and test your code changes. +1. Ensure that your code adheres to the existing style in the code to which + you are contributing. +1. Ensure that your code has an appropriate set of tests which all pass. +1. Title your pull request following [Conventional Commits](https://www.conventionalcommits.org/) styling. +1. Submit a pull request. + +### Before you begin + +1. [Select or create a Cloud Platform project][projects]. +1. [Enable billing for your project][billing]. +1. [Enable the Duplicate_methods_test API][enable_api]. +1. [Set up authentication with a service account][auth] so you can access the + API from your local workstation. + + +## Running the tests + +1. [Prepare your environment for Node.js setup][setup]. + +1. Install dependencies: + + npm install + +1. Run the tests: + + # Run unit tests. + npm test + + # Run sample integration tests. + npm run samples-test + + # Run all system tests. + npm run system-test + +1. Lint (and maybe fix) any changes: + + npm run fix + +[setup]: https://cloud.google.com/nodejs/docs/setup +[projects]: https://console.cloud.google.com/project +[billing]: https://support.google.com/cloud/answer/6293499#enable-billing +[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=duplicatemethodstest.googleapis.com +[auth]: https://cloud.google.com/docs/authentication/getting-started \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/LICENSE b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/README.md b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/README.md new file mode 100644 index 00000000000..689fabc4ed5 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/README.md @@ -0,0 +1,108 @@ +[//]: # "This README.md file is auto-generated, all changes to this file will be lost." +[//]: # "The comments you see below are used to generate those parts of the template in later states." +Google Cloud Platform logo + +# [Duplicate Methods Test Service API: Nodejs Client][homepage] + +[//]: # "releaseLevel" + +[![npm version](https://img.shields.io/npm/v/@google-cloud/duplicate_methods_test.svg)](https://www.npmjs.org/package/@google-cloud/duplicate_methods_test) + +Duplicate Methods Test Service API client for Node.js + +[//]: # "partials.introduction" + +A comprehensive list of changes in each version may be found in +[the CHANGELOG][homepage_changelog]. + +* [Duplicate Methods Test Service API Nodejs Client API Reference](https://cloud.google.com/nodejs/docs/reference/duplicate_methods_test/latest) + + +Read more about the client libraries for Cloud APIs, including the older +Google APIs Client Libraries, in [Client Libraries Explained][explained]. + +[explained]: https://cloud.google.com/apis/docs/client-libraries-explained + +**Table of contents:** + +* [Quickstart](#quickstart) + * [Before you begin](#before-you-begin) + * [Installing the client library](#installing-the-client-library) + +* [Versioning](#versioning) +* [Contributing](#contributing) +* [License](#license) + +## Quickstart +### Before you begin + +1. [Select or create a Cloud Platform project][projects]. +1. [Enable billing for your project][billing]. +1. [Enable the Duplicate Methods Test Service API API][enable_api]. +1. [Set up authentication][auth] so you can access the + API from your local workstation. +### Installing the client library + +```bash +npm install @google-cloud/duplicate_methods_test +``` + +[//]: # "partials.body" + +## Samples + +Samples are in the [`samples/`][homepage_samples] directory. Each sample's `README.md` has instructions for running its sample. + +[//]: # "samples" + +## Supported Node.js Versions + +Our client libraries follow the [Node.js release schedule](https://github.com/nodejs/release#release-schedule). +Libraries are compatible with all current _active_ and _maintenance_ versions of +Node.js. +If you are using an end-of-life version of Node.js, we recommend that you update +as soon as possible to an actively supported LTS version. + +Google's client libraries support legacy versions of Node.js runtimes on a +best-efforts basis with the following warnings: + +* Legacy versions are not tested in continuous integration. +* Some security patches and features cannot be backported. +* Dependencies cannot be kept up-to-date. + +Client libraries targeting some end-of-life versions of Node.js are available, and +can be installed through npm [dist-tags](https://docs.npmjs.com/cli/dist-tag). +The dist-tags follow the naming convention `legacy-(version)`. +For example, `npm install @google-cloud/duplicate_methods_test@legacy-8` installs client libraries +for versions compatible with Node.js 8. + +## Versioning + +This library follows [Semantic Versioning](http://semver.org/). + +More Information: [Google Cloud Platform Launch Stages][launch_stages] + +[launch_stages]: https://cloud.google.com/terms/launch-stages + +## Contributing + +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-duplicate_methods_test/CONTRIBUTING.md). + +Please note that this `README.md` +and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) +are generated from a central template. + +## License + +Apache Version 2.0 + +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-duplicate_methods_test/LICENSE) + +[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png +[projects]: https://console.cloud.google.com/project +[billing]: https://support.google.com/cloud/answer/6293499#enable-billing +[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=duplicatemethodstest.googleapis.com +[auth]: https://cloud.google.com/docs/authentication/external/set-up-adc-local +[homepage_samples]: https://github.com/googleapis/google-cloud-node/blob/main/packages/google-duplicate_methods_test/samples +[homepage_changelog]: https://github.com/googleapis/google-cloud-node/blob/main/packages/google-duplicate_methods_test/CHANGELOG.md +[homepage]: https://github.com/googleapis/google-cloud-node/blob/main/packages/google-duplicate_methods_test diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/package.json b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/package.json new file mode 100644 index 00000000000..63d39e58107 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/duplicate_methods_test", + "version": "0.1.0", + "description": "Duplicate_methods_test client for Node.js", + "repository": "googleapis/nodejs-duplicate-methods-test", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google duplicateMethodsTest", + "duplicateMethodsTest", + "duplicate methods test service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^5.1.1-rc.1" + }, + "devDependencies": { + "@types/mocha": "^10.0.10", + "@types/node": "^22.18.12", + "@types/sinon": "^17.0.4", + "c8": "^10.1.3", + "gapic-tools": "^1.0.3", + "gts": "^6.0.2", + "jsdoc": "^4.0.5", + "jsdoc-fresh": "^5.0.2", + "jsdoc-region-tag": "^4.0.1", + "mocha": "^11.7.4", + "pack-n-play": "^4.2.1", + "typescript": "5.8.3", + "sinon": "^21.0.0" + }, + "engines": { + "node": ">=v18" + } +} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto new file mode 100644 index 00000000000..b91e79094ff --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto @@ -0,0 +1,66 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.duplicate_methods_test.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/cloud/location/locations.proto"; + +option csharp_namespace = "Google.DuplicateMethodsTest.V1"; +option go_package = "google.golang.org/genproto/googleapis/duplicate_methods_test/v1;duplicate_methods_test"; +option java_multiple_files = true; +option java_outer_classname = "DuplicateMethodsTestProto"; +option java_package = "com.google.duplicate_methods_test.v1"; +option php_namespace = "Google\\DuplicateMethodsTest\\V1"; +option ruby_package = "Google::DuplicateMethodsTest::V1"; + +service DuplicateMethodsTestService { + option (google.api.default_host) = "duplicatemethodstest.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Native GetIamPolicy method that conflicts with the IAMPolicy mixin. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + get: "/v1/{resource=projects/*}:getIamPolicy" + }; + } + + // Native ListLocations method that conflicts with the Locations mixin. + rpc ListLocations(google.cloud.location.ListLocationsRequest) returns (google.cloud.location.ListLocationsResponse) { + option (google.api.http) = { + get: "/v1/{name=projects/*}/locations" + }; + } + + // Another native method to ensure the service is valid and has other methods. + rpc Echo(EchoRequest) returns (EchoResponse) { + option (google.api.http) = { + post: "/v1/echo" + body: "*" + }; + } +} + +message EchoRequest { + string content = 1; +} + +message EchoResponse { + string content = 1; +} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.echo.js b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.echo.js new file mode 100644 index 00000000000..a99b8cf9ee6 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.echo.js @@ -0,0 +1,59 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START duplicatemethodstest_v1_generated_DuplicateMethodsTestService_Echo_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. + */ + /** + */ + // const content = 'abc123' + + // Imports the Duplicate_methods_test library + const {DuplicateMethodsTestServiceClient} = require('@google-cloud/duplicate_methods_test').v1; + + // Instantiates a client + const duplicateMethodsTestClient = new DuplicateMethodsTestServiceClient(); + + async function callEcho() { + // Construct request + const request = { + }; + + // Run request + const response = await duplicateMethodsTestClient.echo(request); + console.log(response); + } + + callEcho(); + // [END duplicatemethodstest_v1_generated_DuplicateMethodsTestService_Echo_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js new file mode 100644 index 00000000000..a0285e3a018 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js @@ -0,0 +1,67 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(resource) { + // [START duplicatemethodstest_v1_generated_DuplicateMethodsTestService_GetIamPolicy_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. + */ + /** + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + */ + // const options = {} + + // Imports the Duplicate_methods_test library + const {DuplicateMethodsTestServiceClient} = require('@google-cloud/duplicate_methods_test').v1; + + // Instantiates a client + const duplicateMethodsTestClient = new DuplicateMethodsTestServiceClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await duplicateMethodsTestClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END duplicatemethodstest_v1_generated_DuplicateMethodsTestService_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.list_locations.js b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.list_locations.js new file mode 100644 index 00000000000..a6d87f2e660 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.list_locations.js @@ -0,0 +1,74 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START duplicatemethodstest_v1_generated_DuplicateMethodsTestService_ListLocations_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. + */ + /** + * The resource that owns the locations collection, if applicable. + */ + // const name = 'abc123' + /** + * The standard list filter. + */ + // const filter = 'abc123' + /** + * The standard list page size. + */ + // const pageSize = 1234 + /** + * The standard list page token. + */ + // const pageToken = 'abc123' + + // Imports the Duplicate_methods_test library + const {DuplicateMethodsTestServiceClient} = require('@google-cloud/duplicate_methods_test').v1; + + // Instantiates a client + const duplicateMethodsTestClient = new DuplicateMethodsTestServiceClient(); + + async function callListLocations() { + // Construct request + const request = { + }; + + // Run request + const iterable = duplicateMethodsTestClient.listLocationsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListLocations(); + // [END duplicatemethodstest_v1_generated_DuplicateMethodsTestService_ListLocations_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json new file mode 100644 index 00000000000..5e881b6e29b --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json @@ -0,0 +1,151 @@ +{ + "clientLibrary": { + "name": "nodejs-duplicate-methods-test", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.duplicate_methods_test.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "duplicatemethodstest_v1_generated_DuplicateMethodsTestService_GetIamPolicy_async", + "title": "DuplicateMethodsTestService getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Native GetIamPolicy method that conflicts with the IAMPolicy mixin.", + "canonical": true, + "file": "duplicate_methods_test_service.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "DuplicateMethodsTestServiceClient", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestServiceClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.GetIamPolicy", + "service": { + "shortName": "DuplicateMethodsTestService", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService" + } + } + } + }, + { + "regionTag": "duplicatemethodstest_v1_generated_DuplicateMethodsTestService_ListLocations_async", + "title": "DuplicateMethodsTestService listLocations Sample", + "origin": "API_DEFINITION", + "description": " Native ListLocations method that conflicts with the Locations mixin.", + "canonical": true, + "file": "duplicate_methods_test_service.list_locations.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListLocations", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.ListLocations", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.location.ListLocationsResponse", + "client": { + "shortName": "DuplicateMethodsTestServiceClient", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestServiceClient" + }, + "method": { + "shortName": "ListLocations", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.ListLocations", + "service": { + "shortName": "DuplicateMethodsTestService", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService" + } + } + } + }, + { + "regionTag": "duplicatemethodstest_v1_generated_DuplicateMethodsTestService_Echo_async", + "title": "DuplicateMethodsTestService echo Sample", + "origin": "API_DEFINITION", + "description": " Another native method to ensure the service is valid and has other methods.", + "canonical": true, + "file": "duplicate_methods_test_service.echo.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Echo", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.Echo", + "async": true, + "parameters": [ + { + "name": "content", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.duplicate_methods_test.v1.EchoResponse", + "client": { + "shortName": "DuplicateMethodsTestServiceClient", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestServiceClient" + }, + "method": { + "shortName": "Echo", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.Echo", + "service": { + "shortName": "DuplicateMethodsTestService", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService" + } + } + } + } + ] +} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/index.ts b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/index.ts new file mode 100644 index 00000000000..f49a9ce39e4 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const DuplicateMethodsTestServiceClient = v1.DuplicateMethodsTestServiceClient; +type DuplicateMethodsTestServiceClient = v1.DuplicateMethodsTestServiceClient; +export {v1, DuplicateMethodsTestServiceClient}; +export default {v1, DuplicateMethodsTestServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client.ts b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client.ts new file mode 100644 index 00000000000..9ae11f613b7 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client.ts @@ -0,0 +1,899 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; + +/** + * Client JSON configuration object, loaded from + * `src/v1/duplicate_methods_test_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './duplicate_methods_test_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * @class + * @memberof v1 + */ +export class DuplicateMethodsTestServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; + private _log = logging.log('duplicate_methods_test'); + + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + iamClient: IamClient; + locationsClient: LocationsClient; + duplicateMethodsTestServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DuplicateMethodsTestServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @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 DuplicateMethodsTestServiceClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof DuplicateMethodsTestServiceClient; + if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { + throw new Error('Please set either universe_domain or universeDomain, but not both.'); + } + const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; + this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + this._servicePath = 'duplicatemethodstest.' + this._universeDomain; + const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== this._servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = this._servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === this._servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); + + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process === 'object' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listLocations: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'locations') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.duplicate_methods_test.v1.DuplicateMethodsTestService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.duplicateMethodsTestServiceStub) { + return this.duplicateMethodsTestServiceStub; + } + + // Put together the "service stub" for + // google.duplicate_methods_test.v1.DuplicateMethodsTestService. + this.duplicateMethodsTestServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.duplicate_methods_test.v1.DuplicateMethodsTestService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.duplicate_methods_test.v1.DuplicateMethodsTestService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const duplicateMethodsTestServiceStubMethods = + ['getIamPolicy', 'listLocations', 'echo']; + for (const methodName of duplicateMethodsTestServiceStubMethods) { + const callPromise = this.duplicateMethodsTestServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.duplicateMethodsTestServiceStub; + } + + /** + * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + if (typeof process === 'object' && typeof process.emitWarning === 'function') { + process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + } + return 'duplicatemethodstest.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + if (typeof process === 'object' && typeof process.emitWarning === 'function') { + process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + } + return 'duplicatemethodstest.googleapis.com'; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Native GetIamPolicy method that conflicts with the IAMPolicy mixin. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js + * region_tag:duplicatemethodstest_v1_generated_DuplicateMethodsTestService_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize().catch(err => {throw err}); + this._log.info('getIamPolicy request %j', request); + const wrappedCallback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>|undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getIamPolicy response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls.getIamPolicy(request, options, wrappedCallback) + ?.then(([response, options, rawResponse]: [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, + {}|undefined + ]) => { + this._log.info('getIamPolicy response %j', response); + return [response, options, rawResponse]; + }).catch((error: any) => { + if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { + const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + } + throw error; + }); + } +/** + * Another native method to ensure the service is valid and has other methods. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.content + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.duplicate_methods_test.v1.EchoResponse|EchoResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/duplicate_methods_test_service.echo.js + * region_tag:duplicatemethodstest_v1_generated_DuplicateMethodsTestService_Echo_async + */ + echo( + request?: protos.google.duplicate_methods_test.v1.IEchoRequest, + options?: CallOptions): + Promise<[ + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|undefined, {}|undefined + ]>; + echo( + request: protos.google.duplicate_methods_test.v1.IEchoRequest, + options: CallOptions, + callback: Callback< + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|null|undefined, + {}|null|undefined>): void; + echo( + request: protos.google.duplicate_methods_test.v1.IEchoRequest, + callback: Callback< + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|null|undefined, + {}|null|undefined>): void; + echo( + request?: protos.google.duplicate_methods_test.v1.IEchoRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize().catch(err => {throw err}); + this._log.info('echo request %j', request); + const wrappedCallback: Callback< + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|null|undefined, + {}|null|undefined>|undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('echo response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls.echo(request, options, wrappedCallback) + ?.then(([response, options, rawResponse]: [ + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|undefined, + {}|undefined + ]) => { + this._log.info('echo response %j', response); + return [response, options, rawResponse]; + }).catch((error: any) => { + if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { + const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + } + throw error; + }); + } + + /** + * Native ListLocations method that conflicts with the Locations mixin. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.location.Location|Location}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listLocationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listLocations( + request?: protos.google.cloud.location.IListLocationsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.location.ILocation[], + protos.google.cloud.location.IListLocationsRequest|null, + protos.google.cloud.location.IListLocationsResponse + ]>; + listLocations( + request: protos.google.cloud.location.IListLocationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.location.IListLocationsRequest, + protos.google.cloud.location.IListLocationsResponse|null|undefined, + protos.google.cloud.location.ILocation>): void; + listLocations( + request: protos.google.cloud.location.IListLocationsRequest, + callback: PaginationCallback< + protos.google.cloud.location.IListLocationsRequest, + protos.google.cloud.location.IListLocationsResponse|null|undefined, + protos.google.cloud.location.ILocation>): void; + listLocations( + request?: protos.google.cloud.location.IListLocationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.location.IListLocationsRequest, + protos.google.cloud.location.IListLocationsResponse|null|undefined, + protos.google.cloud.location.ILocation>, + callback?: PaginationCallback< + protos.google.cloud.location.IListLocationsRequest, + protos.google.cloud.location.IListLocationsResponse|null|undefined, + protos.google.cloud.location.ILocation>): + Promise<[ + protos.google.cloud.location.ILocation[], + protos.google.cloud.location.IListLocationsRequest|null, + protos.google.cloud.location.IListLocationsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize().catch(err => {throw err}); + const wrappedCallback: PaginationCallback< + protos.google.cloud.location.IListLocationsRequest, + protos.google.cloud.location.IListLocationsResponse|null|undefined, + protos.google.cloud.location.ILocation>|undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listLocations values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listLocations request %j', request); + return this.innerApiCalls + .listLocations(request, options, wrappedCallback) + ?.then(([response, input, output]: [ + protos.google.cloud.location.ILocation[], + protos.google.cloud.location.IListLocationsRequest|null, + protos.google.cloud.location.IListLocationsResponse + ]) => { + this._log.info('listLocations values %j', response); + return [response, input, output]; + }); + } + +/** + * Equivalent to `listLocations`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.location.Location|Location} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listLocationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listLocationsStream( + request?: protos.google.cloud.location.IListLocationsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listLocations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize().catch(err => {throw err}); + this._log.info('listLocations stream %j', request); + return this.descriptors.page.listLocations.createStream( + this.innerApiCalls.listLocations as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listLocations`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.location.Location|Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/duplicate_methods_test_service.list_locations.js + * region_tag:duplicatemethodstest_v1_generated_DuplicateMethodsTestService_ListLocations_async + */ + listLocationsAsync( + request?: protos.google.cloud.location.IListLocationsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listLocations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize().catch(err => {throw err}); + this._log.info('listLocations iterate %j', request); + return this.descriptors.page.listLocations.asyncIterate( + this.innerApiCalls['listLocations'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + /** + request: IamProtos.google.iam.v1.SetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.Policy]> { + return this.iamClient.setIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ + /** + request: IamProtos.google.iam.v1.TestIamPermissionsRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + return this.iamClient.testIamPermissions(request, options, callback); + } + + + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.duplicateMethodsTestServiceStub && !this._terminated) { + return this.duplicateMethodsTestServiceStub.then(stub => { + this._log.info('ending gRPC channel'); + this._terminated = true; + stub.close(); + this.iamClient.close().catch(err => {throw err}); + this.locationsClient.close().catch(err => {throw err}); + }); + } + return Promise.resolve(); + } +} \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client_config.json b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client_config.json new file mode 100644 index 00000000000..be7baac9386 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client_config.json @@ -0,0 +1,38 @@ +{ + "interfaces": { + "google.duplicate_methods_test.v1.DuplicateMethodsTestService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListLocations": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Echo": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_proto_list.json b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_proto_list.json new file mode 100644 index 00000000000..d3ee7abc5db --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto" +] diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/index.ts b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/index.ts new file mode 100644 index 00000000000..37e108cedea --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {DuplicateMethodsTestServiceClient} from './duplicate_methods_test_service_client'; diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.js b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..c9c75f89903 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const duplicate-methods-test = require('@google-cloud/duplicate_methods_test'); + +function main() { + const duplicateMethodsTestServiceClient = new duplicate-methods-test.DuplicateMethodsTestServiceClient(); +} + +main(); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.ts b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..4327cd683d8 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {DuplicateMethodsTestServiceClient} from '@google-cloud/duplicate_methods_test'; + +// check that the client class type name can be used +function doStuffWithDuplicateMethodsTestServiceClient(client: DuplicateMethodsTestServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const duplicateMethodsTestServiceClient = new DuplicateMethodsTestServiceClient(); + doStuffWithDuplicateMethodsTestServiceClient(duplicateMethodsTestServiceClient); +} + +main(); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/install.ts b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/install.ts new file mode 100644 index 00000000000..394f3362d20 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/test/gapic_duplicate_methods_test_service_v1.ts b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/test/gapic_duplicate_methods_test_service_v1.ts new file mode 100644 index 00000000000..e9f1676ac7c --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/test/gapic_duplicate_methods_test_service_v1.ts @@ -0,0 +1,968 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as duplicatemethodstestserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, IamProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.DuplicateMethodsTestServiceClient', () => { + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'duplicatemethodstest.googleapis.com'); + }); + + it('has universeDomain', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, "googleapis.com"); + }); + + if (typeof process === 'object' && typeof process.emitWarning === 'function') { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient.servicePath; + assert.strictEqual(servicePath, 'duplicatemethodstest.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'duplicatemethodstest.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({universeDomain: 'example.com'}); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'duplicatemethodstest.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({universe_domain: 'example.com'}); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'duplicatemethodstest.example.com'); + }); + + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'duplicatemethodstest.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({universeDomain: 'configured.example.com'}); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'duplicatemethodstest.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + }); + + it('has port', () => { + const port = duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.duplicateMethodsTestServiceStub, undefined); + await client.initialize(); + assert(client.duplicateMethodsTestServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize().catch(err => {throw err}); + assert(client.duplicateMethodsTestServiceStub); + client.close().then(() => { + done(); + }).catch(err => {throw err}); + }); + + it('has close method for the non-initialized client', done => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.duplicateMethodsTestServiceStub, undefined); + client.close().then(() => { + done(); + }).catch(err => {throw err}); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + 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()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + 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); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch(err => {throw err}); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('echo', () => { + it('invokes echo without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoResponse() + ); + client.innerApiCalls.echo = stubSimpleCall(expectedResponse); + const [response] = await client.echo(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes echo without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoResponse() + ); + client.innerApiCalls.echo = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.echo( + request, + (err?: Error|null, result?: protos.google.duplicate_methods_test.v1.IEchoResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes echo with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.echo = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.echo(request), expectedError); + }); + + it('invokes echo with closed client', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch(err => {throw err}); + await assert.rejects(client.echo(request), expectedError); + }); + }); + + describe('listLocations', () => { + it('invokes listLocations without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + ]; + client.innerApiCalls.listLocations = stubSimpleCall(expectedResponse); + const [response] = await client.listLocations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listLocations without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + ]; + client.innerApiCalls.listLocations = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listLocations( + request, + (err?: Error|null, result?: protos.google.cloud.location.ILocation[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listLocations with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedError = new Error('expected'); + client.innerApiCalls.listLocations = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listLocations(request), expectedError); + const actualRequest = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listLocationsStream without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + ]; + client.descriptors.page.listLocations.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listLocationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.location.Location[] = []; + stream.on('data', (response: protos.google.cloud.location.Location) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listLocations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listLocations, request)); + assert( + (client.descriptors.page.listLocations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listLocationsStream with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedError = new Error('expected'); + client.descriptors.page.listLocations.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listLocationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.location.Location[] = []; + stream.on('data', (response: protos.google.cloud.location.Location) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listLocations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listLocations, request)); + assert( + (client.descriptors.page.listLocations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listLocations without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + ]; + client.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listLocations with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedError = new Error('expected'); + client.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }).catch(err => {throw err}); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }).catch(err => {throw err}); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); +}); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/tsconfig.json b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/tsconfig.json new file mode 100644 index 00000000000..ca73e7bfc82 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/tsconfig.json @@ -0,0 +1,22 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2023", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts", + "src/**/*.json", + "samples/**/*.json", + "protos/protos.json" + ] +} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/webpack.config.js b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/webpack.config.js new file mode 100644 index 00000000000..59e373662ce --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'DuplicateMethodsTestService', + filename: './duplicate-methods-test-service.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_locations.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_locations.njk index c147d8c8c04..1db7c0bbfc5 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_locations.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_locations.njk @@ -48,6 +48,7 @@ } {%- endif %} +{%- if service.locationMixinFlags.listLocations %} /** * Lists information about the supported locations for this service. Returns an iterable object. * diff --git a/core/generator/gapic-generator-typescript/typescript/test/unit/baselines-esm.ts b/core/generator/gapic-generator-typescript/typescript/test/unit/baselines-esm.ts index 08e36ff03e8..47ada20e155 100644 --- a/core/generator/gapic-generator-typescript/typescript/test/unit/baselines-esm.ts +++ b/core/generator/gapic-generator-typescript/typescript/test/unit/baselines-esm.ts @@ -23,6 +23,14 @@ describe('Baseline tests: ESM', () => { useCommonProto: true, format: 'esm', }); + runBaselineTest({ + baselineName: 'duplicate_methods_test-esm', + outputDir: '.test-out-duplicate_methods_test-esm', + protoPath: 'google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto', + serviceYaml: 'google/duplicatemethodstest/v1/duplicate_methods_test_v1.yaml', + useCommonProto: true, + format: 'esm', + }); runBaselineTest({ baselineName: 'dlp-esm', outputDir: '.test-out-dlp-esm', diff --git a/core/generator/gapic-generator-typescript/typescript/test/unit/baselines.ts b/core/generator/gapic-generator-typescript/typescript/test/unit/baselines.ts index 735b2e7ee22..8475cf03d10 100644 --- a/core/generator/gapic-generator-typescript/typescript/test/unit/baselines.ts +++ b/core/generator/gapic-generator-typescript/typescript/test/unit/baselines.ts @@ -22,6 +22,13 @@ describe('Baseline tests', () => { protoPath: 'google/cloud/bigquery/v2/*.proto', useCommonProto: true, }); + runBaselineTest({ + baselineName: 'duplicate_methods_test', + outputDir: '.test-out-duplicate_methods_test', + protoPath: 'google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto', + serviceYaml: 'google/duplicatemethodstest/v1/duplicate_methods_test_v1.yaml', + useCommonProto: true, + }); runBaselineTest({ baselineName: 'dlp', outputDir: '.test-out-dlp', From 1e14970a952e0e7946736bbe98ec1dd2e84b763a Mon Sep 17 00:00:00 2001 From: Shivanee Persaud Date: Thu, 23 Apr 2026 18:53:14 +0000 Subject: [PATCH 07/12] feat: clean up precedence for LRO operations mixin duplicate methods --- .../cjs/typescript_gapic/_operations.njk | 8 ++++++++ .../test/gapic_$service_$version.ts.njk | 4 ++++ .../esm/typescript_gapic/_operations.njk | 8 ++++++++ .../esm/test/gapic_$service_$version.ts.njk | 4 ++++ .../typescript/src/schema/proto.ts | 16 ++++++++++++++++ .../typescript/test/unit/proto.ts | 7 +++++++ 6 files changed, 47 insertions(+) diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_operations.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_operations.njk index 2220d387577..908fa0e4cbc 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_operations.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_operations.njk @@ -36,6 +36,7 @@ * // doThingsWith(response) * ``` */ +{%- if service.longRunningOperationsMixinFlags.getOperation %} getOperation( request: protos.google.longrunning.GetOperationRequest, optionsOrCallback?: @@ -67,6 +68,8 @@ }); return this.operationsClient.getOperation(request, options, callback); } +{%- endif %} +{%- if service.longRunningOperationsMixinFlags.listOperations %} /** * Lists operations that match the specified filter in the request. If the * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. @@ -110,6 +113,8 @@ }); return this.operationsClient.listOperationsAsync(request, options); } +{%- endif %} +{%- if service.longRunningOperationsMixinFlags.cancelOperation %} /** * Starts asynchronous cancellation on a long-running operation. The server * makes a best effort to cancel the operation, but success is not @@ -172,7 +177,9 @@ }); return this.operationsClient.cancelOperation(request, options, callback); } +{%- endif %} +{%- if service.longRunningOperationsMixinFlags.deleteOperation %} /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -229,4 +236,5 @@ }); return this.operationsClient.deleteOperation(request, options, callback); } +{%- endif %} {%- endmacro -%} diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk index b23796cfb16..a17e90c9fce 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk @@ -1405,6 +1405,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { {%- if (service.LongRunningOperationsMixin) > 0 %} {%- set Operationsmethods = ['getOperation', 'cancelOperation', 'deleteOperation'] %} {%- for method in Operationsmethods %} +{%- if service.longRunningOperationsMixinFlags[method] %} describe('{{ method }}', () => { it('invokes {{ method }} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client( @@ -1495,8 +1496,10 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { .getCall(0).calledWith(request)); }); }); +{%- endif %} {%- endfor %} {%- set method = 'listOperations' %} +{%- if service.longRunningOperationsMixinFlags.listOperations %} describe('{{ method }}Async', () => { it('uses async iteration with {{method}} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({{- util.initClientOptions(api.rest) -}}); @@ -1561,6 +1564,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { }); }); {%- endif %} +{%- endif %} {%- if (service.pathTemplates.length > 0) %} describe('Path templates', () => { diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_operations.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_operations.njk index 2220d387577..908fa0e4cbc 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_operations.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_operations.njk @@ -36,6 +36,7 @@ * // doThingsWith(response) * ``` */ +{%- if service.longRunningOperationsMixinFlags.getOperation %} getOperation( request: protos.google.longrunning.GetOperationRequest, optionsOrCallback?: @@ -67,6 +68,8 @@ }); return this.operationsClient.getOperation(request, options, callback); } +{%- endif %} +{%- if service.longRunningOperationsMixinFlags.listOperations %} /** * Lists operations that match the specified filter in the request. If the * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. @@ -110,6 +113,8 @@ }); return this.operationsClient.listOperationsAsync(request, options); } +{%- endif %} +{%- if service.longRunningOperationsMixinFlags.cancelOperation %} /** * Starts asynchronous cancellation on a long-running operation. The server * makes a best effort to cancel the operation, but success is not @@ -172,7 +177,9 @@ }); return this.operationsClient.cancelOperation(request, options, callback); } +{%- endif %} +{%- if service.longRunningOperationsMixinFlags.deleteOperation %} /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -229,4 +236,5 @@ }); return this.operationsClient.deleteOperation(request, options, callback); } +{%- endif %} {%- endmacro -%} diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk index bf5cc387e40..8ab598a531e 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk @@ -1411,6 +1411,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { {%- if (service.LongRunningOperationsMixin) > 0 %} {%- set Operationsmethods = ['getOperation', 'cancelOperation', 'deleteOperation'] %} {%- for method in Operationsmethods %} +{%- if service.longRunningOperationsMixinFlags[method] %} describe('{{ method }}', () => { it('invokes {{ method }} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client( @@ -1501,8 +1502,10 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { .getCall(0).calledWith(request)); }); }); +{%- endif %} {%- endfor %} {%- set method = 'listOperations' %} +{%- if service.longRunningOperationsMixinFlags.listOperations %} describe('{{ method }}Async', () => { it('uses async iteration with {{method}} without error', async () => { const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({{- util.initClientOptions(api.rest) -}}); @@ -1567,6 +1570,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { }); }); {%- endif %} +{%- endif %} {%- if (service.pathTemplates.length > 0) %} describe('Path templates', () => { diff --git a/core/generator/gapic-generator-typescript/typescript/src/schema/proto.ts b/core/generator/gapic-generator-typescript/typescript/src/schema/proto.ts index d5c52199bf0..5d84fa3217f 100644 --- a/core/generator/gapic-generator-typescript/typescript/src/schema/proto.ts +++ b/core/generator/gapic-generator-typescript/typescript/src/schema/proto.ts @@ -98,6 +98,13 @@ export interface LocationMixinConfig extends MixinConfig { listLocations: boolean; } +export interface OperationsMixinConfig extends MixinConfig { + cancelOperation: boolean; + deleteOperation: boolean; + getOperation: boolean; + listOperations: boolean; +} + export interface ServiceDescriptorProto extends protos.google.protobuf.IServiceDescriptorProto { internalMethods: MethodDescriptorProto[]; @@ -128,6 +135,7 @@ export interface ServiceDescriptorProto LongRunningOperationsMixin: number; iamPolicyMixinFlags?: IamPolicyMixinConfig; locationMixinFlags?: LocationMixinConfig; + longRunningOperationsMixinFlags?: OperationsMixinConfig; protoFile: string; diregapicLRO?: MethodDescriptorProto[]; httpRules?: protos.google.api.IHttpRule[]; @@ -1103,6 +1111,14 @@ export function augmentService(parameters: AugmentServiceParameters) { augmentedService.LongRunningOperationsMixin = 1; } + augmentedService.longRunningOperationsMixinFlags = { + enabled: augmentedService.LongRunningOperationsMixin === 1, + getOperation: !nativeMethodNames.includes('GetOperation'), + cancelOperation: !nativeMethodNames.includes('CancelOperation'), + deleteOperation: !nativeMethodNames.includes('DeleteOperation'), + listOperations: !nativeMethodNames.includes('ListOperations'), + }; + augmentedService.hostname = ''; augmentedService.port = 0; if (augmentedService.options?.['.google.api.defaultHost']) { diff --git a/core/generator/gapic-generator-typescript/typescript/test/unit/proto.ts b/core/generator/gapic-generator-typescript/typescript/test/unit/proto.ts index 1d274ec2893..7ef9060a439 100644 --- a/core/generator/gapic-generator-typescript/typescript/test/unit/proto.ts +++ b/core/generator/gapic-generator-typescript/typescript/test/unit/proto.ts @@ -427,11 +427,13 @@ describe('src/schema/proto.ts', () => { fd.service[0].method = [ {name: 'GetIamPolicy'}, {name: 'ListLocations'}, + {name: 'GetOperation'}, ] as protos.google.protobuf.MethodDescriptorProto[]; // Simulating mixins being enabled (non-zero value) (fd.service[0] as any).IAMPolicyMixin = 1; (fd.service[0] as any).LocationMixin = 1; + (fd.service[0] as any).LongRunningOperationsMixin = 1; const options: Options = { grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, @@ -464,6 +466,11 @@ describe('src/schema/proto.ts', () => { augmentedService.locationMixinFlags?.listLocations, false ); // Native ListLocations exists + + assert.strictEqual(augmentedService.longRunningOperationsMixinFlags?.getOperation, false); // Native GetOperation exists + assert.strictEqual(augmentedService.longRunningOperationsMixinFlags?.cancelOperation, true); + assert.strictEqual(augmentedService.longRunningOperationsMixinFlags?.deleteOperation, true); + assert.strictEqual(augmentedService.longRunningOperationsMixinFlags?.listOperations, true); }); it('should return api version if it exists', () => { From 362844a3254c80548df6977c544c4bd9eb9c5349 Mon Sep 17 00:00:00 2001 From: Shivanee Persaud Date: Thu, 23 Apr 2026 22:53:04 +0000 Subject: [PATCH 08/12] test: update baselines for LRO precedence changes --- .../.OwlBot.yaml.baseline | 19 + .../.babelrc.json.baseline | 19 + .../.eslintignore.baseline | 11 + .../.eslintrc.json.baseline | 4 + .../.gitignore.baseline | 15 + .../.jsdoc.cjs.baseline | 54 + .../.mocharc.cjs.baseline | 33 + .../.nycrc.baseline | 24 + .../.prettierignore.baseline | 6 + .../.prettierrc.cjs.baseline | 22 + .../README.md.baseline} | 10 +- .../esm/src/index.ts.baseline | 26 + .../esm/src/json-helper.cjs.baseline | 20 + ...te_methods_test_service_client.ts.baseline | 917 ++++++++++++++++ ..._test_service_client_config.json.baseline} | 0 ...ods_test_service_proto_list.json.baseline} | 0 .../esm/src/v1/index.ts.baseline | 19 + .../fixtures/sample/src/index.cjs.baseline | 27 + .../fixtures/sample/src/index.js.baseline | 27 + .../fixtures/sample/src/index.ts.baseline | 33 + .../esm/system-test/install.ts.baseline | 55 + ...licate_methods_test_service_v1.ts.baseline | 977 ++++++++++++++++++ .../duplicate_methods_test-esm/package.json | 105 ++ .../package.json.baseline | 1 + .../cloud/common_resources.proto.baseline | 52 + .../duplicate_methods_test_v1.proto.baseline} | 0 ...ate_methods_test_service.echo.js.baseline} | 2 +- ...s_test_service.get_iam_policy.js.baseline} | 2 +- ...s_test_service.list_locations.js.baseline} | 2 +- ...e.duplicate_methods_test.v1.json.baseline} | 0 .../tsconfig.esm.json.baseline | 27 + .../tsconfig.json.baseline | 32 + .../webpack.config.cjs.baseline} | 0 .../.OwlBot.yaml.baseline | 19 + .../.eslintignore.baseline | 7 + .../.eslintrc.json.baseline | 4 + .../.gitignore.baseline | 14 + .../duplicate_methods_test/.jsdoc.js.baseline | 55 + .../.mocharc.js.baseline | 33 + .../duplicate_methods_test/.nycrc.baseline | 24 + .../.prettierignore.baseline | 6 + .../.prettierrc.js.baseline | 22 + .../duplicate_methods_test/CODE_OF_CONDUCT.md | 94 -- .../duplicate_methods_test/CONTRIBUTING.md | 76 -- .../baselines/duplicate_methods_test/LICENSE | 202 ---- .../duplicate_methods_test/README.md.baseline | 108 ++ .../duplicate_methods_test/package.json | 6 +- .../package.json.baseline | 1 + .../cloud/common_resources.proto.baseline | 52 + .../duplicate_methods_test_v1.proto.baseline | 66 ++ ...cate_methods_test_service.echo.js.baseline | 59 ++ ...ds_test_service.get_iam_policy.js.baseline | 67 ++ ...ds_test_service.list_locations.js.baseline | 74 ++ ...le.duplicate_methods_test.v1.json.baseline | 151 +++ .../src/{index.ts => index.ts.baseline} | 0 ...e_methods_test_service_client.ts.baseline} | 2 +- ...s_test_service_client_config.json.baseline | 38 + ...hods_test_service_proto_list.json.baseline | 3 + .../src/v1/{index.ts => index.ts.baseline} | 0 .../src/{index.js => index.js.baseline} | 2 +- .../src/{index.ts => index.ts.baseline} | 2 +- .../{install.ts => install.ts.baseline} | 2 +- ...icate_methods_test_service_v1.ts.baseline} | 0 .../{tsconfig.json => tsconfig.json.baseline} | 0 .../webpack.config.js.baseline | 64 ++ .../key_management_service_client.ts.baseline | 6 +- .../key_management_service_client.ts.baseline | 6 +- .../pubsub-api-dump-esm/api.json.baseline | 54 + .../pubsub-api-dump/api.json.baseline | 54 + .../v1beta1/cloud_redis_client.ts.baseline | 193 ---- .../v1beta1/cloud_redis_client.ts.baseline | 193 ---- 71 files changed, 3521 insertions(+), 779 deletions(-) create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.OwlBot.yaml.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.babelrc.json.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.eslintignore.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.eslintrc.json.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.gitignore.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.jsdoc.cjs.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.mocharc.cjs.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.nycrc.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.prettierignore.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.prettierrc.cjs.baseline rename core/generator/gapic-generator-typescript/baselines/{duplicate_methods_test/README.md => duplicate_methods_test-esm/README.md.baseline} (89%) create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/index.ts.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/json-helper.cjs.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client.ts.baseline rename core/generator/gapic-generator-typescript/baselines/{duplicate_methods_test/src/v1/duplicate_methods_test_service_client_config.json => duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client_config.json.baseline} (100%) rename core/generator/gapic-generator-typescript/baselines/{duplicate_methods_test/src/v1/duplicate_methods_test_service_proto_list.json => duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_proto_list.json.baseline} (100%) create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/v1/index.ts.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.cjs.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.js.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.ts.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/system-test/install.ts.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/test/gapic_duplicate_methods_test_service_v1.ts.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/package.json create mode 120000 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/package.json.baseline create mode 100755 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/protos/google/cloud/common_resources.proto.baseline rename core/generator/gapic-generator-typescript/baselines/{duplicate_methods_test/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto => duplicate_methods_test-esm/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto.baseline} (100%) mode change 100644 => 100755 rename core/generator/gapic-generator-typescript/baselines/{duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.echo.js => duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.echo.js.baseline} (94%) rename core/generator/gapic-generator-typescript/baselines/{duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js => duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js.baseline} (95%) rename core/generator/gapic-generator-typescript/baselines/{duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.list_locations.js => duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.list_locations.js.baseline} (95%) rename core/generator/gapic-generator-typescript/baselines/{duplicate_methods_test/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json => duplicate_methods_test-esm/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json.baseline} (100%) create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/tsconfig.esm.json.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/tsconfig.json.baseline rename core/generator/gapic-generator-typescript/baselines/{duplicate_methods_test/webpack.config.js => duplicate_methods_test-esm/webpack.config.cjs.baseline} (100%) create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.OwlBot.yaml.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.eslintignore.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.eslintrc.json.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.gitignore.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.jsdoc.js.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.mocharc.js.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.nycrc.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.prettierignore.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.prettierrc.js.baseline delete mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/CODE_OF_CONDUCT.md delete mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/CONTRIBUTING.md delete mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/LICENSE create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/README.md.baseline create mode 120000 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/package.json.baseline create mode 100755 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/protos/google/cloud/common_resources.proto.baseline create mode 100755 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.echo.js.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.list_locations.js.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json.baseline rename core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/{index.ts => index.ts.baseline} (100%) rename core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/{duplicate_methods_test_service_client.ts => duplicate_methods_test_service_client.ts.baseline} (99%) create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client_config.json.baseline create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_proto_list.json.baseline rename core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/{index.ts => index.ts.baseline} (100%) rename core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/{index.js => index.js.baseline} (92%) rename core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/{index.ts => index.ts.baseline} (93%) rename core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/{install.ts => install.ts.baseline} (94%) rename core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/test/{gapic_duplicate_methods_test_service_v1.ts => gapic_duplicate_methods_test_service_v1.ts.baseline} (100%) rename core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/{tsconfig.json => tsconfig.json.baseline} (100%) create mode 100644 core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/webpack.config.js.baseline diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.OwlBot.yaml.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.OwlBot.yaml.baseline new file mode 100644 index 00000000000..5dac9f4a249 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.OwlBot.yaml.baseline @@ -0,0 +1,19 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +deep-copy-regex: + - source: /google/duplicate_methods_test/google-duplicate_methods_test-nodejs + dest: /owl-bot-staging/google-duplicate_methods_test + +api-name: duplicate_methods_test \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.babelrc.json.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.babelrc.json.baseline new file mode 100644 index 00000000000..940d91b0a07 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.babelrc.json.baseline @@ -0,0 +1,19 @@ +{ + "presets": [ + "@babel/preset-typescript", + "@babel/env" + ], + "plugins": [ + [ + "replace-import-extension", + { + "extMapping": { + ".js": ".cjs" + } + } + ], + "./node_modules/gapic-tools/build/src/replaceESMMockingLib.js", + "./node_modules/gapic-tools/build/src/replaceImportMetaUrl.js", + "./node_modules/gapic-tools/build/src/toggleESMFlagVariable.js" + ] +} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.eslintignore.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.eslintignore.baseline new file mode 100644 index 00000000000..a73044f809c --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.eslintignore.baseline @@ -0,0 +1,11 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/ +esm/src/**/*.d.ts +esm/test/**/*.d.ts +esm/system-test/**/*.d.ts +esm/system-test/fixtures/sample/src/*.ts \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.eslintrc.json.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.eslintrc.json.baseline new file mode 100644 index 00000000000..3e8d97ccb39 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.eslintrc.json.baseline @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.gitignore.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.gitignore.baseline new file mode 100644 index 00000000000..b391f5f9cd1 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.gitignore.baseline @@ -0,0 +1,15 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ +esm/**/*.d.ts \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.jsdoc.cjs.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.jsdoc.cjs.baseline new file mode 100644 index 00000000000..e049b518ce9 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.jsdoc.cjs.baseline @@ -0,0 +1,54 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2026 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: 'duplicate-methods-test', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.mocharc.cjs.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.mocharc.cjs.baseline new file mode 100644 index 00000000000..5eb34e86c87 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.mocharc.cjs.baseline @@ -0,0 +1,33 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.nycrc.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.nycrc.baseline new file mode 100644 index 00000000000..81a95fc94b0 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.nycrc.baseline @@ -0,0 +1,24 @@ +{ + "report-dir": "./.coverage", + "reporter": ["text", "lcov"], + "exclude": [ + "**/*-test", + "**/.coverage", + "**/apis", + "**/benchmark", + "**/conformance", + "**/docs", + "**/samples", + "**/scripts", + "**/protos", + "**/test", + "**/*.d.ts", + ".jsdoc.js", + "**/.jsdoc.js", + "karma.conf.js", + "webpack-tests.config.js", + "webpack.config.js" + ], + "exclude-after-remap": false, + "all": true +} \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.prettierignore.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.prettierignore.baseline new file mode 100644 index 00000000000..a27d1f92d1b --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.prettierignore.baseline @@ -0,0 +1,6 @@ +**/node_modules +**/coverage +test/fixtures +build/ +docs/ +protos/ \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.prettierrc.cjs.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.prettierrc.cjs.baseline new file mode 100644 index 00000000000..7649ee3c254 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/.prettierrc.cjs.baseline @@ -0,0 +1,22 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/README.md b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/README.md.baseline similarity index 89% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/README.md rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/README.md.baseline index 689fabc4ed5..fa4497f8102 100644 --- a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/README.md +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/README.md.baseline @@ -6,7 +6,7 @@ [//]: # "releaseLevel" -[![npm version](https://img.shields.io/npm/v/@google-cloud/duplicate_methods_test.svg)](https://www.npmjs.org/package/@google-cloud/duplicate_methods_test) +[![npm version](https://img.shields.io/npm/v/duplicate-methods-test.svg)](https://www.npmjs.org/package/duplicate-methods-test) Duplicate Methods Test Service API client for Node.js @@ -44,7 +44,7 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained]. ### Installing the client library ```bash -npm install @google-cloud/duplicate_methods_test +npm install duplicate-methods-test ``` [//]: # "partials.body" @@ -73,7 +73,7 @@ best-efforts basis with the following warnings: Client libraries targeting some end-of-life versions of Node.js are available, and can be installed through npm [dist-tags](https://docs.npmjs.com/cli/dist-tag). The dist-tags follow the naming convention `legacy-(version)`. -For example, `npm install @google-cloud/duplicate_methods_test@legacy-8` installs client libraries +For example, `npm install duplicate-methods-test@legacy-8` installs client libraries for versions compatible with Node.js 8. ## Versioning @@ -86,7 +86,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-duplicate_methods_test/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md). Please note that this `README.md` and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -96,7 +96,7 @@ are generated from a central template. Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-duplicate_methods_test/LICENSE) +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [projects]: https://console.cloud.google.com/project diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/index.ts.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/index.ts.baseline new file mode 100644 index 00000000000..2f77a606018 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/index.ts.baseline @@ -0,0 +1,26 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1/index.js'; +const DuplicateMethodsTestServiceClient = v1.DuplicateMethodsTestServiceClient; +type DuplicateMethodsTestServiceClient = v1.DuplicateMethodsTestServiceClient; +export {v1, DuplicateMethodsTestServiceClient}; +export default {v1, DuplicateMethodsTestServiceClient}; +// @ts-ignore +import * as protos from '../../protos/protos.js'; +export {protos} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/json-helper.cjs.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/json-helper.cjs.baseline new file mode 100644 index 00000000000..3c1fc730201 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/json-helper.cjs.baseline @@ -0,0 +1,20 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* eslint-disable node/no-missing-require */ +function getJSON(path) { + return require(path); +} + +exports.getJSON = getJSON; diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client.ts.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client.ts.baseline new file mode 100644 index 00000000000..1e4d8ed7abc --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client.ts.baseline @@ -0,0 +1,917 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +// @ts-ignore +import type * as protos from '../../../protos/protos.js'; +import * as duplicate_methods_test_service_client_config from './duplicate_methods_test_service_client_config.json'; +import fs from 'fs'; +import path from 'path'; +import {fileURLToPath} from 'url'; +import {getJSON} from '../json-helper.cjs'; +// @ts-ignore +const dirname = path.dirname(fileURLToPath(import.meta.url)); + +/** + * Client JSON configuration object, loaded from + * `src/v1/duplicate_methods_test_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +const gapicConfig = getJSON( + path.join(dirname, 'duplicate_methods_test_service_client_config.json') +); + +const jsonProtos = getJSON( + path.join(dirname, '..', '..', '..', 'protos/protos.json') +); +import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +const version = getJSON( + path.join(dirname, '..', '..', '..', '..', 'package.json') +).version; + +/** + * @class + * @memberof v1 + */ +export class DuplicateMethodsTestServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; + private _log = logging.log('duplicate-methods-test'); + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + iamClient: IamClient; + locationsClient: LocationsClient; + duplicateMethodsTestServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DuplicateMethodsTestServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * 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. + * 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 DuplicateMethodsTestServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof DuplicateMethodsTestServiceClient; + if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { + throw new Error('Please set either universe_domain or universeDomain, but not both.'); + } + const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; + this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + this._servicePath = 'duplicatemethodstest.' + this._universeDomain; + const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== this._servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = gax as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = this._servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === this._servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); + + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Add ESM headers + const isEsm = true; + const isEsmString = isEsm ? '-esm' : '-cjs'; + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process === 'object' && 'versions' in process) { + clientHeader.push(`gl-node/{process.versions.node}${isEsmString}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos as gax.protobuf.INamespace); + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listLocations: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'locations') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.duplicate_methods_test.v1.DuplicateMethodsTestService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.duplicateMethodsTestServiceStub) { + return this.duplicateMethodsTestServiceStub; + } + + // Put together the "service stub" for + // google.duplicate_methods_test.v1.DuplicateMethodsTestService. + this.duplicateMethodsTestServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.duplicate_methods_test.v1.DuplicateMethodsTestService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.duplicate_methods_test.v1.DuplicateMethodsTestService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const duplicateMethodsTestServiceStubMethods = + ['getIamPolicy', 'listLocations', 'echo']; + for (const methodName of duplicateMethodsTestServiceStubMethods) { + const callPromise = this.duplicateMethodsTestServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.duplicateMethodsTestServiceStub; + } + + /** + * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + if (typeof process === 'object' && typeof process.emitWarning === 'function') { + process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + } + return 'duplicatemethodstest.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath, + * exists for compatibility reasons. + * @deprecated Use the apiEndpoint method of the client instance. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + if (typeof process === 'object' && typeof process.emitWarning === 'function') { + process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + } + return 'duplicatemethodstest.googleapis.com'; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Native GetIamPolicy method that conflicts with the IAMPolicy mixin. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js + * region_tag:duplicatemethodstest_v1_generated_DuplicateMethodsTestService_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize().catch(err => {throw err}); + this._log.info('getIamPolicy request %j', request); + const wrappedCallback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>|undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getIamPolicy response %j', response); + callback!(error, response, options, rawResponse); + } + : undefined; + return this.innerApiCalls.getIamPolicy(request, options, wrappedCallback) + ?.then(([response, options, rawResponse]: [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]) => { + this._log.info('getIamPolicy response %j', response); + return [response, options, rawResponse]; + }).catch((error: any) => { + if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { + const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + } + throw error; + }); + } +/** + * Another native method to ensure the service is valid and has other methods. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.content + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.duplicate_methods_test.v1.EchoResponse|EchoResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/duplicate_methods_test_service.echo.js + * region_tag:duplicatemethodstest_v1_generated_DuplicateMethodsTestService_Echo_async + */ + echo( + request?: protos.google.duplicate_methods_test.v1.IEchoRequest, + options?: CallOptions): + Promise<[ + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|undefined, {}|undefined + ]>; + echo( + request: protos.google.duplicate_methods_test.v1.IEchoRequest, + options: CallOptions, + callback: Callback< + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|null|undefined, + {}|null|undefined>): void; + echo( + request: protos.google.duplicate_methods_test.v1.IEchoRequest, + callback: Callback< + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|null|undefined, + {}|null|undefined>): void; + echo( + request?: protos.google.duplicate_methods_test.v1.IEchoRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize().catch(err => {throw err}); + this._log.info('echo request %j', request); + const wrappedCallback: Callback< + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|null|undefined, + {}|null|undefined>|undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('echo response %j', response); + callback!(error, response, options, rawResponse); + } + : undefined; + return this.innerApiCalls.echo(request, options, wrappedCallback) + ?.then(([response, options, rawResponse]: [ + protos.google.duplicate_methods_test.v1.IEchoResponse, + protos.google.duplicate_methods_test.v1.IEchoRequest|undefined, {}|undefined + ]) => { + this._log.info('echo response %j', response); + return [response, options, rawResponse]; + }).catch((error: any) => { + if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { + const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + } + throw error; + }); + } + + /** + * Native ListLocations method that conflicts with the Locations mixin. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.location.Location|Location}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listLocationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listLocations( + request?: protos.google.cloud.location.IListLocationsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.location.ILocation[], + protos.google.cloud.location.IListLocationsRequest|null, + protos.google.cloud.location.IListLocationsResponse + ]>; + listLocations( + request: protos.google.cloud.location.IListLocationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.location.IListLocationsRequest, + protos.google.cloud.location.IListLocationsResponse|null|undefined, + protos.google.cloud.location.ILocation>): void; + listLocations( + request: protos.google.cloud.location.IListLocationsRequest, + callback: PaginationCallback< + protos.google.cloud.location.IListLocationsRequest, + protos.google.cloud.location.IListLocationsResponse|null|undefined, + protos.google.cloud.location.ILocation>): void; + listLocations( + request?: protos.google.cloud.location.IListLocationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.location.IListLocationsRequest, + protos.google.cloud.location.IListLocationsResponse|null|undefined, + protos.google.cloud.location.ILocation>, + callback?: PaginationCallback< + protos.google.cloud.location.IListLocationsRequest, + protos.google.cloud.location.IListLocationsResponse|null|undefined, + protos.google.cloud.location.ILocation>): + Promise<[ + protos.google.cloud.location.ILocation[], + protos.google.cloud.location.IListLocationsRequest|null, + protos.google.cloud.location.IListLocationsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize().catch(err => {throw err}); + const wrappedCallback: PaginationCallback< + protos.google.cloud.location.IListLocationsRequest, + protos.google.cloud.location.IListLocationsResponse|null|undefined, + protos.google.cloud.location.ILocation>|undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listLocations values %j', values); + callback!(error, values, nextPageRequest, rawResponse); + } + : undefined; + this._log.info('listLocations request %j', request); + return this.innerApiCalls + .listLocations(request, options, wrappedCallback) + ?.then(([response, input, output]: [ + protos.google.cloud.location.ILocation[], + protos.google.cloud.location.IListLocationsRequest|null, + protos.google.cloud.location.IListLocationsResponse + ]) => { + this._log.info('listLocations values %j', response); + return [response, input, output]; + }); + } + +/** + * Equivalent to `listLocations`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.location.Location|Location} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listLocationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listLocationsStream( + request?: protos.google.cloud.location.IListLocationsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listLocations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize().catch(err => {throw err}); + this._log.info('listLocations stream %j', request); + return this.descriptors.page.listLocations.createStream( + this.innerApiCalls.listLocations as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listLocations`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.location.Location|Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/duplicate_methods_test_service.list_locations.js + * region_tag:duplicatemethodstest_v1_generated_DuplicateMethodsTestService_ListLocations_async + */ + listLocationsAsync( + request?: protos.google.cloud.location.IListLocationsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listLocations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize().catch(err => {throw err}); + this._log.info('listLocations iterate %j', request); + return this.descriptors.page.listLocations.asyncIterate( + this.innerApiCalls['listLocations'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + /** + request: IamProtos.google.iam.v1.SetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.Policy]> { + return this.iamClient.setIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ + /** + request: IamProtos.google.iam.v1.TestIamPermissionsRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + return this.iamClient.testIamPermissions(request, options, callback); + } + + + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.duplicateMethodsTestServiceStub && !this._terminated) { + return this.duplicateMethodsTestServiceStub.then(stub => { + this._log.info('ending gRPC channel'); + this._terminated = true; + stub.close(); + this.iamClient.close().catch(err => {throw err}); + this.locationsClient.close().catch(err => {throw err}); + }); + } + return Promise.resolve(); + } +} \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client_config.json b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client_config.json.baseline similarity index 100% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client_config.json rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client_config.json.baseline diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_proto_list.json b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_proto_list.json.baseline similarity index 100% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_proto_list.json rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_proto_list.json.baseline diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/v1/index.ts.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/v1/index.ts.baseline new file mode 100644 index 00000000000..0104bde3222 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/v1/index.ts.baseline @@ -0,0 +1,19 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {DuplicateMethodsTestServiceClient} from './duplicate_methods_test_service_client.js'; diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.cjs.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.cjs.baseline new file mode 100644 index 00000000000..d42714603ce --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.cjs.baseline @@ -0,0 +1,27 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars, no-undef */ +const duplicate-methods-test = require('duplicate-methods-test'); + +function main() { + const duplicateMethodsTestServiceClient = new duplicate-methods-test.DuplicateMethodsTestServiceClient(); +} + +main(); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.js.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.js.baseline new file mode 100644 index 00000000000..eb41e84cb72 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.js.baseline @@ -0,0 +1,27 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars, no-undef */ +import * as duplicate-methods-test from 'duplicate-methods-test'; + +function main() { + const duplicateMethodsTestServiceClient = new duplicate-methods-test.DuplicateMethodsTestServiceClient(); +} + +main(); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.ts.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.ts.baseline new file mode 100644 index 00000000000..b5b59ab8282 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/system-test/fixtures/sample/src/index.ts.baseline @@ -0,0 +1,33 @@ +/* eslint-disable node/no-missing-require, no-unused-vars, no-undef */ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {DuplicateMethodsTestServiceClient} from 'duplicate-methods-test'; + +// check that the client class type name can be used +function doStuffWithDuplicateMethodsTestServiceClient(client: DuplicateMethodsTestServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const duplicateMethodsTestServiceClient = new DuplicateMethodsTestServiceClient(); + doStuffWithDuplicateMethodsTestServiceClient(duplicateMethodsTestServiceClient); +} + +main(); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/system-test/install.ts.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/system-test/install.ts.baseline new file mode 100644 index 00000000000..e079c4fa110 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/system-test/install.ts.baseline @@ -0,0 +1,55 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + it('TypeScript', async function() { + this.timeout(300000); + await packNTest({ + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./esm/system-test/fixtures/sample/src/index.ts').toString() + } + }); + }); + + it('ESM module', async function() { + this.timeout(300000); + await packNTest({ + sample: { + description: 'Should be able to import using ESM', + esm: readFileSync('./esm/system-test/fixtures/sample/src/index.js').toString(), + }, + }); + }); + + it('CJS module', async function() { + this.timeout(300000); + await packNTest({ + sample: { + description: 'Should be able to import using CJS', + cjs: readFileSync('./esm/system-test/fixtures/sample/src/index.cjs').toString(), + }, + }); + }); + +}); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/test/gapic_duplicate_methods_test_service_v1.ts.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/test/gapic_duplicate_methods_test_service_v1.ts.baseline new file mode 100644 index 00000000000..ad48c9cffc7 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/test/gapic_duplicate_methods_test_service_v1.ts.baseline @@ -0,0 +1,977 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +// @ts-ignore +import * as protos from '../../protos/protos.js'; +import assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as duplicatemethodstestserviceModule from '../src/index.js'; + +import {PassThrough} from 'stream'; + +import {protobuf, IamProtos, LocationProtos} from 'google-gax'; +import fs from 'fs'; +import path from 'path'; +import {fileURLToPath} from 'url'; + +// @ts-ignore +const dirname = path.dirname(fileURLToPath(import.meta.url)); +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + JSON.parse( + fs.readFileSync(path.join(dirname, '..', '..', 'protos/protos.json'), 'utf8') + )) + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type?.fields[field]?.resolvedType as protobuf.Type; + } + return type?.fields[fields[fields.length - 1]]?.defaultValue ?? null; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.DuplicateMethodsTestServiceClient', () => { + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'duplicatemethodstest.googleapis.com'); + }); + + it('has universeDomain', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, "googleapis.com"); + }); + + if (typeof process === 'object' && typeof process.emitWarning === 'function') { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient.servicePath; + assert.strictEqual(servicePath, 'duplicatemethodstest.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'duplicatemethodstest.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({universeDomain: 'example.com'}); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'duplicatemethodstest.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({universe_domain: 'example.com'}); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'duplicatemethodstest.example.com'); + }); + + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'duplicatemethodstest.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({universeDomain: 'configured.example.com'}); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'duplicatemethodstest.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + }); + + it('has port', () => { + const port = duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.duplicateMethodsTestServiceStub, undefined); + await client.initialize(); + assert(client.duplicateMethodsTestServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize().catch(err => {throw err}); + assert(client.duplicateMethodsTestServiceStub); + client.close().then(() => { + done(); + }).catch(err => {throw err}); + }); + + it('has close method for the non-initialized client', done => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.duplicateMethodsTestServiceStub, undefined); + client.close().then(() => { + done(); + }).catch(err => {throw err}); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + 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()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + 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); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch(err => {throw err}); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('echo', () => { + it('invokes echo without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoResponse() + ); + client.innerApiCalls.echo = stubSimpleCall(expectedResponse); + const [response] = await client.echo(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes echo without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoResponse() + ); + client.innerApiCalls.echo = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.echo( + request, + (err?: Error|null, result?: protos.google.duplicate_methods_test.v1.IEchoResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes echo with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.echo = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.echo(request), expectedError); + }); + + it('invokes echo with closed client', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.duplicate_methods_test.v1.EchoRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch(err => {throw err}); + await assert.rejects(client.echo(request), expectedError); + }); + }); + + describe('listLocations', () => { + it('invokes listLocations without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + ]; + client.innerApiCalls.listLocations = stubSimpleCall(expectedResponse); + const [response] = await client.listLocations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listLocations without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + ]; + client.innerApiCalls.listLocations = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listLocations( + request, + (err?: Error|null, result?: protos.google.cloud.location.ILocation[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listLocations with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedError = new Error('expected'); + client.innerApiCalls.listLocations = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listLocations(request), expectedError); + const actualRequest = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listLocations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listLocationsStream without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + ]; + client.descriptors.page.listLocations.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listLocationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.location.Location[] = []; + stream.on('data', (response: protos.google.cloud.location.Location) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listLocations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listLocations, request)); + assert( + (client.descriptors.page.listLocations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listLocationsStream with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedError = new Error('expected'); + client.descriptors.page.listLocations.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listLocationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.location.Location[] = []; + stream.on('data', (response: protos.google.cloud.location.Location) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listLocations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listLocations, request)); + assert( + (client.descriptors.page.listLocations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listLocations without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + generateSampleMessage(new protos.google.cloud.location.Location()), + ]; + client.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listLocations with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.location.ListLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.location.ListLocationsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; + const expectedError = new Error('expected'); + client.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }).catch(err => {throw err}); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }).catch(err => {throw err}); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new duplicatemethodstestserviceModule.v1.DuplicateMethodsTestServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); +}); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/package.json b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/package.json new file mode 100644 index 00000000000..71c6fe0a200 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/package.json @@ -0,0 +1,105 @@ +{ + "name": "duplicate-methods-test", + "version": "0.1.0", + "description": "Duplicate_methods_test client for Node.js", + "repository": "googleapis/nodejs-duplicate-methods-test", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "./build/cjs/src/index.cjs", + "types": "./build/cjs/src/index.d.ts", + "type": "module", + "exports": { + ".": { + "import": { + "types": "./build/esm/src/index.d.ts", + "default": "./build/esm/src/index.js" + }, + "require": { + "types": "./build/cjs/src/index.d.ts", + "default": "./build/cjs/src/index.cjs" + } + }, + "./build/protos/protos": { + "import": { + "types": "./build/protos/protos/protos.d.ts", + "default": "./build/protos/protos/protos.js" + }, + "require": { + "types": "./build/protos/protos/protos.d.ts", + "default": "./build/protos/protos/protos.cjs" + } + } + }, + "files": [ + "build/esm", + "build/cjs", + "build/protos", + "!build/esm/**/*.map", + "!build/cjs/**/*.map" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google duplicateMethodsTest", + "duplicateMethodsTest", + "duplicate methods test service" + ], + "scripts": { + "clean": "gts clean", + "compile-protos": "compileProtos esm/src --esm ", + "docs": "jsdoc -c .jsdoc.cjs", + "postpack": "minifyProtoJson build/cjs && minifyProtoJson build/esm", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test:cjs": "c8 mocha build/cjs/system-test", + "system-test:esm": "c8 mocha build/esm/system-test", + "system-test": "npm run system-test:esm && npm run system-test:cjs", + "test:cjs": "c8 mocha build/cjs/test", + "test:esm": "c8 mocha build/esm/test", + "test": "npm run test:cjs && npm run test:esm", + "compile:esm": "tsc -p ./tsconfig.esm.json && cp -r esm/src/json-helper.cjs build/esm/src/json-helper.cjs", + "babel": "babel esm --out-dir build/cjs --ignore \"esm/**/*.d.ts\" --extensions \".ts\" --out-file-extension .cjs --copy-files", + "compile:cjs": "tsc -p ./tsconfig.json && npm run babel", + "compile": "npm run compile:esm && rm -rf esm/src/json-helper.d.cts && npm run compile:cjs && rm -rf build/protos && cp -r protos build/protos", + "samples-test": "cd samples/ && npm link ../ && npm i && npm test" + }, + "dependencies": { + "google-gax": "^5.1.1-rc.1" + }, + "devDependencies": { + "@babel/cli": "^7.28.3", + "@babel/core": "^7.28.5", + "@babel/preset-env": "^7.28.5", + "@babel/preset-typescript": "^7.28.5", + "@types/mocha": "^10.0.10", + "@types/node": "^22.18.12", + "@types/sinon": "^20.0.0", + "babel-plugin-replace-import-extension": "^1.1.5", + "c8": "^10.1.3", + "gapic-tools": "^1.0.3", + "gts": "^6.0.2", + "jsdoc": "^4.0.5", + "jsdoc-region-tag": "^4.0.1", + "jsdoc-fresh": "^5.0.2", + "long": "^5.3.2", + "mocha": "^11.7.4", + "typescript": "5.8.3", + "pack-n-play": "^4.2.1", + "sinon": "^20.0.0", + "ts-loader": "^8.4.0", + "webpack": "^5.102.1", + "webpack-cli": "^6.0.1" + }, + "engines": { + "node": ">=v18" + } +} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/package.json.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/package.json.baseline new file mode 120000 index 00000000000..2ff8622f172 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/package.json.baseline @@ -0,0 +1 @@ +package.json \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/protos/google/cloud/common_resources.proto.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/protos/google/cloud/common_resources.proto.baseline new file mode 100755 index 00000000000..a2f46cea3e1 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/protos/google/cloud/common_resources.proto.baseline @@ -0,0 +1,52 @@ +// Copyright 2020 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file contains stub messages for common resources in GCP. +// It is not intended to be directly generated, and is instead used by +// other tooling to be able to match common resource patterns. +syntax = "proto3"; + +package google.cloud; + +import "google/api/resource.proto"; + + +option (google.api.resource_definition) = { + type: "cloudresourcemanager.googleapis.com/Project" + pattern: "projects/{project}" +}; + + +option (google.api.resource_definition) = { + type: "cloudresourcemanager.googleapis.com/Organization" + pattern: "organizations/{organization}" +}; + + +option (google.api.resource_definition) = { + type: "cloudresourcemanager.googleapis.com/Folder" + pattern: "folders/{folder}" +}; + + +option (google.api.resource_definition) = { + type: "cloudbilling.googleapis.com/BillingAccount" + pattern: "billingAccounts/{billing_account}" +}; + +option (google.api.resource_definition) = { + type: "locations.googleapis.com/Location" + pattern: "projects/{project}/locations/{location}" +}; + diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto.baseline old mode 100644 new mode 100755 similarity index 100% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto.baseline diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.echo.js b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.echo.js.baseline similarity index 94% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.echo.js rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.echo.js.baseline index a99b8cf9ee6..3741fd8a179 100644 --- a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.echo.js +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.echo.js.baseline @@ -33,7 +33,7 @@ function main() { // const content = 'abc123' // Imports the Duplicate_methods_test library - const {DuplicateMethodsTestServiceClient} = require('@google-cloud/duplicate_methods_test').v1; + const {DuplicateMethodsTestServiceClient} = require('duplicate-methods-test').v1; // Instantiates a client const duplicateMethodsTestClient = new DuplicateMethodsTestServiceClient(); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js.baseline similarity index 95% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js.baseline index a0285e3a018..aeee64b6143 100644 --- a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js.baseline @@ -40,7 +40,7 @@ function main(resource) { // const options = {} // Imports the Duplicate_methods_test library - const {DuplicateMethodsTestServiceClient} = require('@google-cloud/duplicate_methods_test').v1; + const {DuplicateMethodsTestServiceClient} = require('duplicate-methods-test').v1; // Instantiates a client const duplicateMethodsTestClient = new DuplicateMethodsTestServiceClient(); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.list_locations.js b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.list_locations.js.baseline similarity index 95% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.list_locations.js rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.list_locations.js.baseline index a6d87f2e660..4506a9a8664 100644 --- a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.list_locations.js +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/samples/generated/v1/duplicate_methods_test_service.list_locations.js.baseline @@ -46,7 +46,7 @@ function main() { // const pageToken = 'abc123' // Imports the Duplicate_methods_test library - const {DuplicateMethodsTestServiceClient} = require('@google-cloud/duplicate_methods_test').v1; + const {DuplicateMethodsTestServiceClient} = require('duplicate-methods-test').v1; // Instantiates a client const duplicateMethodsTestClient = new DuplicateMethodsTestServiceClient(); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json.baseline similarity index 100% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json.baseline diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/tsconfig.esm.json.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/tsconfig.esm.json.baseline new file mode 100644 index 00000000000..9ea46f074fa --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/tsconfig.esm.json.baseline @@ -0,0 +1,27 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "module": "es2020", + "moduleResolution": "node", + "esModuleInterop": true, + "sourceMap": false, + "allowJs": true, + "lib": [ + "es2020", + "DOM" + ] + }, + "include": [ + "esm/src/*.ts", + "esm/src/**/*.ts", + "esm/test/*.ts", + "esm/test/**/*.ts", + "esm/system-test/*.ts", + "esm/src/**/*.json", + "protos/protos.json", + "esm/src/*.cjs" + ] +} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/tsconfig.json.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/tsconfig.json.baseline new file mode 100644 index 00000000000..110f6eccd41 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/tsconfig.json.baseline @@ -0,0 +1,32 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "resolveJsonModule": true, + "moduleResolution": "node", + "allowJs": true, + "esModuleInterop": true, + "sourceMap": false, + "target": "esnext", + "module": "CommonJS", + "declaration": true, + "strict": true, + "isolatedModules": false, + "emitDeclarationOnly": true, + "lib": [ + "es2023", + "dom" + ] + }, + "include": [ + "esm/src/*.ts", + "esm/src/**/*.ts", + "esm/test/*.ts", + "esm/test/**/*.ts", + "esm/src/**/*.json", + "esm/system-test/*.ts", + "esm/src/*.cjs", + "samples/**/*.json", + "protos/protos.json" + ] +} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/webpack.config.js b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/webpack.config.cjs.baseline similarity index 100% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/webpack.config.js rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/webpack.config.cjs.baseline diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.OwlBot.yaml.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.OwlBot.yaml.baseline new file mode 100644 index 00000000000..5dac9f4a249 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.OwlBot.yaml.baseline @@ -0,0 +1,19 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +deep-copy-regex: + - source: /google/duplicate_methods_test/google-duplicate_methods_test-nodejs + dest: /owl-bot-staging/google-duplicate_methods_test + +api-name: duplicate_methods_test \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.eslintignore.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.eslintignore.baseline new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.eslintignore.baseline @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.eslintrc.json.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.eslintrc.json.baseline new file mode 100644 index 00000000000..3e8d97ccb39 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.eslintrc.json.baseline @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.gitignore.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.gitignore.baseline new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.gitignore.baseline @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.jsdoc.js.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.jsdoc.js.baseline new file mode 100644 index 00000000000..9a7ab0b0fad --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.jsdoc.js.baseline @@ -0,0 +1,55 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2026 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: 'duplicate-methods-test', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.mocharc.js.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.mocharc.js.baseline new file mode 100644 index 00000000000..5eb34e86c87 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.mocharc.js.baseline @@ -0,0 +1,33 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.nycrc.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.nycrc.baseline new file mode 100644 index 00000000000..81a95fc94b0 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.nycrc.baseline @@ -0,0 +1,24 @@ +{ + "report-dir": "./.coverage", + "reporter": ["text", "lcov"], + "exclude": [ + "**/*-test", + "**/.coverage", + "**/apis", + "**/benchmark", + "**/conformance", + "**/docs", + "**/samples", + "**/scripts", + "**/protos", + "**/test", + "**/*.d.ts", + ".jsdoc.js", + "**/.jsdoc.js", + "karma.conf.js", + "webpack-tests.config.js", + "webpack.config.js" + ], + "exclude-after-remap": false, + "all": true +} \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.prettierignore.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.prettierignore.baseline new file mode 100644 index 00000000000..9340ad9b86d --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.prettierignore.baseline @@ -0,0 +1,6 @@ +**/node_modules +**/coverage +test/fixtures +build/ +docs/ +protos/ diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.prettierrc.js.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.prettierrc.js.baseline new file mode 100644 index 00000000000..7649ee3c254 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/.prettierrc.js.baseline @@ -0,0 +1,22 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/CODE_OF_CONDUCT.md b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/CODE_OF_CONDUCT.md deleted file mode 100644 index 2add2547a81..00000000000 --- a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,94 +0,0 @@ - -# Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, gender identity and expression, level of -experience, education, socio-economic status, nationality, personal appearance, -race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, or to ban temporarily or permanently any -contributor for other behaviors that they deem inappropriate, threatening, -offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. - -This Code of Conduct also applies outside the project spaces when the Project -Steward has a reasonable belief that an individual's behavior may have a -negative impact on the project or its community. - -## Conflict Resolution - -We do not believe that all conflict is bad; healthy debate and disagreement -often yield positive results. However, it is never okay to be disrespectful or -to engage in behavior that violates the project’s code of conduct. - -If you see someone violating the code of conduct, you are encouraged to address -the behavior directly with those involved. Many issues can be resolved quickly -and easily, and this gives people more control over the outcome of their -dispute. If you are unable to resolve the matter for any reason, or if the -behavior is threatening or harassing, report it. We are dedicated to providing -an environment where participants feel welcome and safe. - -Reports should be directed to *googleapis-stewards@google.com*, the -Project Steward(s) for *Google Cloud Client Libraries*. It is the Project Steward’s duty to -receive and address reported violations of the code of conduct. They will then -work with a committee consisting of representatives from the Open Source -Programs Office and the Google Open Source Strategy team. If for any reason you -are uncomfortable reaching out to the Project Steward, please email -opensource@google.com. - -We will investigate every complaint, but you may not receive a direct response. -We will use our discretion in determining when and how to follow up on reported -incidents, which may range from not taking action to permanent expulsion from -the project and project-sponsored spaces. We will notify the accused of the -report and provide them an opportunity to discuss it before any action is taken. -The identity of the reporter will be omitted from the details of the report -supplied to the accused. In potentially harmful situations, such as ongoing -harassment or threats to anyone's safety, we may take action without notice. - -## Attribution - -This Code of Conduct is adapted from the Contributor Covenant, version 1.4, -available at -https://www.contributor-covenant.org/version/1/4/code-of-conduct.html \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/CONTRIBUTING.md b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/CONTRIBUTING.md deleted file mode 100644 index 099d8bfb0e8..00000000000 --- a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/CONTRIBUTING.md +++ /dev/null @@ -1,76 +0,0 @@ -# How to become a contributor and submit your own code - -**Table of contents** - -* [Contributor License Agreements](#contributor-license-agreements) -* [Contributing a patch](#contributing-a-patch) -* [Running the tests](#running-the-tests) -* [Releasing the library](#releasing-the-library) - -## Contributor License Agreements - -We'd love to accept your sample apps and patches! Before we can take them, we -have to jump a couple of legal hurdles. - -Please fill out either the individual or corporate Contributor License Agreement -(CLA). - - * If you are an individual writing original source code and you're sure you - own the intellectual property, then you'll need to sign an [individual CLA](https://developers.google.com/open-source/cla/individual). - * If you work for a company that wants to allow you to contribute your work, - then you'll need to sign a [corporate CLA](https://developers.google.com/open-source/cla/corporate). - -Follow either of the two links above to access the appropriate CLA and -instructions for how to sign and return it. Once we receive it, we'll be able to -accept your pull requests. - -## Contributing A Patch - -1. Submit an issue describing your proposed change to the repo in question. -1. The repo owner will respond to your issue promptly. -1. If your proposed change is accepted, and you haven't already done so, sign a - Contributor License Agreement (see details above). -1. Fork the desired repo, develop and test your code changes. -1. Ensure that your code adheres to the existing style in the code to which - you are contributing. -1. Ensure that your code has an appropriate set of tests which all pass. -1. Title your pull request following [Conventional Commits](https://www.conventionalcommits.org/) styling. -1. Submit a pull request. - -### Before you begin - -1. [Select or create a Cloud Platform project][projects]. -1. [Enable billing for your project][billing]. -1. [Enable the Duplicate_methods_test API][enable_api]. -1. [Set up authentication with a service account][auth] so you can access the - API from your local workstation. - - -## Running the tests - -1. [Prepare your environment for Node.js setup][setup]. - -1. Install dependencies: - - npm install - -1. Run the tests: - - # Run unit tests. - npm test - - # Run sample integration tests. - npm run samples-test - - # Run all system tests. - npm run system-test - -1. Lint (and maybe fix) any changes: - - npm run fix - -[setup]: https://cloud.google.com/nodejs/docs/setup -[projects]: https://console.cloud.google.com/project -[billing]: https://support.google.com/cloud/answer/6293499#enable-billing -[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=duplicatemethodstest.googleapis.com -[auth]: https://cloud.google.com/docs/authentication/getting-started \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/LICENSE b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/LICENSE deleted file mode 100644 index d6456956733..00000000000 --- a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/README.md.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/README.md.baseline new file mode 100644 index 00000000000..fa4497f8102 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/README.md.baseline @@ -0,0 +1,108 @@ +[//]: # "This README.md file is auto-generated, all changes to this file will be lost." +[//]: # "The comments you see below are used to generate those parts of the template in later states." +Google Cloud Platform logo + +# [Duplicate Methods Test Service API: Nodejs Client][homepage] + +[//]: # "releaseLevel" + +[![npm version](https://img.shields.io/npm/v/duplicate-methods-test.svg)](https://www.npmjs.org/package/duplicate-methods-test) + +Duplicate Methods Test Service API client for Node.js + +[//]: # "partials.introduction" + +A comprehensive list of changes in each version may be found in +[the CHANGELOG][homepage_changelog]. + +* [Duplicate Methods Test Service API Nodejs Client API Reference](https://cloud.google.com/nodejs/docs/reference/duplicate_methods_test/latest) + + +Read more about the client libraries for Cloud APIs, including the older +Google APIs Client Libraries, in [Client Libraries Explained][explained]. + +[explained]: https://cloud.google.com/apis/docs/client-libraries-explained + +**Table of contents:** + +* [Quickstart](#quickstart) + * [Before you begin](#before-you-begin) + * [Installing the client library](#installing-the-client-library) + +* [Versioning](#versioning) +* [Contributing](#contributing) +* [License](#license) + +## Quickstart +### Before you begin + +1. [Select or create a Cloud Platform project][projects]. +1. [Enable billing for your project][billing]. +1. [Enable the Duplicate Methods Test Service API API][enable_api]. +1. [Set up authentication][auth] so you can access the + API from your local workstation. +### Installing the client library + +```bash +npm install duplicate-methods-test +``` + +[//]: # "partials.body" + +## Samples + +Samples are in the [`samples/`][homepage_samples] directory. Each sample's `README.md` has instructions for running its sample. + +[//]: # "samples" + +## Supported Node.js Versions + +Our client libraries follow the [Node.js release schedule](https://github.com/nodejs/release#release-schedule). +Libraries are compatible with all current _active_ and _maintenance_ versions of +Node.js. +If you are using an end-of-life version of Node.js, we recommend that you update +as soon as possible to an actively supported LTS version. + +Google's client libraries support legacy versions of Node.js runtimes on a +best-efforts basis with the following warnings: + +* Legacy versions are not tested in continuous integration. +* Some security patches and features cannot be backported. +* Dependencies cannot be kept up-to-date. + +Client libraries targeting some end-of-life versions of Node.js are available, and +can be installed through npm [dist-tags](https://docs.npmjs.com/cli/dist-tag). +The dist-tags follow the naming convention `legacy-(version)`. +For example, `npm install duplicate-methods-test@legacy-8` installs client libraries +for versions compatible with Node.js 8. + +## Versioning + +This library follows [Semantic Versioning](http://semver.org/). + +More Information: [Google Cloud Platform Launch Stages][launch_stages] + +[launch_stages]: https://cloud.google.com/terms/launch-stages + +## Contributing + +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md). + +Please note that this `README.md` +and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) +are generated from a central template. + +## License + +Apache Version 2.0 + +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) + +[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png +[projects]: https://console.cloud.google.com/project +[billing]: https://support.google.com/cloud/answer/6293499#enable-billing +[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=duplicatemethodstest.googleapis.com +[auth]: https://cloud.google.com/docs/authentication/external/set-up-adc-local +[homepage_samples]: https://github.com/googleapis/google-cloud-node/blob/main/packages/google-duplicate_methods_test/samples +[homepage_changelog]: https://github.com/googleapis/google-cloud-node/blob/main/packages/google-duplicate_methods_test/CHANGELOG.md +[homepage]: https://github.com/googleapis/google-cloud-node/blob/main/packages/google-duplicate_methods_test diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/package.json b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/package.json index 63d39e58107..3f72914705f 100644 --- a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/package.json +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/package.json @@ -1,5 +1,5 @@ { - "name": "@google-cloud/duplicate_methods_test", + "name": "duplicate-methods-test", "version": "0.1.0", "description": "Duplicate_methods_test client for Node.js", "repository": "googleapis/nodejs-duplicate-methods-test", @@ -40,7 +40,7 @@ "devDependencies": { "@types/mocha": "^10.0.10", "@types/node": "^22.18.12", - "@types/sinon": "^17.0.4", + "@types/sinon": "^20.0.0", "c8": "^10.1.3", "gapic-tools": "^1.0.3", "gts": "^6.0.2", @@ -50,7 +50,7 @@ "mocha": "^11.7.4", "pack-n-play": "^4.2.1", "typescript": "5.8.3", - "sinon": "^21.0.0" + "sinon": "^20.0.0" }, "engines": { "node": ">=v18" diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/package.json.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/package.json.baseline new file mode 120000 index 00000000000..2ff8622f172 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/package.json.baseline @@ -0,0 +1 @@ +package.json \ No newline at end of file diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/protos/google/cloud/common_resources.proto.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/protos/google/cloud/common_resources.proto.baseline new file mode 100755 index 00000000000..a2f46cea3e1 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/protos/google/cloud/common_resources.proto.baseline @@ -0,0 +1,52 @@ +// Copyright 2020 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file contains stub messages for common resources in GCP. +// It is not intended to be directly generated, and is instead used by +// other tooling to be able to match common resource patterns. +syntax = "proto3"; + +package google.cloud; + +import "google/api/resource.proto"; + + +option (google.api.resource_definition) = { + type: "cloudresourcemanager.googleapis.com/Project" + pattern: "projects/{project}" +}; + + +option (google.api.resource_definition) = { + type: "cloudresourcemanager.googleapis.com/Organization" + pattern: "organizations/{organization}" +}; + + +option (google.api.resource_definition) = { + type: "cloudresourcemanager.googleapis.com/Folder" + pattern: "folders/{folder}" +}; + + +option (google.api.resource_definition) = { + type: "cloudbilling.googleapis.com/BillingAccount" + pattern: "billingAccounts/{billing_account}" +}; + +option (google.api.resource_definition) = { + type: "locations.googleapis.com/Location" + pattern: "projects/{project}/locations/{location}" +}; + diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto.baseline new file mode 100755 index 00000000000..b91e79094ff --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto.baseline @@ -0,0 +1,66 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.duplicate_methods_test.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/cloud/location/locations.proto"; + +option csharp_namespace = "Google.DuplicateMethodsTest.V1"; +option go_package = "google.golang.org/genproto/googleapis/duplicate_methods_test/v1;duplicate_methods_test"; +option java_multiple_files = true; +option java_outer_classname = "DuplicateMethodsTestProto"; +option java_package = "com.google.duplicate_methods_test.v1"; +option php_namespace = "Google\\DuplicateMethodsTest\\V1"; +option ruby_package = "Google::DuplicateMethodsTest::V1"; + +service DuplicateMethodsTestService { + option (google.api.default_host) = "duplicatemethodstest.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Native GetIamPolicy method that conflicts with the IAMPolicy mixin. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + get: "/v1/{resource=projects/*}:getIamPolicy" + }; + } + + // Native ListLocations method that conflicts with the Locations mixin. + rpc ListLocations(google.cloud.location.ListLocationsRequest) returns (google.cloud.location.ListLocationsResponse) { + option (google.api.http) = { + get: "/v1/{name=projects/*}/locations" + }; + } + + // Another native method to ensure the service is valid and has other methods. + rpc Echo(EchoRequest) returns (EchoResponse) { + option (google.api.http) = { + post: "/v1/echo" + body: "*" + }; + } +} + +message EchoRequest { + string content = 1; +} + +message EchoResponse { + string content = 1; +} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.echo.js.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.echo.js.baseline new file mode 100644 index 00000000000..3741fd8a179 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.echo.js.baseline @@ -0,0 +1,59 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START duplicatemethodstest_v1_generated_DuplicateMethodsTestService_Echo_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. + */ + /** + */ + // const content = 'abc123' + + // Imports the Duplicate_methods_test library + const {DuplicateMethodsTestServiceClient} = require('duplicate-methods-test').v1; + + // Instantiates a client + const duplicateMethodsTestClient = new DuplicateMethodsTestServiceClient(); + + async function callEcho() { + // Construct request + const request = { + }; + + // Run request + const response = await duplicateMethodsTestClient.echo(request); + console.log(response); + } + + callEcho(); + // [END duplicatemethodstest_v1_generated_DuplicateMethodsTestService_Echo_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js.baseline new file mode 100644 index 00000000000..aeee64b6143 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.get_iam_policy.js.baseline @@ -0,0 +1,67 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(resource) { + // [START duplicatemethodstest_v1_generated_DuplicateMethodsTestService_GetIamPolicy_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. + */ + /** + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + */ + // const options = {} + + // Imports the Duplicate_methods_test library + const {DuplicateMethodsTestServiceClient} = require('duplicate-methods-test').v1; + + // Instantiates a client + const duplicateMethodsTestClient = new DuplicateMethodsTestServiceClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await duplicateMethodsTestClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END duplicatemethodstest_v1_generated_DuplicateMethodsTestService_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.list_locations.js.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.list_locations.js.baseline new file mode 100644 index 00000000000..4506a9a8664 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/duplicate_methods_test_service.list_locations.js.baseline @@ -0,0 +1,74 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START duplicatemethodstest_v1_generated_DuplicateMethodsTestService_ListLocations_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. + */ + /** + * The resource that owns the locations collection, if applicable. + */ + // const name = 'abc123' + /** + * The standard list filter. + */ + // const filter = 'abc123' + /** + * The standard list page size. + */ + // const pageSize = 1234 + /** + * The standard list page token. + */ + // const pageToken = 'abc123' + + // Imports the Duplicate_methods_test library + const {DuplicateMethodsTestServiceClient} = require('duplicate-methods-test').v1; + + // Instantiates a client + const duplicateMethodsTestClient = new DuplicateMethodsTestServiceClient(); + + async function callListLocations() { + // Construct request + const request = { + }; + + // Run request + const iterable = duplicateMethodsTestClient.listLocationsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListLocations(); + // [END duplicatemethodstest_v1_generated_DuplicateMethodsTestService_ListLocations_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json.baseline new file mode 100644 index 00000000000..5e881b6e29b --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/samples/generated/v1/snippet_metadata_google.duplicate_methods_test.v1.json.baseline @@ -0,0 +1,151 @@ +{ + "clientLibrary": { + "name": "nodejs-duplicate-methods-test", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.duplicate_methods_test.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "duplicatemethodstest_v1_generated_DuplicateMethodsTestService_GetIamPolicy_async", + "title": "DuplicateMethodsTestService getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Native GetIamPolicy method that conflicts with the IAMPolicy mixin.", + "canonical": true, + "file": "duplicate_methods_test_service.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "DuplicateMethodsTestServiceClient", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestServiceClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.GetIamPolicy", + "service": { + "shortName": "DuplicateMethodsTestService", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService" + } + } + } + }, + { + "regionTag": "duplicatemethodstest_v1_generated_DuplicateMethodsTestService_ListLocations_async", + "title": "DuplicateMethodsTestService listLocations Sample", + "origin": "API_DEFINITION", + "description": " Native ListLocations method that conflicts with the Locations mixin.", + "canonical": true, + "file": "duplicate_methods_test_service.list_locations.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListLocations", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.ListLocations", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.location.ListLocationsResponse", + "client": { + "shortName": "DuplicateMethodsTestServiceClient", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestServiceClient" + }, + "method": { + "shortName": "ListLocations", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.ListLocations", + "service": { + "shortName": "DuplicateMethodsTestService", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService" + } + } + } + }, + { + "regionTag": "duplicatemethodstest_v1_generated_DuplicateMethodsTestService_Echo_async", + "title": "DuplicateMethodsTestService echo Sample", + "origin": "API_DEFINITION", + "description": " Another native method to ensure the service is valid and has other methods.", + "canonical": true, + "file": "duplicate_methods_test_service.echo.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Echo", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.Echo", + "async": true, + "parameters": [ + { + "name": "content", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.duplicate_methods_test.v1.EchoResponse", + "client": { + "shortName": "DuplicateMethodsTestServiceClient", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestServiceClient" + }, + "method": { + "shortName": "Echo", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService.Echo", + "service": { + "shortName": "DuplicateMethodsTestService", + "fullName": "google.duplicate_methods_test.v1.DuplicateMethodsTestService" + } + } + } + } + ] +} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/index.ts b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/index.ts.baseline similarity index 100% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/index.ts rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/index.ts.baseline diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client.ts b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client.ts.baseline similarity index 99% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client.ts rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client.ts.baseline index 9ae11f613b7..e033bfee059 100644 --- a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client.ts +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client.ts.baseline @@ -46,7 +46,7 @@ export class DuplicateMethodsTestServiceClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; - private _log = logging.log('duplicate_methods_test'); + private _log = logging.log('duplicate-methods-test'); auth: gax.GoogleAuth; descriptors: Descriptors = { diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client_config.json.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client_config.json.baseline new file mode 100644 index 00000000000..be7baac9386 --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client_config.json.baseline @@ -0,0 +1,38 @@ +{ + "interfaces": { + "google.duplicate_methods_test.v1.DuplicateMethodsTestService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListLocations": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Echo": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_proto_list.json.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_proto_list.json.baseline new file mode 100644 index 00000000000..d3ee7abc5db --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_proto_list.json.baseline @@ -0,0 +1,3 @@ +[ + "../../protos/google/duplicatemethodstest/v1/duplicate_methods_test_v1.proto" +] diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/index.ts b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/index.ts.baseline similarity index 100% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/index.ts rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/index.ts.baseline diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.js b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.js.baseline similarity index 92% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.js rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.js.baseline index c9c75f89903..8e82e79cd31 100644 --- a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.js +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.js.baseline @@ -18,7 +18,7 @@ /* eslint-disable node/no-missing-require, no-unused-vars */ -const duplicate-methods-test = require('@google-cloud/duplicate_methods_test'); +const duplicate-methods-test = require('duplicate-methods-test'); function main() { const duplicateMethodsTestServiceClient = new duplicate-methods-test.DuplicateMethodsTestServiceClient(); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.ts b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.ts.baseline similarity index 93% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.ts rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.ts.baseline index 4327cd683d8..b837e1bcff4 100644 --- a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.ts +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/fixtures/sample/src/index.ts.baseline @@ -16,7 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {DuplicateMethodsTestServiceClient} from '@google-cloud/duplicate_methods_test'; +import {DuplicateMethodsTestServiceClient} from 'duplicate-methods-test'; // check that the client class type name can be used function doStuffWithDuplicateMethodsTestServiceClient(client: DuplicateMethodsTestServiceClient) { diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/install.ts b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/install.ts.baseline similarity index 94% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/install.ts rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/install.ts.baseline index 394f3362d20..f66069aa394 100644 --- a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/install.ts +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/system-test/install.ts.baseline @@ -40,7 +40,7 @@ describe('📦 pack-n-play test', () => { packageDir: process.cwd(), sample: { description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + cjs: readFileSync('./system-test/fixtures/sample/src/index.js').toString() } }; await packNTest(options); diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/test/gapic_duplicate_methods_test_service_v1.ts b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/test/gapic_duplicate_methods_test_service_v1.ts.baseline similarity index 100% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/test/gapic_duplicate_methods_test_service_v1.ts rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/test/gapic_duplicate_methods_test_service_v1.ts.baseline diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/tsconfig.json b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/tsconfig.json.baseline similarity index 100% rename from core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/tsconfig.json rename to core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/tsconfig.json.baseline diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/webpack.config.js.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/webpack.config.js.baseline new file mode 100644 index 00000000000..59e373662ce --- /dev/null +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/webpack.config.js.baseline @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'DuplicateMethodsTestService', + filename: './duplicate-methods-test-service.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/core/generator/gapic-generator-typescript/baselines/kms-esm/esm/src/v1/key_management_service_client.ts.baseline b/core/generator/gapic-generator-typescript/baselines/kms-esm/esm/src/v1/key_management_service_client.ts.baseline index 205e430c9fc..285bd8d25f6 100644 --- a/core/generator/gapic-generator-typescript/baselines/kms-esm/esm/src/v1/key_management_service_client.ts.baseline +++ b/core/generator/gapic-generator-typescript/baselines/kms-esm/esm/src/v1/key_management_service_client.ts.baseline @@ -3205,7 +3205,7 @@ export class KeyManagementServiceClient { * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. * The promise has a method named "cancel" which cancels the ongoing API call. */ - getIamPolicy( + /** request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: | gax.CallOptions @@ -3252,7 +3252,7 @@ export class KeyManagementServiceClient { * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. * The promise has a method named "cancel" which cancels the ongoing API call. */ - setIamPolicy( + /** request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: | gax.CallOptions @@ -3300,7 +3300,7 @@ export class KeyManagementServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. * */ - testIamPermissions( + /** request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: | gax.CallOptions diff --git a/core/generator/gapic-generator-typescript/baselines/kms/src/v1/key_management_service_client.ts.baseline b/core/generator/gapic-generator-typescript/baselines/kms/src/v1/key_management_service_client.ts.baseline index 5ab7909bf3b..25cee48e6a4 100644 --- a/core/generator/gapic-generator-typescript/baselines/kms/src/v1/key_management_service_client.ts.baseline +++ b/core/generator/gapic-generator-typescript/baselines/kms/src/v1/key_management_service_client.ts.baseline @@ -3204,7 +3204,7 @@ export class KeyManagementServiceClient { * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. * The promise has a method named "cancel" which cancels the ongoing API call. */ - getIamPolicy( + /** request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: | gax.CallOptions @@ -3251,7 +3251,7 @@ export class KeyManagementServiceClient { * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. * The promise has a method named "cancel" which cancels the ongoing API call. */ - setIamPolicy( + /** request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: | gax.CallOptions @@ -3299,7 +3299,7 @@ export class KeyManagementServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. * */ - testIamPermissions( + /** request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: | gax.CallOptions diff --git a/core/generator/gapic-generator-typescript/baselines/pubsub-api-dump-esm/api.json.baseline b/core/generator/gapic-generator-typescript/baselines/pubsub-api-dump-esm/api.json.baseline index 6d9cb24672d..22b35ea2302 100644 --- a/core/generator/gapic-generator-typescript/baselines/pubsub-api-dump-esm/api.json.baseline +++ b/core/generator/gapic-generator-typescript/baselines/pubsub-api-dump-esm/api.json.baseline @@ -4498,6 +4498,17 @@ "grpcServiceConfig": {}, "bundleConfigs": [], "internalMethods": [], + "iamPolicyMixinFlags": { + "enabled": false, + "getIamPolicy": true, + "setIamPolicy": true, + "testIamPermissions": true + }, + "locationMixinFlags": { + "enabled": false, + "getLocation": true, + "listLocations": true + }, "bundleConfigsMethods": [], "simpleMethods": [ { @@ -5000,6 +5011,13 @@ ] } ], + "longRunningOperationsMixinFlags": { + "enabled": false, + "getOperation": true, + "cancelOperation": true, + "deleteOperation": true, + "listOperations": true + }, "hostname": "", "port": 0, "oauthScopes": [ @@ -9390,6 +9408,17 @@ "grpcServiceConfig": {}, "bundleConfigs": [], "internalMethods": [], + "iamPolicyMixinFlags": { + "enabled": false, + "getIamPolicy": true, + "setIamPolicy": true, + "testIamPermissions": true + }, + "locationMixinFlags": { + "enabled": false, + "getLocation": true, + "listLocations": true + }, "bundleConfigsMethods": [], "simpleMethods": [ { @@ -9738,6 +9767,13 @@ ] } ], + "longRunningOperationsMixinFlags": { + "enabled": false, + "getOperation": true, + "cancelOperation": true, + "deleteOperation": true, + "listOperations": true + }, "hostname": "", "port": 0, "oauthScopes": [ @@ -14926,6 +14962,17 @@ "grpcServiceConfig": {}, "bundleConfigs": [], "internalMethods": [], + "iamPolicyMixinFlags": { + "enabled": false, + "getIamPolicy": true, + "setIamPolicy": true, + "testIamPermissions": true + }, + "locationMixinFlags": { + "enabled": false, + "getLocation": true, + "listLocations": true + }, "bundleConfigsMethods": [], "simpleMethods": [ { @@ -16203,6 +16250,13 @@ ] } ], + "longRunningOperationsMixinFlags": { + "enabled": false, + "getOperation": true, + "cancelOperation": true, + "deleteOperation": true, + "listOperations": true + }, "hostname": "", "port": 0, "oauthScopes": [ diff --git a/core/generator/gapic-generator-typescript/baselines/pubsub-api-dump/api.json.baseline b/core/generator/gapic-generator-typescript/baselines/pubsub-api-dump/api.json.baseline index 6d9cb24672d..22b35ea2302 100644 --- a/core/generator/gapic-generator-typescript/baselines/pubsub-api-dump/api.json.baseline +++ b/core/generator/gapic-generator-typescript/baselines/pubsub-api-dump/api.json.baseline @@ -4498,6 +4498,17 @@ "grpcServiceConfig": {}, "bundleConfigs": [], "internalMethods": [], + "iamPolicyMixinFlags": { + "enabled": false, + "getIamPolicy": true, + "setIamPolicy": true, + "testIamPermissions": true + }, + "locationMixinFlags": { + "enabled": false, + "getLocation": true, + "listLocations": true + }, "bundleConfigsMethods": [], "simpleMethods": [ { @@ -5000,6 +5011,13 @@ ] } ], + "longRunningOperationsMixinFlags": { + "enabled": false, + "getOperation": true, + "cancelOperation": true, + "deleteOperation": true, + "listOperations": true + }, "hostname": "", "port": 0, "oauthScopes": [ @@ -9390,6 +9408,17 @@ "grpcServiceConfig": {}, "bundleConfigs": [], "internalMethods": [], + "iamPolicyMixinFlags": { + "enabled": false, + "getIamPolicy": true, + "setIamPolicy": true, + "testIamPermissions": true + }, + "locationMixinFlags": { + "enabled": false, + "getLocation": true, + "listLocations": true + }, "bundleConfigsMethods": [], "simpleMethods": [ { @@ -9738,6 +9767,13 @@ ] } ], + "longRunningOperationsMixinFlags": { + "enabled": false, + "getOperation": true, + "cancelOperation": true, + "deleteOperation": true, + "listOperations": true + }, "hostname": "", "port": 0, "oauthScopes": [ @@ -14926,6 +14962,17 @@ "grpcServiceConfig": {}, "bundleConfigs": [], "internalMethods": [], + "iamPolicyMixinFlags": { + "enabled": false, + "getIamPolicy": true, + "setIamPolicy": true, + "testIamPermissions": true + }, + "locationMixinFlags": { + "enabled": false, + "getLocation": true, + "listLocations": true + }, "bundleConfigsMethods": [], "simpleMethods": [ { @@ -16203,6 +16250,13 @@ ] } ], + "longRunningOperationsMixinFlags": { + "enabled": false, + "getOperation": true, + "cancelOperation": true, + "deleteOperation": true, + "listOperations": true + }, "hostname": "", "port": 0, "oauthScopes": [ diff --git a/core/generator/gapic-generator-typescript/baselines/redis-esm/esm/src/v1beta1/cloud_redis_client.ts.baseline b/core/generator/gapic-generator-typescript/baselines/redis-esm/esm/src/v1beta1/cloud_redis_client.ts.baseline index 3e3101f16c3..be50f53be07 100644 --- a/core/generator/gapic-generator-typescript/baselines/redis-esm/esm/src/v1beta1/cloud_redis_client.ts.baseline +++ b/core/generator/gapic-generator-typescript/baselines/redis-esm/esm/src/v1beta1/cloud_redis_client.ts.baseline @@ -1497,199 +1497,6 @@ export class CloudRedisClient { * // doThingsWith(response) * ``` */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); - return this.operationsClient.deleteOperation(request, options, callback); - } // -------------------- // -- Path templates -- diff --git a/core/generator/gapic-generator-typescript/baselines/redis/src/v1beta1/cloud_redis_client.ts.baseline b/core/generator/gapic-generator-typescript/baselines/redis/src/v1beta1/cloud_redis_client.ts.baseline index c3bc1f721e6..caa483ceb22 100644 --- a/core/generator/gapic-generator-typescript/baselines/redis/src/v1beta1/cloud_redis_client.ts.baseline +++ b/core/generator/gapic-generator-typescript/baselines/redis/src/v1beta1/cloud_redis_client.ts.baseline @@ -1478,199 +1478,6 @@ export class CloudRedisClient { * // doThingsWith(response) * ``` */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); - return this.operationsClient.deleteOperation(request, options, callback); - } // -------------------- // -- Path templates -- From 6e54286d644dcb81de0fb488f30df4a579d36e71 Mon Sep 17 00:00:00 2001 From: Shivanee Persaud Date: Thu, 23 Apr 2026 23:21:03 +0000 Subject: [PATCH 09/12] fix: restore missing method names in IAM mixin templates --- .../templates/cjs/typescript_gapic/_iam.njk | 6 +++--- .../templates/esm/typescript_gapic/_iam.njk | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_iam.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_iam.njk index 2e3d3b938f5..1aa30849f38 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_iam.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_iam.njk @@ -31,7 +31,7 @@ * The promise has a method named "cancel" which cancels the ongoing API call. */ {%- if service.iamPolicyMixinFlags.getIamPolicy == true %} - /** + getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: | gax.CallOptions @@ -80,7 +80,7 @@ * The promise has a method named "cancel" which cancels the ongoing API call. */ {%- if service.iamPolicyMixinFlags.setIamPolicy %} - /** + setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: | gax.CallOptions @@ -130,7 +130,7 @@ * */ {%- if service.iamPolicyMixinFlags.testIamPermissions %} - /** + testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: | gax.CallOptions diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_iam.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_iam.njk index a756f6d798d..d36b03e71ae 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_iam.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_iam.njk @@ -31,7 +31,7 @@ * The promise has a method named "cancel" which cancels the ongoing API call. */ {%- if service.iamPolicyMixinFlags.getIamPolicy %} - /** + getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: | gax.CallOptions @@ -80,7 +80,7 @@ * The promise has a method named "cancel" which cancels the ongoing API call. */ {%- if service.iamPolicyMixinFlags.setIamPolicy %} - /** + setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: | gax.CallOptions @@ -112,7 +112,7 @@ * The request object that will be sent. * @param {string} request.resource * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. + * See the operation documentation for the a ppropriate value for this field. * @param {string[]} request.permissions * The set of permissions to check for the `resource`. Permissions with * wildcards (such as '*' or 'storage.*') are not allowed. For more @@ -130,7 +130,7 @@ * */ {%- if service.iamPolicyMixinFlags.testIamPermissions %} - /** + testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: | gax.CallOptions From a11f0d71690bf75f1fb68c591cd5ea195295a947 Mon Sep 17 00:00:00 2001 From: Shivanee Persaud Date: Thu, 23 Apr 2026 23:25:20 +0000 Subject: [PATCH 10/12] test: update baselines for IAM methods restore --- .../v1/duplicate_methods_test_service_client.ts.baseline | 6 +++--- .../v1/duplicate_methods_test_service_client.ts.baseline | 4 ++-- .../esm/src/v1/key_management_service_client.ts.baseline | 8 ++++---- .../kms/src/v1/key_management_service_client.ts.baseline | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client.ts.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client.ts.baseline index 1e4d8ed7abc..e1aa466192c 100644 --- a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client.ts.baseline +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test-esm/esm/src/v1/duplicate_methods_test_service_client.ts.baseline @@ -788,7 +788,7 @@ export class DuplicateMethodsTestServiceClient { * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. * The promise has a method named "cancel" which cancels the ongoing API call. */ - /** + setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: | gax.CallOptions @@ -819,7 +819,7 @@ export class DuplicateMethodsTestServiceClient { * The request object that will be sent. * @param {string} request.resource * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. + * See the operation documentation for the a ppropriate value for this field. * @param {string[]} request.permissions * The set of permissions to check for the `resource`. Permissions with * wildcards (such as '*' or 'storage.*') are not allowed. For more @@ -836,7 +836,7 @@ export class DuplicateMethodsTestServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. * */ - /** + testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: | gax.CallOptions diff --git a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client.ts.baseline b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client.ts.baseline index e033bfee059..d50cf3be6a4 100644 --- a/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client.ts.baseline +++ b/core/generator/gapic-generator-typescript/baselines/duplicate_methods_test/src/v1/duplicate_methods_test_service_client.ts.baseline @@ -770,7 +770,7 @@ export class DuplicateMethodsTestServiceClient { * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. * The promise has a method named "cancel" which cancels the ongoing API call. */ - /** + setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: | gax.CallOptions @@ -818,7 +818,7 @@ export class DuplicateMethodsTestServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. * */ - /** + testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: | gax.CallOptions diff --git a/core/generator/gapic-generator-typescript/baselines/kms-esm/esm/src/v1/key_management_service_client.ts.baseline b/core/generator/gapic-generator-typescript/baselines/kms-esm/esm/src/v1/key_management_service_client.ts.baseline index 285bd8d25f6..e42e4f66fd6 100644 --- a/core/generator/gapic-generator-typescript/baselines/kms-esm/esm/src/v1/key_management_service_client.ts.baseline +++ b/core/generator/gapic-generator-typescript/baselines/kms-esm/esm/src/v1/key_management_service_client.ts.baseline @@ -3205,7 +3205,7 @@ export class KeyManagementServiceClient { * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. * The promise has a method named "cancel" which cancels the ongoing API call. */ - /** + getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: | gax.CallOptions @@ -3252,7 +3252,7 @@ export class KeyManagementServiceClient { * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. * The promise has a method named "cancel" which cancels the ongoing API call. */ - /** + setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: | gax.CallOptions @@ -3283,7 +3283,7 @@ export class KeyManagementServiceClient { * The request object that will be sent. * @param {string} request.resource * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. + * See the operation documentation for the a ppropriate value for this field. * @param {string[]} request.permissions * The set of permissions to check for the `resource`. Permissions with * wildcards (such as '*' or 'storage.*') are not allowed. For more @@ -3300,7 +3300,7 @@ export class KeyManagementServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. * */ - /** + testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: | gax.CallOptions diff --git a/core/generator/gapic-generator-typescript/baselines/kms/src/v1/key_management_service_client.ts.baseline b/core/generator/gapic-generator-typescript/baselines/kms/src/v1/key_management_service_client.ts.baseline index 25cee48e6a4..5ab7909bf3b 100644 --- a/core/generator/gapic-generator-typescript/baselines/kms/src/v1/key_management_service_client.ts.baseline +++ b/core/generator/gapic-generator-typescript/baselines/kms/src/v1/key_management_service_client.ts.baseline @@ -3204,7 +3204,7 @@ export class KeyManagementServiceClient { * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. * The promise has a method named "cancel" which cancels the ongoing API call. */ - /** + getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: | gax.CallOptions @@ -3251,7 +3251,7 @@ export class KeyManagementServiceClient { * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. * The promise has a method named "cancel" which cancels the ongoing API call. */ - /** + setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: | gax.CallOptions @@ -3299,7 +3299,7 @@ export class KeyManagementServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. * */ - /** + testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: | gax.CallOptions From b1cc7fdcd108539e7ad2b14521e3cc222903065d Mon Sep 17 00:00:00 2001 From: Shivanee Persaud Date: Fri, 24 Apr 2026 15:53:49 +0000 Subject: [PATCH 11/12] fix: pass service parameter to operations mixin macro to fix method generation --- .../templates/cjs/typescript_gapic/_operations.njk | 2 +- .../cjs/typescript_gapic/src/$version/$service_client.ts.njk | 2 +- .../templates/esm/typescript_gapic/_operations.njk | 2 +- .../typescript_gapic/esm/src/$version/$service_client.ts.njk | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_operations.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_operations.njk index 908fa0e4cbc..a62dac2bf3a 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_operations.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/_operations.njk @@ -1,4 +1,4 @@ -{%- macro operationsServiceMethods() -%} +{%- macro operationsServiceMethods(service) -%} {#- This part will be added into src/version/client.ts. If the --service-yaml contains "google.longrunning.Operations", it means the client requires Operations methods [getOperation, listOperationsAsync, cancelOperation, deleteOperation]. diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk index e4a61222783..90553e89770 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/src/$version/$service_client.ts.njk @@ -1109,7 +1109,7 @@ export class {{ service.name }}Client { {{ location.locationServiceMethods(service)}} {% endif -%} {%- if service.LongRunningOperationsMixin > 0 %} -{{ operations.operationsServiceMethods()}} +{{ operations.operationsServiceMethods(service)}} {% endif -%} {%- if service.pathTemplates.length > 0 %} // -------------------- diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_operations.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_operations.njk index 908fa0e4cbc..a62dac2bf3a 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_operations.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/_operations.njk @@ -1,4 +1,4 @@ -{%- macro operationsServiceMethods() -%} +{%- macro operationsServiceMethods(service) -%} {#- This part will be added into src/version/client.ts. If the --service-yaml contains "google.longrunning.Operations", it means the client requires Operations methods [getOperation, listOperationsAsync, cancelOperation, deleteOperation]. diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk index ce28ddabb44..e505db0eef1 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/esm/src/$version/$service_client.ts.njk @@ -1116,7 +1116,7 @@ export class {{ service.name }}Client { {{ location.locationServiceMethods(service)}} {% endif -%} {%- if service.LongRunningOperationsMixin > 0 %} -{{ operations.operationsServiceMethods()}} +{{ operations.operationsServiceMethods(service)}} {% endif -%} {%- if service.pathTemplates.length > 0 %} // -------------------- From d643c9626b60def9f3710de9909f29f27e2c3168 Mon Sep 17 00:00:00 2001 From: Shivanee Persaud Date: Fri, 24 Apr 2026 15:59:54 +0000 Subject: [PATCH 12/12] test: update baselines for redis client --- .../v1beta1/cloud_redis_client.ts.baseline | 192 ++++++++++++++++++ .../v1beta1/cloud_redis_client.ts.baseline | 192 ++++++++++++++++++ 2 files changed, 384 insertions(+) diff --git a/core/generator/gapic-generator-typescript/baselines/redis-esm/esm/src/v1beta1/cloud_redis_client.ts.baseline b/core/generator/gapic-generator-typescript/baselines/redis-esm/esm/src/v1beta1/cloud_redis_client.ts.baseline index be50f53be07..2a96fdfee5a 100644 --- a/core/generator/gapic-generator-typescript/baselines/redis-esm/esm/src/v1beta1/cloud_redis_client.ts.baseline +++ b/core/generator/gapic-generator-typescript/baselines/redis-esm/esm/src/v1beta1/cloud_redis_client.ts.baseline @@ -1497,6 +1497,198 @@ export class CloudRedisClient { * // doThingsWith(response) * ``` */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + return this.operationsClient.cancelOperation(request, options, callback); + } + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + return this.operationsClient.deleteOperation(request, options, callback); + } // -------------------- // -- Path templates -- diff --git a/core/generator/gapic-generator-typescript/baselines/redis/src/v1beta1/cloud_redis_client.ts.baseline b/core/generator/gapic-generator-typescript/baselines/redis/src/v1beta1/cloud_redis_client.ts.baseline index caa483ceb22..5aa29671579 100644 --- a/core/generator/gapic-generator-typescript/baselines/redis/src/v1beta1/cloud_redis_client.ts.baseline +++ b/core/generator/gapic-generator-typescript/baselines/redis/src/v1beta1/cloud_redis_client.ts.baseline @@ -1478,6 +1478,198 @@ export class CloudRedisClient { * // doThingsWith(response) * ``` */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + return this.operationsClient.cancelOperation(request, options, callback); + } + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + return this.operationsClient.deleteOperation(request, options, callback); + } // -------------------- // -- Path templates --