googleapis / google-cloud-java

Google Cloud Client Library for Java
https://cloud.google.com/java/docs/reference
Apache License 2.0
1.86k stars 1.06k forks source link

Setting fields to return with AsyncGetPlace #10945

Open hybp opened 3 weeks ago

hybp commented 3 weeks ago

Here is a sample usage getting the place details using the client.

import com.google.api.core.ApiFuture;
import com.google.maps.places.v1.GetPlaceRequest;
import com.google.maps.places.v1.Place;
import com.google.maps.places.v1.PlaceName;
import com.google.maps.places.v1.PlacesClient;

public class AsyncGetPlace {

  public static void main(String[] args) throws Exception {
    asyncGetPlace();
  }

  public static void asyncGetPlace() throws Exception {
    // 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()) {
      GetPlaceRequest request =
          GetPlaceRequest.newBuilder()
              .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.
      Place response = future.get();
    }
  }
}

I am not sure how to set the fields that I want (e.g., displayName, shortFormattedAddress, location, ...).

Same goes for SearchNearby and SearchText.

I found a github issue about this for google-cloud-python, but I couldn't find one for Java.

Thanks in advance.

nicolasjandre commented 2 days ago

I'm also facing the same issue, do you was able to figure out?