Skip to content

Commit 86743c8

Browse files
feat: [google-maps-places] add AutoComplete API (googleapis#12329)
BEGIN_COMMIT_OVERRIDE feat: add AutoComplete API feat: add Searchable EV feature to TextSearch API END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. feat: add Searchable EV feature to TextSearch API PiperOrigin-RevId: 608184544 Source-Link: googleapis/googleapis@3049b76 Source-Link: https://github.com/googleapis/googleapis-gen/commit/2cac391ac8a560e9031c1c502ca08d62faad35ab Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLW1hcHMtcGxhY2VzLy5Pd2xCb3QueWFtbCIsImgiOiIyY2FjMzkxYWM4YTU2MGU5MDMxYzFjNTAyY2EwOGQ2MmZhYWQzNWFiIn0= --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: ohmayr <omairnaveed@ymail.com>
1 parent 7c4dc23 commit 86743c8

17 files changed

Lines changed: 1548 additions & 33 deletions

File tree

packages/google-maps-places/google/maps/places/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
from google.maps.places_v1.types.photo import Photo
2828
from google.maps.places_v1.types.place import Place, PriceLevel
2929
from google.maps.places_v1.types.places_service import (
30+
AutocompletePlacesRequest,
31+
AutocompletePlacesResponse,
3032
GetPhotoMediaRequest,
3133
GetPlaceRequest,
3234
PhotoMedia,
@@ -48,6 +50,8 @@
4850
"Photo",
4951
"Place",
5052
"PriceLevel",
53+
"AutocompletePlacesRequest",
54+
"AutocompletePlacesResponse",
5155
"GetPhotoMediaRequest",
5256
"GetPlaceRequest",
5357
"PhotoMedia",

packages/google-maps-places/google/maps/places_v1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
from .types.photo import Photo
2727
from .types.place import Place, PriceLevel
2828
from .types.places_service import (
29+
AutocompletePlacesRequest,
30+
AutocompletePlacesResponse,
2931
GetPhotoMediaRequest,
3032
GetPlaceRequest,
3133
PhotoMedia,
@@ -39,6 +41,8 @@
3941
__all__ = (
4042
"PlacesAsyncClient",
4143
"AuthorAttribution",
44+
"AutocompletePlacesRequest",
45+
"AutocompletePlacesResponse",
4246
"Circle",
4347
"EVChargeOptions",
4448
"EVConnectorType",

packages/google-maps-places/google/maps/places_v1/gapic_metadata.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
"grpc": {
1111
"libraryClient": "PlacesClient",
1212
"rpcs": {
13+
"AutocompletePlaces": {
14+
"methods": [
15+
"autocomplete_places"
16+
]
17+
},
1318
"GetPhotoMedia": {
1419
"methods": [
1520
"get_photo_media"
@@ -35,6 +40,11 @@
3540
"grpc-async": {
3641
"libraryClient": "PlacesAsyncClient",
3742
"rpcs": {
43+
"AutocompletePlaces": {
44+
"methods": [
45+
"autocomplete_places"
46+
]
47+
},
3848
"GetPhotoMedia": {
3949
"methods": [
4050
"get_photo_media"
@@ -60,6 +70,11 @@
6070
"rest": {
6171
"libraryClient": "PlacesClient",
6272
"rpcs": {
73+
"AutocompletePlaces": {
74+
"methods": [
75+
"autocomplete_places"
76+
]
77+
},
6378
"GetPhotoMedia": {
6479
"methods": [
6580
"get_photo_media"

packages/google-maps-places/google/maps/places_v1/services/places/async_client.py

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,8 @@ async def get_place(
533533
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
534534
metadata: Sequence[Tuple[str, str]] = (),
535535
) -> place.Place:
536-
r"""Get place details with a place id (in a name) string.
536+
r"""Get the details of a place based on its resource name, which is
537+
a string in the ``places/{place_id}`` format.
537538
538539
.. code-block:: python
539540
@@ -563,12 +564,11 @@ async def sample_get_place():
563564
564565
Args:
565566
request (Optional[Union[google.maps.places_v1.types.GetPlaceRequest, dict]]):
566-
The request object. Request for fetching a Place with a
567-
place id (in a name) string.
567+
The request object. Request for fetching a Place based on its resource name,
568+
which is a string in the ``places/{place_id}`` format.
568569
name (:class:`str`):
569-
Required. A place ID returned in a Place (with "places/"
570-
prefix), or equivalently the name in the same Place.
571-
Format: ``places/{place_id}``.
570+
Required. The resource name of a place, in the
571+
``places/{place_id}`` format.
572572
573573
This corresponds to the ``name`` field
574574
on the ``request`` instance; if ``request`` is provided, this
@@ -630,6 +630,82 @@ async def sample_get_place():
630630
# Done; return the response.
631631
return response
632632

633+
async def autocomplete_places(
634+
self,
635+
request: Optional[Union[places_service.AutocompletePlacesRequest, dict]] = None,
636+
*,
637+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
638+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
639+
metadata: Sequence[Tuple[str, str]] = (),
640+
) -> places_service.AutocompletePlacesResponse:
641+
r"""Returns predictions for the given input.
642+
643+
.. code-block:: python
644+
645+
# This snippet has been automatically generated and should be regarded as a
646+
# code template only.
647+
# It will require modifications to work:
648+
# - It may require correct/in-range values for request initialization.
649+
# - It may require specifying regional endpoints when creating the service
650+
# client as shown in:
651+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
652+
from google.maps import places_v1
653+
654+
async def sample_autocomplete_places():
655+
# Create a client
656+
client = places_v1.PlacesAsyncClient()
657+
658+
# Initialize request argument(s)
659+
request = places_v1.AutocompletePlacesRequest(
660+
input="input_value",
661+
)
662+
663+
# Make the request
664+
response = await client.autocomplete_places(request=request)
665+
666+
# Handle the response
667+
print(response)
668+
669+
Args:
670+
request (Optional[Union[google.maps.places_v1.types.AutocompletePlacesRequest, dict]]):
671+
The request object. Request proto for AutocompletePlaces.
672+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
673+
should be retried.
674+
timeout (float): The timeout for this request.
675+
metadata (Sequence[Tuple[str, str]]): Strings which should be
676+
sent along with the request as metadata.
677+
678+
Returns:
679+
google.maps.places_v1.types.AutocompletePlacesResponse:
680+
Response proto for
681+
AutocompletePlaces.
682+
683+
"""
684+
# Create or coerce a protobuf request object.
685+
request = places_service.AutocompletePlacesRequest(request)
686+
687+
# Wrap the RPC method; this adds retry and timeout information,
688+
# and friendly error handling.
689+
rpc = gapic_v1.method_async.wrap_method(
690+
self._client._transport.autocomplete_places,
691+
default_timeout=None,
692+
client_info=DEFAULT_CLIENT_INFO,
693+
)
694+
695+
# Validate the universe domain.
696+
self._client._validate_universe_domain()
697+
698+
# Send the request.
699+
response = await rpc(
700+
request,
701+
retry=retry,
702+
timeout=timeout,
703+
metadata=metadata,
704+
)
705+
706+
# Done; return the response.
707+
return response
708+
633709
async def __aenter__(self) -> "PlacesAsyncClient":
634710
return self
635711

packages/google-maps-places/google/maps/places_v1/services/places/client.py

Lines changed: 83 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,8 @@ def get_place(
993993
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
994994
metadata: Sequence[Tuple[str, str]] = (),
995995
) -> place.Place:
996-
r"""Get place details with a place id (in a name) string.
996+
r"""Get the details of a place based on its resource name, which is
997+
a string in the ``places/{place_id}`` format.
997998
998999
.. code-block:: python
9991000
@@ -1023,12 +1024,11 @@ def sample_get_place():
10231024
10241025
Args:
10251026
request (Union[google.maps.places_v1.types.GetPlaceRequest, dict]):
1026-
The request object. Request for fetching a Place with a
1027-
place id (in a name) string.
1027+
The request object. Request for fetching a Place based on its resource name,
1028+
which is a string in the ``places/{place_id}`` format.
10281029
name (str):
1029-
Required. A place ID returned in a Place (with "places/"
1030-
prefix), or equivalently the name in the same Place.
1031-
Format: ``places/{place_id}``.
1030+
Required. The resource name of a place, in the
1031+
``places/{place_id}`` format.
10321032
10331033
This corresponds to the ``name`` field
10341034
on the ``request`` instance; if ``request`` is provided, this
@@ -1090,6 +1090,83 @@ def sample_get_place():
10901090
# Done; return the response.
10911091
return response
10921092

1093+
def autocomplete_places(
1094+
self,
1095+
request: Optional[Union[places_service.AutocompletePlacesRequest, dict]] = None,
1096+
*,
1097+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1098+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1099+
metadata: Sequence[Tuple[str, str]] = (),
1100+
) -> places_service.AutocompletePlacesResponse:
1101+
r"""Returns predictions for the given input.
1102+
1103+
.. code-block:: python
1104+
1105+
# This snippet has been automatically generated and should be regarded as a
1106+
# code template only.
1107+
# It will require modifications to work:
1108+
# - It may require correct/in-range values for request initialization.
1109+
# - It may require specifying regional endpoints when creating the service
1110+
# client as shown in:
1111+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
1112+
from google.maps import places_v1
1113+
1114+
def sample_autocomplete_places():
1115+
# Create a client
1116+
client = places_v1.PlacesClient()
1117+
1118+
# Initialize request argument(s)
1119+
request = places_v1.AutocompletePlacesRequest(
1120+
input="input_value",
1121+
)
1122+
1123+
# Make the request
1124+
response = client.autocomplete_places(request=request)
1125+
1126+
# Handle the response
1127+
print(response)
1128+
1129+
Args:
1130+
request (Union[google.maps.places_v1.types.AutocompletePlacesRequest, dict]):
1131+
The request object. Request proto for AutocompletePlaces.
1132+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
1133+
should be retried.
1134+
timeout (float): The timeout for this request.
1135+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1136+
sent along with the request as metadata.
1137+
1138+
Returns:
1139+
google.maps.places_v1.types.AutocompletePlacesResponse:
1140+
Response proto for
1141+
AutocompletePlaces.
1142+
1143+
"""
1144+
# Create or coerce a protobuf request object.
1145+
# Minor optimization to avoid making a copy if the user passes
1146+
# in a places_service.AutocompletePlacesRequest.
1147+
# There's no risk of modifying the input as we've already verified
1148+
# there are no flattened fields.
1149+
if not isinstance(request, places_service.AutocompletePlacesRequest):
1150+
request = places_service.AutocompletePlacesRequest(request)
1151+
1152+
# Wrap the RPC method; this adds retry and timeout information,
1153+
# and friendly error handling.
1154+
rpc = self._transport._wrapped_methods[self._transport.autocomplete_places]
1155+
1156+
# Validate the universe domain.
1157+
self._validate_universe_domain()
1158+
1159+
# Send the request.
1160+
response = rpc(
1161+
request,
1162+
retry=retry,
1163+
timeout=timeout,
1164+
metadata=metadata,
1165+
)
1166+
1167+
# Done; return the response.
1168+
return response
1169+
10931170
def __enter__(self) -> "PlacesClient":
10941171
return self
10951172

packages/google-maps-places/google/maps/places_v1/services/places/transports/base.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ def _prep_wrapped_messages(self, client_info):
146146
default_timeout=None,
147147
client_info=client_info,
148148
),
149+
self.autocomplete_places: gapic_v1.method.wrap_method(
150+
self.autocomplete_places,
151+
default_timeout=None,
152+
client_info=client_info,
153+
),
149154
}
150155

151156
def close(self):
@@ -198,6 +203,18 @@ def get_place(
198203
]:
199204
raise NotImplementedError()
200205

206+
@property
207+
def autocomplete_places(
208+
self,
209+
) -> Callable[
210+
[places_service.AutocompletePlacesRequest],
211+
Union[
212+
places_service.AutocompletePlacesResponse,
213+
Awaitable[places_service.AutocompletePlacesResponse],
214+
],
215+
]:
216+
raise NotImplementedError()
217+
201218
@property
202219
def kind(self) -> str:
203220
raise NotImplementedError()

packages/google-maps-places/google/maps/places_v1/services/places/transports/grpc.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ def get_photo_media(
318318
def get_place(self) -> Callable[[places_service.GetPlaceRequest], place.Place]:
319319
r"""Return a callable for the get place method over gRPC.
320320
321-
Get place details with a place id (in a name) string.
321+
Get the details of a place based on its resource name, which is
322+
a string in the ``places/{place_id}`` format.
322323
323324
Returns:
324325
Callable[[~.GetPlaceRequest],
@@ -338,6 +339,35 @@ def get_place(self) -> Callable[[places_service.GetPlaceRequest], place.Place]:
338339
)
339340
return self._stubs["get_place"]
340341

342+
@property
343+
def autocomplete_places(
344+
self,
345+
) -> Callable[
346+
[places_service.AutocompletePlacesRequest],
347+
places_service.AutocompletePlacesResponse,
348+
]:
349+
r"""Return a callable for the autocomplete places method over gRPC.
350+
351+
Returns predictions for the given input.
352+
353+
Returns:
354+
Callable[[~.AutocompletePlacesRequest],
355+
~.AutocompletePlacesResponse]:
356+
A function that, when called, will call the underlying RPC
357+
on the server.
358+
"""
359+
# Generate a "stub function" on-the-fly which will actually make
360+
# the request.
361+
# gRPC handles serialization and deserialization, so we just need
362+
# to pass in the functions for each.
363+
if "autocomplete_places" not in self._stubs:
364+
self._stubs["autocomplete_places"] = self.grpc_channel.unary_unary(
365+
"/google.maps.places.v1.Places/AutocompletePlaces",
366+
request_serializer=places_service.AutocompletePlacesRequest.serialize,
367+
response_deserializer=places_service.AutocompletePlacesResponse.deserialize,
368+
)
369+
return self._stubs["autocomplete_places"]
370+
341371
def close(self):
342372
self.grpc_channel.close()
343373

0 commit comments

Comments
 (0)