Skip to content

Commit f3498c7

Browse files
committed
restore changes from 1144
1 parent 368d168 commit f3498c7

File tree

16 files changed

+1806
-81
lines changed

16 files changed

+1806
-81
lines changed

.librarian/state.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-li
22
libraries:
33
- id: google-cloud-firestore
44
version: 2.21.0
5-
last_generated_commit: 659ea6e98acc7d58661ce2aa7b4cf76a7ef3fd42
5+
last_generated_commit: 1a9d00bed77e6db82ff67764ffe14e3b5209f5cd
66
apis:
77
- path: google/firestore/v1
88
service_config: firestore_v1.yaml

google/cloud/firestore_v1/gapic_metadata.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
"delete_document"
4141
]
4242
},
43+
"ExecutePipeline": {
44+
"methods": [
45+
"execute_pipeline"
46+
]
47+
},
4348
"GetDocument": {
4449
"methods": [
4550
"get_document"
@@ -125,6 +130,11 @@
125130
"delete_document"
126131
]
127132
},
133+
"ExecutePipeline": {
134+
"methods": [
135+
"execute_pipeline"
136+
]
137+
},
128138
"GetDocument": {
129139
"methods": [
130140
"get_document"
@@ -210,6 +220,11 @@
210220
"delete_document"
211221
]
212222
},
223+
"ExecutePipeline": {
224+
"methods": [
225+
"execute_pipeline"
226+
]
227+
},
213228
"GetDocument": {
214229
"methods": [
215230
"get_document"

google/cloud/firestore_v1/services/firestore/async_client.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
from google.cloud.firestore_v1.types import common
5454
from google.cloud.firestore_v1.types import document
5555
from google.cloud.firestore_v1.types import document as gf_document
56+
from google.cloud.firestore_v1.types import explain_stats
5657
from google.cloud.firestore_v1.types import firestore
5758
from google.cloud.firestore_v1.types import query
5859
from google.cloud.firestore_v1.types import query_profile
@@ -1248,6 +1249,109 @@ async def sample_run_query():
12481249
# Done; return the response.
12491250
return response
12501251

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+
12511355
def run_aggregation_query(
12521356
self,
12531357
request: Optional[Union[firestore.RunAggregationQueryRequest, dict]] = None,

google/cloud/firestore_v1/services/firestore/client.py

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
from google.cloud.firestore_v1.types import common
6969
from google.cloud.firestore_v1.types import document
7070
from google.cloud.firestore_v1.types import document as gf_document
71+
from google.cloud.firestore_v1.types import explain_stats
7172
from google.cloud.firestore_v1.types import firestore
7273
from google.cloud.firestore_v1.types import query
7374
from google.cloud.firestore_v1.types import query_profile
@@ -1649,6 +1650,107 @@ def sample_run_query():
16491650
# Done; return the response.
16501651
return response
16511652

1653+
def execute_pipeline(
1654+
self,
1655+
request: Optional[Union[firestore.ExecutePipelineRequest, dict]] = None,
1656+
*,
1657+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1658+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1659+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1660+
) -> Iterable[firestore.ExecutePipelineResponse]:
1661+
r"""Executes a pipeline query.
1662+
1663+
.. code-block:: python
1664+
1665+
# This snippet has been automatically generated and should be regarded as a
1666+
# code template only.
1667+
# It will require modifications to work:
1668+
# - It may require correct/in-range values for request initialization.
1669+
# - It may require specifying regional endpoints when creating the service
1670+
# client as shown in:
1671+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
1672+
from google.cloud import firestore_v1
1673+
1674+
def sample_execute_pipeline():
1675+
# Create a client
1676+
client = firestore_v1.FirestoreClient()
1677+
1678+
# Initialize request argument(s)
1679+
structured_pipeline = firestore_v1.StructuredPipeline()
1680+
structured_pipeline.pipeline.stages.name = "name_value"
1681+
1682+
request = firestore_v1.ExecutePipelineRequest(
1683+
structured_pipeline=structured_pipeline,
1684+
transaction=b'transaction_blob',
1685+
database="database_value",
1686+
)
1687+
1688+
# Make the request
1689+
stream = client.execute_pipeline(request=request)
1690+
1691+
# Handle the response
1692+
for response in stream:
1693+
print(response)
1694+
1695+
Args:
1696+
request (Union[google.cloud.firestore_v1.types.ExecutePipelineRequest, dict]):
1697+
The request object. The request for
1698+
[Firestore.ExecutePipeline][google.firestore.v1.Firestore.ExecutePipeline].
1699+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
1700+
should be retried.
1701+
timeout (float): The timeout for this request.
1702+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1703+
sent along with the request as metadata. Normally, each value must be of type `str`,
1704+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
1705+
be of type `bytes`.
1706+
1707+
Returns:
1708+
Iterable[google.cloud.firestore_v1.types.ExecutePipelineResponse]:
1709+
The response for [Firestore.Execute][].
1710+
"""
1711+
# Create or coerce a protobuf request object.
1712+
# - Use the request object if provided (there's no risk of modifying the input as
1713+
# there are no flattened fields), or create one.
1714+
if not isinstance(request, firestore.ExecutePipelineRequest):
1715+
request = firestore.ExecutePipelineRequest(request)
1716+
1717+
# Wrap the RPC method; this adds retry and timeout information,
1718+
# and friendly error handling.
1719+
rpc = self._transport._wrapped_methods[self._transport.execute_pipeline]
1720+
1721+
header_params = {}
1722+
1723+
routing_param_regex = re.compile("^projects/(?P<project_id>[^/]+)(?:/.*)?$")
1724+
regex_match = routing_param_regex.match(request.database)
1725+
if regex_match and regex_match.group("project_id"):
1726+
header_params["project_id"] = regex_match.group("project_id")
1727+
1728+
routing_param_regex = re.compile(
1729+
"^projects/[^/]+/databases/(?P<database_id>[^/]+)(?:/.*)?$"
1730+
)
1731+
regex_match = routing_param_regex.match(request.database)
1732+
if regex_match and regex_match.group("database_id"):
1733+
header_params["database_id"] = regex_match.group("database_id")
1734+
1735+
if header_params:
1736+
metadata = tuple(metadata) + (
1737+
gapic_v1.routing_header.to_grpc_metadata(header_params),
1738+
)
1739+
1740+
# Validate the universe domain.
1741+
self._validate_universe_domain()
1742+
1743+
# Send the request.
1744+
response = rpc(
1745+
request,
1746+
retry=retry,
1747+
timeout=timeout,
1748+
metadata=metadata,
1749+
)
1750+
1751+
# Done; return the response.
1752+
return response
1753+
16521754
def run_aggregation_query(
16531755
self,
16541756
request: Optional[Union[firestore.RunAggregationQueryRequest, dict]] = None,

google/cloud/firestore_v1/services/firestore/transports/base.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,23 @@ def _prep_wrapped_messages(self, client_info):
291291
default_timeout=300.0,
292292
client_info=client_info,
293293
),
294+
self.execute_pipeline: gapic_v1.method.wrap_method(
295+
self.execute_pipeline,
296+
default_retry=retries.Retry(
297+
initial=0.1,
298+
maximum=60.0,
299+
multiplier=1.3,
300+
predicate=retries.if_exception_type(
301+
core_exceptions.DeadlineExceeded,
302+
core_exceptions.InternalServerError,
303+
core_exceptions.ResourceExhausted,
304+
core_exceptions.ServiceUnavailable,
305+
),
306+
deadline=300.0,
307+
),
308+
default_timeout=300.0,
309+
client_info=client_info,
310+
),
294311
self.run_aggregation_query: gapic_v1.method.wrap_method(
295312
self.run_aggregation_query,
296313
default_retry=retries.Retry(
@@ -514,6 +531,18 @@ def run_query(
514531
]:
515532
raise NotImplementedError()
516533

534+
@property
535+
def execute_pipeline(
536+
self,
537+
) -> Callable[
538+
[firestore.ExecutePipelineRequest],
539+
Union[
540+
firestore.ExecutePipelineResponse,
541+
Awaitable[firestore.ExecutePipelineResponse],
542+
],
543+
]:
544+
raise NotImplementedError()
545+
517546
@property
518547
def run_aggregation_query(
519548
self,

google/cloud/firestore_v1/services/firestore/transports/grpc.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,34 @@ def run_query(
573573
)
574574
return self._stubs["run_query"]
575575

576+
@property
577+
def execute_pipeline(
578+
self,
579+
) -> Callable[
580+
[firestore.ExecutePipelineRequest], firestore.ExecutePipelineResponse
581+
]:
582+
r"""Return a callable for the execute pipeline method over gRPC.
583+
584+
Executes a pipeline query.
585+
586+
Returns:
587+
Callable[[~.ExecutePipelineRequest],
588+
~.ExecutePipelineResponse]:
589+
A function that, when called, will call the underlying RPC
590+
on the server.
591+
"""
592+
# Generate a "stub function" on-the-fly which will actually make
593+
# the request.
594+
# gRPC handles serialization and deserialization, so we just need
595+
# to pass in the functions for each.
596+
if "execute_pipeline" not in self._stubs:
597+
self._stubs["execute_pipeline"] = self._logged_channel.unary_stream(
598+
"/google.firestore.v1.Firestore/ExecutePipeline",
599+
request_serializer=firestore.ExecutePipelineRequest.serialize,
600+
response_deserializer=firestore.ExecutePipelineResponse.deserialize,
601+
)
602+
return self._stubs["execute_pipeline"]
603+
576604
@property
577605
def run_aggregation_query(
578606
self,

0 commit comments

Comments
 (0)