-
Notifications
You must be signed in to change notification settings - Fork 83
chore: librarian generate pull request: 20251215T152333Z #1138
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
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.