|
53 | 53 | from google.cloud.firestore_v1.types import common |
54 | 54 | from google.cloud.firestore_v1.types import document |
55 | 55 | from google.cloud.firestore_v1.types import document as gf_document |
| 56 | +from google.cloud.firestore_v1.types import explain_stats |
56 | 57 | from google.cloud.firestore_v1.types import firestore |
57 | 58 | from google.cloud.firestore_v1.types import query |
58 | 59 | from google.cloud.firestore_v1.types import query_profile |
@@ -1248,6 +1249,109 @@ async def sample_run_query(): |
1248 | 1249 | # Done; return the response. |
1249 | 1250 | return response |
1250 | 1251 |
|
| 1252 | + def execute_pipeline( |
| 1253 | + self, |
| 1254 | + request: Optional[Union[firestore.ExecutePipelineRequest, dict]] = None, |
| 1255 | + *, |
| 1256 | + retry: OptionalRetry = gapic_v1.method.DEFAULT, |
| 1257 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
| 1258 | + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), |
| 1259 | + ) -> Awaitable[AsyncIterable[firestore.ExecutePipelineResponse]]: |
| 1260 | + r"""Executes a pipeline query. |
| 1261 | +
|
| 1262 | + .. code-block:: python |
| 1263 | +
|
| 1264 | + # This snippet has been automatically generated and should be regarded as a |
| 1265 | + # code template only. |
| 1266 | + # It will require modifications to work: |
| 1267 | + # - It may require correct/in-range values for request initialization. |
| 1268 | + # - It may require specifying regional endpoints when creating the service |
| 1269 | + # client as shown in: |
| 1270 | + # https://googleapis.dev/python/google-api-core/latest/client_options.html |
| 1271 | + from google.cloud import firestore_v1 |
| 1272 | +
|
| 1273 | + async def sample_execute_pipeline(): |
| 1274 | + # Create a client |
| 1275 | + client = firestore_v1.FirestoreAsyncClient() |
| 1276 | +
|
| 1277 | + # Initialize request argument(s) |
| 1278 | + structured_pipeline = firestore_v1.StructuredPipeline() |
| 1279 | + structured_pipeline.pipeline.stages.name = "name_value" |
| 1280 | +
|
| 1281 | + request = firestore_v1.ExecutePipelineRequest( |
| 1282 | + structured_pipeline=structured_pipeline, |
| 1283 | + transaction=b'transaction_blob', |
| 1284 | + database="database_value", |
| 1285 | + ) |
| 1286 | +
|
| 1287 | + # Make the request |
| 1288 | + stream = await client.execute_pipeline(request=request) |
| 1289 | +
|
| 1290 | + # Handle the response |
| 1291 | + async for response in stream: |
| 1292 | + print(response) |
| 1293 | +
|
| 1294 | + Args: |
| 1295 | + request (Optional[Union[google.cloud.firestore_v1.types.ExecutePipelineRequest, dict]]): |
| 1296 | + The request object. The request for |
| 1297 | + [Firestore.ExecutePipeline][google.firestore.v1.Firestore.ExecutePipeline]. |
| 1298 | + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, |
| 1299 | + should be retried. |
| 1300 | + timeout (float): The timeout for this request. |
| 1301 | + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be |
| 1302 | + sent along with the request as metadata. Normally, each value must be of type `str`, |
| 1303 | + but for metadata keys ending with the suffix `-bin`, the corresponding values must |
| 1304 | + be of type `bytes`. |
| 1305 | +
|
| 1306 | + Returns: |
| 1307 | + AsyncIterable[google.cloud.firestore_v1.types.ExecutePipelineResponse]: |
| 1308 | + The response for [Firestore.Execute][]. |
| 1309 | + """ |
| 1310 | + # Create or coerce a protobuf request object. |
| 1311 | + # - Use the request object if provided (there's no risk of modifying the input as |
| 1312 | + # there are no flattened fields), or create one. |
| 1313 | + if not isinstance(request, firestore.ExecutePipelineRequest): |
| 1314 | + request = firestore.ExecutePipelineRequest(request) |
| 1315 | + |
| 1316 | + # Wrap the RPC method; this adds retry and timeout information, |
| 1317 | + # and friendly error handling. |
| 1318 | + rpc = self._client._transport._wrapped_methods[ |
| 1319 | + self._client._transport.execute_pipeline |
| 1320 | + ] |
| 1321 | + |
| 1322 | + header_params = {} |
| 1323 | + |
| 1324 | + routing_param_regex = re.compile("^projects/(?P<project_id>[^/]+)(?:/.*)?$") |
| 1325 | + regex_match = routing_param_regex.match(request.database) |
| 1326 | + if regex_match and regex_match.group("project_id"): |
| 1327 | + header_params["project_id"] = regex_match.group("project_id") |
| 1328 | + |
| 1329 | + routing_param_regex = re.compile( |
| 1330 | + "^projects/[^/]+/databases/(?P<database_id>[^/]+)(?:/.*)?$" |
| 1331 | + ) |
| 1332 | + regex_match = routing_param_regex.match(request.database) |
| 1333 | + if regex_match and regex_match.group("database_id"): |
| 1334 | + header_params["database_id"] = regex_match.group("database_id") |
| 1335 | + |
| 1336 | + if header_params: |
| 1337 | + metadata = tuple(metadata) + ( |
| 1338 | + gapic_v1.routing_header.to_grpc_metadata(header_params), |
| 1339 | + ) |
| 1340 | + |
| 1341 | + # Validate the universe domain. |
| 1342 | + self._client._validate_universe_domain() |
| 1343 | + |
| 1344 | + # Send the request. |
| 1345 | + response = rpc( |
| 1346 | + request, |
| 1347 | + retry=retry, |
| 1348 | + timeout=timeout, |
| 1349 | + metadata=metadata, |
| 1350 | + ) |
| 1351 | + |
| 1352 | + # Done; return the response. |
| 1353 | + return response |
| 1354 | + |
1251 | 1355 | def run_aggregation_query( |
1252 | 1356 | self, |
1253 | 1357 | request: Optional[Union[firestore.RunAggregationQueryRequest, dict]] = None, |
|
0 commit comments