Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support request params {key} with no =value #436

Merged
merged 3 commits into from
Apr 22, 2020
Merged
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
7 changes: 7 additions & 0 deletions baselines/dlp/src/v2/dlp_service_client.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,13 @@ export class DlpServiceClient {
options = optionsOrCallback as gax.CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
'location_id': request.locationId || '',
});
this.initialize();
return this.innerApiCalls.listInfoTypes(request, options, callback);
}
Expand Down
30 changes: 27 additions & 3 deletions baselines/dlp/test/gapic_dlp_service_v2.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,15 @@ describe('v2.DlpServiceClient', () => {
});
client.initialize();
const request = generateSampleMessage(new protos.google.privacy.dlp.v2.ListInfoTypesRequest());
const expectedOptions = {};
request.locationId = '';
const expectedHeaderRequestParams = "location_id=";
const expectedOptions = {
otherArgs: {
headers: {
'x-goog-request-params': expectedHeaderRequestParams,
},
},
};
const expectedResponse = generateSampleMessage(new protos.google.privacy.dlp.v2.ListInfoTypesResponse());
client.innerApiCalls.listInfoTypes = stubSimpleCall(expectedResponse);
const [response] = await client.listInfoTypes(request);
Expand All @@ -525,7 +533,15 @@ describe('v2.DlpServiceClient', () => {
});
client.initialize();
const request = generateSampleMessage(new protos.google.privacy.dlp.v2.ListInfoTypesRequest());
const expectedOptions = {};
request.locationId = '';
const expectedHeaderRequestParams = "location_id=";
const expectedOptions = {
otherArgs: {
headers: {
'x-goog-request-params': expectedHeaderRequestParams,
},
},
};
const expectedResponse = generateSampleMessage(new protos.google.privacy.dlp.v2.ListInfoTypesResponse());
client.innerApiCalls.listInfoTypes = stubSimpleCallWithCallback(expectedResponse);
const promise = new Promise((resolve, reject) => {
Expand All @@ -552,7 +568,15 @@ describe('v2.DlpServiceClient', () => {
});
client.initialize();
const request = generateSampleMessage(new protos.google.privacy.dlp.v2.ListInfoTypesRequest());
const expectedOptions = {};
request.locationId = '';
const expectedHeaderRequestParams = "location_id=";
const expectedOptions = {
otherArgs: {
headers: {
'x-goog-request-params': expectedHeaderRequestParams,
},
},
};
const expectedError = new Error('expected');
client.innerApiCalls.listInfoTypes = stubSimpleCall(undefined, expectedError);
await assert.rejects(async () => { await client.listInfoTypes(request); }, expectedError);
Expand Down
2 changes: 1 addition & 1 deletion typescript/src/schema/proto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export function getSingleHeaderParam(
const message =
rule.post || rule.delete || rule.get || rule.put || rule.patch;
if (message) {
const res = message.match(/{(.*?)=/);
const res = message.match(/{(.*?)[=}]/);
return res?.[1] ? res[1].split('.') : [];
}
return [];
Expand Down