Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -45,7 +50,9 @@
): Promise<LocationProtos.google.cloud.location.ILocation> {
return this.locationsClient.getLocation(request, options, callback);
}
{%- endmacro -%}

{%- macro listLocationsAsync() -%}
/**
* Lists information about the supported locations for this service. Returns an iterable object.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ 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 -%}
import {% if (not api.legacyProtoLoad) and (autoPopulated === false) %}type {% endif %}* as gax from 'google-gax';
import type {Callback, CallOptions, Descriptors, ClientOptions
Expand Down Expand Up @@ -1103,10 +1105,23 @@ export class {{ service.name }}Client {
{%- endif %}
{%- endfor %}
{%- if service.IAMPolicyMixin > 0 %}
{{ iam.iamServiceMethods()}}
{%- 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 '|getLocation|' not in methodNamesStr %}
{{ location.getLocation() }}
{%- endif %}
{%- if '|listLocations|' not in methodNamesStr %}
{{ location.listLocationsAsync() }}
{%- endif %}
{% endif -%}
{%- if service.LongRunningOperationsMixin > 0 %}
{{ operations.operationsServiceMethods()}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 ("|" + 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(
Expand Down Expand Up @@ -1314,7 +1321,9 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
.getCall(0).calledWith(request, expectedOptions, undefined));
});
});
{%- endif %}
{%- set method = 'listLocations' %}
{%- if ("|" + method + "|") not in methodNamesStr %}
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) -}});
Expand Down Expand Up @@ -1395,6 +1404,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
);
});
});
{%- endif %}
{%- endif %}
{%- if (service.LongRunningOperationsMixin) > 0 %}
{%- set Operationsmethods = ['getOperation', 'cancelOperation', 'deleteOperation'] %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -45,7 +50,9 @@
): Promise<LocationProtos.google.cloud.location.ILocation> {
return this.locationsClient.getLocation(request, options, callback);
}
{%- endmacro -%}

{%- macro listLocationsAsync() -%}
/**
* Lists information about the supported locations for this service. Returns an iterable object.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ import {loggingUtils as logging} from 'google-gax';
const version = getJSON(
path.join(dirname, '..', '..', '..', '..', 'package.json')
).version;
{%- set methodNamesStr = "|" %}
{%- for method in service.method -%}
{%- set methodNamesStr = methodNamesStr + method.name.toCamelCase() + "|" -%}
{%- endfor -%}

/**
{{- util.printCommentsForService(service) }}
Expand Down Expand Up @@ -448,7 +452,6 @@ export class {{ service.name }}Client {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(this._protos as any).{{api.naming.protoPackage}}.{{ service.name }},
this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>;

{%- set stubMethodsContent %}
{%- set stubMethodsJoiner = joiner(', ') -%}
{%- for method in service.method -%}
Expand Down Expand Up @@ -1110,10 +1113,23 @@ export class {{ service.name }}Client {
{%- endif %}
{%- endfor %}
{%- if service.IAMPolicyMixin > 0 %}
{{ iam.iamServiceMethods()}}
{%- 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 '|getLocation|' not in methodNamesStr %}
{{ location.getLocation() }}
{%- endif %}
{%- if '|listLocations|' not in methodNamesStr %}
{{ location.listLocationsAsync() }}
{%- endif %}
{% endif -%}
{%- if service.LongRunningOperationsMixin > 0 %}
{{ operations.operationsServiceMethods()}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 ("|" + 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(
Expand Down Expand Up @@ -1320,7 +1327,9 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
.getCall(0).calledWith(request, expectedOptions, undefined));
});
});
{%- endif %}
{%- set method = 'listLocations' %}
{%- if ("|" + method + "|") not in methodNamesStr %}
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) -}});
Expand Down Expand Up @@ -1401,6 +1410,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
);
});
});
{%- endif %}
{%- endif %}
{%- if (service.LongRunningOperationsMixin) > 0 %}
{%- set Operationsmethods = ['getOperation', 'cancelOperation', 'deleteOperation'] %}
Expand Down
Loading