This repository was archived by the owner on Mar 2, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
chore: librarian generate pull request: 20251215T152333Z #1138
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -68,6 +68,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||
| from google.cloud.firestore_v1.types import common | ||||||||||||||||||||||||||||||||||||||||||||||
| from google.cloud.firestore_v1.types import document | ||||||||||||||||||||||||||||||||||||||||||||||
| from google.cloud.firestore_v1.types import document as gf_document | ||||||||||||||||||||||||||||||||||||||||||||||
| from google.cloud.firestore_v1.types import explain_stats | ||||||||||||||||||||||||||||||||||||||||||||||
| from google.cloud.firestore_v1.types import firestore | ||||||||||||||||||||||||||||||||||||||||||||||
| from google.cloud.firestore_v1.types import query | ||||||||||||||||||||||||||||||||||||||||||||||
| from google.cloud.firestore_v1.types import query_profile | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1631,6 +1632,107 @@ def sample_run_query(): | |||||||||||||||||||||||||||||||||||||||||||||
| # Done; return the response. | ||||||||||||||||||||||||||||||||||||||||||||||
| return response | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| def execute_pipeline( | ||||||||||||||||||||||||||||||||||||||||||||||
| self, | ||||||||||||||||||||||||||||||||||||||||||||||
| request: Optional[Union[firestore.ExecutePipelineRequest, dict]] = None, | ||||||||||||||||||||||||||||||||||||||||||||||
| *, | ||||||||||||||||||||||||||||||||||||||||||||||
| retry: OptionalRetry = gapic_v1.method.DEFAULT, | ||||||||||||||||||||||||||||||||||||||||||||||
| timeout: Union[float, object] = gapic_v1.method.DEFAULT, | ||||||||||||||||||||||||||||||||||||||||||||||
| metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), | ||||||||||||||||||||||||||||||||||||||||||||||
| ) -> Iterable[firestore.ExecutePipelineResponse]: | ||||||||||||||||||||||||||||||||||||||||||||||
| r"""Executes a pipeline query. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| .. code-block:: python | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # This snippet has been automatically generated and should be regarded as a | ||||||||||||||||||||||||||||||||||||||||||||||
| # code template only. | ||||||||||||||||||||||||||||||||||||||||||||||
| # It will require modifications to work: | ||||||||||||||||||||||||||||||||||||||||||||||
| # - It may require correct/in-range values for request initialization. | ||||||||||||||||||||||||||||||||||||||||||||||
| # - It may require specifying regional endpoints when creating the service | ||||||||||||||||||||||||||||||||||||||||||||||
| # client as shown in: | ||||||||||||||||||||||||||||||||||||||||||||||
| # https://googleapis.dev/python/google-api-core/latest/client_options.html | ||||||||||||||||||||||||||||||||||||||||||||||
| from google.cloud import firestore_v1 | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| def sample_execute_pipeline(): | ||||||||||||||||||||||||||||||||||||||||||||||
| # Create a client | ||||||||||||||||||||||||||||||||||||||||||||||
| client = firestore_v1.FirestoreClient() | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Initialize request argument(s) | ||||||||||||||||||||||||||||||||||||||||||||||
| structured_pipeline = firestore_v1.StructuredPipeline() | ||||||||||||||||||||||||||||||||||||||||||||||
| structured_pipeline.pipeline.stages.name = "name_value" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| request = firestore_v1.ExecutePipelineRequest( | ||||||||||||||||||||||||||||||||||||||||||||||
| structured_pipeline=structured_pipeline, | ||||||||||||||||||||||||||||||||||||||||||||||
| transaction=b'transaction_blob', | ||||||||||||||||||||||||||||||||||||||||||||||
| database="database_value", | ||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Make the request | ||||||||||||||||||||||||||||||||||||||||||||||
| stream = client.execute_pipeline(request=request) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Handle the response | ||||||||||||||||||||||||||||||||||||||||||||||
| for response in stream: | ||||||||||||||||||||||||||||||||||||||||||||||
| print(response) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Args: | ||||||||||||||||||||||||||||||||||||||||||||||
| request (Union[google.cloud.firestore_v1.types.ExecutePipelineRequest, dict]): | ||||||||||||||||||||||||||||||||||||||||||||||
| The request object. The request for | ||||||||||||||||||||||||||||||||||||||||||||||
| [Firestore.ExecutePipeline][google.firestore.v1.Firestore.ExecutePipeline]. | ||||||||||||||||||||||||||||||||||||||||||||||
| retry (google.api_core.retry.Retry): Designation of what errors, if any, | ||||||||||||||||||||||||||||||||||||||||||||||
| should be retried. | ||||||||||||||||||||||||||||||||||||||||||||||
| timeout (float): The timeout for this request. | ||||||||||||||||||||||||||||||||||||||||||||||
| metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be | ||||||||||||||||||||||||||||||||||||||||||||||
| sent along with the request as metadata. Normally, each value must be of type `str`, | ||||||||||||||||||||||||||||||||||||||||||||||
| but for metadata keys ending with the suffix `-bin`, the corresponding values must | ||||||||||||||||||||||||||||||||||||||||||||||
| be of type `bytes`. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Returns: | ||||||||||||||||||||||||||||||||||||||||||||||
| Iterable[google.cloud.firestore_v1.types.ExecutePipelineResponse]: | ||||||||||||||||||||||||||||||||||||||||||||||
| The response for [Firestore.Execute][]. | ||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||
| # Create or coerce a protobuf request object. | ||||||||||||||||||||||||||||||||||||||||||||||
| # - Use the request object if provided (there's no risk of modifying the input as | ||||||||||||||||||||||||||||||||||||||||||||||
| # there are no flattened fields), or create one. | ||||||||||||||||||||||||||||||||||||||||||||||
| if not isinstance(request, firestore.ExecutePipelineRequest): | ||||||||||||||||||||||||||||||||||||||||||||||
| request = firestore.ExecutePipelineRequest(request) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Wrap the RPC method; this adds retry and timeout information, | ||||||||||||||||||||||||||||||||||||||||||||||
| # and friendly error handling. | ||||||||||||||||||||||||||||||||||||||||||||||
| rpc = self._transport._wrapped_methods[self._transport.execute_pipeline] | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| header_params = {} | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| routing_param_regex = re.compile("^projects/(?P<project_id>[^/]+)(?:/.*)?$") | ||||||||||||||||||||||||||||||||||||||||||||||
| regex_match = routing_param_regex.match(request.database) | ||||||||||||||||||||||||||||||||||||||||||||||
| if regex_match and regex_match.group("project_id"): | ||||||||||||||||||||||||||||||||||||||||||||||
| header_params["project_id"] = regex_match.group("project_id") | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| routing_param_regex = re.compile( | ||||||||||||||||||||||||||||||||||||||||||||||
| "^projects/[^/]+/databases/(?P<database_id>[^/]+)(?:/.*)?$" | ||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||
| regex_match = routing_param_regex.match(request.database) | ||||||||||||||||||||||||||||||||||||||||||||||
| if regex_match and regex_match.group("database_id"): | ||||||||||||||||||||||||||||||||||||||||||||||
| header_params["database_id"] = regex_match.group("database_id") | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1705
to
+1715
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For performance, it's best to compile regular expressions only once at the module level, rather than inside a function that might be called frequently. This avoids the overhead of recompiling the regex on every call. Please define
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if header_params: | ||||||||||||||||||||||||||||||||||||||||||||||
| metadata = tuple(metadata) + ( | ||||||||||||||||||||||||||||||||||||||||||||||
| gapic_v1.routing_header.to_grpc_metadata(header_params), | ||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Validate the universe domain. | ||||||||||||||||||||||||||||||||||||||||||||||
| self._validate_universe_domain() | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Send the request. | ||||||||||||||||||||||||||||||||||||||||||||||
| response = rpc( | ||||||||||||||||||||||||||||||||||||||||||||||
| request, | ||||||||||||||||||||||||||||||||||||||||||||||
| retry=retry, | ||||||||||||||||||||||||||||||||||||||||||||||
| timeout=timeout, | ||||||||||||||||||||||||||||||||||||||||||||||
| metadata=metadata, | ||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Done; return the response. | ||||||||||||||||||||||||||||||||||||||||||||||
| return response | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| def run_aggregation_query( | ||||||||||||||||||||||||||||||||||||||||||||||
| self, | ||||||||||||||||||||||||||||||||||||||||||||||
| request: Optional[Union[firestore.RunAggregationQueryRequest, dict]] = None, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For performance, it's best to compile regular expressions only once at the module level, rather than inside a function that might be called frequently. This avoids the overhead of recompiling the regex on every call.
Please define
_PROJECT_ID_REGEXand_DATABASE_ID_REGEXas module-level constants. I've also used more descriptive variable names for the match objects to improve clarity and avoid reusing theregex_matchvariable.