Skip to content

Commit

Permalink
fix: pass x-goog-request-params to streaming methods (#234)
Browse files Browse the repository at this point in the history
* fix: pass x-goog-request-params to streaming methods
  • Loading branch information
alexander-fenster authored Feb 6, 2020
1 parent 1c09160 commit 456fed0
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 31 deletions.
20 changes: 11 additions & 9 deletions templates/typescript_gapic/src/$version/$service_client.ts.njk
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export class {{ service.name }}Client {
{{ method.name.toCamelCase() }}(
options?: gax.CallOptions):
gax.CancellableStream{
options = options || {};
{{ util.buildHeaderRequestParam(method) }}
return this._innerApiCalls.{{ method.name.toCamelCase() }}(options);
}
{%- elif method.serverStreaming %}
Expand All @@ -396,26 +396,26 @@ export class {{ service.name }}Client {
options?: gax.CallOptions):
gax.CancellableStream{
request = request || {};
options = options || {};
{{ util.buildHeaderRequestParam(method) }}
return this._innerApiCalls.{{ method.name.toCamelCase() }}(request, options);
}
{%- elif method.clientStreaming %}
{{ method.name.toCamelCase() }}(
options: gax.CallOptions,
callback: Callback<
options?: gax.CallOptions,
callback?: Callback<
{{ util.toInterface(method.outputInterface) }},
{{ util.toInterface(method.inputInterface) }}|undefined, {}|undefined>):
gax.CancellableStream;
{{ method.name.toCamelCase() }}(
callback: Callback<
callback?: Callback<
{{ util.toInterface(method.outputInterface) }},
{{ util.toInterface(method.inputInterface) }}|undefined, {}|undefined>):
gax.CancellableStream;
/**
{{- util.printComments(method, service) }}
*/
{{ method.name.toCamelCase() }}(
optionsOrCallback: gax.CallOptions|Callback<
optionsOrCallback?: gax.CallOptions|Callback<
{{ util.toInterface(method.outputInterface) }},
{{ util.toInterface(method.inputInterface) }}|undefined, {}|undefined>,
callback?: Callback<
Expand All @@ -426,8 +426,9 @@ export class {{ service.name }}Client {
callback = optionsOrCallback;
optionsOrCallback = {};
}
optionsOrCallback = optionsOrCallback || {};
return this._innerApiCalls.{{ method.name.toCamelCase() }}(null, optionsOrCallback, callback);
let options = optionsOrCallback as gax.CallOptions;
{{ util.buildHeaderRequestParam(method) }}
return this._innerApiCalls.{{ method.name.toCamelCase() }}(null, options, callback);
}
{%- endif %}
{% endfor %}
Expand Down Expand Up @@ -527,9 +528,10 @@ export class {{ service.name }}Client {
*/
{{ method.name.toCamelCase() }}Stream(
request?: {{ util.toInterface(method.inputInterface) }},
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
{{ util.buildHeaderRequestParam(method) }}
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.{{ method.name.toCamelCase() }}.createStream(
this._innerApiCalls.{{ method.name.toCamelCase() }} as gax.GaxCall,
Expand Down
50 changes: 45 additions & 5 deletions typescript/test/testdata/dlp/src/v2/dlp_service_client.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -2225,9 +2225,17 @@ export class DlpServiceClient {
*/
listInspectTemplatesStream(
request?: protosTypes.google.privacy.dlp.v2.IListInspectTemplatesRequest,
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
'parent': request.parent || '',
});
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.listInspectTemplates.createStream(
this._innerApiCalls.listInspectTemplates as gax.GaxCall,
Expand Down Expand Up @@ -2384,9 +2392,17 @@ export class DlpServiceClient {
*/
listDeidentifyTemplatesStream(
request?: protosTypes.google.privacy.dlp.v2.IListDeidentifyTemplatesRequest,
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
'parent': request.parent || '',
});
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.listDeidentifyTemplates.createStream(
this._innerApiCalls.listDeidentifyTemplates as gax.GaxCall,
Expand Down Expand Up @@ -2594,9 +2610,17 @@ export class DlpServiceClient {
*/
listJobTriggersStream(
request?: protosTypes.google.privacy.dlp.v2.IListJobTriggersRequest,
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
'parent': request.parent || '',
});
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.listJobTriggers.createStream(
this._innerApiCalls.listJobTriggers as gax.GaxCall,
Expand Down Expand Up @@ -2809,9 +2833,17 @@ export class DlpServiceClient {
*/
listDlpJobsStream(
request?: protosTypes.google.privacy.dlp.v2.IListDlpJobsRequest,
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
'parent': request.parent || '',
});
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.listDlpJobs.createStream(
this._innerApiCalls.listDlpJobs as gax.GaxCall,
Expand Down Expand Up @@ -2970,9 +3002,17 @@ export class DlpServiceClient {
*/
listStoredInfoTypesStream(
request?: protosTypes.google.privacy.dlp.v2.IListStoredInfoTypesRequest,
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
'parent': request.parent || '',
});
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.listStoredInfoTypes.createStream(
this._innerApiCalls.listStoredInfoTypes as gax.GaxCall,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1655,9 +1655,17 @@ export class KeyManagementServiceClient {
*/
listKeyRingsStream(
request?: protosTypes.google.cloud.kms.v1.IListKeyRingsRequest,
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
'parent': request.parent || '',
});
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.listKeyRings.createStream(
this._innerApiCalls.listKeyRings as gax.GaxCall,
Expand Down Expand Up @@ -1796,9 +1804,17 @@ export class KeyManagementServiceClient {
*/
listCryptoKeysStream(
request?: protosTypes.google.cloud.kms.v1.IListCryptoKeysRequest,
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
'parent': request.parent || '',
});
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.listCryptoKeys.createStream(
this._innerApiCalls.listCryptoKeys as gax.GaxCall,
Expand Down Expand Up @@ -1939,9 +1955,17 @@ export class KeyManagementServiceClient {
*/
listCryptoKeyVersionsStream(
request?: protosTypes.google.cloud.kms.v1.IListCryptoKeyVersionsRequest,
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
'parent': request.parent || '',
});
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.listCryptoKeyVersions.createStream(
this._innerApiCalls.listCryptoKeyVersions as gax.GaxCall,
Expand Down Expand Up @@ -2076,9 +2100,17 @@ export class KeyManagementServiceClient {
*/
listImportJobsStream(
request?: protosTypes.google.cloud.kms.v1.IListImportJobsRequest,
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
'parent': request.parent || '',
});
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.listImportJobs.createStream(
this._innerApiCalls.listImportJobs as gax.GaxCall,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -932,9 +932,17 @@ export class ServiceMonitoringServiceClient {
*/
listServicesStream(
request?: protosTypes.google.monitoring.v3.IListServicesRequest,
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
'parent': request.parent || '',
});
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.listServices.createStream(
this._innerApiCalls.listServices as gax.GaxCall,
Expand Down Expand Up @@ -1071,9 +1079,17 @@ export class ServiceMonitoringServiceClient {
*/
listServiceLevelObjectivesStream(
request?: protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest,
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
'parent': request.parent || '',
});
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.listServiceLevelObjectives.createStream(
this._innerApiCalls.listServiceLevelObjectives as gax.GaxCall,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,17 @@ export class UptimeCheckServiceClient {
*/
listUptimeCheckConfigsStream(
request?: protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest,
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
'parent': request.parent || '',
});
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.listUptimeCheckConfigs.createStream(
this._innerApiCalls.listUptimeCheckConfigs as gax.GaxCall,
Expand Down Expand Up @@ -786,9 +794,10 @@ export class UptimeCheckServiceClient {
*/
listUptimeCheckIpsStream(
request?: protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest,
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
options = options || {};
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.listUptimeCheckIps.createStream(
this._innerApiCalls.listUptimeCheckIps as gax.GaxCall,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -945,9 +945,17 @@ export class CloudRedisClient {
*/
listInstancesStream(
request?: protosTypes.google.cloud.redis.v1beta1.IListInstancesRequest,
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
'parent': request.parent || '',
});
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.listInstances.createStream(
this._innerApiCalls.listInstances as gax.GaxCall,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,13 @@ export class EchoClient {
}

collect(
options: gax.CallOptions,
callback: Callback<
options?: gax.CallOptions,
callback?: Callback<
protosTypes.google.showcase.v1beta1.IEchoResponse,
protosTypes.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>):
gax.CancellableStream;
collect(
callback: Callback<
callback?: Callback<
protosTypes.google.showcase.v1beta1.IEchoResponse,
protosTypes.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>):
gax.CancellableStream;
Expand All @@ -371,7 +371,7 @@ export class EchoClient {
* [EchoRequest]{@link google.showcase.v1beta1.EchoRequest}.
*/
collect(
optionsOrCallback: gax.CallOptions|Callback<
optionsOrCallback?: gax.CallOptions|Callback<
protosTypes.google.showcase.v1beta1.IEchoResponse,
protosTypes.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>,
callback?: Callback<
Expand All @@ -382,8 +382,9 @@ export class EchoClient {
callback = optionsOrCallback;
optionsOrCallback = {};
}
optionsOrCallback = optionsOrCallback || {};
return this._innerApiCalls.collect(null, optionsOrCallback, callback);
let options = optionsOrCallback as gax.CallOptions;
options = options || {};
return this._innerApiCalls.collect(null, options, callback);
}

/**
Expand Down Expand Up @@ -566,9 +567,10 @@ export class EchoClient {
*/
pagedExpandStream(
request?: protosTypes.google.showcase.v1beta1.IPagedExpandRequest,
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
options = options || {};
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.pagedExpand.createStream(
this._innerApiCalls.pagedExpand as gax.GaxCall,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1018,9 +1018,17 @@ export class TranslationServiceClient {
*/
listGlossariesStream(
request?: protosTypes.google.cloud.translation.v3beta1.IListGlossariesRequest,
options?: gax.CallOptions | {}):
options?: gax.CallOptions):
Transform{
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
'parent': request.parent || '',
});
const callSettings = new gax.CallSettings(options);
return this._descriptors.page.listGlossaries.createStream(
this._innerApiCalls.listGlossaries as gax.GaxCall,
Expand Down

0 comments on commit 456fed0

Please sign in to comment.