Skip to content

Commit

Permalink
feat: [maps-places] add AutoComplete API (#10403)
Browse files Browse the repository at this point in the history
* feat: add AutoComplete API
feat: add Searchable EV feature to TextSearch API

PiperOrigin-RevId: 608184544

Source-Link: googleapis/googleapis@3049b76

Source-Link: googleapis/googleapis-gen@2cac391
Copy-Tag: eyJwIjoiamF2YS1tYXBzLXBsYWNlcy8uT3dsQm90LnlhbWwiLCJoIjoiMmNhYzM5MWFjOGE1NjBlOTAzMWMxYzUwMmNhMDhkNjJmYWFkMzVhYiJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed Feb 20, 2024
1 parent 973716d commit 20075da
Show file tree
Hide file tree
Showing 31 changed files with 19,342 additions and 141 deletions.
Expand Up @@ -115,7 +115,7 @@
* </tr>
* <tr>
* <td><p> GetPlace</td>
* <td><p> Get place details with a place id (in a name) string.</td>
* <td><p> Get the details of a place based on its resource name, which is a string in the `places/{place_id}` format.</td>
* <td>
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
* <ul>
Expand All @@ -132,6 +132,20 @@
* </ul>
* </td>
* </tr>
* <tr>
* <td><p> AutocompletePlaces</td>
* <td><p> Returns predictions for the given input.</td>
* <td>
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
* <ul>
* <li><p> autocompletePlaces(AutocompletePlacesRequest request)
* </ul>
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
* <ul>
* <li><p> autocompletePlacesCallable()
* </ul>
* </td>
* </tr>
* </table>
*
* <p>See the individual methods for example code.
Expand Down Expand Up @@ -329,6 +343,7 @@ public final UnaryCallable<SearchNearbyRequest, SearchNearbyResponse> searchNear
* .setStrictTypeFiltering(true)
* .setLocationBias(SearchTextRequest.LocationBias.newBuilder().build())
* .setLocationRestriction(SearchTextRequest.LocationRestriction.newBuilder().build())
* .setEvOptions(SearchTextRequest.EVOptions.newBuilder().build())
* .build();
* SearchTextResponse response = placesClient.searchText(request);
* }
Expand Down Expand Up @@ -367,6 +382,7 @@ public final SearchTextResponse searchText(SearchTextRequest request) {
* .setStrictTypeFiltering(true)
* .setLocationBias(SearchTextRequest.LocationBias.newBuilder().build())
* .setLocationRestriction(SearchTextRequest.LocationRestriction.newBuilder().build())
* .setEvOptions(SearchTextRequest.EVOptions.newBuilder().build())
* .build();
* ApiFuture<SearchTextResponse> future = placesClient.searchTextCallable().futureCall(request);
* // Do something.
Expand Down Expand Up @@ -502,7 +518,8 @@ public final UnaryCallable<GetPhotoMediaRequest, PhotoMedia> getPhotoMediaCallab

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Get place details with a place id (in a name) string.
* Get the details of a place based on its resource name, which is a string in the
* `places/{place_id}` format.
*
* <p>Sample code:
*
Expand All @@ -518,8 +535,7 @@ public final UnaryCallable<GetPhotoMediaRequest, PhotoMedia> getPhotoMediaCallab
* }
* }</pre>
*
* @param name Required. A place ID returned in a Place (with "places/" prefix), or equivalently
* the name in the same Place. Format: `places/{place_id}`.
* @param name Required. The resource name of a place, in the `places/{place_id}` format.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Place getPlace(PlaceName name) {
Expand All @@ -530,7 +546,8 @@ public final Place getPlace(PlaceName name) {

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Get place details with a place id (in a name) string.
* Get the details of a place based on its resource name, which is a string in the
* `places/{place_id}` format.
*
* <p>Sample code:
*
Expand All @@ -546,8 +563,7 @@ public final Place getPlace(PlaceName name) {
* }
* }</pre>
*
* @param name Required. A place ID returned in a Place (with "places/" prefix), or equivalently
* the name in the same Place. Format: `places/{place_id}`.
* @param name Required. The resource name of a place, in the `places/{place_id}` format.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Place getPlace(String name) {
Expand All @@ -557,7 +573,8 @@ public final Place getPlace(String name) {

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Get place details with a place id (in a name) string.
* Get the details of a place based on its resource name, which is a string in the
* `places/{place_id}` format.
*
* <p>Sample code:
*
Expand All @@ -573,6 +590,7 @@ public final Place getPlace(String name) {
* .setName(PlaceName.of("[PLACE_ID]").toString())
* .setLanguageCode("languageCode-2092349083")
* .setRegionCode("regionCode-1991004415")
* .setSessionToken("sessionToken-696552189")
* .build();
* Place response = placesClient.getPlace(request);
* }
Expand All @@ -587,7 +605,8 @@ public final Place getPlace(GetPlaceRequest request) {

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Get place details with a place id (in a name) string.
* Get the details of a place based on its resource name, which is a string in the
* `places/{place_id}` format.
*
* <p>Sample code:
*
Expand All @@ -603,6 +622,7 @@ public final Place getPlace(GetPlaceRequest request) {
* .setName(PlaceName.of("[PLACE_ID]").toString())
* .setLanguageCode("languageCode-2092349083")
* .setRegionCode("regionCode-1991004415")
* .setSessionToken("sessionToken-696552189")
* .build();
* ApiFuture<Place> future = placesClient.getPlaceCallable().futureCall(request);
* // Do something.
Expand All @@ -614,6 +634,85 @@ public final UnaryCallable<GetPlaceRequest, Place> getPlaceCallable() {
return stub.getPlaceCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns predictions for the given input.
*
* <p>Sample code:
*
* <pre>{@code
* // 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (PlacesClient placesClient = PlacesClient.create()) {
* AutocompletePlacesRequest request =
* AutocompletePlacesRequest.newBuilder()
* .setInput("input100358090")
* .setLocationBias(AutocompletePlacesRequest.LocationBias.newBuilder().build())
* .setLocationRestriction(
* AutocompletePlacesRequest.LocationRestriction.newBuilder().build())
* .addAllIncludedPrimaryTypes(new ArrayList<String>())
* .addAllIncludedRegionCodes(new ArrayList<String>())
* .setLanguageCode("languageCode-2092349083")
* .setRegionCode("regionCode-1991004415")
* .setOrigin(LatLng.newBuilder().build())
* .setInputOffset(1010406056)
* .setIncludeQueryPredictions(true)
* .setSessionToken("sessionToken-696552189")
* .build();
* AutocompletePlacesResponse response = placesClient.autocompletePlaces(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final AutocompletePlacesResponse autocompletePlaces(AutocompletePlacesRequest request) {
return autocompletePlacesCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns predictions for the given input.
*
* <p>Sample code:
*
* <pre>{@code
* // 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (PlacesClient placesClient = PlacesClient.create()) {
* AutocompletePlacesRequest request =
* AutocompletePlacesRequest.newBuilder()
* .setInput("input100358090")
* .setLocationBias(AutocompletePlacesRequest.LocationBias.newBuilder().build())
* .setLocationRestriction(
* AutocompletePlacesRequest.LocationRestriction.newBuilder().build())
* .addAllIncludedPrimaryTypes(new ArrayList<String>())
* .addAllIncludedRegionCodes(new ArrayList<String>())
* .setLanguageCode("languageCode-2092349083")
* .setRegionCode("regionCode-1991004415")
* .setOrigin(LatLng.newBuilder().build())
* .setInputOffset(1010406056)
* .setIncludeQueryPredictions(true)
* .setSessionToken("sessionToken-696552189")
* .build();
* ApiFuture<AutocompletePlacesResponse> future =
* placesClient.autocompletePlacesCallable().futureCall(request);
* // Do something.
* AutocompletePlacesResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<AutocompletePlacesRequest, AutocompletePlacesResponse>
autocompletePlacesCallable() {
return stub.autocompletePlacesCallable();
}

@Override
public final void close() {
stub.close();
Expand Down
Expand Up @@ -91,6 +91,12 @@ public UnaryCallSettings<GetPlaceRequest, Place> getPlaceSettings() {
return ((PlacesStubSettings) getStubSettings()).getPlaceSettings();
}

/** Returns the object with the settings used for calls to autocompletePlaces. */
public UnaryCallSettings<AutocompletePlacesRequest, AutocompletePlacesResponse>
autocompletePlacesSettings() {
return ((PlacesStubSettings) getStubSettings()).autocompletePlacesSettings();
}

public static final PlacesSettings create(PlacesStubSettings stub) throws IOException {
return new PlacesSettings.Builder(stub.toBuilder()).build();
}
Expand Down Expand Up @@ -225,6 +231,12 @@ public UnaryCallSettings.Builder<GetPlaceRequest, Place> getPlaceSettings() {
return getStubSettingsBuilder().getPlaceSettings();
}

/** Returns the builder for the settings used for calls to autocompletePlaces. */
public UnaryCallSettings.Builder<AutocompletePlacesRequest, AutocompletePlacesResponse>
autocompletePlacesSettings() {
return getStubSettingsBuilder().autocompletePlacesSettings();
}

@Override
public PlacesSettings build() throws IOException {
return new PlacesSettings(this);
Expand Down
Expand Up @@ -10,6 +10,9 @@
"grpc": {
"libraryClient": "PlacesClient",
"rpcs": {
"AutocompletePlaces": {
"methods": ["autocompletePlaces", "autocompletePlacesCallable"]
},
"GetPhotoMedia": {
"methods": ["getPhotoMedia", "getPhotoMedia", "getPhotoMedia", "getPhotoMediaCallable"]
},
Expand Down
Expand Up @@ -24,6 +24,8 @@
import com.google.api.gax.rpc.RequestParamsBuilder;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.longrunning.stub.GrpcOperationsStub;
import com.google.maps.places.v1.AutocompletePlacesRequest;
import com.google.maps.places.v1.AutocompletePlacesResponse;
import com.google.maps.places.v1.GetPhotoMediaRequest;
import com.google.maps.places.v1.GetPlaceRequest;
import com.google.maps.places.v1.PhotoMedia;
Expand Down Expand Up @@ -83,10 +85,23 @@ public class GrpcPlacesStub extends PlacesStub {
.setResponseMarshaller(ProtoUtils.marshaller(Place.getDefaultInstance()))
.build();

private static final MethodDescriptor<AutocompletePlacesRequest, AutocompletePlacesResponse>
autocompletePlacesMethodDescriptor =
MethodDescriptor.<AutocompletePlacesRequest, AutocompletePlacesResponse>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.maps.places.v1.Places/AutocompletePlaces")
.setRequestMarshaller(
ProtoUtils.marshaller(AutocompletePlacesRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(AutocompletePlacesResponse.getDefaultInstance()))
.build();

private final UnaryCallable<SearchNearbyRequest, SearchNearbyResponse> searchNearbyCallable;
private final UnaryCallable<SearchTextRequest, SearchTextResponse> searchTextCallable;
private final UnaryCallable<GetPhotoMediaRequest, PhotoMedia> getPhotoMediaCallable;
private final UnaryCallable<GetPlaceRequest, Place> getPlaceCallable;
private final UnaryCallable<AutocompletePlacesRequest, AutocompletePlacesResponse>
autocompletePlacesCallable;

private final BackgroundResource backgroundResources;
private final GrpcOperationsStub operationsStub;
Expand Down Expand Up @@ -155,6 +170,11 @@ protected GrpcPlacesStub(
return builder.build();
})
.build();
GrpcCallSettings<AutocompletePlacesRequest, AutocompletePlacesResponse>
autocompletePlacesTransportSettings =
GrpcCallSettings.<AutocompletePlacesRequest, AutocompletePlacesResponse>newBuilder()
.setMethodDescriptor(autocompletePlacesMethodDescriptor)
.build();

this.searchNearbyCallable =
callableFactory.createUnaryCallable(
Expand All @@ -168,6 +188,11 @@ protected GrpcPlacesStub(
this.getPlaceCallable =
callableFactory.createUnaryCallable(
getPlaceTransportSettings, settings.getPlaceSettings(), clientContext);
this.autocompletePlacesCallable =
callableFactory.createUnaryCallable(
autocompletePlacesTransportSettings,
settings.autocompletePlacesSettings(),
clientContext);

this.backgroundResources =
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
Expand Down Expand Up @@ -197,6 +222,12 @@ public UnaryCallable<GetPlaceRequest, Place> getPlaceCallable() {
return getPlaceCallable;
}

@Override
public UnaryCallable<AutocompletePlacesRequest, AutocompletePlacesResponse>
autocompletePlacesCallable() {
return autocompletePlacesCallable;
}

@Override
public final void close() {
try {
Expand Down

0 comments on commit 20075da

Please sign in to comment.