Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3179,7 +3179,7 @@ export class KeyManagementServiceClient {
callSettings
) as AsyncIterable<protos.google.cloud.kms.v1.IImportJob>;
}
/**
/**
* 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 @@ -3221,8 +3221,7 @@ export class KeyManagementServiceClient {
):Promise<[IamProtos.google.iam.v1.Policy]> {
return this.iamClient.getIamPolicy(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.
Expand Down Expand Up @@ -3268,8 +3267,7 @@ export class KeyManagementServiceClient {
):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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// ** 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';
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 @@ -27,11 +27,15 @@ 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 -%}
Expand Down Expand Up @@ -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 %}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1103,10 +1107,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 Expand Up @@ -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 %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ 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 -%}
{%- set enableIamTest = false %}
{%- if service.IAMPolicyMixin > 0 %}
{%- if ('|getIamPolicy|' not in methodNamesStr) or ('|setIamPolicy|' not in methodNamesStr) or ('|testIamPermissions|' not in methodNamesStr) %}
{%- set enableIamTest = true %}
{%- endif %}
{%- endif %}

{%- set enableLocationTest = false %}
{%- if service.LocationMixin > 0 %}
{%- if ('|getLocation|' not in methodNamesStr) or ('|listLocations|' not in methodNamesStr) %}
{%- set enableLocationTest = true %}
{%- endif %}
{%- endif %}

import * as protos from '../protos/protos';
import * as assert from 'assert';
import * as sinon from 'sinon';
Expand All @@ -44,8 +62,8 @@ import {protobuf
{%- if service.longRunning.length > 0 or service.LongRunningOperationsMixin > 0 -%}
, operationsProtos
{%- endif -%}
{%- if service.IAMPolicyMixin > 0 %}, IamProtos{%- endif -%}
{%- if service.LocationMixin > 0 %}, LocationProtos{%- endif -%}
{%- if enableIamTest %}, IamProtos{%- endif -%}
{%- if enableLocationTest %}, LocationProtos{%- endif -%}
} from 'google-gax';
{%- if not api.legacyProtoLoad %}

Expand Down Expand Up @@ -1089,6 +1107,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 +1223,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 +1335,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 +1418,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 @@ -26,6 +26,12 @@ 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 -%}
Expand Down Expand Up @@ -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 %}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -448,7 +454,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 +1115,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 Expand Up @@ -1172,10 +1190,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 %}
Expand Down
Loading
Loading