Class GeoLocationAsyncClient

java.lang.Object
com.azure.maps.geolocation.GeoLocationAsyncClient

public final class GeoLocationAsyncClient extends Object
Initializes a new instance of the asynchronous GeoLocationClient type. Creating an async client using a AzureKeyCredential:
 // Authenticates using subscription key
 AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY"));

 // Creates an async client
 GeoLocationAsyncClient asyncClient = new GeoLocationClientBuilder()
     .credential(keyCredential)
     .buildAsyncClient();
 
Creating an async client using a TokenCredential:
 // Authenticates using Azure AD building a default credential
 // This will look for AZURE_CLIENT_ID, AZURE_TENANT_ID, and AZURE_CLIENT_SECRET env variables
 DefaultAzureCredential tokenCredential = new DefaultAzureCredentialBuilder().build();

 // Creates an async client
 GeoLocationAsyncClient asyncClient = new GeoLocationClientBuilder()
     .credential(tokenCredential)
     .buildAsyncClient();
 
  • Method Details

    • getLocation

      public Mono<IpAddressToLocationResult> getLocation(String ipAddress)
      Get Location
       asyncClient.getLocation("131.107.0.89");
       
      **Applies to**: S0 and S1 pricing tiers.

      This service will return the ISO country code for the provided IP address. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.

      Parameters:
      ipAddress - The IP address. Both IPv4 and IPv6 are allowed.
      Returns:
      this object is returned from a successful call to IP Address to country/region API.
      Throws:
      IllegalArgumentException - thrown if parameters fail the validation.
      com.azure.core.exception.HttpResponseException - thrown if the request is rejected by server.
      RuntimeException - all other wrapped checked exceptions if the request fails to be sent.
    • getLocationWithResponse

      public Mono<com.azure.core.http.rest.Response<IpAddressToLocationResult>> getLocationWithResponse(String ipAddress)
      Get Location
       asyncClient.getLocation("131.107.0.89");
       
      **Applies to**: S0 and S1 pricing tiers.

      This service will return the ISO country code for the provided IP address. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.

      Parameters:
      ipAddress - The IP address. Both IPv4 and IPv6 are allowed.
      Returns:
      this object is returned from a successful call to IP Address to country/region API.
      Throws:
      IllegalArgumentException - thrown if parameters fail the validation.
      com.azure.core.exception.HttpResponseException - thrown if the request is rejected by server.
      RuntimeException - all other wrapped checked exceptions if the request fails to be sent.