Skip to content

Commit 20075da

Browse files
feat: [maps-places] add AutoComplete API (#10403)
* feat: add AutoComplete API 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: 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>
1 parent 973716d commit 20075da

File tree

31 files changed

+19342
-141
lines changed

31 files changed

+19342
-141
lines changed

java-maps-places/google-maps-places/src/main/java/com/google/maps/places/v1/PlacesClient.java

Lines changed: 108 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
* </tr>
116116
* <tr>
117117
* <td><p> GetPlace</td>
118-
* <td><p> Get place details with a place id (in a name) string.</td>
118+
* <td><p> Get the details of a place based on its resource name, which is a string in the `places/{place_id}` format.</td>
119119
* <td>
120120
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
121121
* <ul>
@@ -132,6 +132,20 @@
132132
* </ul>
133133
* </td>
134134
* </tr>
135+
* <tr>
136+
* <td><p> AutocompletePlaces</td>
137+
* <td><p> Returns predictions for the given input.</td>
138+
* <td>
139+
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
140+
* <ul>
141+
* <li><p> autocompletePlaces(AutocompletePlacesRequest request)
142+
* </ul>
143+
* <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>
144+
* <ul>
145+
* <li><p> autocompletePlacesCallable()
146+
* </ul>
147+
* </td>
148+
* </tr>
135149
* </table>
136150
*
137151
* <p>See the individual methods for example code.
@@ -329,6 +343,7 @@ public final UnaryCallable<SearchNearbyRequest, SearchNearbyResponse> searchNear
329343
* .setStrictTypeFiltering(true)
330344
* .setLocationBias(SearchTextRequest.LocationBias.newBuilder().build())
331345
* .setLocationRestriction(SearchTextRequest.LocationRestriction.newBuilder().build())
346+
* .setEvOptions(SearchTextRequest.EVOptions.newBuilder().build())
332347
* .build();
333348
* SearchTextResponse response = placesClient.searchText(request);
334349
* }
@@ -367,6 +382,7 @@ public final SearchTextResponse searchText(SearchTextRequest request) {
367382
* .setStrictTypeFiltering(true)
368383
* .setLocationBias(SearchTextRequest.LocationBias.newBuilder().build())
369384
* .setLocationRestriction(SearchTextRequest.LocationRestriction.newBuilder().build())
385+
* .setEvOptions(SearchTextRequest.EVOptions.newBuilder().build())
370386
* .build();
371387
* ApiFuture<SearchTextResponse> future = placesClient.searchTextCallable().futureCall(request);
372388
* // Do something.
@@ -502,7 +518,8 @@ public final UnaryCallable<GetPhotoMediaRequest, PhotoMedia> getPhotoMediaCallab
502518

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

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

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

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

637+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
638+
/**
639+
* Returns predictions for the given input.
640+
*
641+
* <p>Sample code:
642+
*
643+
* <pre>{@code
644+
* // This snippet has been automatically generated and should be regarded as a code template only.
645+
* // It will require modifications to work:
646+
* // - It may require correct/in-range values for request initialization.
647+
* // - It may require specifying regional endpoints when creating the service client as shown in
648+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
649+
* try (PlacesClient placesClient = PlacesClient.create()) {
650+
* AutocompletePlacesRequest request =
651+
* AutocompletePlacesRequest.newBuilder()
652+
* .setInput("input100358090")
653+
* .setLocationBias(AutocompletePlacesRequest.LocationBias.newBuilder().build())
654+
* .setLocationRestriction(
655+
* AutocompletePlacesRequest.LocationRestriction.newBuilder().build())
656+
* .addAllIncludedPrimaryTypes(new ArrayList<String>())
657+
* .addAllIncludedRegionCodes(new ArrayList<String>())
658+
* .setLanguageCode("languageCode-2092349083")
659+
* .setRegionCode("regionCode-1991004415")
660+
* .setOrigin(LatLng.newBuilder().build())
661+
* .setInputOffset(1010406056)
662+
* .setIncludeQueryPredictions(true)
663+
* .setSessionToken("sessionToken-696552189")
664+
* .build();
665+
* AutocompletePlacesResponse response = placesClient.autocompletePlaces(request);
666+
* }
667+
* }</pre>
668+
*
669+
* @param request The request object containing all of the parameters for the API call.
670+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
671+
*/
672+
public final AutocompletePlacesResponse autocompletePlaces(AutocompletePlacesRequest request) {
673+
return autocompletePlacesCallable().call(request);
674+
}
675+
676+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
677+
/**
678+
* Returns predictions for the given input.
679+
*
680+
* <p>Sample code:
681+
*
682+
* <pre>{@code
683+
* // This snippet has been automatically generated and should be regarded as a code template only.
684+
* // It will require modifications to work:
685+
* // - It may require correct/in-range values for request initialization.
686+
* // - It may require specifying regional endpoints when creating the service client as shown in
687+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
688+
* try (PlacesClient placesClient = PlacesClient.create()) {
689+
* AutocompletePlacesRequest request =
690+
* AutocompletePlacesRequest.newBuilder()
691+
* .setInput("input100358090")
692+
* .setLocationBias(AutocompletePlacesRequest.LocationBias.newBuilder().build())
693+
* .setLocationRestriction(
694+
* AutocompletePlacesRequest.LocationRestriction.newBuilder().build())
695+
* .addAllIncludedPrimaryTypes(new ArrayList<String>())
696+
* .addAllIncludedRegionCodes(new ArrayList<String>())
697+
* .setLanguageCode("languageCode-2092349083")
698+
* .setRegionCode("regionCode-1991004415")
699+
* .setOrigin(LatLng.newBuilder().build())
700+
* .setInputOffset(1010406056)
701+
* .setIncludeQueryPredictions(true)
702+
* .setSessionToken("sessionToken-696552189")
703+
* .build();
704+
* ApiFuture<AutocompletePlacesResponse> future =
705+
* placesClient.autocompletePlacesCallable().futureCall(request);
706+
* // Do something.
707+
* AutocompletePlacesResponse response = future.get();
708+
* }
709+
* }</pre>
710+
*/
711+
public final UnaryCallable<AutocompletePlacesRequest, AutocompletePlacesResponse>
712+
autocompletePlacesCallable() {
713+
return stub.autocompletePlacesCallable();
714+
}
715+
617716
@Override
618717
public final void close() {
619718
stub.close();

java-maps-places/google-maps-places/src/main/java/com/google/maps/places/v1/PlacesSettings.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ public UnaryCallSettings<GetPlaceRequest, Place> getPlaceSettings() {
9191
return ((PlacesStubSettings) getStubSettings()).getPlaceSettings();
9292
}
9393

94+
/** Returns the object with the settings used for calls to autocompletePlaces. */
95+
public UnaryCallSettings<AutocompletePlacesRequest, AutocompletePlacesResponse>
96+
autocompletePlacesSettings() {
97+
return ((PlacesStubSettings) getStubSettings()).autocompletePlacesSettings();
98+
}
99+
94100
public static final PlacesSettings create(PlacesStubSettings stub) throws IOException {
95101
return new PlacesSettings.Builder(stub.toBuilder()).build();
96102
}
@@ -225,6 +231,12 @@ public UnaryCallSettings.Builder<GetPlaceRequest, Place> getPlaceSettings() {
225231
return getStubSettingsBuilder().getPlaceSettings();
226232
}
227233

234+
/** Returns the builder for the settings used for calls to autocompletePlaces. */
235+
public UnaryCallSettings.Builder<AutocompletePlacesRequest, AutocompletePlacesResponse>
236+
autocompletePlacesSettings() {
237+
return getStubSettingsBuilder().autocompletePlacesSettings();
238+
}
239+
228240
@Override
229241
public PlacesSettings build() throws IOException {
230242
return new PlacesSettings(this);

java-maps-places/google-maps-places/src/main/java/com/google/maps/places/v1/gapic_metadata.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"grpc": {
1111
"libraryClient": "PlacesClient",
1212
"rpcs": {
13+
"AutocompletePlaces": {
14+
"methods": ["autocompletePlaces", "autocompletePlacesCallable"]
15+
},
1316
"GetPhotoMedia": {
1417
"methods": ["getPhotoMedia", "getPhotoMedia", "getPhotoMedia", "getPhotoMediaCallable"]
1518
},

java-maps-places/google-maps-places/src/main/java/com/google/maps/places/v1/stub/GrpcPlacesStub.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import com.google.api.gax.rpc.RequestParamsBuilder;
2525
import com.google.api.gax.rpc.UnaryCallable;
2626
import com.google.longrunning.stub.GrpcOperationsStub;
27+
import com.google.maps.places.v1.AutocompletePlacesRequest;
28+
import com.google.maps.places.v1.AutocompletePlacesResponse;
2729
import com.google.maps.places.v1.GetPhotoMediaRequest;
2830
import com.google.maps.places.v1.GetPlaceRequest;
2931
import com.google.maps.places.v1.PhotoMedia;
@@ -83,10 +85,23 @@ public class GrpcPlacesStub extends PlacesStub {
8385
.setResponseMarshaller(ProtoUtils.marshaller(Place.getDefaultInstance()))
8486
.build();
8587

88+
private static final MethodDescriptor<AutocompletePlacesRequest, AutocompletePlacesResponse>
89+
autocompletePlacesMethodDescriptor =
90+
MethodDescriptor.<AutocompletePlacesRequest, AutocompletePlacesResponse>newBuilder()
91+
.setType(MethodDescriptor.MethodType.UNARY)
92+
.setFullMethodName("google.maps.places.v1.Places/AutocompletePlaces")
93+
.setRequestMarshaller(
94+
ProtoUtils.marshaller(AutocompletePlacesRequest.getDefaultInstance()))
95+
.setResponseMarshaller(
96+
ProtoUtils.marshaller(AutocompletePlacesResponse.getDefaultInstance()))
97+
.build();
98+
8699
private final UnaryCallable<SearchNearbyRequest, SearchNearbyResponse> searchNearbyCallable;
87100
private final UnaryCallable<SearchTextRequest, SearchTextResponse> searchTextCallable;
88101
private final UnaryCallable<GetPhotoMediaRequest, PhotoMedia> getPhotoMediaCallable;
89102
private final UnaryCallable<GetPlaceRequest, Place> getPlaceCallable;
103+
private final UnaryCallable<AutocompletePlacesRequest, AutocompletePlacesResponse>
104+
autocompletePlacesCallable;
90105

91106
private final BackgroundResource backgroundResources;
92107
private final GrpcOperationsStub operationsStub;
@@ -155,6 +170,11 @@ protected GrpcPlacesStub(
155170
return builder.build();
156171
})
157172
.build();
173+
GrpcCallSettings<AutocompletePlacesRequest, AutocompletePlacesResponse>
174+
autocompletePlacesTransportSettings =
175+
GrpcCallSettings.<AutocompletePlacesRequest, AutocompletePlacesResponse>newBuilder()
176+
.setMethodDescriptor(autocompletePlacesMethodDescriptor)
177+
.build();
158178

159179
this.searchNearbyCallable =
160180
callableFactory.createUnaryCallable(
@@ -168,6 +188,11 @@ protected GrpcPlacesStub(
168188
this.getPlaceCallable =
169189
callableFactory.createUnaryCallable(
170190
getPlaceTransportSettings, settings.getPlaceSettings(), clientContext);
191+
this.autocompletePlacesCallable =
192+
callableFactory.createUnaryCallable(
193+
autocompletePlacesTransportSettings,
194+
settings.autocompletePlacesSettings(),
195+
clientContext);
171196

172197
this.backgroundResources =
173198
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
@@ -197,6 +222,12 @@ public UnaryCallable<GetPlaceRequest, Place> getPlaceCallable() {
197222
return getPlaceCallable;
198223
}
199224

225+
@Override
226+
public UnaryCallable<AutocompletePlacesRequest, AutocompletePlacesResponse>
227+
autocompletePlacesCallable() {
228+
return autocompletePlacesCallable;
229+
}
230+
200231
@Override
201232
public final void close() {
202233
try {

0 commit comments

Comments
 (0)