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: pass x-goog-request-params header for streaming calls #920

Merged
merged 2 commits into from
Feb 7, 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
14 changes: 14 additions & 0 deletions dev/.gitignore
Original file line number Diff line number Diff line change
@@ -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__
5 changes: 5 additions & 0 deletions dev/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"enable-source-maps": true,
"throw-deprecation": true,
"timeout": 10000
}
2,488 changes: 1,244 additions & 1,244 deletions dev/protos/protos.json

Large diffs are not rendered by default.

146 changes: 81 additions & 65 deletions dev/src/v1/firestore_admin_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ export class FirestoreAdminClient {
collectionGroupPathTemplate: new gaxModule.PathTemplate(
'projects/{project}/databases/{database}/collectionGroups/{collection}'
),
indexPathTemplate: new gaxModule.PathTemplate(
'projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}'
databasePathTemplate: new gaxModule.PathTemplate(
'projects/{project}/databases/{database}'
),
fieldPathTemplate: new gaxModule.PathTemplate(
'projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}'
),
databasePathTemplate: new gaxModule.PathTemplate(
'projects/{project}/databases/{database}'
indexPathTemplate: new gaxModule.PathTemplate(
'projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}'
),
};

Expand Down Expand Up @@ -764,7 +764,7 @@ export class FirestoreAdminClient {
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
field_name: request.field!.name || '',
'field.name': request.field!.name || '',
});
return this._innerApiCalls.updateField(request, options, callback);
}
Expand Down Expand Up @@ -1099,9 +1099,17 @@ export class FirestoreAdminClient {
*/
listIndexesStream(
request?: protosTypes.google.firestore.admin.v1.IListIndexesRequest,
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.listIndexes.createStream(
this._innerApiCalls.listIndexes as gax.GaxCall,
Expand Down Expand Up @@ -1248,9 +1256,17 @@ export class FirestoreAdminClient {
*/
listFieldsStream(
request?: protosTypes.google.firestore.admin.v1.IListFieldsRequest,
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.listFields.createStream(
this._innerApiCalls.listFields as gax.GaxCall,
Expand Down Expand Up @@ -1318,70 +1334,40 @@ export class FirestoreAdminClient {
}

/**
* Return a fully-qualified index resource name string.
* Return a fully-qualified database resource name string.
*
* @param {string} project
* @param {string} database
* @param {string} collection
* @param {string} index
* @returns {string} Resource name string.
*/
indexPath(
project: string,
database: string,
collection: string,
index: string
) {
return this._pathTemplates.indexPathTemplate.render({
databasePath(project: string, database: string) {
return this._pathTemplates.databasePathTemplate.render({
project,
database,
collection,
index,
});
}

/**
* Parse the project from Index resource.
* Parse the project from Database resource.
*
* @param {string} indexName
* A fully-qualified path representing Index resource.
* @param {string} databaseName
* A fully-qualified path representing Database resource.
* @returns {string} A string representing the project.
*/
matchProjectFromIndexName(indexName: string) {
return this._pathTemplates.indexPathTemplate.match(indexName).project;
matchProjectFromDatabaseName(databaseName: string) {
return this._pathTemplates.databasePathTemplate.match(databaseName).project;
}

/**
* Parse the database from Index resource.
* Parse the database from Database resource.
*
* @param {string} indexName
* A fully-qualified path representing Index resource.
* @param {string} databaseName
* A fully-qualified path representing Database resource.
* @returns {string} A string representing the database.
*/
matchDatabaseFromIndexName(indexName: string) {
return this._pathTemplates.indexPathTemplate.match(indexName).database;
}

/**
* Parse the collection from Index resource.
*
* @param {string} indexName
* A fully-qualified path representing Index resource.
* @returns {string} A string representing the collection.
*/
matchCollectionFromIndexName(indexName: string) {
return this._pathTemplates.indexPathTemplate.match(indexName).collection;
}

/**
* Parse the index from Index resource.
*
* @param {string} indexName
* A fully-qualified path representing Index resource.
* @returns {string} A string representing the index.
*/
matchIndexFromIndexName(indexName: string) {
return this._pathTemplates.indexPathTemplate.match(indexName).index;
matchDatabaseFromDatabaseName(databaseName: string) {
return this._pathTemplates.databasePathTemplate.match(databaseName)
.database;
}

/**
Expand Down Expand Up @@ -1452,40 +1438,70 @@ export class FirestoreAdminClient {
}

/**
* Return a fully-qualified database resource name string.
* Return a fully-qualified index resource name string.
*
* @param {string} project
* @param {string} database
* @param {string} collection
* @param {string} index
* @returns {string} Resource name string.
*/
databasePath(project: string, database: string) {
return this._pathTemplates.databasePathTemplate.render({
indexPath(
project: string,
database: string,
collection: string,
index: string
) {
return this._pathTemplates.indexPathTemplate.render({
project,
database,
collection,
index,
});
}

/**
* Parse the project from Database resource.
* Parse the project from Index resource.
*
* @param {string} databaseName
* A fully-qualified path representing Database resource.
* @param {string} indexName
* A fully-qualified path representing Index resource.
* @returns {string} A string representing the project.
*/
matchProjectFromDatabaseName(databaseName: string) {
return this._pathTemplates.databasePathTemplate.match(databaseName).project;
matchProjectFromIndexName(indexName: string) {
return this._pathTemplates.indexPathTemplate.match(indexName).project;
}

/**
* Parse the database from Database resource.
* Parse the database from Index resource.
*
* @param {string} databaseName
* A fully-qualified path representing Database resource.
* @param {string} indexName
* A fully-qualified path representing Index resource.
* @returns {string} A string representing the database.
*/
matchDatabaseFromDatabaseName(databaseName: string) {
return this._pathTemplates.databasePathTemplate.match(databaseName)
.database;
matchDatabaseFromIndexName(indexName: string) {
return this._pathTemplates.indexPathTemplate.match(indexName).database;
}

/**
* Parse the collection from Index resource.
*
* @param {string} indexName
* A fully-qualified path representing Index resource.
* @returns {string} A string representing the collection.
*/
matchCollectionFromIndexName(indexName: string) {
return this._pathTemplates.indexPathTemplate.match(indexName).collection;
}

/**
* Parse the index from Index resource.
*
* @param {string} indexName
* A fully-qualified path representing Index resource.
* @returns {string} A string representing the index.
*/
matchIndexFromIndexName(indexName: string) {
return this._pathTemplates.indexPathTemplate.match(indexName).index;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion dev/src/v1/firestore_admin_proto_list.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
"../../protos/google/firestore/admin/v1/index.proto",
"../../protos/google/firestore/admin/v1/field.proto",
"../../protos/google/firestore/admin/v1/firestore_admin.proto",
"../../protos/google/firestore/admin/v1/index.proto",
"../../protos/google/firestore/admin/v1/location.proto",
"../../protos/google/firestore/admin/v1/operation.proto"
]
36 changes: 32 additions & 4 deletions dev/src/v1/firestore_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,13 @@ export class FirestoreClient {
): gax.CancellableStream {
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
database: request.database || '',
});
return this._innerApiCalls.batchGetDocuments(request, options);
}

Expand Down Expand Up @@ -937,6 +944,13 @@ export class FirestoreClient {
): gax.CancellableStream {
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 || '',
});
return this._innerApiCalls.runQuery(request, options);
}

Expand All @@ -951,7 +965,6 @@ export class FirestoreClient {
* will emit objects representing [WriteResponse]{@link google.firestore.v1.WriteResponse} on 'data' event asynchronously.
*/
write(options?: gax.CallOptions): gax.CancellableStream {
options = options || {};
return this._innerApiCalls.write(options);
}

Expand All @@ -966,7 +979,6 @@ export class FirestoreClient {
* will emit objects representing [ListenResponse]{@link google.firestore.v1.ListenResponse} on 'data' event asynchronously.
*/
listen(options?: gax.CallOptions): gax.CancellableStream {
options = options || {};
return this._innerApiCalls.listen({}, options);
}

Expand Down Expand Up @@ -1142,9 +1154,17 @@ export class FirestoreClient {
*/
listDocumentsStream(
request?: protosTypes.google.firestore.v1.IListDocumentsRequest,
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.listDocuments.createStream(
this._innerApiCalls.listDocuments as gax.GaxCall,
Expand Down Expand Up @@ -1276,9 +1296,17 @@ export class FirestoreClient {
*/
listCollectionIdsStream(
request?: protosTypes.google.firestore.v1.IListCollectionIdsRequest,
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.listCollectionIds.createStream(
this._innerApiCalls.listCollectionIds as gax.GaxCall,
Expand Down
4 changes: 2 additions & 2 deletions dev/src/v1/firestore_proto_list.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
"../../protos/google/firestore/v1/common.proto",
"../../protos/google/firestore/v1/document.proto",
"../../protos/google/firestore/v1/write.proto",
"../../protos/google/firestore/v1/firestore.proto",
"../../protos/google/firestore/v1/query.proto",
"../../protos/google/firestore/v1/firestore.proto"
"../../protos/google/firestore/v1/write.proto"
]
Loading