@@ -23,9 +23,12 @@ import {
23
23
CallOptions ,
24
24
Descriptors ,
25
25
ClientOptions ,
26
+ GrpcClientOptions ,
26
27
LROperation ,
27
28
PaginationCallback ,
28
29
GaxCall ,
30
+ LocationsClient ,
31
+ LocationProtos ,
29
32
} from 'google-gax' ;
30
33
31
34
import { Transform } from 'stream' ;
@@ -90,6 +93,7 @@ export class FirestoreAdminClient {
90
93
} ;
91
94
warn : ( code : string , message : string , warnType ?: string ) => void ;
92
95
innerApiCalls : { [ name : string ] : Function } ;
96
+ locationsClient : LocationsClient ;
93
97
pathTemplates : { [ name : string ] : gax . PathTemplate } ;
94
98
operationsClient : gax . OperationsClient ;
95
99
firestoreAdminStub ?: Promise < { [ name : string ] : Function } > ;
@@ -99,7 +103,7 @@ export class FirestoreAdminClient {
99
103
*
100
104
* @param {object } [options] - The configuration object.
101
105
* The options accepted by the constructor are described in detail
102
- * in [this document](https://github.com/googleapis/gax-nodejs/blob/master /client-libraries.md#creating-the-client-instance).
106
+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/main /client-libraries.md#creating-the-client-instance).
103
107
* The common options are:
104
108
* @param {object } [options.credentials] - Credentials object.
105
109
* @param {string } [options.credentials.client_email]
@@ -122,11 +126,10 @@ export class FirestoreAdminClient {
122
126
* API remote host.
123
127
* @param {gax.ClientConfig } [options.clientConfig] - Client configuration override.
124
128
* Follows the structure of {@link gapicConfig}.
125
- * @param {boolean } [options.fallback] - Use HTTP fallback mode.
126
- * In fallback mode, a special browser-compatible transport implementation is used
127
- * instead of gRPC transport. In browser context (if the `window` object is defined)
128
- * the fallback mode is enabled automatically; set `options.fallback` to `false`
129
- * if you need to override this behavior.
129
+ * @param {boolean | "rest" } [options.fallback] - Use HTTP fallback mode.
130
+ * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
131
+ * For more information, please check the
132
+ * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
130
133
*/
131
134
constructor ( opts ?: ClientOptions ) {
132
135
// Ensure that options include all the required fields.
@@ -170,6 +173,7 @@ export class FirestoreAdminClient {
170
173
if ( servicePath === staticMembers . servicePath ) {
171
174
this . auth . defaultScopes = staticMembers . scopes ;
172
175
}
176
+ this . locationsClient = new LocationsClient ( this . _gaxGrpc , opts ) ;
173
177
174
178
// Determine the client header string.
175
179
const clientHeader = [ `gax/${ this . _gaxModule . version } ` , `gapic/${ version } ` ] ;
@@ -227,16 +231,37 @@ export class FirestoreAdminClient {
227
231
} ;
228
232
229
233
const protoFilesRoot = this . _gaxModule . protobuf . Root . fromJSON ( jsonProtos ) ;
230
-
231
234
// This API contains "long-running operations", which return a
232
235
// an Operation object that allows for tracking of the operation,
233
236
// rather than holding a request open.
234
-
237
+ const lroOptions : GrpcClientOptions = {
238
+ auth : this . auth ,
239
+ grpc : 'grpc' in this . _gaxGrpc ? this . _gaxGrpc . grpc : undefined ,
240
+ } ;
241
+ if ( opts . fallback === 'rest' ) {
242
+ lroOptions . protoJson = protoFilesRoot ;
243
+ lroOptions . httpRules = [
244
+ {
245
+ selector : 'google.longrunning.Operations.CancelOperation' ,
246
+ post : '/v1/{name=projects/*/databases/*/operations/*}:cancel' ,
247
+ body : '*' ,
248
+ } ,
249
+ {
250
+ selector : 'google.longrunning.Operations.DeleteOperation' ,
251
+ delete : '/v1/{name=projects/*/databases/*/operations/*}' ,
252
+ } ,
253
+ {
254
+ selector : 'google.longrunning.Operations.GetOperation' ,
255
+ get : '/v1/{name=projects/*/databases/*/operations/*}' ,
256
+ } ,
257
+ {
258
+ selector : 'google.longrunning.Operations.ListOperations' ,
259
+ get : '/v1/{name=projects/*/databases/*}/operations' ,
260
+ } ,
261
+ ] ;
262
+ }
235
263
this . operationsClient = this . _gaxModule
236
- . lro ( {
237
- auth : this . auth ,
238
- grpc : 'grpc' in this . _gaxGrpc ? this . _gaxGrpc . grpc : undefined ,
239
- } )
264
+ . lro ( lroOptions )
240
265
. operationsClient ( opts ) ;
241
266
const createIndexResponse = protoFilesRoot . lookup (
242
267
'.google.firestore.admin.v1.Index'
@@ -2030,6 +2055,263 @@ export class FirestoreAdminClient {
2030
2055
callSettings
2031
2056
) as AsyncIterable < protos . google . firestore . admin . v1 . IField > ;
2032
2057
}
2058
+ /**
2059
+ * Gets information about a location.
2060
+ *
2061
+ * @param {Object } request
2062
+ * The request object that will be sent.
2063
+ * @param {string } request.name
2064
+ * Resource name for the location.
2065
+ * @param {object } [options]
2066
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
2067
+ * @returns {Promise } - The promise which resolves to an array.
2068
+ * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}.
2069
+ * Please see the
2070
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
2071
+ * for more details and examples.
2072
+ * @example
2073
+ * ```
2074
+ * const [response] = await client.getLocation(request);
2075
+ * ```
2076
+ */
2077
+ getLocation (
2078
+ request : LocationProtos . google . cloud . location . IGetLocationRequest ,
2079
+ options ?:
2080
+ | gax . CallOptions
2081
+ | Callback <
2082
+ LocationProtos . google . cloud . location . ILocation ,
2083
+ | LocationProtos . google . cloud . location . IGetLocationRequest
2084
+ | null
2085
+ | undefined ,
2086
+ { } | null | undefined
2087
+ > ,
2088
+ callback ?: Callback <
2089
+ LocationProtos . google . cloud . location . ILocation ,
2090
+ | LocationProtos . google . cloud . location . IGetLocationRequest
2091
+ | null
2092
+ | undefined ,
2093
+ { } | null | undefined
2094
+ >
2095
+ ) : Promise < LocationProtos . google . cloud . location . ILocation > {
2096
+ return this . locationsClient . getLocation ( request , options , callback ) ;
2097
+ }
2098
+
2099
+ /**
2100
+ * Lists information about the supported locations for this service. Returns an iterable object.
2101
+ *
2102
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
2103
+ * @param {Object } request
2104
+ * The request object that will be sent.
2105
+ * @param {string } request.name
2106
+ * The resource that owns the locations collection, if applicable.
2107
+ * @param {string } request.filter
2108
+ * The standard list filter.
2109
+ * @param {number } request.pageSize
2110
+ * The standard list page size.
2111
+ * @param {string } request.pageToken
2112
+ * The standard list page token.
2113
+ * @param {object } [options]
2114
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
2115
+ * @returns {Object }
2116
+ * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
2117
+ * When you iterate the returned iterable, each element will be an object representing
2118
+ * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page,
2119
+ * so you can stop the iteration when you don't need more results.
2120
+ * Please see the
2121
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
2122
+ * for more details and examples.
2123
+ * @example
2124
+ * ```
2125
+ * const iterable = client.listLocationsAsync(request);
2126
+ * for await (const response of iterable) {
2127
+ * // process response
2128
+ * }
2129
+ * ```
2130
+ */
2131
+ listLocationsAsync (
2132
+ request : LocationProtos . google . cloud . location . IListLocationsRequest ,
2133
+ options ?: CallOptions
2134
+ ) : AsyncIterable < LocationProtos . google . cloud . location . ILocation > {
2135
+ return this . locationsClient . listLocationsAsync ( request , options ) ;
2136
+ }
2137
+
2138
+ /**
2139
+ * Gets the latest state of a long-running operation. Clients can use this
2140
+ * method to poll the operation result at intervals as recommended by the API
2141
+ * service.
2142
+ *
2143
+ * @param {Object } request - The request object that will be sent.
2144
+ * @param {string } request.name - The name of the operation resource.
2145
+ * @param {Object= } options
2146
+ * Optional parameters. You can override the default settings for this call,
2147
+ * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
2148
+ * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
2149
+ * details.
2150
+ * @param {function(?Error, ?Object)= } callback
2151
+ * The function which will be called with the result of the API call.
2152
+ *
2153
+ * The second parameter to the callback is an object representing
2154
+ * [google.longrunning.Operation]{@link
2155
+ * external:"google.longrunning.Operation"}.
2156
+ * @return {Promise } - The promise which resolves to an array.
2157
+ * The first element of the array is an object representing
2158
+ * [google.longrunning.Operation]{@link
2159
+ * external:"google.longrunning.Operation"}. The promise has a method named
2160
+ * "cancel" which cancels the ongoing API call.
2161
+ *
2162
+ * @example
2163
+ * ```
2164
+ * const client = longrunning.operationsClient();
2165
+ * const name = '';
2166
+ * const [response] = await client.getOperation({name});
2167
+ * // doThingsWith(response)
2168
+ * ```
2169
+ */
2170
+ getOperation (
2171
+ request : protos . google . longrunning . GetOperationRequest ,
2172
+ options ?:
2173
+ | gax . CallOptions
2174
+ | Callback <
2175
+ protos . google . longrunning . Operation ,
2176
+ protos . google . longrunning . GetOperationRequest ,
2177
+ { } | null | undefined
2178
+ > ,
2179
+ callback ?: Callback <
2180
+ protos . google . longrunning . Operation ,
2181
+ protos . google . longrunning . GetOperationRequest ,
2182
+ { } | null | undefined
2183
+ >
2184
+ ) : Promise < [ protos . google . longrunning . Operation ] > {
2185
+ return this . operationsClient . getOperation ( request , options , callback ) ;
2186
+ }
2187
+ /**
2188
+ * Lists operations that match the specified filter in the request. If the
2189
+ * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object.
2190
+ *
2191
+ * For-await-of syntax is used with the iterable to recursively get response element on-demand.
2192
+ *
2193
+ * @param {Object } request - The request object that will be sent.
2194
+ * @param {string } request.name - The name of the operation collection.
2195
+ * @param {string } request.filter - The standard list filter.
2196
+ * @param {number= } request.pageSize -
2197
+ * The maximum number of resources contained in the underlying API
2198
+ * response. If page streaming is performed per-resource, this
2199
+ * parameter does not affect the return value. If page streaming is
2200
+ * performed per-page, this determines the maximum number of
2201
+ * resources in a page.
2202
+ * @param {Object= } options
2203
+ * Optional parameters. You can override the default settings for this call,
2204
+ * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
2205
+ * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
2206
+ * details.
2207
+ * @returns {Object }
2208
+ * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
2209
+ *
2210
+ * @example
2211
+ * ```
2212
+ * const client = longrunning.operationsClient();
2213
+ * for await (const response of client.listOperationsAsync(request));
2214
+ * // doThingsWith(response)
2215
+ * ```
2216
+ */
2217
+ listOperationsAsync (
2218
+ request : protos . google . longrunning . ListOperationsRequest ,
2219
+ options ?: gax . CallOptions
2220
+ ) : AsyncIterable < protos . google . longrunning . ListOperationsResponse > {
2221
+ return this . operationsClient . listOperationsAsync ( request , options ) ;
2222
+ }
2223
+ /**
2224
+ * Starts asynchronous cancellation on a long-running operation. The server
2225
+ * makes a best effort to cancel the operation, but success is not
2226
+ * guaranteed. If the server doesn't support this method, it returns
2227
+ * `google.rpc.Code.UNIMPLEMENTED`. Clients can use
2228
+ * {@link Operations.GetOperation} or
2229
+ * other methods to check whether the cancellation succeeded or whether the
2230
+ * operation completed despite cancellation. On successful cancellation,
2231
+ * the operation is not deleted; instead, it becomes an operation with
2232
+ * an {@link Operation.error} value with a {@link google.rpc.Status.code} of
2233
+ * 1, corresponding to `Code.CANCELLED`.
2234
+ *
2235
+ * @param {Object } request - The request object that will be sent.
2236
+ * @param {string } request.name - The name of the operation resource to be cancelled.
2237
+ * @param {Object= } options
2238
+ * Optional parameters. You can override the default settings for this call,
2239
+ * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
2240
+ * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
2241
+ * details.
2242
+ * @param {function(?Error)= } callback
2243
+ * The function which will be called with the result of the API call.
2244
+ * @return {Promise } - The promise which resolves when API call finishes.
2245
+ * The promise has a method named "cancel" which cancels the ongoing API
2246
+ * call.
2247
+ *
2248
+ * @example
2249
+ * ```
2250
+ * const client = longrunning.operationsClient();
2251
+ * await client.cancelOperation({name: ''});
2252
+ * ```
2253
+ */
2254
+ cancelOperation (
2255
+ request : protos . google . longrunning . CancelOperationRequest ,
2256
+ options ?:
2257
+ | gax . CallOptions
2258
+ | Callback <
2259
+ protos . google . protobuf . Empty ,
2260
+ protos . google . longrunning . CancelOperationRequest ,
2261
+ { } | undefined | null
2262
+ > ,
2263
+ callback ?: Callback <
2264
+ protos . google . longrunning . CancelOperationRequest ,
2265
+ protos . google . protobuf . Empty ,
2266
+ { } | undefined | null
2267
+ >
2268
+ ) : Promise < protos . google . protobuf . Empty > {
2269
+ return this . operationsClient . cancelOperation ( request , options , callback ) ;
2270
+ }
2271
+
2272
+ /**
2273
+ * Deletes a long-running operation. This method indicates that the client is
2274
+ * no longer interested in the operation result. It does not cancel the
2275
+ * operation. If the server doesn't support this method, it returns
2276
+ * `google.rpc.Code.UNIMPLEMENTED`.
2277
+ *
2278
+ * @param {Object } request - The request object that will be sent.
2279
+ * @param {string } request.name - The name of the operation resource to be deleted.
2280
+ * @param {Object= } options
2281
+ * Optional parameters. You can override the default settings for this call,
2282
+ * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
2283
+ * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
2284
+ * details.
2285
+ * @param {function(?Error)= } callback
2286
+ * The function which will be called with the result of the API call.
2287
+ * @return {Promise } - The promise which resolves when API call finishes.
2288
+ * The promise has a method named "cancel" which cancels the ongoing API
2289
+ * call.
2290
+ *
2291
+ * @example
2292
+ * ```
2293
+ * const client = longrunning.operationsClient();
2294
+ * await client.deleteOperation({name: ''});
2295
+ * ```
2296
+ */
2297
+ deleteOperation (
2298
+ request : protos . google . longrunning . DeleteOperationRequest ,
2299
+ options ?:
2300
+ | gax . CallOptions
2301
+ | Callback <
2302
+ protos . google . protobuf . Empty ,
2303
+ protos . google . longrunning . DeleteOperationRequest ,
2304
+ { } | null | undefined
2305
+ > ,
2306
+ callback ?: Callback <
2307
+ protos . google . protobuf . Empty ,
2308
+ protos . google . longrunning . DeleteOperationRequest ,
2309
+ { } | null | undefined
2310
+ >
2311
+ ) : Promise < protos . google . protobuf . Empty > {
2312
+ return this . operationsClient . deleteOperation ( request , options , callback ) ;
2313
+ }
2314
+
2033
2315
// --------------------
2034
2316
// -- Path templates --
2035
2317
// --------------------
@@ -2293,6 +2575,7 @@ export class FirestoreAdminClient {
2293
2575
return this . firestoreAdminStub . then ( stub => {
2294
2576
this . _terminated = true ;
2295
2577
stub . close ( ) ;
2578
+ this . locationsClient . close ( ) ;
2296
2579
this . operationsClient . close ( ) ;
2297
2580
} ) ;
2298
2581
}
0 commit comments