From c23633aca43f76101f441cf84c3c9e271b472f16 Mon Sep 17 00:00:00 2001 From: Katherine <96520421+khmic5@users.noreply.github.com> Date: Thu, 13 Oct 2022 14:21:26 -0700 Subject: [PATCH] Azure Maps Elevation Java SDK (#31279) * Add Azure Maps Elevation Java SDK --- eng/versioning/version_client.txt | 1 + sdk/maps/azure-maps-elevation/CHANGELOG.md | 5 + sdk/maps/azure-maps-elevation/README.md | 125 ++ sdk/maps/azure-maps-elevation/ci.yml | 35 + sdk/maps/azure-maps-elevation/pom.xml | 104 ++ .../maps/elevation/ElevationAsyncClient.java | 443 ++++++ .../azure/maps/elevation/ElevationClient.java | 284 ++++ .../elevation/ElevationClientBuilder.java | 386 ++++++ .../elevation/ElevationServiceVersion.java | 44 + .../implementation/ElevationClientImpl.java | 156 +++ .../ElevationClientImplBuilder.java | 305 ++++ .../implementation/ElevationsImpl.java | 1229 +++++++++++++++++ .../implementation/helpers/Utility.java | 35 + .../implementation/models/Elevation.java | 53 + .../models/ErrorAdditionalInfo.java | 42 + .../implementation/models/ErrorDetail.java | 88 ++ .../implementation/models/ErrorResponse.java | 41 + .../models/ErrorResponseException.java | 37 + .../implementation/models/JsonFormat.java | 35 + .../implementation/models/LatLongPair.java | 64 + .../models/LatLongPairAbbreviated.java | 64 + .../implementation/models/package-info.java | 14 + .../implementation/package-info.java | 14 + .../elevation/models/ElevationResult.java | 44 + .../maps/elevation/models/package-info.java | 14 + .../azure/maps/elevation/package-info.java | 14 + .../src/main/java/module-info.java | 13 + .../elevation/samples/ElevationSample.java | 76 + .../samples/GetDataForBoundingBox.java | 71 + .../elevation/samples/GetDataForPoints.java | 66 + .../elevation/samples/GetDataForPolyline.java | 72 + .../elevation/ElevationAsyncClientTest.java | 179 +++ .../elevation/ElevationClientBuilderTest.java | 97 ++ .../maps/elevation/ElevationClientTest.java | 124 ++ .../elevation/ElevationClientTestBase.java | 156 +++ .../com/azure/maps/elevation/TestUtils.java | 109 ++ .../test/resources/getdataforboundingbox.json | 67 + .../src/test/resources/getdataforpoints.json | 18 + .../test/resources/getdataforpolyline.json | 39 + .../src/test/resources/postdataforpoints.json | 18 + .../test/resources/postdataforpolyline.json | 39 + ...cGetDataForBoundingBoxWithResponse[1].json | 24 + ...est.testAsyncGetDataForBoundingBox[1].json | 24 + ...tAsyncGetDataForPointsWithResponse[1].json | 24 + ...ientTest.testAsyncGetDataForPoints[1].json | 24 + ...syncGetDataForPolylineWithResponse[1].json | 24 + ...ntTest.testAsyncGetDataForPolyline[1].json | 24 + ...dGetDataForBoundingBoxWithResponse[1].json | 24 + ...nvalidGetDataForPointsWithResponse[1].json | 24 + ...alidGetDataForPolylineWithResponse[1].json | 24 + ...tGetDataForBoundingBoxWithResponse[1].json | 24 + ...ientTest.testGetDataForBoundingBox[1].json | 24 + ...t.testGetDataForPointsWithResponse[1].json | 24 + ...ionClientTest.testGetDataForPoints[1].json | 24 + ...testGetDataForPolylineWithResponse[1].json | 24 + ...nClientTest.testGetDataForPolyline[1].json | 24 + ...dGetDataForBoundingBoxWithResponse[1].json | 24 + ...nvalidGetDataForPointsWithResponse[1].json | 24 + ...alidGetDataForPolylineWithResponse[1].json | 24 + .../azure-maps-elevation/swagger/README.md | 56 + sdk/maps/azure-maps-elevation/swagger/pom.xml | 31 + .../src/main/java/ElevationCustomization.java | 59 + sdk/maps/azure-maps-elevation/tests.yml | 7 + sdk/maps/pom.xml | 1 + 64 files changed, 5406 insertions(+) create mode 100644 sdk/maps/azure-maps-elevation/CHANGELOG.md create mode 100644 sdk/maps/azure-maps-elevation/README.md create mode 100644 sdk/maps/azure-maps-elevation/ci.yml create mode 100644 sdk/maps/azure-maps-elevation/pom.xml create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/ElevationAsyncClient.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/ElevationClient.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/ElevationClientBuilder.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/ElevationServiceVersion.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/ElevationClientImpl.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/ElevationClientImplBuilder.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/ElevationsImpl.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/helpers/Utility.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/Elevation.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/ErrorAdditionalInfo.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/ErrorDetail.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/ErrorResponse.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/ErrorResponseException.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/JsonFormat.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/LatLongPair.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/LatLongPairAbbreviated.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/package-info.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/package-info.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/models/ElevationResult.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/models/package-info.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/package-info.java create mode 100644 sdk/maps/azure-maps-elevation/src/main/java/module-info.java create mode 100644 sdk/maps/azure-maps-elevation/src/samples/java/com/azure/maps/elevation/samples/ElevationSample.java create mode 100644 sdk/maps/azure-maps-elevation/src/samples/java/com/azure/maps/elevation/samples/GetDataForBoundingBox.java create mode 100644 sdk/maps/azure-maps-elevation/src/samples/java/com/azure/maps/elevation/samples/GetDataForPoints.java create mode 100644 sdk/maps/azure-maps-elevation/src/samples/java/com/azure/maps/elevation/samples/GetDataForPolyline.java create mode 100644 sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/ElevationAsyncClientTest.java create mode 100644 sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/ElevationClientBuilderTest.java create mode 100644 sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/ElevationClientTest.java create mode 100644 sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/ElevationClientTestBase.java create mode 100644 sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/TestUtils.java create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/getdataforboundingbox.json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/getdataforpoints.json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/getdataforpolyline.json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/postdataforpoints.json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/postdataforpolyline.json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForBoundingBoxWithResponse[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForBoundingBox[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForPointsWithResponse[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForPoints[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForPolylineWithResponse[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForPolyline[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncInvalidGetDataForBoundingBoxWithResponse[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncInvalidGetDataForPointsWithResponse[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncInvalidGetDataForPolylineWithResponse[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForBoundingBoxWithResponse[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForBoundingBox[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForPointsWithResponse[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForPoints[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForPolylineWithResponse[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForPolyline[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testInvalidGetDataForBoundingBoxWithResponse[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testInvalidGetDataForPointsWithResponse[1].json create mode 100644 sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testInvalidGetDataForPolylineWithResponse[1].json create mode 100644 sdk/maps/azure-maps-elevation/swagger/README.md create mode 100644 sdk/maps/azure-maps-elevation/swagger/pom.xml create mode 100644 sdk/maps/azure-maps-elevation/swagger/src/main/java/ElevationCustomization.java create mode 100644 sdk/maps/azure-maps-elevation/tests.yml diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 2ffd2680dd596..9763ec3b88000 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -106,6 +106,7 @@ com.azure:azure-identity;1.6.1;1.7.0-beta.2 com.azure:azure-identity-perf;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-iot-deviceupdate;1.0.0;1.1.0-beta.1 com.azure:azure-iot-modelsrepository;1.0.0-beta.1;1.0.0-beta.2 +com.azure:azure-maps-elevation;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-maps-timezone;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-maps-geolocation;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-maps-render;1.0.0-beta.1;1.0.0-beta.2 diff --git a/sdk/maps/azure-maps-elevation/CHANGELOG.md b/sdk/maps/azure-maps-elevation/CHANGELOG.md new file mode 100644 index 0000000000000..2bb7d7175679e --- /dev/null +++ b/sdk/maps/azure-maps-elevation/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2022-10-11) + +- This package contains the Azure Maps SDK Elevation client library for Java. Package tag 1.0.0-beta.1. For documentation on how to use this package, please see [Microsoft Azure SDK for Elevation SDK](https://docs.microsoft.com/rest/api/maps/elevation). diff --git a/sdk/maps/azure-maps-elevation/README.md b/sdk/maps/azure-maps-elevation/README.md new file mode 100644 index 0000000000000..1eecac776b6a3 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/README.md @@ -0,0 +1,125 @@ +# Azure Maps SDK Elevation client library for Java + +Azure Maps SDK Elevation client library for Java. + +This package contains the Azure Maps SDK Elevation client library which contains Azure Maps Elevation APIs. For documentation on how to use this package, please see [Azure Maps Elevation REST APIs](https://docs.microsoft.com/rest/api/maps/elevation). + +[Source code][source] | [API reference documentation][docs] | [REST API documentation][rest_docs] | [Product documentation][product_docs] | [Samples][samples] + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure-maps-elevation;current}) +```xml + + com.azure.resourcemanager + azure-maps-elevation + 1.0.0-beta.1 + +``` +[//]: # ({x-version-update-end}) + +### Include the recommended packages + +Azure Management Libraries require a `TokenCredential` implementation for authentication and an `HttpClient` implementation for HTTP client. + +[Azure Identity][azure_identity] package and [Azure Core Netty HTTP][azure_core_http_netty] package provide the default implementation. + +### Authentication + +By default, Azure Active Directory token authentication depends on correct configure of following environment variables. + +- `AZURE_CLIENT_ID` for Azure client ID. +- `AZURE_TENANT_ID` for Azure tenant ID. +- `AZURE_CLIENT_SECRET` or `AZURE_CLIENT_CERTIFICATE_PATH` for client secret or client certificate. + +In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`. + +With above configuration, `azure` client can be authenticated by following code: + +```java com.azure.maps.elevation.sync.builder.ad.instantiation +// 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 a client +ElevationClient client = new ElevationClientBuilder() + .credential(tokenCredential) + .elevationClientId(System.getenv("MAPS_CLIENT_ID")) + .buildClient(); +``` + +The sample code assumes global Azure. Please change `AzureEnvironment.AZURE` variable if otherwise. + +See [Authentication][authenticate] for more options. + +## Key concepts + +See [API design][design] for general introduction on design and key concepts on Azure Management Libraries. + +## Examples +Get Data For Points +```java com.azure.maps.elevation.sync.get_data_for_points +client.getDataForPoints(Arrays.asList( + new GeoPosition(-121.66853362143818, 46.84646479863713), + new GeoPosition(-121.68853362143818, 46.856464798637127))); +``` + +Get Data For Polyline +```java com.azure.maps.elevation.sync.get_data_for_polyline +client.getDataForPolyline(Arrays.asList( + new GeoPosition(-121.66853362143818, 46.84646479863713), + new GeoPosition(-121.65853362143818, 46.85646479863713)), 5); +``` + +Get Data For Bounding Box +```java com.azure.maps.elevation.sync.get_data_for_bounding_box +client.getDataForBoundingBox(new GeoBoundingBox(-121.668533621438, 46.8464647986371, + -121.658533621438, 46.8564647986371), 3, 3); +``` + +## Troubleshooting +When you interact with the Azure Maps Services, errors returned by the Maps service correspond to the same HTTP status codes returned for REST API requests. + +For example, if you search with an invalid coordinate, a error is returned, indicating "Bad Request".400 + +## Next steps +Several Azure Maps Elevation Java SDK samples are available to you in the SDK's GitHub repository. +[Azure Maps Elevation Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-elevation/src/samples) + +## Contributing + +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/master/CONTRIBUTING.md). + +1. Fork it +1. Create your feature branch (`git checkout -b my-new-feature`) +1. Commit your changes (`git commit -am 'Add some feature'`) +1. Push to the branch (`git push origin my-new-feature`) +1. Create new Pull Request + + +[source]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-elevation/src +[samples]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-elevation/src/samples +[rest_docs]: https://docs.microsoft.com/rest/api/maps +[product_docs]: https://docs.microsoft.com/azure/azure-maps/ +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://docs.microsoft.com/java/azure/jdk/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity +[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-http-netty +[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/AUTH.md +[design]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/DESIGN.md + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Fmaps%2Fazure-maps-elevation%2FREADME.png) diff --git a/sdk/maps/azure-maps-elevation/ci.yml b/sdk/maps/azure-maps-elevation/ci.yml new file mode 100644 index 0000000000000..69cfef55837aa --- /dev/null +++ b/sdk/maps/azure-maps-elevation/ci.yml @@ -0,0 +1,35 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/maps/azure-maps-elevation/ + exclude: + - sdk/maps/azure-maps-elevation/pom.xml +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/maps/azure-maps-elevation/ + + exclude: + - sdk/maps/azure-maps-elevation/pom.xml + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: maps + Artifacts: + - name: azure-maps-elevation + groupId: com.azure + safeName: azuremapselevation diff --git a/sdk/maps/azure-maps-elevation/pom.xml b/sdk/maps/azure-maps-elevation/pom.xml new file mode 100644 index 0000000000000..97f7a0b60f20a --- /dev/null +++ b/sdk/maps/azure-maps-elevation/pom.xml @@ -0,0 +1,104 @@ + + + 4.0.0 + + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure + azure-maps-elevation + 1.0.0-beta.1 + jar + + Azure Maps SDK Elevation client library + This package contains the Microsoft Azure SDK for Elevation SDK. For documentation on how to use this package, please see https://docs.microsoft.com/en-us/rest/api/maps/elevation. The Azure Maps Elevation API provides an HTTP interface to query elevation data on the surface of the Earth. Elevation data can be retrieved at specific locations by sending lat/lon coordinates, by defining an ordered set of vertices that form a Polyline and a number of sample points along the length of a Polyline, or by defining a bounding box that consists of equally spaced vertices as rows and columns. The vertical datum is EPSG:3855. This datum uses the EGM2008 geoid model applied to the WGS84 ellipsoid as its zero height reference surface. The vertical unit is measured in meters, the spatial resolution of the elevation data is 0.8 arc-second for global coverage (~24 meters). Package tag 1.0-preview. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + + 0.4 + 0.2 + + + + com.azure + azure-core + 1.33.0 + + + com.azure + azure-core-http-netty + 1.12.6 + + + com.azure + azure-core-http-okhttp + 1.11.3 + test + + + com.azure + azure-identity + 1.6.1 + test + + + com.azure + azure-core-test + 1.12.1 + test + + + org.junit.jupiter + junit-jupiter-api + 5.8.2 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.8.2 + test + + + org.junit.jupiter + junit-jupiter-params + 5.8.2 + test + + + io.projectreactor + reactor-test + 3.4.23 + test + + + \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/ElevationAsyncClient.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/ElevationAsyncClient.java new file mode 100644 index 0000000000000..00b8b994cf2ce --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/ElevationAsyncClient.java @@ -0,0 +1,443 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.maps.elevation; + +import java.util.List; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.http.rest.Response; +import com.azure.core.models.GeoBoundingBox; +import com.azure.core.models.GeoPosition; +import com.azure.core.util.Context; +import com.azure.maps.elevation.implementation.ElevationsImpl; +import com.azure.maps.elevation.implementation.helpers.Utility; +import com.azure.maps.elevation.models.ElevationResult; +import com.azure.maps.elevation.implementation.models.JsonFormat; +import com.azure.maps.elevation.implementation.models.ErrorResponseException; + +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the asynchronous ElevationClient type. +* Creating an async client using a {@link com.azure.core.credential.AzureKeyCredential}: +* +*
+* // Authenticates using subscription key
+* AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY"));
+*
+* // Creates a client
+* ElevationAsyncClient asyncClient = new ElevationClientBuilder()
+*     .credential(keyCredential)
+*     .elevationClientId(System.getenv("MAPS_CLIENT_ID"))
+*     .buildAsyncClient();
+* 
+* +*/ +@ServiceClient(builder = ElevationClientBuilder.class, isAsync = true) +public final class ElevationAsyncClient { + private final ElevationsImpl serviceClient; + private static final int ELEVATION_DATA_SMALL_SIZE = 100; + + /** + * + * Initializes an instance of ElevationClient client. + * + * @param serviceClient the service client implementation. + */ + ElevationAsyncClient(ElevationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get Data For Points + * + *
+     * asyncClient.getDataForPoints(Arrays.asList(
+     *     new GeoPosition(-121.66853362143818, 46.84646479863713), 
+     *     new GeoPosition(-121.68853362143818, 46.856464798637127)));
+     * 
+ * + * + * **Applies to**: S1 pricing tier. + * + *

The Get Data for Points API provides elevation data for one or more points. A point is defined in lat,long + * coordinate format. + * + *

Due to the URL character length limit of 2048, it's not possible to pass more than 100 coordinates as a + * pipeline delimited string in a URL GET request. If you intend to pass more than 100 coordinates as a pipeline + * delimited string, use the [POST Data For + * Points](https://docs.microsoft.com/rest/api/maps/elevation/postdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. If multiple points are requested, each of the points in a list should be separated + * by the pipe ('|') character. The maximum number of points that can be requested in a single request is 2,000. + * The resolution of the elevation data will be the highest for a single point and will decrease if multiple + * points are spread further apart. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDataForPoints(List points) { + Mono> result = this.getDataForPointsWithResponse(points); + return result.flatMap(response -> { + return Mono.just(response.getValue()); + }); + } + + /** + * Get Data For Points + * + *

+     * asyncClient.getDataForPoints(Arrays.asList(
+     *     new GeoPosition(-121.66853362143818, 46.84646479863713), 
+     *     new GeoPosition(-121.68853362143818, 46.856464798637127)));
+     * 
+ * + * + * **Applies to**: S1 pricing tier. + * + *

The Get Data for Points API provides elevation data for one or more points. A point is defined in lat,long + * coordinate format. + * + *

Due to the URL character length limit of 2048, it's not possible to pass more than 100 coordinates as a + * pipeline delimited string in a URL GET request. If you intend to pass more than 100 coordinates as a pipeline + * delimited string, use the [POST Data For + * Points](https://docs.microsoft.com/rest/api/maps/elevation/postdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. If multiple points are requested, each of the points in a list should be separated + * by the pipe ('|') character. The maximum number of points that can be requested in a single request is 2,000. + * The resolution of the elevation data will be the highest for a single point and will decrease if multiple + * points are spread further apart. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDataForPointsWithResponse(List points) { + return this.getDataForPointsWithResponse(points, null); + } + + /** + * Get Data For Points + * + *

+     * asyncClient.getDataForPoints(Arrays.asList(
+     *     new GeoPosition(-121.66853362143818, 46.84646479863713), 
+     *     new GeoPosition(-121.68853362143818, 46.856464798637127)));
+     * 
+ * + * + * **Applies to**: S1 pricing tier. + * + *

The Get Data for Points API provides elevation data for one or more points. A point is defined in lat,long + * coordinate format. + * + *

Due to the URL character length limit of 2048, it's not possible to pass more than 100 coordinates as a + * pipeline delimited string in a URL GET request. If you intend to pass more than 100 coordinates as a pipeline + * delimited string, use the [POST Data For + * Points](https://docs.microsoft.com/rest/api/maps/elevation/postdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. If multiple points are requested, each of the points in a list should be separated + * by the pipe ('|') character. The maximum number of points that can be requested in a single request is 2,000. + * The resolution of the elevation data will be the highest for a single point and will decrease if multiple + * points are spread further apart. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + Mono> getDataForPointsWithResponse(List points, Context context) { + if (points.size() < ELEVATION_DATA_SMALL_SIZE) { + return this.serviceClient.getDataForPointsWithResponseAsync(JsonFormat.JSON, Utility.geoPositionToString(points), context); + } + return this.serviceClient.postDataForPointsWithResponseAsync(JsonFormat.JSON, Utility.toLatLongPairAbbreviated(points), context).onErrorMap(throwable -> { + if (!(throwable instanceof ErrorResponseException)) { + return throwable; + } + ErrorResponseException exception = (ErrorResponseException) throwable; + return new HttpResponseException(exception.getMessage(), exception.getResponse()); + }); + } + + /** + * Get Data For Polyline + * + *

+     * asyncClient.getDataForPolyline(Arrays.asList(
+     *     new GeoPosition(-121.66853362143818, 46.84646479863713), 
+     *     new GeoPosition(-121.65853362143818, 46.85646479863713)), 5);
+     * 
+ * + * + * **Applies to**: S1 pricing tier. + * + *

The Get Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and endpoints, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param lines The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. + *

The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate reference system. + * The resolution of the data used to compute the elevation depends on the distance between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDataForPolyline(List lines, Integer samples) { + Mono> result = this.getDataForPolylineWithResponse(lines, samples); + return result.flatMap(response -> { + return Mono.just(response.getValue()); + }); + } + + /** + * Get Data For Polyline + * + *

+     * asyncClient.getDataForPolyline(Arrays.asList(
+     *     new GeoPosition(-121.66853362143818, 46.84646479863713), 
+     *     new GeoPosition(-121.65853362143818, 46.85646479863713)), 5);
+     * 
+ * + * + * **Applies to**: S1 pricing tier. + * + *

The Get Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and endpoints, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param lines The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. + *

The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate reference system. + * The resolution of the data used to compute the elevation depends on the distance between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDataForPolylineWithResponse(List lines, Integer samples) { + return this.getDataForPolylineWithResponse(lines, samples, null); + } + + /** + * Get Data For Polyline + * + *

+     * asyncClient.getDataForPolyline(Arrays.asList(
+     *     new GeoPosition(-121.66853362143818, 46.84646479863713), 
+     *     new GeoPosition(-121.65853362143818, 46.85646479863713)), 5);
+     * 
+ * + * + * **Applies to**: S1 pricing tier. + * + *

The Get Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and endpoints, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param lines The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. + *

The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate reference system. + * The resolution of the data used to compute the elevation depends on the distance between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + Mono> getDataForPolylineWithResponse(List lines, Integer samples, Context context) { + if (lines.size() < ELEVATION_DATA_SMALL_SIZE) { + return this.serviceClient.getDataForPolylineWithResponseAsync(JsonFormat.JSON, Utility.geoPositionToString(lines), samples, context); + } + return this.serviceClient.postDataForPolylineWithResponseAsync(JsonFormat.JSON, Utility.toLatLongPairAbbreviated(lines), samples, context).onErrorMap(throwable -> { + if (!(throwable instanceof ErrorResponseException)) { + return throwable; + } + ErrorResponseException exception = (ErrorResponseException) throwable; + return new HttpResponseException(exception.getMessage(), exception.getResponse()); + }); + } + + /** + * Get Data For Bounding Box + * + *

+     * asyncClient.getDataForBoundingBox(new GeoBoundingBox(-121.668533621438f, 46.8464647986371f, 
+     *     -121.658533621438f, 46.8564647986371f), 3, 3);
+     * 
+ * + * + * **Applies to**: S1 pricing tier. + * + *

The Get Data for Bounding Box API provides elevation data at equally spaced locations within a bounding box. A + * bounding box is defined by the coordinates for two corners (southwest, northeast) and then subsequently divided + * into rows and columns. + * + *

Elevations are returned for the vertices of the grid created by the rows and columns. Up to 2,000 elevations + * can be returned in a single request. The returned elevation values are ordered, starting at the southwest corner, + * and then proceeding west to east along the row. At the end of the row, it moves north to the next row, and + * repeats the process until it reaches the far northeast corner. + * + * @param bounds The string that represents the rectangular area of a bounding box. The bounds parameter is defined + * by the 4 bounding box coordinates, with WGS84 longitude and latitude of the southwest corner followed by + * WGS84 longitude and latitude of the northeast corner. The string is presented in the following format: + * `[SouthwestCorner_Longitude, SouthwestCorner_Latitude, NortheastCorner_Longitude, NortheastCorner_Latitude]`. + * @param rows Specifies the number of rows to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @param columns Specifies the number of columns to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDataForBoundingBox(GeoBoundingBox bounds, Integer rows, Integer columns) { + Mono> result = this.getDataForBoundingBoxWithResponse(bounds, rows, columns); + return result.flatMap(response -> { + return Mono.just(response.getValue()); + }); + } + + /** + * Get Data For Bounding Box + * + *

+     * asyncClient.getDataForBoundingBox(new GeoBoundingBox(-121.668533621438f, 46.8464647986371f, 
+     *     -121.658533621438f, 46.8564647986371f), 3, 3);
+     * 
+ * + * + * **Applies to**: S1 pricing tier. + * + *

The Get Data for Bounding Box API provides elevation data at equally spaced locations within a bounding box. A + * bounding box is defined by the coordinates for two corners (southwest, northeast) and then subsequently divided + * into rows and columns. + * + *

Elevations are returned for the vertices of the grid created by the rows and columns. Up to 2,000 elevations + * can be returned in a single request. The returned elevation values are ordered, starting at the southwest corner, + * and then proceeding west to east along the row. At the end of the row, it moves north to the next row, and + * repeats the process until it reaches the far northeast corner. + * + * @param bounds The string that represents the rectangular area of a bounding box. The bounds parameter is defined + * by the 4 bounding box coordinates, with WGS84 longitude and latitude of the southwest corner followed by + * WGS84 longitude and latitude of the northeast corner. The string is presented in the following format: + * `[SouthwestCorner_Longitude, SouthwestCorner_Latitude, NortheastCorner_Longitude, NortheastCorner_Latitude]`. + * @param rows Specifies the number of rows to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @param columns Specifies the number of columns to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDataForBoundingBoxWithResponse(GeoBoundingBox bounds, Integer rows, Integer columns) { + return this.getDataForBoundingBoxWithResponse(bounds, rows, columns, null); + } + + /** + * Get Data For Bounding Box + * + *

+     * asyncClient.getDataForBoundingBox(new GeoBoundingBox(-121.668533621438f, 46.8464647986371f, 
+     *     -121.658533621438f, 46.8564647986371f), 3, 3);
+     * 
+ * + * + * **Applies to**: S1 pricing tier. + * + *

The Get Data for Bounding Box API provides elevation data at equally spaced locations within a bounding box. A + * bounding box is defined by the coordinates for two corners (southwest, northeast) and then subsequently divided + * into rows and columns. + * + *

Elevations are returned for the vertices of the grid created by the rows and columns. Up to 2,000 elevations + * can be returned in a single request. The returned elevation values are ordered, starting at the southwest corner, + * and then proceeding west to east along the row. At the end of the row, it moves north to the next row, and + * repeats the process until it reaches the far northeast corner. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param bounds The string that represents the rectangular area of a bounding box. The bounds parameter is defined + * by the 4 bounding box coordinates, with WGS84 longitude and latitude of the southwest corner followed by + * WGS84 longitude and latitude of the northeast corner. The string is presented in the following format: + * `[SouthwestCorner_Longitude, SouthwestCorner_Latitude, NortheastCorner_Longitude, NortheastCorner_Latitude]`. + * @param rows Specifies the number of rows to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @param columns Specifies the number of columns to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + Mono> getDataForBoundingBoxWithResponse(GeoBoundingBox bounds, Integer rows, Integer columns, Context context) { + return this.serviceClient.getDataForBoundingBoxWithResponseAsync(JsonFormat.JSON, Utility.geoBoundingBoxAsList(bounds), rows, columns, context).onErrorMap(throwable -> { + if (!(throwable instanceof ErrorResponseException)) { + return throwable; + } + ErrorResponseException exception = (ErrorResponseException) throwable; + return new HttpResponseException(exception.getMessage(), exception.getResponse()); + }); + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/ElevationClient.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/ElevationClient.java new file mode 100644 index 0000000000000..9583be628ded3 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/ElevationClient.java @@ -0,0 +1,284 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.maps.elevation; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.http.rest.Response; +import com.azure.core.models.GeoBoundingBox; +import com.azure.core.models.GeoPosition; +import com.azure.core.util.Context; +import com.azure.maps.elevation.models.ElevationResult; +import com.azure.maps.elevation.implementation.models.ErrorResponseException; +import java.util.List; + +/** * {@link ElevationClient} instances are created via the {@link ElevationClientBuilder}, as shown below. + * Creating a sync client using a {@link AzureKeyCredential}: + * + *

+ * // Authenticates using subscription key
+ * AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY"));
+ *
+ * // Creates a client
+ * ElevationClient client = new ElevationClientBuilder() 
+ *     .credential(keyCredential)
+ *     .elevationClientId(System.getenv("MAPS_CLIENT_ID"))
+ *     .buildClient();
+ * 
+ * + */ +@ServiceClient(builder = ElevationClientBuilder.class) +public final class ElevationClient { + private final ElevationAsyncClient asyncClient; + + /** + * Initializes an instance of ElevationClient client. + * + * @param serviceClient the service client implementation. + */ + ElevationClient(ElevationAsyncClient asyncClient) { + this.asyncClient = asyncClient; + } + + /** + * Get Data For Points + * + *
+     * client.getDataForPoints(Arrays.asList(
+     *     new GeoPosition(-121.66853362143818, 46.84646479863713), 
+     *     new GeoPosition(-121.68853362143818, 46.856464798637127)));
+     * 
+ * + * + * **Applies to**: S1 pricing tier. + * + *

The Get Data for Points API provides elevation data for one or more points. A point is defined in lat,long + * coordinate format. + * + *

Due to the URL character length limit of 2048, it's not possible to pass more than 100 coordinates as a + * pipeline delimited string in a URL GET request. If you intend to pass more than 100 coordinates as a pipeline + * delimited string, use the [POST Data For + * Points](https://docs.microsoft.com/rest/api/maps/elevation/postdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. If multiple points are requested, each of the points in a list should be separated + * by the pipe ('|') character. The maximum number of points that can be requested in a single request is 2,000. + * The resolution of the elevation data will be the highest for a single point and will decrease if multiple + * points are spread further apart. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ElevationResult getDataForPoints(List points) { + return this.asyncClient.getDataForPoints(points).block(); + } + + /** + * Get Data For Points + * + *

+     * client.getDataForPoints(Arrays.asList(
+     *     new GeoPosition(-121.66853362143818, 46.84646479863713), 
+     *     new GeoPosition(-121.68853362143818, 46.856464798637127)));
+     * 
+ * + * + * **Applies to**: S1 pricing tier. + * + *

The Get Data for Points API provides elevation data for one or more points. A point is defined in lat,long + * coordinate format. + * + *

Due to the URL character length limit of 2048, it's not possible to pass more than 100 coordinates as a + * pipeline delimited string in a URL GET request. If you intend to pass more than 100 coordinates as a pipeline + * delimited string, use the [POST Data For + * Points](https://docs.microsoft.com/rest/api/maps/elevation/postdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. If multiple points are requested, each of the points in a list should be separated + * by the pipe ('|') character. The maximum number of points that can be requested in a single request is 2,000. + * The resolution of the elevation data will be the highest for a single point and will decrease if multiple + * points are spread further apart. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDataForPointsWithResponse(List points, Context context) { + return this.asyncClient.getDataForPointsWithResponse(points, context).block(); + } + + /** + * Get Data For Polyline + * + *

+     * client.getDataForPolyline(Arrays.asList(
+     *     new GeoPosition(-121.66853362143818, 46.84646479863713), 
+     *     new GeoPosition(-121.65853362143818, 46.85646479863713)), 5);
+     * 
+ * + * + * **Applies to**: S1 pricing tier. + * + *

The Get Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and endpoints, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param lines The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. + *

The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate reference system. + * The resolution of the data used to compute the elevation depends on the distance between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ElevationResult getDataForPolyline(List lines, Integer samples) { + return this.asyncClient.getDataForPolyline(lines, samples).block(); + } + + /** + * Get Data For Polyline + * + *

+     * client.getDataForPolyline(Arrays.asList(
+     *     new GeoPosition(-121.66853362143818, 46.84646479863713), 
+     *     new GeoPosition(-121.65853362143818, 46.85646479863713)), 5);
+     * 
+ * + * + * **Applies to**: S1 pricing tier. + * + *

The Get Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and endpoints, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param lines The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. + *

The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate reference system. + * The resolution of the data used to compute the elevation depends on the distance between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDataForPolylineWithResponse(List lines, Integer samples, Context context) { + return this.asyncClient.getDataForPolylineWithResponse(lines, samples, context).block(); + } + + /** + * Get Data For Bounding Box + * + *

+     * client.getDataForBoundingBox(new GeoBoundingBox(-121.668533621438, 46.8464647986371, 
+     *     -121.658533621438, 46.8564647986371), 3, 3);
+     * 
+ * + * + * **Applies to**: S1 pricing tier. + * + *

The Get Data for Bounding Box API provides elevation data at equally spaced locations within a bounding box. A + * bounding box is defined by the coordinates for two corners (southwest, northeast) and then subsequently divided + * into rows and columns. + * + *

Elevations are returned for the vertices of the grid created by the rows and columns. Up to 2,000 elevations + * can be returned in a single request. The returned elevation values are ordered, starting at the southwest corner, + * and then proceeding west to east along the row. At the end of the row, it moves north to the next row, and + * repeats the process until it reaches the far northeast corner. + * + * @param bounds The string that represents the rectangular area of a bounding box. The bounds parameter is defined + * by the 4 bounding box coordinates, with WGS84 longitude and latitude of the southwest corner followed by + * WGS84 longitude and latitude of the northeast corner. The string is presented in the following format: + * `[SouthwestCorner_Longitude, SouthwestCorner_Latitude, NortheastCorner_Longitude, NortheastCorner_Latitude]`. + * @param rows Specifies the number of rows to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @param columns Specifies the number of columns to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ElevationResult getDataForBoundingBox(GeoBoundingBox bounds, Integer rows, Integer columns) { + return this.asyncClient.getDataForBoundingBox(bounds, rows, columns).block(); + } + + /** + * Get Data For Bounding Box + * + *

+     * client.getDataForBoundingBox(new GeoBoundingBox(-121.668533621438, 46.8464647986371, 
+     *     -121.658533621438, 46.8564647986371), 3, 3);
+     * 
+ * + * + * **Applies to**: S1 pricing tier. + * + *

The Get Data for Bounding Box API provides elevation data at equally spaced locations within a bounding box. A + * bounding box is defined by the coordinates for two corners (southwest, northeast) and then subsequently divided + * into rows and columns. + * + *

Elevations are returned for the vertices of the grid created by the rows and columns. Up to 2,000 elevations + * can be returned in a single request. The returned elevation values are ordered, starting at the southwest corner, + * and then proceeding west to east along the row. At the end of the row, it moves north to the next row, and + * repeats the process until it reaches the far northeast corner. + * + * @param bounds The string that represents the rectangular area of a bounding box. The bounds parameter is defined + * by the 4 bounding box coordinates, with WGS84 longitude and latitude of the southwest corner followed by + * WGS84 longitude and latitude of the northeast corner. The string is presented in the following format: + * `[SouthwestCorner_Longitude, SouthwestCorner_Latitude, NortheastCorner_Longitude, NortheastCorner_Latitude]`. + * @param rows Specifies the number of rows to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @param columns Specifies the number of columns to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDataForBoundingBoxWithResponse(GeoBoundingBox bounds, Integer rows, Integer columns, Context context) { + return this.asyncClient.getDataForBoundingBoxWithResponse(bounds, rows, columns, context).block(); + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/ElevationClientBuilder.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/ElevationClientBuilder.java new file mode 100644 index 0000000000000..eae1e435041b0 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/ElevationClientBuilder.java @@ -0,0 +1,386 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.maps.elevation; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.client.traits.AzureKeyCredentialTrait; +import com.azure.core.client.traits.ConfigurationTrait; +import com.azure.core.client.traits.EndpointTrait; +import com.azure.core.client.traits.HttpTrait; +import com.azure.core.client.traits.TokenCredentialTrait; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.AddHeadersPolicy; +import com.azure.core.http.policy.AzureKeyCredentialPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.CookiePolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.ClientOptions; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.maps.elevation.implementation.ElevationClientImpl; +import com.azure.maps.elevation.implementation.ElevationClientImplBuilder; + +/** Builder class used to instantiate both synchronous and asynchronous {@link ElevationClient} clients. + *

Example usage

+ * Creating a sync client using a {@link AzureKeyCredential}: + * + *
+ * // Authenticates using subscription key
+ * AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY"));
+ *
+ * // Creates a client
+ * ElevationClient client = new ElevationClientBuilder() 
+ *     .credential(keyCredential)
+ *     .elevationClientId(System.getenv("MAPS_CLIENT_ID"))
+ *     .buildClient();
+ * 
+ * + */ +@ServiceClientBuilder(serviceClients = {ElevationClient.class, ElevationAsyncClient.class}) +public final class ElevationClientBuilder implements AzureKeyCredentialTrait, + TokenCredentialTrait, HttpTrait, + ConfigurationTrait, EndpointTrait { + // auth scope + static final String[] DEFAULT_SCOPES = new String[] {"https://atlas.microsoft.com/.default"}; + + // constants + private static final String SDK_NAME = "name"; + private static final String SDK_VERSION = "version"; + private static final String MAPS_SUBSCRIPTION_KEY = "subscription-key"; + private static final String X_MS_CLIENT_ID = "x-ms-client-id"; + + // instance fields + private static final ClientLogger LOGGER = new ClientLogger(ElevationClientBuilder.class); + private final Map properties = new HashMap<>(); + private String endpoint; + private ElevationServiceVersion serviceVersion; + /* + * Specifies which account is intended for usage in conjunction with the + * Azure AD security model. It represents a unique ID for the Azure Maps + * account and can be retrieved from the Azure Maps management plane + * Account API. To use Azure AD security in Azure Maps see the following + * [articles](https://aka.ms/amauthdetails) for guidance. + */ + private String elevationClientId; + // The HTTP pipeline to send requests through + private HttpPipeline pipeline; + //The HTTP client used to send the request + private HttpClient httpClient; + // The configuration store that is used during construction of the service client. + private Configuration configuration; + // The logging configuration for HTTP requests and responses. + private HttpLogOptions httpLogOptions; + // The list of Http pipeline policies to add. + private final List pipelinePolicies; + // The client options such as application ID and custom headers to set on a request. + private ClientOptions clientOptions; + // The retry policy that will attempt to retry failed requests, if applicable. + private RetryPolicy retryPolicy; + private RetryOptions retryOptions; + + // credentials + private AzureKeyCredential keyCredential; + private TokenCredential tokenCredential; + + /** Default constructor for the builder class; Create an instance of the ElevationClientBuilder. */ + public ElevationClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /** + * Sets the Azure Maps client id for use with Azure AD Authentication. This client id + * is the account-based GUID that appears on the Azure Maps Authentication page. + * + * More details: Azure Maps AD Authentication + * + * @param elevationClientId the clientId value. + * @return the ElevationClientBuilder. + */ + public ElevationClientBuilder elevationClientId(String elevationClientId) { + this.elevationClientId = Objects.requireNonNull(elevationClientId, "'elevationClientId' cannot be null."); + return this; + } + + /** + * Set endpoint of the service. + * + * @param endpoint url of the service + * @return ElevationClientBuilder + */ + @Override + public ElevationClientBuilder endpoint(String endpoint) { + this.endpoint = Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + return this; + } + + /** + * Sets the {@link ElevationServiceVersion} that is used when making API requests. + *

+ * If a service version is not provided, the service version that will be used will be the latest known service + * version based on the version of the client library being used. If no service version is specified, updating to a + * newer version of the client library will have the result of potentially moving to a newer service version. + *

+ * Targeting a specific service version may also mean that the service will return an error for newer APIs. + * + * @param version {@link ElevationServiceVersion} of the service to be used when making requests. + * @return the updated ElevationClientBuilder object + */ + public ElevationClientBuilder serviceVersion(ElevationServiceVersion version) { + this.serviceVersion = version; + return this; + } + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the ElevationClientBuilder. + */ + @Override + public ElevationClientBuilder pipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.info("Pipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /** + * Sets The HTTP client used to send the request. + * + * @param httpClient the httpClient value. + * @return the ElevationClientBuilder. + */ + @Override + public ElevationClientBuilder httpClient(HttpClient httpClient) { + if (this.httpClient != null && httpClient == null) { + LOGGER.info("HttpClient is being set to 'null' when it was previously configured."); + } + this.httpClient = httpClient; + return this; + } + + /** + * Sets The configuration store that is used during construction of the service client. + * + * @param configuration the configuration value. + * @return the ElevationClientBuilder. + */ + @Override + public ElevationClientBuilder configuration(Configuration configuration) { + this.configuration = Objects.requireNonNull(configuration, "'configuration' cannot be null."); + return this; + } + + /** + * Sets The logging configuration for HTTP requests and responses. + * + * @param httpLogOptions the httpLogOptions value. + * @return the ElevationClientBuilder. + */ + @Override + public ElevationClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'logOptions' cannot be null."); + return this; + } + + /** + * Sets The retry policy that will attempt to retry failed requests, if applicable. + * + * @param retryPolicy the retryPolicy value. + * @return the ElevationClientBuilder. + */ + public ElevationClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets The client options such as application ID and custom headers to set on a request. + * + * @param clientOptions the clientOptions value. + * @return the ElevationClientBuilder. + */ + @Override + public ElevationClientBuilder clientOptions(ClientOptions clientOptions) { + this.clientOptions = Objects.requireNonNull(clientOptions, "'clientOptions' cannot be null."); + return this; + } + + /** + * Adds a custom Http pipeline policy. + * + * @param customPolicy The custom Http pipeline policy to add. + * @return the ElevationClientBuilder. + */ + @Override + public ElevationClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { + pipelinePolicies.add(Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null.")); + return this; + } + + /** + * Sets the {@link TokenCredential} used to authenticate HTTP requests. + * + * @param tokenCredential {@link TokenCredential} used to authenticate HTTP requests. + * @return The updated {@link ElevationClientBuilder} object. + * @throws NullPointerException If {@code tokenCredential} is null. + */ + @Override + public ElevationClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = Objects.requireNonNull(tokenCredential, "'tokenCredential' cannot be null."); + return this; + } + + /** + * Sets the {@link AzureKeyCredential} used to authenticate HTTP requests. + * + * @param keyCredential The {@link AzureKeyCredential} used to authenticate HTTP requests. + * @return The updated {@link ElevationClientBuilder} object. + * @throws NullPointerException If {@code keyCredential} is null. + */ + @Override + public ElevationClientBuilder credential(AzureKeyCredential keyCredential) { + this.keyCredential = Objects.requireNonNull(keyCredential, "'keyCredential' cannot be null."); + return this; + } + + /** + * Sets retry options + * @param retryOptions the retry options for the client + * @return a reference to this {@code ElevationClientBuilder} + */ + @Override + public ElevationClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * Builds an instance of ElevationClientImpl with the provided parameters. + * + * @return an instance of ElevationClientImpl. + */ + private ElevationClientImpl buildInnerClient() { + if (endpoint == null) { + this.endpoint = "https://atlas.microsoft.com"; + } + if (serviceVersion == null) { + this.serviceVersion = ElevationServiceVersion.getLatest(); + } + if (pipeline == null) { + this.pipeline = createHttpPipeline(); + } + // client impl + ElevationClientImplBuilder builder = new ElevationClientImplBuilder(); + builder.host(this.endpoint); + builder.apiVersion(this.serviceVersion.getVersion()); + builder.pipeline(this.pipeline); + builder.clientId(this.elevationClientId); + builder.httpClient(this.httpClient); + builder.httpLogOptions(this.httpLogOptions); + + ElevationClientImpl client = builder.buildClient(); + return client; + } + + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration = + (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + if (httpLogOptions == null) { + httpLogOptions = new HttpLogOptions(); + } + if (clientOptions == null) { + clientOptions = new ClientOptions(); + } + + // Configure pipelines and user agent + List policies = new ArrayList<>(); + String clientName = properties.getOrDefault(SDK_NAME, "JavaTrafficSDK"); + String clientVersion = properties.getOrDefault(SDK_VERSION, serviceVersion.getVersion()); + String applicationId = CoreUtils.getApplicationId(clientOptions, httpLogOptions); + policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); + + // configure headers + HttpHeaders headers = new HttpHeaders(); + clientOptions.getHeaders().forEach(header -> headers.set(header.getName(), header.getValue())); + if (headers.getSize() > 0) { + policies.add(new AddHeadersPolicy(headers)); + } + + // Authentications + if (tokenCredential != null) { + if (this.elevationClientId == null) { + throw LOGGER.logExceptionAsError( + new IllegalArgumentException("Missing 'elevationClientId' parameter required for Azure AD Authentication")); + } + // we need the x-ms-client header + HttpHeaders clientHeader = new HttpHeaders(); + clientHeader.add(X_MS_CLIENT_ID, this.elevationClientId); + policies.add(new AddHeadersPolicy(clientHeader)); + + // User token based policy + policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); + } else if (keyCredential != null) { + policies.add(new AzureKeyCredentialPolicy(MAPS_SUBSCRIPTION_KEY, keyCredential)); + } else { + // Throw exception that credential and tokenCredential cannot be null + throw LOGGER.logExceptionAsError( + new IllegalArgumentException("Missing credential information while building a client.")); + } + + // Add final policies + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy == null ? new RetryPolicy() : retryPolicy); + policies.add(new CookiePolicy()); + policies.addAll(this.pipelinePolicies); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + + // build the http pipeline + HttpPipeline httpPipeline = + new HttpPipelineBuilder() + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .build(); + return httpPipeline; + } + + /** + * Builds an instance of ElevationAsyncClient async client. + * + * @return an instance of ElevationAsyncClient. + */ + public ElevationAsyncClient buildAsyncClient() { + return new ElevationAsyncClient(buildInnerClient().getElevations()); + } + + /** + * Builds an instance of ElevationClient sync client. + * + * @return an instance of ElevationClient. + */ + public ElevationClient buildClient() { + return new ElevationClient(buildAsyncClient()); + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/ElevationServiceVersion.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/ElevationServiceVersion.java new file mode 100644 index 0000000000000..4d2d00141152a --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/ElevationServiceVersion.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.maps.elevation; + +import com.azure.core.util.ServiceVersion; + +/** + * Contains the versions of the Elevation Service available for the clients. + */ +public enum ElevationServiceVersion implements ServiceVersion { + /** + * Service version {@code 1.0}. + */ + V1_0("1.0"); + + private final String version; + + /** + * Creates a new {@link ElevationServiceVersion} with a version string. + * + * @param version the version string + */ + ElevationServiceVersion(String version) { + this.version = version; + } + + /** + * Gets the latest service version supported by this client library + * + * @return the latest {@link ElevationServiceVersion} + */ + public static ElevationServiceVersion getLatest() { + return V1_0; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/ElevationClientImpl.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/ElevationClientImpl.java new file mode 100644 index 0000000000000..595f82e8fbb78 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/ElevationClientImpl.java @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.maps.elevation.implementation; + +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.CookiePolicy; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** Initializes a new instance of the ElevationClient type. */ +public final class ElevationClientImpl { + /** + * Specifies which account is intended for usage in conjunction with the Azure AD security model. It represents a + * unique ID for the Azure Maps account and can be retrieved from the Azure Maps management plane Account API. To + * use Azure AD security in Azure Maps see the following [articles](https://aka.ms/amauthdetails) for guidance. + */ + private final String clientId; + + /** + * Gets Specifies which account is intended for usage in conjunction with the Azure AD security model. It represents + * a unique ID for the Azure Maps account and can be retrieved from the Azure Maps management plane Account API. To + * use Azure AD security in Azure Maps see the following [articles](https://aka.ms/amauthdetails) for guidance. + * + * @return the clientId value. + */ + public String getClientId() { + return this.clientId; + } + + /** server parameter. */ + private final String host; + + /** + * Gets server parameter. + * + * @return the host value. + */ + public String getHost() { + return this.host; + } + + /** Api Version. */ + private final String apiVersion; + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** The HTTP pipeline to send requests through. */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** The serializer to serialize an object into a string. */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + public SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** The ElevationsImpl object to access its operations. */ + private final ElevationsImpl elevations; + + /** + * Gets the ElevationsImpl object to access its operations. + * + * @return the ElevationsImpl object. + */ + public ElevationsImpl getElevations() { + return this.elevations; + } + + /** + * Initializes an instance of ElevationClient client. + * + * @param clientId Specifies which account is intended for usage in conjunction with the Azure AD security model. It + * represents a unique ID for the Azure Maps account and can be retrieved from the Azure Maps management plane + * Account API. To use Azure AD security in Azure Maps see the following + * [articles](https://aka.ms/amauthdetails) for guidance. + * @param host server parameter. + * @param apiVersion Api Version. + */ + ElevationClientImpl(String clientId, String host, String apiVersion) { + this( + new HttpPipelineBuilder() + .policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()) + .build(), + JacksonAdapter.createDefaultSerializerAdapter(), + clientId, + host, + apiVersion); + } + + /** + * Initializes an instance of ElevationClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param clientId Specifies which account is intended for usage in conjunction with the Azure AD security model. It + * represents a unique ID for the Azure Maps account and can be retrieved from the Azure Maps management plane + * Account API. To use Azure AD security in Azure Maps see the following + * [articles](https://aka.ms/amauthdetails) for guidance. + * @param host server parameter. + * @param apiVersion Api Version. + */ + ElevationClientImpl(HttpPipeline httpPipeline, String clientId, String host, String apiVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), clientId, host, apiVersion); + } + + /** + * Initializes an instance of ElevationClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param clientId Specifies which account is intended for usage in conjunction with the Azure AD security model. It + * represents a unique ID for the Azure Maps account and can be retrieved from the Azure Maps management plane + * Account API. To use Azure AD security in Azure Maps see the following + * [articles](https://aka.ms/amauthdetails) for guidance. + * @param host server parameter. + * @param apiVersion Api Version. + */ + ElevationClientImpl( + HttpPipeline httpPipeline, + SerializerAdapter serializerAdapter, + String clientId, + String host, + String apiVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.clientId = clientId; + this.host = host; + this.apiVersion = apiVersion; + this.elevations = new ElevationsImpl(this); + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/ElevationClientImplBuilder.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/ElevationClientImplBuilder.java new file mode 100644 index 0000000000000..f6af228c9440a --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/ElevationClientImplBuilder.java @@ -0,0 +1,305 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.maps.elevation.implementation; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.client.traits.ConfigurationTrait; +import com.azure.core.client.traits.HttpTrait; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.AddHeadersPolicy; +import com.azure.core.http.policy.CookiePolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.ClientOptions; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.builder.ClientBuilderUtil; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** A builder for creating a new instance of the ElevationClient type. */ +@ServiceClientBuilder(serviceClients = {ElevationClientImpl.class}) +public final class ElevationClientImplBuilder + implements HttpTrait, ConfigurationTrait { + @Generated private static final String SDK_NAME = "name"; + + @Generated private static final String SDK_VERSION = "version"; + + @Generated private final Map properties = new HashMap<>(); + + @Generated private final List pipelinePolicies; + + /** Create an instance of the ElevationClientImplBuilder. */ + @Generated + public ElevationClientImplBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated private HttpPipeline pipeline; + + /** {@inheritDoc}. */ + @Generated + @Override + public ElevationClientImplBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Generated private HttpClient httpClient; + + /** {@inheritDoc}. */ + @Generated + @Override + public ElevationClientImplBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated private HttpLogOptions httpLogOptions; + + /** {@inheritDoc}. */ + @Generated + @Override + public ElevationClientImplBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The client options such as application ID and custom headers to set on a + * request. + */ + @Generated private ClientOptions clientOptions; + + /** {@inheritDoc}. */ + @Generated + @Override + public ElevationClientImplBuilder clientOptions(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Generated private RetryOptions retryOptions; + + /** {@inheritDoc}. */ + @Generated + @Override + public ElevationClientImplBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** {@inheritDoc}. */ + @Generated + @Override + public ElevationClientImplBuilder addPolicy(HttpPipelinePolicy customPolicy) { + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The configuration store that is used during construction of the service + * client. + */ + @Generated private Configuration configuration; + + /** {@inheritDoc}. */ + @Generated + @Override + public ElevationClientImplBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * Specifies which account is intended for usage in conjunction with the + * Azure AD security model. It represents a unique ID for the Azure Maps + * account and can be retrieved from the Azure Maps management plane + * Account API. To use Azure AD security in Azure Maps see the following + * [articles](https://aka.ms/amauthdetails) for guidance. + */ + @Generated private String clientId; + + /** + * Sets Specifies which account is intended for usage in conjunction with the Azure AD security model. It represents + * a unique ID for the Azure Maps account and can be retrieved from the Azure Maps management plane Account API. To + * use Azure AD security in Azure Maps see the following [articles](https://aka.ms/amauthdetails) for guidance. + * + * @param clientId the clientId value. + * @return the ElevationClientImplBuilder. + */ + @Generated + public ElevationClientImplBuilder clientId(String clientId) { + this.clientId = clientId; + return this; + } + + /* + * server parameter + */ + @Generated private String host; + + /** + * Sets server parameter. + * + * @param host the host value. + * @return the ElevationClientImplBuilder. + */ + @Generated + public ElevationClientImplBuilder host(String host) { + this.host = host; + return this; + } + + /* + * Api Version + */ + @Generated private String apiVersion; + + /** + * Sets Api Version. + * + * @param apiVersion the apiVersion value. + * @return the ElevationClientImplBuilder. + */ + @Generated + public ElevationClientImplBuilder apiVersion(String apiVersion) { + this.apiVersion = apiVersion; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + @Generated private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the ElevationClientImplBuilder. + */ + @Generated + public ElevationClientImplBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /* + * The retry policy that will attempt to retry failed requests, if + * applicable. + */ + @Generated private RetryPolicy retryPolicy; + + /** + * Sets The retry policy that will attempt to retry failed requests, if applicable. + * + * @param retryPolicy the retryPolicy value. + * @return the ElevationClientImplBuilder. + */ + @Generated + public ElevationClientImplBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ElevationClientImpl with the provided parameters. + * + * @return an instance of ElevationClientImpl. + */ + @Generated + public ElevationClientImpl buildClient() { + if (pipeline == null) { + this.pipeline = createHttpPipeline(); + } + if (host == null) { + this.host = "https://atlas.microsoft.com"; + } + if (apiVersion == null) { + this.apiVersion = "1.0"; + } + if (serializerAdapter == null) { + this.serializerAdapter = JacksonAdapter.createDefaultSerializerAdapter(); + } + ElevationClientImpl client = new ElevationClientImpl(pipeline, serializerAdapter, clientId, host, apiVersion); + return client; + } + + @Generated + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration = + (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + if (httpLogOptions == null) { + httpLogOptions = new HttpLogOptions(); + } + if (clientOptions == null) { + clientOptions = new ClientOptions(); + } + List policies = new ArrayList<>(); + String clientName = properties.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = properties.getOrDefault(SDK_VERSION, "UnknownVersion"); + String applicationId = CoreUtils.getApplicationId(clientOptions, httpLogOptions); + policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); + policies.add(new RequestIdPolicy()); + policies.add(new AddHeadersFromContextPolicy()); + HttpHeaders headers = new HttpHeaders(); + clientOptions.getHeaders().forEach(header -> headers.set(header.getName(), header.getValue())); + if (headers.getSize() > 0) { + policies.add(new AddHeadersPolicy(headers)); + } + policies.addAll( + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); + policies.add(new AddDatePolicy()); + policies.add(new CookiePolicy()); + policies.addAll( + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = + new HttpPipelineBuilder() + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .clientOptions(clientOptions) + .build(); + return httpPipeline; + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/ElevationsImpl.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/ElevationsImpl.java new file mode 100644 index 0000000000000..fc0f4a9be4d74 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/ElevationsImpl.java @@ -0,0 +1,1229 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.maps.elevation.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.CollectionFormat; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.maps.elevation.implementation.models.ErrorResponseException; +import com.azure.maps.elevation.implementation.models.JsonFormat; +import com.azure.maps.elevation.implementation.models.LatLongPairAbbreviated; +import com.azure.maps.elevation.models.ElevationResult; +import java.util.List; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in Elevations. */ +public final class ElevationsImpl { + /** The proxy service used to perform REST calls. */ + private final ElevationsService service; + + /** The service client containing this operation class. */ + private final ElevationClientImpl client; + + /** + * Initializes an instance of ElevationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ElevationsImpl(ElevationClientImpl client) { + this.service = + RestProxy.create(ElevationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ElevationClientElevations to be used by the proxy service to perform + * REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "ElevationClientEleva") + private interface ElevationsService { + @Get("/elevation/point/{format}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ErrorResponseException.class) + Mono> getDataForPoints( + @HostParam("$host") String host, + @HeaderParam("x-ms-client-id") String clientId, + @QueryParam("api-version") String apiVersion, + @PathParam("format") JsonFormat format, + @QueryParam("points") String points, + @HeaderParam("Accept") String accept, + Context context); + + @Post("/elevation/point/{format}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ErrorResponseException.class) + Mono> postDataForPoints( + @HostParam("$host") String host, + @HeaderParam("x-ms-client-id") String clientId, + @QueryParam("api-version") String apiVersion, + @PathParam("format") JsonFormat format, + @BodyParam("application/json") List points, + @HeaderParam("Accept") String accept, + Context context); + + @Get("/elevation/line/{format}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ErrorResponseException.class) + Mono> getDataForPolyline( + @HostParam("$host") String host, + @HeaderParam("x-ms-client-id") String clientId, + @QueryParam("api-version") String apiVersion, + @PathParam("format") JsonFormat format, + @QueryParam("lines") String lines, + @QueryParam("samples") Integer samples, + @HeaderParam("Accept") String accept, + Context context); + + @Post("/elevation/line/{format}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ErrorResponseException.class) + Mono> postDataForPolyline( + @HostParam("$host") String host, + @HeaderParam("x-ms-client-id") String clientId, + @QueryParam("api-version") String apiVersion, + @PathParam("format") JsonFormat format, + @QueryParam("samples") Integer samples, + @BodyParam("application/json") List polyline, + @HeaderParam("Accept") String accept, + Context context); + + @Get("/elevation/lattice/{format}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ErrorResponseException.class) + Mono> getDataForBoundingBox( + @HostParam("$host") String host, + @HeaderParam("x-ms-client-id") String clientId, + @QueryParam("api-version") String apiVersion, + @PathParam("format") JsonFormat format, + @QueryParam("bounds") String bounds, + @QueryParam("rows") int rows, + @QueryParam("columns") int columns, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Points API provides elevation data for one or more points. A point is defined in lat,long + * coordinate format. + * + *

Due to the URL character length limit of 2048, it's not possible to pass more than 100 coordinates as a + * pipeline delimited string in a URL GET request. If you intend to pass more than 100 coordinates as a pipeline + * delimited string, use the [POST Data For + * Points](https://docs.microsoft.com/rest/api/maps/elevation/postdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. If multiple points are requested, each of the points in a list should be separated + * by the pipe ('|') character. The maximum number of points that can be requested in a single request is 2,000. + * The resolution of the elevation data will be the highest for a single point and will decrease if multiple + * points are spread further apart. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDataForPointsWithResponseAsync(JsonFormat format, List points) { + final String accept = "application/json"; + String pointsConverted = + JacksonAdapter.createDefaultSerializerAdapter().serializeList(points, CollectionFormat.PIPES); + return FluxUtil.withContext( + context -> + service.getDataForPoints( + this.client.getHost(), + this.client.getClientId(), + this.client.getApiVersion(), + format, + pointsConverted, + accept, + context)); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Points API provides elevation data for one or more points. A point is defined in lat,long + * coordinate format. + * + *

Due to the URL character length limit of 2048, it's not possible to pass more than 100 coordinates as a + * pipeline delimited string in a URL GET request. If you intend to pass more than 100 coordinates as a pipeline + * delimited string, use the [POST Data For + * Points](https://docs.microsoft.com/rest/api/maps/elevation/postdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. If multiple points are requested, each of the points in a list should be separated + * by the pipe ('|') character. The maximum number of points that can be requested in a single request is 2,000. + * The resolution of the elevation data will be the highest for a single point and will decrease if multiple + * points are spread further apart. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDataForPointsWithResponseAsync( + JsonFormat format, List points, Context context) { + final String accept = "application/json"; + String pointsConverted = + JacksonAdapter.createDefaultSerializerAdapter().serializeList(points, CollectionFormat.PIPES); + return service.getDataForPoints( + this.client.getHost(), + this.client.getClientId(), + this.client.getApiVersion(), + format, + pointsConverted, + accept, + context); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Points API provides elevation data for one or more points. A point is defined in lat,long + * coordinate format. + * + *

Due to the URL character length limit of 2048, it's not possible to pass more than 100 coordinates as a + * pipeline delimited string in a URL GET request. If you intend to pass more than 100 coordinates as a pipeline + * delimited string, use the [POST Data For + * Points](https://docs.microsoft.com/rest/api/maps/elevation/postdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. If multiple points are requested, each of the points in a list should be separated + * by the pipe ('|') character. The maximum number of points that can be requested in a single request is 2,000. + * The resolution of the elevation data will be the highest for a single point and will decrease if multiple + * points are spread further apart. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDataForPointsAsync(JsonFormat format, List points) { + return getDataForPointsWithResponseAsync(format, points).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Points API provides elevation data for one or more points. A point is defined in lat,long + * coordinate format. + * + *

Due to the URL character length limit of 2048, it's not possible to pass more than 100 coordinates as a + * pipeline delimited string in a URL GET request. If you intend to pass more than 100 coordinates as a pipeline + * delimited string, use the [POST Data For + * Points](https://docs.microsoft.com/rest/api/maps/elevation/postdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. If multiple points are requested, each of the points in a list should be separated + * by the pipe ('|') character. The maximum number of points that can be requested in a single request is 2,000. + * The resolution of the elevation data will be the highest for a single point and will decrease if multiple + * points are spread further apart. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDataForPointsAsync(JsonFormat format, List points, Context context) { + return getDataForPointsWithResponseAsync(format, points, context) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Points API provides elevation data for one or more points. A point is defined in lat,long + * coordinate format. + * + *

Due to the URL character length limit of 2048, it's not possible to pass more than 100 coordinates as a + * pipeline delimited string in a URL GET request. If you intend to pass more than 100 coordinates as a pipeline + * delimited string, use the [POST Data For + * Points](https://docs.microsoft.com/rest/api/maps/elevation/postdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. If multiple points are requested, each of the points in a list should be separated + * by the pipe ('|') character. The maximum number of points that can be requested in a single request is 2,000. + * The resolution of the elevation data will be the highest for a single point and will decrease if multiple + * points are spread further apart. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ElevationResult getDataForPoints(JsonFormat format, List points) { + return getDataForPointsAsync(format, points).block(); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Points API provides elevation data for one or more points. A point is defined in lat,long + * coordinate format. + * + *

Due to the URL character length limit of 2048, it's not possible to pass more than 100 coordinates as a + * pipeline delimited string in a URL GET request. If you intend to pass more than 100 coordinates as a pipeline + * delimited string, use the [POST Data For + * Points](https://docs.microsoft.com/rest/api/maps/elevation/postdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. If multiple points are requested, each of the points in a list should be separated + * by the pipe ('|') character. The maximum number of points that can be requested in a single request is 2,000. + * The resolution of the elevation data will be the highest for a single point and will decrease if multiple + * points are spread further apart. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDataForPointsWithResponse( + JsonFormat format, List points, Context context) { + return getDataForPointsWithResponseAsync(format, points, context).block(); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Post Data for Points API provides elevation data for multiple points. A point is defined lon/lat + * coordinate format. + * + *

Use the POST endpoint only if you intend to pass multiple points in the request. If you intend to pass a + * single coordinate into the API, use the [GET Data For Points + * API](https://docs.microsoft.com/rest/api/maps/elevation/getdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. Each points in a list should be separated by the pipe ('|') character. The number of + * points that can be requested in a POST request ranges from 2 to 2,000. The resolution of the elevation data + * will be the highest for a single point and will decrease if multiple points are spread further apart. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postDataForPointsWithResponseAsync( + JsonFormat format, List points) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.postDataForPoints( + this.client.getHost(), + this.client.getClientId(), + this.client.getApiVersion(), + format, + points, + accept, + context)); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Post Data for Points API provides elevation data for multiple points. A point is defined lon/lat + * coordinate format. + * + *

Use the POST endpoint only if you intend to pass multiple points in the request. If you intend to pass a + * single coordinate into the API, use the [GET Data For Points + * API](https://docs.microsoft.com/rest/api/maps/elevation/getdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. Each points in a list should be separated by the pipe ('|') character. The number of + * points that can be requested in a POST request ranges from 2 to 2,000. The resolution of the elevation data + * will be the highest for a single point and will decrease if multiple points are spread further apart. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postDataForPointsWithResponseAsync( + JsonFormat format, List points, Context context) { + final String accept = "application/json"; + return service.postDataForPoints( + this.client.getHost(), + this.client.getClientId(), + this.client.getApiVersion(), + format, + points, + accept, + context); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Post Data for Points API provides elevation data for multiple points. A point is defined lon/lat + * coordinate format. + * + *

Use the POST endpoint only if you intend to pass multiple points in the request. If you intend to pass a + * single coordinate into the API, use the [GET Data For Points + * API](https://docs.microsoft.com/rest/api/maps/elevation/getdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. Each points in a list should be separated by the pipe ('|') character. The number of + * points that can be requested in a POST request ranges from 2 to 2,000. The resolution of the elevation data + * will be the highest for a single point and will decrease if multiple points are spread further apart. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono postDataForPointsAsync(JsonFormat format, List points) { + return postDataForPointsWithResponseAsync(format, points).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Post Data for Points API provides elevation data for multiple points. A point is defined lon/lat + * coordinate format. + * + *

Use the POST endpoint only if you intend to pass multiple points in the request. If you intend to pass a + * single coordinate into the API, use the [GET Data For Points + * API](https://docs.microsoft.com/rest/api/maps/elevation/getdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. Each points in a list should be separated by the pipe ('|') character. The number of + * points that can be requested in a POST request ranges from 2 to 2,000. The resolution of the elevation data + * will be the highest for a single point and will decrease if multiple points are spread further apart. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono postDataForPointsAsync( + JsonFormat format, List points, Context context) { + return postDataForPointsWithResponseAsync(format, points, context) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Post Data for Points API provides elevation data for multiple points. A point is defined lon/lat + * coordinate format. + * + *

Use the POST endpoint only if you intend to pass multiple points in the request. If you intend to pass a + * single coordinate into the API, use the [GET Data For Points + * API](https://docs.microsoft.com/rest/api/maps/elevation/getdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. Each points in a list should be separated by the pipe ('|') character. The number of + * points that can be requested in a POST request ranges from 2 to 2,000. The resolution of the elevation data + * will be the highest for a single point and will decrease if multiple points are spread further apart. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ElevationResult postDataForPoints(JsonFormat format, List points) { + return postDataForPointsAsync(format, points).block(); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Post Data for Points API provides elevation data for multiple points. A point is defined lon/lat + * coordinate format. + * + *

Use the POST endpoint only if you intend to pass multiple points in the request. If you intend to pass a + * single coordinate into the API, use the [GET Data For Points + * API](https://docs.microsoft.com/rest/api/maps/elevation/getdataforpoints). + * + *

The result will be in the same sequence of points listed in the request. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param points The string representation of a list of points. A point is defined in lon/lat WGS84 coordinate + * reference system format. Each points in a list should be separated by the pipe ('|') character. The number of + * points that can be requested in a POST request ranges from 2 to 2,000. The resolution of the elevation data + * will be the highest for a single point and will decrease if multiple points are spread further apart. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response postDataForPointsWithResponse( + JsonFormat format, List points, Context context) { + return postDataForPointsWithResponseAsync(format, points, context).block(); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and endpoints, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param lines The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. + *

The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate reference system. + * The resolution of the data used to compute the elevation depends on the distance between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDataForPolylineWithResponseAsync( + JsonFormat format, List lines, Integer samples) { + final String accept = "application/json"; + String linesConverted = + JacksonAdapter.createDefaultSerializerAdapter().serializeList(lines, CollectionFormat.PIPES); + return FluxUtil.withContext( + context -> + service.getDataForPolyline( + this.client.getHost(), + this.client.getClientId(), + this.client.getApiVersion(), + format, + linesConverted, + samples, + accept, + context)); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and endpoints, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param lines The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. + *

The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate reference system. + * The resolution of the data used to compute the elevation depends on the distance between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDataForPolylineWithResponseAsync( + JsonFormat format, List lines, Integer samples, Context context) { + final String accept = "application/json"; + String linesConverted = + JacksonAdapter.createDefaultSerializerAdapter().serializeList(lines, CollectionFormat.PIPES); + return service.getDataForPolyline( + this.client.getHost(), + this.client.getClientId(), + this.client.getApiVersion(), + format, + linesConverted, + samples, + accept, + context); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and endpoints, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param lines The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. + *

The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate reference system. + * The resolution of the data used to compute the elevation depends on the distance between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDataForPolylineAsync(JsonFormat format, List lines, Integer samples) { + return getDataForPolylineWithResponseAsync(format, lines, samples) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and endpoints, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param lines The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. + *

The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate reference system. + * The resolution of the data used to compute the elevation depends on the distance between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDataForPolylineAsync( + JsonFormat format, List lines, Integer samples, Context context) { + return getDataForPolylineWithResponseAsync(format, lines, samples, context) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and endpoints, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param lines The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. + *

The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate reference system. + * The resolution of the data used to compute the elevation depends on the distance between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ElevationResult getDataForPolyline(JsonFormat format, List lines, Integer samples) { + return getDataForPolylineAsync(format, lines, samples).block(); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and endpoints, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param lines The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. + *

The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate reference system. + * The resolution of the data used to compute the elevation depends on the distance between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDataForPolylineWithResponse( + JsonFormat format, List lines, Integer samples, Context context) { + return getDataForPolylineWithResponseAsync(format, lines, samples, context).block(); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Post Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and end points, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param polyline The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate + * reference system. The resolution of the data used to compute the elevation will depend on the distance + * between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postDataForPolylineWithResponseAsync( + JsonFormat format, List polyline, Integer samples) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.postDataForPolyline( + this.client.getHost(), + this.client.getClientId(), + this.client.getApiVersion(), + format, + samples, + polyline, + accept, + context)); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Post Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and end points, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param polyline The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate + * reference system. The resolution of the data used to compute the elevation will depend on the distance + * between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postDataForPolylineWithResponseAsync( + JsonFormat format, List polyline, Integer samples, Context context) { + final String accept = "application/json"; + return service.postDataForPolyline( + this.client.getHost(), + this.client.getClientId(), + this.client.getApiVersion(), + format, + samples, + polyline, + accept, + context); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Post Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and end points, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param polyline The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate + * reference system. The resolution of the data used to compute the elevation will depend on the distance + * between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono postDataForPolylineAsync( + JsonFormat format, List polyline, Integer samples) { + return postDataForPolylineWithResponseAsync(format, polyline, samples) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Post Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and end points, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param polyline The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate + * reference system. The resolution of the data used to compute the elevation will depend on the distance + * between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono postDataForPolylineAsync( + JsonFormat format, List polyline, Integer samples, Context context) { + return postDataForPolylineWithResponseAsync(format, polyline, samples, context) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Post Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and end points, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param polyline The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate + * reference system. The resolution of the data used to compute the elevation will depend on the distance + * between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ElevationResult postDataForPolyline( + JsonFormat format, List polyline, Integer samples) { + return postDataForPolylineAsync(format, polyline, samples).block(); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Post Data for Polyline API provides elevation data along a polyline. + * + *

A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + * In addition to passing in endpoints, customers can specify the number of sample points that will be used to + * divide polyline into equally spaced segments. + * + *

Elevation data at both start and end points, as well as equally spaced points along the polyline will be + * returned. The results will be listed in the direction from the first endpoint towards the last endpoint. A line + * between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate + * reference system. Note that the point is chosen based on Euclidean distance and may markedly differ from the + * geodesic path along the curved surface of the reference ellipsoid. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param polyline The string representation of a polyline path. A polyline is defined by endpoint coordinates, with + * each endpoint separated by a pipe ('|') character. The polyline should be defined in the following format: + * `[longitude_point1, latitude_point1 | longitude_point2, latitude_point2, ..., longitude_pointN, + * latitude_pointN]`. The longitude and latitude values refer to the World Geodetic System (WGS84) coordinate + * reference system. The resolution of the data used to compute the elevation will depend on the distance + * between the endpoints. + * @param samples The samples parameter specifies the number of equally spaced points at which elevation values + * should be provided along a polyline path. The number of samples should range from 2 to 2,000. Default value + * is 10. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response postDataForPolylineWithResponse( + JsonFormat format, List polyline, Integer samples, Context context) { + return postDataForPolylineWithResponseAsync(format, polyline, samples, context).block(); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Bounding Box API provides elevation data at equally spaced locations within a bounding box. A + * bounding box is defined by the coordinates for two corners (southwest, northeast) and then subsequently divided + * into rows and columns. + * + *

Elevations are returned for the vertices of the grid created by the rows and columns. Up to 2,000 elevations + * can be returned in a single request. The returned elevation values are ordered, starting at the southwest corner, + * and then proceeding west to east along the row. At the end of the row, it moves north to the next row, and + * repeats the process until it reaches the far northeast corner. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param bounds The string that represents the rectangular area of a bounding box. The bounds parameter is defined + * by the 4 bounding box coordinates, with WGS84 longitude and latitude of the southwest corner followed by + * WGS84 longitude and latitude of the northeast corner. The string is presented in the following format: + * `[SouthwestCorner_Longitude, SouthwestCorner_Latitude, NortheastCorner_Longitude, NortheastCorner_Latitude]`. + * @param rows Specifies the number of rows to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @param columns Specifies the number of columns to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDataForBoundingBoxWithResponseAsync( + JsonFormat format, List bounds, int rows, int columns) { + final String accept = "application/json"; + String boundsConverted = + JacksonAdapter.createDefaultSerializerAdapter().serializeList(bounds, CollectionFormat.CSV); + return FluxUtil.withContext( + context -> + service.getDataForBoundingBox( + this.client.getHost(), + this.client.getClientId(), + this.client.getApiVersion(), + format, + boundsConverted, + rows, + columns, + accept, + context)); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Bounding Box API provides elevation data at equally spaced locations within a bounding box. A + * bounding box is defined by the coordinates for two corners (southwest, northeast) and then subsequently divided + * into rows and columns. + * + *

Elevations are returned for the vertices of the grid created by the rows and columns. Up to 2,000 elevations + * can be returned in a single request. The returned elevation values are ordered, starting at the southwest corner, + * and then proceeding west to east along the row. At the end of the row, it moves north to the next row, and + * repeats the process until it reaches the far northeast corner. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param bounds The string that represents the rectangular area of a bounding box. The bounds parameter is defined + * by the 4 bounding box coordinates, with WGS84 longitude and latitude of the southwest corner followed by + * WGS84 longitude and latitude of the northeast corner. The string is presented in the following format: + * `[SouthwestCorner_Longitude, SouthwestCorner_Latitude, NortheastCorner_Longitude, NortheastCorner_Latitude]`. + * @param rows Specifies the number of rows to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @param columns Specifies the number of columns to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDataForBoundingBoxWithResponseAsync( + JsonFormat format, List bounds, int rows, int columns, Context context) { + final String accept = "application/json"; + String boundsConverted = + JacksonAdapter.createDefaultSerializerAdapter().serializeList(bounds, CollectionFormat.CSV); + return service.getDataForBoundingBox( + this.client.getHost(), + this.client.getClientId(), + this.client.getApiVersion(), + format, + boundsConverted, + rows, + columns, + accept, + context); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Bounding Box API provides elevation data at equally spaced locations within a bounding box. A + * bounding box is defined by the coordinates for two corners (southwest, northeast) and then subsequently divided + * into rows and columns. + * + *

Elevations are returned for the vertices of the grid created by the rows and columns. Up to 2,000 elevations + * can be returned in a single request. The returned elevation values are ordered, starting at the southwest corner, + * and then proceeding west to east along the row. At the end of the row, it moves north to the next row, and + * repeats the process until it reaches the far northeast corner. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param bounds The string that represents the rectangular area of a bounding box. The bounds parameter is defined + * by the 4 bounding box coordinates, with WGS84 longitude and latitude of the southwest corner followed by + * WGS84 longitude and latitude of the northeast corner. The string is presented in the following format: + * `[SouthwestCorner_Longitude, SouthwestCorner_Latitude, NortheastCorner_Longitude, NortheastCorner_Latitude]`. + * @param rows Specifies the number of rows to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @param columns Specifies the number of columns to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDataForBoundingBoxAsync( + JsonFormat format, List bounds, int rows, int columns) { + return getDataForBoundingBoxWithResponseAsync(format, bounds, rows, columns) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Bounding Box API provides elevation data at equally spaced locations within a bounding box. A + * bounding box is defined by the coordinates for two corners (southwest, northeast) and then subsequently divided + * into rows and columns. + * + *

Elevations are returned for the vertices of the grid created by the rows and columns. Up to 2,000 elevations + * can be returned in a single request. The returned elevation values are ordered, starting at the southwest corner, + * and then proceeding west to east along the row. At the end of the row, it moves north to the next row, and + * repeats the process until it reaches the far northeast corner. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param bounds The string that represents the rectangular area of a bounding box. The bounds parameter is defined + * by the 4 bounding box coordinates, with WGS84 longitude and latitude of the southwest corner followed by + * WGS84 longitude and latitude of the northeast corner. The string is presented in the following format: + * `[SouthwestCorner_Longitude, SouthwestCorner_Latitude, NortheastCorner_Longitude, NortheastCorner_Latitude]`. + * @param rows Specifies the number of rows to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @param columns Specifies the number of columns to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDataForBoundingBoxAsync( + JsonFormat format, List bounds, int rows, int columns, Context context) { + return getDataForBoundingBoxWithResponseAsync(format, bounds, rows, columns, context) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Bounding Box API provides elevation data at equally spaced locations within a bounding box. A + * bounding box is defined by the coordinates for two corners (southwest, northeast) and then subsequently divided + * into rows and columns. + * + *

Elevations are returned for the vertices of the grid created by the rows and columns. Up to 2,000 elevations + * can be returned in a single request. The returned elevation values are ordered, starting at the southwest corner, + * and then proceeding west to east along the row. At the end of the row, it moves north to the next row, and + * repeats the process until it reaches the far northeast corner. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param bounds The string that represents the rectangular area of a bounding box. The bounds parameter is defined + * by the 4 bounding box coordinates, with WGS84 longitude and latitude of the southwest corner followed by + * WGS84 longitude and latitude of the northeast corner. The string is presented in the following format: + * `[SouthwestCorner_Longitude, SouthwestCorner_Latitude, NortheastCorner_Longitude, NortheastCorner_Latitude]`. + * @param rows Specifies the number of rows to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @param columns Specifies the number of columns to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ElevationResult getDataForBoundingBox(JsonFormat format, List bounds, int rows, int columns) { + return getDataForBoundingBoxAsync(format, bounds, rows, columns).block(); + } + + /** + * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + *

The Get Data for Bounding Box API provides elevation data at equally spaced locations within a bounding box. A + * bounding box is defined by the coordinates for two corners (southwest, northeast) and then subsequently divided + * into rows and columns. + * + *

Elevations are returned for the vertices of the grid created by the rows and columns. Up to 2,000 elevations + * can be returned in a single request. The returned elevation values are ordered, starting at the southwest corner, + * and then proceeding west to east along the row. At the end of the row, it moves north to the next row, and + * repeats the process until it reaches the far northeast corner. + * + * @param format Desired format of the response. Only `json` format is supported. + * @param bounds The string that represents the rectangular area of a bounding box. The bounds parameter is defined + * by the 4 bounding box coordinates, with WGS84 longitude and latitude of the southwest corner followed by + * WGS84 longitude and latitude of the northeast corner. The string is presented in the following format: + * `[SouthwestCorner_Longitude, SouthwestCorner_Latitude, NortheastCorner_Longitude, NortheastCorner_Latitude]`. + * @param rows Specifies the number of rows to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @param columns Specifies the number of columns to use to divide the bounding box area into a grid. The number of + * vertices (rows x columns) in the grid should be less than 2,000. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response from a successful Get Data for Bounding Box API along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDataForBoundingBoxWithResponse( + JsonFormat format, List bounds, int rows, int columns, Context context) { + return getDataForBoundingBoxWithResponseAsync(format, bounds, rows, columns, context).block(); + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/helpers/Utility.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/helpers/Utility.java new file mode 100644 index 0000000000000..7af0cee07b9f9 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/helpers/Utility.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.maps.elevation.implementation.helpers; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.azure.core.models.GeoBoundingBox; +import com.azure.core.models.GeoPosition; +import com.azure.maps.elevation.implementation.models.LatLongPairAbbreviated; + +public class Utility { + + public static List toLatLongPairAbbreviated(List points) { + List latLongPairList = new ArrayList<>((points.size())); + for (GeoPosition point : points) { + latLongPairList.add(new LatLongPairAbbreviated().setLat(point.getLatitude()).setLon(point.getLongitude())); + } + return latLongPairList; + } + + public static List geoPositionToString(List points) { + List stringPointsList = new ArrayList<>(); + for (GeoPosition point : points) { + stringPointsList.add(point.getLongitude() + "," + point.getLatitude()); + } + return stringPointsList; + } + + public static List geoBoundingBoxAsList(GeoBoundingBox boundingBox) { + return Arrays.asList(boundingBox.getWest(), boundingBox.getSouth(), boundingBox.getEast(), boundingBox.getNorth()); + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/Elevation.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/Elevation.java new file mode 100644 index 0000000000000..5f4792f1d555a --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/Elevation.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.maps.elevation.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The elevation data. */ +@Fluent +public final class Elevation { + /* + * A location represented as a latitude and longitude. + */ + @JsonProperty(value = "coordinate") + private LatLongPair coordinate; + + /* + * The elevation value in meters. + */ + @JsonProperty(value = "elevationInMeter", access = JsonProperty.Access.WRITE_ONLY) + private Float elevationInMeter; + + /** + * Get the coordinate property: A location represented as a latitude and longitude. + * + * @return the coordinate value. + */ + public LatLongPair getCoordinate() { + return this.coordinate; + } + + /** + * Set the coordinate property: A location represented as a latitude and longitude. + * + * @param coordinate the coordinate value to set. + * @return the Elevation object itself. + */ + public Elevation setCoordinate(LatLongPair coordinate) { + this.coordinate = coordinate; + return this; + } + + /** + * Get the elevationInMeter property: The elevation value in meters. + * + * @return the elevationInMeter value. + */ + public Float getElevationInMeters() { + return this.elevationInMeter; + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/ErrorAdditionalInfo.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/ErrorAdditionalInfo.java new file mode 100644 index 0000000000000..3adfa0e0c93d7 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/ErrorAdditionalInfo.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.maps.elevation.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The resource management error additional info. */ +@Immutable +public final class ErrorAdditionalInfo { + /* + * The additional info type. + */ + @JsonProperty(value = "type", access = JsonProperty.Access.WRITE_ONLY) + private String type; + + /* + * The additional info. + */ + @JsonProperty(value = "info", access = JsonProperty.Access.WRITE_ONLY) + private Object info; + + /** + * Get the type property: The additional info type. + * + * @return the type value. + */ + public String getType() { + return this.type; + } + + /** + * Get the info property: The additional info. + * + * @return the info value. + */ + public Object getInfo() { + return this.info; + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/ErrorDetail.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/ErrorDetail.java new file mode 100644 index 0000000000000..127b4bc192b22 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/ErrorDetail.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.maps.elevation.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The error detail. */ +@Immutable +public final class ErrorDetail { + /* + * The error code. + */ + @JsonProperty(value = "code", access = JsonProperty.Access.WRITE_ONLY) + private String code; + + /* + * The error message. + */ + @JsonProperty(value = "message", access = JsonProperty.Access.WRITE_ONLY) + private String message; + + /* + * The error target. + */ + @JsonProperty(value = "target", access = JsonProperty.Access.WRITE_ONLY) + private String target; + + /* + * The error details. + */ + @JsonProperty(value = "details", access = JsonProperty.Access.WRITE_ONLY) + private List details; + + /* + * The error additional info. + */ + @JsonProperty(value = "additionalInfo", access = JsonProperty.Access.WRITE_ONLY) + private List additionalInfo; + + /** + * Get the code property: The error code. + * + * @return the code value. + */ + public String getCode() { + return this.code; + } + + /** + * Get the message property: The error message. + * + * @return the message value. + */ + public String getMessage() { + return this.message; + } + + /** + * Get the target property: The error target. + * + * @return the target value. + */ + public String getTarget() { + return this.target; + } + + /** + * Get the details property: The error details. + * + * @return the details value. + */ + public List getDetails() { + return this.details; + } + + /** + * Get the additionalInfo property: The error additional info. + * + * @return the additionalInfo value. + */ + public List getAdditionalInfo() { + return this.additionalInfo; + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/ErrorResponse.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/ErrorResponse.java new file mode 100644 index 0000000000000..009fff774f277 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/ErrorResponse.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.maps.elevation.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Error response Common error response for all Azure Resource Manager APIs to return error details for failed + * operations. (This also follows the OData error response format.). + */ +@Fluent +public final class ErrorResponse { + /* + * The error object. + */ + @JsonProperty(value = "error") + private ErrorDetail error; + + /** + * Get the error property: The error object. + * + * @return the error value. + */ + public ErrorDetail getError() { + return this.error; + } + + /** + * Set the error property: The error object. + * + * @param error the error value to set. + * @return the ErrorResponse object itself. + */ + public ErrorResponse setError(ErrorDetail error) { + this.error = error; + return this; + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/ErrorResponseException.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/ErrorResponseException.java new file mode 100644 index 0000000000000..3463a0c58187c --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/ErrorResponseException.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.maps.elevation.implementation.models; + +import com.azure.core.exception.HttpResponseException; +import com.azure.core.http.HttpResponse; + +/** Exception thrown for an invalid response with ErrorResponse information. */ +public final class ErrorResponseException extends HttpResponseException { + /** + * Initializes a new instance of the ErrorResponseException class. + * + * @param message the exception message or the response content if a message is not available. + * @param response the HTTP response. + */ + public ErrorResponseException(String message, HttpResponse response) { + super(message, response); + } + + /** + * Initializes a new instance of the ErrorResponseException class. + * + * @param message the exception message or the response content if a message is not available. + * @param response the HTTP response. + * @param value the deserialized response value. + */ + public ErrorResponseException(String message, HttpResponse response, ErrorResponse value) { + super(message, response, value); + } + + @Override + public ErrorResponse getValue() { + return (ErrorResponse) super.getValue(); + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/JsonFormat.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/JsonFormat.java new file mode 100644 index 0000000000000..2ee37d107b949 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/JsonFormat.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.maps.elevation.implementation.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for JsonFormat. */ +public final class JsonFormat extends ExpandableStringEnum { + /** Static value json for JsonFormat. */ + public static final JsonFormat JSON = fromString("json"); + + /** + * Creates or finds a JsonFormat from its string representation. + * + * @param name a name to look for. + * @return the corresponding JsonFormat. + */ + @JsonCreator + public static JsonFormat fromString(String name) { + return fromString(name, JsonFormat.class); + } + + /** + * Gets known JsonFormat values. + * + * @return known JsonFormat values. + */ + public static Collection values() { + return values(JsonFormat.class); + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/LatLongPair.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/LatLongPair.java new file mode 100644 index 0000000000000..f0780524273cc --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/LatLongPair.java @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.maps.elevation.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** A location represented as a latitude and longitude. */ +@Fluent +public final class LatLongPair { + /* + * Latitude property + */ + @JsonProperty(value = "latitude") + private Double latitude; + + /* + * Longitude property + */ + @JsonProperty(value = "longitude") + private Double longitude; + + /** + * Get the latitude property: Latitude property. + * + * @return the latitude value. + */ + public Double getLatitude() { + return this.latitude; + } + + /** + * Set the latitude property: Latitude property. + * + * @param latitude the latitude value to set. + * @return the LatLongPair object itself. + */ + public LatLongPair setLatitude(Double latitude) { + this.latitude = latitude; + return this; + } + + /** + * Get the longitude property: Longitude property. + * + * @return the longitude value. + */ + public Double getLongitude() { + return this.longitude; + } + + /** + * Set the longitude property: Longitude property. + * + * @param longitude the longitude value to set. + * @return the LatLongPair object itself. + */ + public LatLongPair setLongitude(Double longitude) { + this.longitude = longitude; + return this; + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/LatLongPairAbbreviated.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/LatLongPairAbbreviated.java new file mode 100644 index 0000000000000..83a3793f5ac43 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/LatLongPairAbbreviated.java @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.maps.elevation.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** A location represented as a latitude and longitude using short names 'lat' & 'lon'. */ +@Fluent +public final class LatLongPairAbbreviated { + /* + * Latitude property + */ + @JsonProperty(value = "lat") + private Double lat; + + /* + * Longitude property + */ + @JsonProperty(value = "lon") + private Double lon; + + /** + * Get the lat property: Latitude property. + * + * @return the lat value. + */ + public Double getLat() { + return this.lat; + } + + /** + * Set the lat property: Latitude property. + * + * @param lat the lat value to set. + * @return the LatLongPairAbbreviated object itself. + */ + public LatLongPairAbbreviated setLat(Double lat) { + this.lat = lat; + return this; + } + + /** + * Get the lon property: Longitude property. + * + * @return the lon value. + */ + public Double getLon() { + return this.lon; + } + + /** + * Set the lon property: Longitude property. + * + * @param lon the lon value to set. + * @return the LatLongPairAbbreviated object itself. + */ + public LatLongPairAbbreviated setLon(Double lon) { + this.lon = lon; + return this; + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/package-info.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/package-info.java new file mode 100644 index 0000000000000..3be4e852878b5 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/models/package-info.java @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the data models for ElevationClient. The Azure Maps Elevation API provides an HTTP interface to + * query elevation data on the surface of the Earth. Elevation data can be retrieved at specific locations by sending + * lat/lon coordinates, by defining an ordered set of vertices that form a Polyline and a number of sample points along + * the length of a Polyline, or by defining a bounding box that consists of equally spaced vertices as rows and columns. + * The vertical datum is EPSG:3855. This datum uses the EGM2008 geoid model applied to the WGS84 ellipsoid as its zero + * height reference surface. The vertical unit is measured in meters, the spatial resolution of the elevation data is + * 0.8 arc-second for global coverage (~24 meters). + */ +package com.azure.maps.elevation.implementation.models; diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/package-info.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/package-info.java new file mode 100644 index 0000000000000..c024fad78a678 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/implementation/package-info.java @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the implementations for ElevationClient. The Azure Maps Elevation API provides an HTTP interface + * to query elevation data on the surface of the Earth. Elevation data can be retrieved at specific locations by sending + * lat/lon coordinates, by defining an ordered set of vertices that form a Polyline and a number of sample points along + * the length of a Polyline, or by defining a bounding box that consists of equally spaced vertices as rows and columns. + * The vertical datum is EPSG:3855. This datum uses the EGM2008 geoid model applied to the WGS84 ellipsoid as its zero + * height reference surface. The vertical unit is measured in meters, the spatial resolution of the elevation data is + * 0.8 arc-second for global coverage (~24 meters). + */ +package com.azure.maps.elevation.implementation; diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/models/ElevationResult.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/models/ElevationResult.java new file mode 100644 index 0000000000000..4f9a2b5a3cda6 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/models/ElevationResult.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.maps.elevation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.models.GeoPosition; +import com.azure.maps.elevation.implementation.models.Elevation; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.List; + +/** The response from a successful Get Data for Bounding Box API. */ +@Immutable +public final class ElevationResult { + /* + * The response for point/points elevation API. The result will be in same + * sequence of points listed in request. + */ + @JsonProperty(value = "data", access = JsonProperty.Access.WRITE_ONLY) + private List elevations; + + /** Set default ElevationResult constructor to private */ + private ElevationResult() {} + + /** + * Get the elevations property: The response for point/points elevation API. The result will be in same sequence of + * points listed in request. + * + * @return the elevations value + */ + public List getElevations() { + List toreturn = new ArrayList<>(); + for (Elevation e : this.elevations) { + toreturn.add( + new GeoPosition( + e.getCoordinate().getLatitude(), + e.getCoordinate().getLongitude(), + (double) e.getElevationInMeters())); + } + return toreturn; + } +} diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/models/package-info.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/models/package-info.java new file mode 100644 index 0000000000000..b8554dd51c922 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/models/package-info.java @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing classes for ElevationClient. The Azure Maps Elevation API provides an HTTP interface to query + * elevation data on the surface of the Earth. Elevation data can be retrieved at specific locations by sending lat/lon + * coordinates, by defining an ordered set of vertices that form a Polyline and a number of sample points along the + * length of a Polyline, or by defining a bounding box that consists of equally spaced vertices as rows and columns. The + * vertical datum is EPSG:3855. This datum uses the EGM2008 geoid model applied to the WGS84 ellipsoid as its zero + * height reference surface. The vertical unit is measured in meters, the spatial resolution of the elevation data is + * 0.8 arc-second for global coverage (~24 meters). + */ +package com.azure.maps.elevation.models; diff --git a/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/package-info.java b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/package-info.java new file mode 100644 index 0000000000000..992496af5e0d2 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/com/azure/maps/elevation/package-info.java @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the classes for ElevationClient. The Azure Maps Elevation API provides an HTTP interface to query + * elevation data on the surface of the Earth. Elevation data can be retrieved at specific locations by sending lat/lon + * coordinates, by defining an ordered set of vertices that form a Polyline and a number of sample points along the + * length of a Polyline, or by defining a bounding box that consists of equally spaced vertices as rows and columns. The + * vertical datum is EPSG:3855. This datum uses the EGM2008 geoid model applied to the WGS84 ellipsoid as its zero + * height reference surface. The vertical unit is measured in meters, the spatial resolution of the elevation data is + * 0.8 arc-second for global coverage (~24 meters). + */ +package com.azure.maps.elevation; diff --git a/sdk/maps/azure-maps-elevation/src/main/java/module-info.java b/sdk/maps/azure-maps-elevation/src/main/java/module-info.java new file mode 100644 index 0000000000000..b4eba54f39624 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/main/java/module-info.java @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +module com.azure.maps.elevation { + requires transitive com.azure.core; + + exports com.azure.maps.elevation; + exports com.azure.maps.elevation.models; + + opens com.azure.maps.elevation.implementation to com.fasterxml.jackson.databind, com.azure.core; + opens com.azure.maps.elevation.models to com.fasterxml.jackson.databind, com.azure.core; + opens com.azure.maps.elevation.implementation.models to com.fasterxml.jackson.databind, com.azure.core; +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/samples/java/com/azure/maps/elevation/samples/ElevationSample.java b/sdk/maps/azure-maps-elevation/src/samples/java/com/azure/maps/elevation/samples/ElevationSample.java new file mode 100644 index 0000000000000..767d8dce54caa --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/samples/java/com/azure/maps/elevation/samples/ElevationSample.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.maps.elevation.samples; + +import com.azure.core.credential.AzureKeyCredential; +import com.azure.identity.DefaultAzureCredential; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.maps.elevation.ElevationAsyncClient; +import com.azure.maps.elevation.ElevationClient; +import com.azure.maps.elevation.ElevationClientBuilder; + +public class ElevationSample { + public ElevationClient createMapsSyncClientUsingAzureKeyCredential() { + // BEGIN: com.azure.maps.elevation.sync.builder.key.instantiation + // Authenticates using subscription key + AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY")); + + // Creates a client + ElevationClient client = new ElevationClientBuilder() + .credential(keyCredential) + .elevationClientId(System.getenv("MAPS_CLIENT_ID")) + .buildClient(); + // END: com.azure.maps.elevation.sync.builder.key.instantiation + + return client; + } + + public ElevationClient createMapsSyncClientUsingAzureADCredential() { + // BEGIN: com.azure.maps.elevation.sync.builder.ad.instantiation + // 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 a client + ElevationClient client = new ElevationClientBuilder() + .credential(tokenCredential) + .elevationClientId(System.getenv("MAPS_CLIENT_ID")) + .buildClient(); + // END: com.azure.maps.elevation.sync.builder.ad.instantiation + + return client; + } + + public ElevationAsyncClient createMapsElevationAsyncClientUsingAzureKeyCredential() { + // BEGIN: com.azure.maps.elevation.async.builder.key.instantiation + // Authenticates using subscription key + AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY")); + + // Creates a client + ElevationAsyncClient asyncClient = new ElevationClientBuilder() + .credential(keyCredential) + .elevationClientId(System.getenv("MAPS_CLIENT_ID")) + .buildAsyncClient(); + // END: com.azure.maps.elevation.async.builder.key.instantiation + + return asyncClient; + } + + public ElevationAsyncClient createMapsElevationAsyncClientUsingAzureADCredential() { + // BEGIN: com.azure.maps.elevation.async.builder.ad.instantiation + // 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 a client + ElevationAsyncClient asyncClient = new ElevationClientBuilder() + .credential(tokenCredential) + .elevationClientId(System.getenv("MAPS_CLIENT_ID")) + .buildAsyncClient(); + + // END: com.azure.maps.elevation.async.builder.ad.instantiation + + return asyncClient; + } +} diff --git a/sdk/maps/azure-maps-elevation/src/samples/java/com/azure/maps/elevation/samples/GetDataForBoundingBox.java b/sdk/maps/azure-maps-elevation/src/samples/java/com/azure/maps/elevation/samples/GetDataForBoundingBox.java new file mode 100644 index 0000000000000..01349f2c979e0 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/samples/java/com/azure/maps/elevation/samples/GetDataForBoundingBox.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.maps.elevation.samples; + +import com.azure.core.models.GeoBoundingBox; +import com.azure.identity.DefaultAzureCredential; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.maps.elevation.ElevationAsyncClient; +import com.azure.maps.elevation.ElevationClient; +import com.azure.maps.elevation.ElevationClientBuilder; + +public class GetDataForBoundingBox { + public static void main(String[] args) { + // Authenticates using subscription key + // AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY")); + // builder.credential(keyCredential); + + // 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(); + + ElevationClient client = new ElevationClientBuilder() + .credential(tokenCredential) + .elevationClientId(System.getenv("MAPS_CLIENT_ID")) + .buildClient(); + + // Get Data For Bounding Box - + // https://docs.microsoft.com/en-us/rest/api/maps/elevation/get-data-for-bounding-box + // The Get Data for Bounding Box API provides elevation data at equally spaced locations within a bounding box. + // A bounding box is defined by the coordinates for two corners (southwest, northeast) + // and then subsequently divided into rows and columns. + // Elevations are returned for the vertices of the grid created by the rows and columns. + // Up to 2,000 elevations can be returned in a single request. + // The returned elevation values are ordered, starting at the southwest corner, + // and then proceeding west to east along the row. At the end of the row, + // it moves north to the next row, and repeats the process until it reaches the far northeast corner. + // BEGIN: com.azure.maps.elevation.sync.get_data_for_bounding_box + client.getDataForBoundingBox(new GeoBoundingBox(-121.668533621438, 46.8464647986371, + -121.658533621438, 46.8564647986371), 3, 3); + // END: com.azure.maps.elevation.sync.get_data_for_bounding_box + + // Authenticates using subscription key + // AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY")); + // builder.credential(keyCredential); + + // 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 asyncClientTokenCredential = new DefaultAzureCredentialBuilder().build(); + + ElevationAsyncClient asyncClient = new ElevationClientBuilder() + .credential(asyncClientTokenCredential) + .elevationClientId(System.getenv("MAPS_CLIENT_ID")) + .buildAsyncClient(); + + // Get Data For Bounding Box - + // https://docs.microsoft.com/en-us/rest/api/maps/elevation/get-data-for-bounding-box + // The Get Data for Bounding Box API provides elevation data at equally spaced locations within a bounding box. + // A bounding box is defined by the coordinates for two corners (southwest, northeast) + // and then subsequently divided into rows and columns. + // Elevations are returned for the vertices of the grid created by the rows and columns. + // Up to 2,000 elevations can be returned in a single request. + // The returned elevation values are ordered, starting at the southwest corner, + // and then proceeding west to east along the row. At the end of the row, + // it moves north to the next row, and repeats the process until it reaches the far northeast corner. + // BEGIN: com.azure.maps.elevation.async.get_data_for_bounding_box + asyncClient.getDataForBoundingBox(new GeoBoundingBox(-121.668533621438f, 46.8464647986371f, + -121.658533621438f, 46.8564647986371f), 3, 3); + // END: com.azure.maps.elevation.async.get_data_for_bounding_box + } +} diff --git a/sdk/maps/azure-maps-elevation/src/samples/java/com/azure/maps/elevation/samples/GetDataForPoints.java b/sdk/maps/azure-maps-elevation/src/samples/java/com/azure/maps/elevation/samples/GetDataForPoints.java new file mode 100644 index 0000000000000..a3326c80575e1 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/samples/java/com/azure/maps/elevation/samples/GetDataForPoints.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.maps.elevation.samples; + +import com.azure.core.models.GeoPosition; +import com.azure.identity.DefaultAzureCredential; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.maps.elevation.ElevationAsyncClient; +import com.azure.maps.elevation.ElevationClient; +import com.azure.maps.elevation.ElevationClientBuilder; +import java.util.Arrays; + +public class GetDataForPoints { + public static void main(String[] args) { + // Authenticates using subscription key + // AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY")); + // builder.credential(keyCredential); + + // 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(); + + ElevationClient client = new ElevationClientBuilder() + .credential(tokenCredential) + .elevationClientId(System.getenv("MAPS_CLIENT_ID")) + .buildClient(); + + // Get Data For Points - + // https://docs.microsoft.com/en-us/rest/api/maps/elevation/get-data-for-points + // The Get Data for Points API provides elevation data for one or more points. + // A point is defined in lat,long coordinate format. + // Due to the URL character length limit of 2048, it's not possible to pass more than 100 coordinates as a pipeline delimited string in a URL GET request. + // If you intend to pass more than 100 coordinates as a pipeline delimited string, use the POST Data For Points. + // BEGIN: com.azure.maps.elevation.sync.get_data_for_points + client.getDataForPoints(Arrays.asList( + new GeoPosition(-121.66853362143818, 46.84646479863713), + new GeoPosition(-121.68853362143818, 46.856464798637127))); + // END: com.azure.maps.elevation.sync.get_data_for_points + + // Authenticates using subscription key + // AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY")); + // builder.credential(keyCredential); + + // 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 asyncClientTokenCredential = new DefaultAzureCredentialBuilder().build(); + + ElevationAsyncClient asyncClient = new ElevationClientBuilder() + .credential(asyncClientTokenCredential) + .elevationClientId(System.getenv("MAPS_CLIENT_ID")) + .buildAsyncClient(); + + // Get Data For Points - + // https://docs.microsoft.com/en-us/rest/api/maps/elevation/get-data-for-points + // The Get Data for Points API provides elevation data for one or more points. + // A point is defined in lat,long coordinate format. + // Due to the URL character length limit of 2048, it's not possible to pass more than 100 coordinates as a pipeline delimited string in a URL GET request. + // If you intend to pass more than 100 coordinates as a pipeline delimited string, use the POST Data For Points. + // BEGIN: com.azure.maps.elevation.async.get_data_for_points + asyncClient.getDataForPoints(Arrays.asList( + new GeoPosition(-121.66853362143818, 46.84646479863713), + new GeoPosition(-121.68853362143818, 46.856464798637127))); + // END: com.azure.maps.elevation.async.get_data_for_points + } +} diff --git a/sdk/maps/azure-maps-elevation/src/samples/java/com/azure/maps/elevation/samples/GetDataForPolyline.java b/sdk/maps/azure-maps-elevation/src/samples/java/com/azure/maps/elevation/samples/GetDataForPolyline.java new file mode 100644 index 0000000000000..39def3ccfa0eb --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/samples/java/com/azure/maps/elevation/samples/GetDataForPolyline.java @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.maps.elevation.samples; + +import com.azure.core.models.GeoPosition; +import com.azure.identity.DefaultAzureCredential; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.maps.elevation.ElevationAsyncClient; +import com.azure.maps.elevation.ElevationClient; +import com.azure.maps.elevation.ElevationClientBuilder; +import java.util.Arrays; + +public class GetDataForPolyline { + public static void main(String[] args) { + // Authenticates using subscription key + // AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY")); + // builder.credential(keyCredential); + + // 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(); + + ElevationClient client = new ElevationClientBuilder() + .credential(tokenCredential) + .elevationClientId(System.getenv("MAPS_CLIENT_ID")) + .buildClient(); + + // Get Data For Polyline - + // https://docs.microsoft.com/en-us/rest/api/maps/elevation/get-data-for-polyline + // A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + // In addition to passing in endpoints, customers can specify the number of sample points that will be used to divide polyline into equally spaced segments. + // Elevation data at both start and end points, as well as equally spaced points along the polyline will be returned. + // The results will be listed in the direction from the first endpoint towards the last endpoint. + // A line between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate reference system. + // Note that the point is chosen based on Euclidean distance and may markedly differ from the geodesic path along the curved surface of the reference ellipsoid. + // If you intend to pass more than 100 coordinates as a pipeline delimited string, use the POST Data For Polyline. + // BEGIN: com.azure.maps.elevation.sync.get_data_for_polyline + client.getDataForPolyline(Arrays.asList( + new GeoPosition(-121.66853362143818, 46.84646479863713), + new GeoPosition(-121.65853362143818, 46.85646479863713)), 5); + // END: com.azure.maps.elevation.sync.get_data_for_polyline + + // Authenticates using subscription key + // AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY")); + // builder.credential(keyCredential); + + // 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 asyncClientTokenCredential = new DefaultAzureCredentialBuilder().build(); + + ElevationAsyncClient asyncClient = new ElevationClientBuilder() + .credential(asyncClientTokenCredential) + .elevationClientId(System.getenv("MAPS_CLIENT_ID")) + .buildAsyncClient(); + + // Get Data For Polyline - + // https://docs.microsoft.com/en-us/rest/api/maps/elevation/get-data-for-polyline + // A polyline is defined by passing in between 2 and N endpoint coordinates separated by a pipe ('|') character. + // In addition to passing in endpoints, customers can specify the number of sample points that will be used to divide polyline into equally spaced segments. + // Elevation data at both start and end points, as well as equally spaced points along the polyline will be returned. + // The results will be listed in the direction from the first endpoint towards the last endpoint. + // A line between two endpoints is a straight Cartesian line, the shortest line between those two points in the coordinate reference system. + // Note that the point is chosen based on Euclidean distance and may markedly differ from the geodesic path along the curved surface of the reference ellipsoid. + // If you intend to pass more than 100 coordinates as a pipeline delimited string, use the POST Data For Polyline. + // BEGIN: com.azure.maps.elevation.async.get_data_for_polyline + asyncClient.getDataForPolyline(Arrays.asList( + new GeoPosition(-121.66853362143818, 46.84646479863713), + new GeoPosition(-121.65853362143818, 46.85646479863713)), 5); + // END: com.azure.maps.elevation.async.get_data_for_polyline + } +} diff --git a/sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/ElevationAsyncClientTest.java b/sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/ElevationAsyncClientTest.java new file mode 100644 index 0000000000000..be34220749cde --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/ElevationAsyncClientTest.java @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.maps.elevation; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; +import java.time.Duration; +import java.util.Arrays; + +import com.azure.core.exception.HttpResponseException; +import com.azure.core.http.HttpClient; +import com.azure.core.models.GeoBoundingBox; +import com.azure.core.models.GeoPosition; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import reactor.test.StepVerifier; + +public class ElevationAsyncClientTest extends ElevationClientTestBase { + private static final String DISPLAY_NAME_WITH_ARGUMENTS = "{displayName} with [{arguments}]"; + + @BeforeAll + public static void beforeAll() { + StepVerifier.setDefaultTimeout(Duration.ofSeconds(30)); + } + + @AfterAll + public static void afterAll() { + StepVerifier.resetDefaultTimeout(); + } + + private ElevationAsyncClient getElevationAsyncClient(HttpClient httpClient, ElevationServiceVersion serviceVersion) { + return getElevationAsyncClientBuilder(httpClient, serviceVersion).buildAsyncClient(); + } + + // Test async get data for points + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testAsyncGetDataForPoints(HttpClient httpClient, ElevationServiceVersion serviceVersion) throws IOException { + ElevationAsyncClient client = getElevationAsyncClient(httpClient, serviceVersion); + StepVerifier.create(client.getDataForPoints(Arrays.asList(new GeoPosition(-121.66853362143818, 46.84646479863713), new GeoPosition(-121.68853362143818, 46.856464798637127)))) + .assertNext(actualResults -> { + try { + validateGetDataForPoints(TestUtils.getExpectedDataForPoints(), actualResults); + } catch (IOException e) { + Assertions.fail("Unable to get data for points"); + } + }).verifyComplete(); + } + + // Test async get data for points with response + // Case 1: 200 + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testAsyncGetDataForPointsWithResponse(HttpClient httpClient, ElevationServiceVersion serviceVersion) { + ElevationAsyncClient client = getElevationAsyncClient(httpClient, serviceVersion); + StepVerifier.create(client.getDataForPointsWithResponse(Arrays.asList(new GeoPosition(-121.66853362143818, 46.84646479863713), new GeoPosition(-121.68853362143818, 46.856464798637127)), null)) + .assertNext(response -> { + try { + validateGetDataForPointsWithResponse(TestUtils.getExpectedDataForPoints(), 200, response); + } catch (IOException e) { + Assertions.fail("Unable to get data for points"); + } + }).verifyComplete(); + } + + // Case 2: 400 invalid input + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testAsyncInvalidGetDataForPointsWithResponse(HttpClient httpClient, ElevationServiceVersion serviceVersion) { + ElevationAsyncClient client = getElevationAsyncClient(httpClient, serviceVersion); + StepVerifier.create(client.getDataForPointsWithResponse(Arrays.asList(new GeoPosition(-100000000, 46.84646479863713), new GeoPosition(-121.68853362143818, 46.856464798637127)), null)) + .verifyErrorSatisfies(ex -> { + final HttpResponseException httpResponseException = (HttpResponseException) ex; + assertEquals(400, httpResponseException.getResponse().getStatusCode()); + }); + } + + // Test async get data for polyline + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testAsyncGetDataForPolyline(HttpClient httpClient, ElevationServiceVersion serviceVersion) throws IOException { + ElevationAsyncClient client = getElevationAsyncClient(httpClient, serviceVersion); + StepVerifier.create(client.getDataForPolyline(Arrays.asList( + new GeoPosition(-121.66853362143818, 46.84646479863713), + new GeoPosition(-121.65853362143818, 46.85646479863713)), 5)) + .assertNext(actualResults -> { + try { + validateGetDataForPolyline(TestUtils.getExpectedDataForPolyline(), actualResults); + } catch (IOException e) { + Assertions.fail("Unable to get data for polyline"); + } + }).verifyComplete(); + } + + // Test async get data for polyline with response + // Case 1: 200 + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testAsyncGetDataForPolylineWithResponse(HttpClient httpClient, ElevationServiceVersion serviceVersion) { + ElevationAsyncClient client = getElevationAsyncClient(httpClient, serviceVersion); + StepVerifier.create(client.getDataForPolylineWithResponse(Arrays.asList( + new GeoPosition(-121.66853362143818, 46.84646479863713), + new GeoPosition(-121.65853362143818, 46.85646479863713)), 5, null)) + .assertNext(response -> { + try { + validateGetDataForPolylineWithResponse(TestUtils.getExpectedDataForPolyline(), 200, response); + } catch (IOException e) { + Assertions.fail("Unable to get data for polyline"); + } + }).verifyComplete(); + } + + // Case 2: 400 invalid input + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testAsyncInvalidGetDataForPolylineWithResponse(HttpClient httpClient, ElevationServiceVersion serviceVersion) { + ElevationAsyncClient client = getElevationAsyncClient(httpClient, serviceVersion); + StepVerifier.create(client.getDataForPolylineWithResponse(Arrays.asList( + new GeoPosition(-1000000, 46.84646479863713), + new GeoPosition(-121.65853362143818, 46.85646479863713)), 5, null)) + .verifyErrorSatisfies(ex -> { + final HttpResponseException httpResponseException = (HttpResponseException) ex; + assertEquals(400, httpResponseException.getResponse().getStatusCode()); + }); + } + + // Test get data for bounding box + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testAsyncGetDataForBoundingBox(HttpClient httpClient, ElevationServiceVersion serviceVersion) throws IOException { + ElevationAsyncClient client = getElevationAsyncClient(httpClient, serviceVersion); + StepVerifier.create(client.getDataForBoundingBox(new GeoBoundingBox(-121.668533621438f, 46.8464647986371f, + -121.658533621438f, 46.8564647986371f), 3, 3)) + .assertNext(actualResults -> { + try { + validateGetDataForBoundingBox(TestUtils.getExpectedDataForBoundingBox(), actualResults); + } catch (IOException e) { + Assertions.fail("Unable to get data for bounding box"); + } + }).verifyComplete(); + } + + // Test async get data for bounding box with response + // Case 1: 200 + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testAsyncGetDataForBoundingBoxWithResponse(HttpClient httpClient, ElevationServiceVersion serviceVersion) { + ElevationAsyncClient client = getElevationAsyncClient(httpClient, serviceVersion); + StepVerifier.create(client.getDataForBoundingBoxWithResponse(new GeoBoundingBox(-121.668533621438f, 46.8464647986371f, + -121.658533621438f, 46.8564647986371f), 3, 3, null)) + .assertNext(response -> { + try { + validateGetDataForBoundingBoxWithResponse(TestUtils.getExpectedDataForBoundingBox(), 200, response); + } catch (IOException e) { + Assertions.fail("Unable to get data for bounding box"); + } + }).verifyComplete(); + } + + // Case 2: 400 invalid input + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testAsyncInvalidGetDataForBoundingBoxWithResponse(HttpClient httpClient, ElevationServiceVersion serviceVersion) { + ElevationAsyncClient client = getElevationAsyncClient(httpClient, serviceVersion); + StepVerifier.create(client.getDataForBoundingBoxWithResponse(new GeoBoundingBox(-121.668533621438f, 46.8464647986371f, + -10000000f, 46.8564647986371f), 3, 3, null)) + .verifyErrorSatisfies(ex -> { + final HttpResponseException httpResponseException = (HttpResponseException) ex; + assertEquals(400, httpResponseException.getResponse().getStatusCode()); + }); + } +} diff --git a/sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/ElevationClientBuilderTest.java b/sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/ElevationClientBuilderTest.java new file mode 100644 index 0000000000000..3367b123df3db --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/ElevationClientBuilderTest.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.maps.elevation; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +import com.azure.identity.DefaultAzureCredential; +import com.azure.identity.DefaultAzureCredentialBuilder; + +import org.junit.jupiter.api.Test; + +public class ElevationClientBuilderTest { + // Test for null RenderClientId, the client ID value + @Test + public void missingMapsClientId() { + assertThrows(NullPointerException.class, () -> { + final ElevationClientBuilder builder = new ElevationClientBuilder(); + builder.elevationClientId(null); + }); + } + + // Test for missing endpoint + @Test + public void missingEndpoint() { + assertThrows(NullPointerException.class, () -> { + final ElevationClientBuilder builder = new ElevationClientBuilder(); + builder.endpoint(null); + }); + } + + // Test for missing configuration + @Test + public void missingConfiguration() { + assertThrows(NullPointerException.class, () -> { + final ElevationClientBuilder builder = new ElevationClientBuilder(); + builder.configuration(null); + }); + } + + // Test for missing http log options + @Test + public void missingHttpLogOptions() { + assertThrows(NullPointerException.class, () -> { + final ElevationClientBuilder builder = new ElevationClientBuilder(); + builder.httpLogOptions(null); + }); + } + + // Test for missing retry policy + @Test + public void missingRetryPolicy() { + assertThrows(NullPointerException.class, () -> { + final ElevationClientBuilder builder = new ElevationClientBuilder(); + builder.retryPolicy(null); + }); + } + + // Test for missing client options + @Test + public void missingClientOptions() { + assertThrows(NullPointerException.class, () -> { + final ElevationClientBuilder builder = new ElevationClientBuilder(); + builder.clientOptions(null); + }); + } + + // Test for missing add policy + @Test + public void missingAddPolicy() { + assertThrows(NullPointerException.class, () -> { + final ElevationClientBuilder builder = new ElevationClientBuilder(); + builder.addPolicy(null); + }); + } + + // Test for null map id, valid token credential + @Test + public void missingMapsClientIdValidTokenCredential() { + assertThrows(IllegalArgumentException.class, () -> { + final ElevationClientBuilder builder = new ElevationClientBuilder(); + DefaultAzureCredential tokenCredential = new DefaultAzureCredentialBuilder().build(); + builder.credential(tokenCredential); + builder.buildClient(); + }); + } + + // Test for null key credential and null token credential despite valid mapsClientId + @Test + public void missingCredentials() { + assertThrows(IllegalArgumentException.class, () -> { + final ElevationClientBuilder builder = new ElevationClientBuilder(); + builder.elevationClientId("elevationClientId"); + builder.buildClient(); + }); + } +} diff --git a/sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/ElevationClientTest.java b/sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/ElevationClientTest.java new file mode 100644 index 0000000000000..aaa31bcca7543 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/ElevationClientTest.java @@ -0,0 +1,124 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.maps.elevation; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.io.IOException; +import java.util.Arrays; + +import com.azure.core.exception.HttpResponseException; +import com.azure.core.http.HttpClient; +import com.azure.core.models.GeoBoundingBox; +import com.azure.core.models.GeoPosition; +import com.azure.maps.elevation.models.ElevationResult; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +public class ElevationClientTest extends ElevationClientTestBase { + private ElevationClient client; + private static final String DISPLAY_NAME_WITH_ARGUMENTS = "{displayName} with [{arguments}]"; + + private ElevationClient getElevationClient(HttpClient httpClient, ElevationServiceVersion serviceVersion) { + return getElevationAsyncClientBuilder(httpClient, serviceVersion).buildClient(); + } + + // Test get data for points + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testGetDataForPoints(HttpClient httpClient, ElevationServiceVersion serviceVersion) throws IOException { + client = getElevationClient(httpClient, serviceVersion); + ElevationResult actualResult = client.getDataForPoints(Arrays.asList(new GeoPosition(-121.66853362143818, 46.84646479863713), new GeoPosition(-121.68853362143818, 46.856464798637127))); + ElevationResult expectedResult = TestUtils.getExpectedDataForPoints(); + validateGetDataForPoints(actualResult, expectedResult); + } + + // Test get data for points with response + // Case 1: 200 + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testGetDataForPointsWithResponse(HttpClient httpClient, ElevationServiceVersion serviceVersion) throws IOException { + client = getElevationClient(httpClient, serviceVersion); + validateGetDataForPointsWithResponse(TestUtils.getExpectedDataForPoints(), 200, client.getDataForPointsWithResponse(Arrays.asList(new GeoPosition(-121.66853362143818, 46.84646479863713), new GeoPosition(-121.68853362143818, 46.856464798637127)), null)); + } + + // Case 2: Respone 400, incorrect input + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testInvalidGetDataForPointsWithResponse(HttpClient httpClient, ElevationServiceVersion serviceVersion) throws IOException { + client = getElevationClient(httpClient, serviceVersion); + final HttpResponseException httpResponseException = assertThrows(HttpResponseException.class, + () -> client.getDataForPointsWithResponse(Arrays.asList(new GeoPosition(-100000000, 46.84646479863713), new GeoPosition(-121.68853362143818, 46.856464798637127)), null)); + assertEquals(400, httpResponseException.getResponse().getStatusCode()); + } + + // Test get data for polyline + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testGetDataForPolyline(HttpClient httpClient, ElevationServiceVersion serviceVersion) throws IOException { + client = getElevationClient(httpClient, serviceVersion); + ElevationResult actualResult = client.getDataForPolyline(Arrays.asList( + new GeoPosition(-121.66853362143818, 46.84646479863713), + new GeoPosition(-121.65853362143818, 46.85646479863713)), 5); + ElevationResult expectedResult = TestUtils.getExpectedDataForPolyline(); + validateGetDataForPolyline(actualResult, expectedResult); + } + + // Test get data for polyline with response + // Case 1: 200 + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testGetDataForPolylineWithResponse(HttpClient httpClient, ElevationServiceVersion serviceVersion) throws IOException { + client = getElevationClient(httpClient, serviceVersion); + validateGetDataForPolylineWithResponse(TestUtils.getExpectedDataForPolyline(), 200, client.getDataForPolylineWithResponse(Arrays.asList( + new GeoPosition(-121.66853362143818, 46.84646479863713), + new GeoPosition(-121.65853362143818, 46.85646479863713)), 5, null)); + } + + // Case 2: Respone 400, incorrect input + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testInvalidGetDataForPolylineWithResponse(HttpClient httpClient, ElevationServiceVersion serviceVersion) throws IOException { + client = getElevationClient(httpClient, serviceVersion); + final HttpResponseException httpResponseException = assertThrows(HttpResponseException.class, + () -> client.getDataForPolylineWithResponse(Arrays.asList( + new GeoPosition(-1000000000, 46.84646479863713), + new GeoPosition(-121.65853362143818, 46.85646479863713)), 5, null)); + assertEquals(400, httpResponseException.getResponse().getStatusCode()); + } + + // Test get data for bounding box + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testGetDataForBoundingBox(HttpClient httpClient, ElevationServiceVersion serviceVersion) throws IOException { + client = getElevationClient(httpClient, serviceVersion); + ElevationResult actualResult = client.getDataForBoundingBox(new GeoBoundingBox(-121.668533621438, 46.8464647986371, + -121.658533621438, 46.8564647986371), 3, 3); + ElevationResult expectedResult = TestUtils.getExpectedDataForBoundingBox(); + validateGetDataForBoundingBox(actualResult, expectedResult); + } + + // Test get data for bounding box with response + // Case 1: 200 + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testGetDataForBoundingBoxWithResponse(HttpClient httpClient, ElevationServiceVersion serviceVersion) throws IOException { + client = getElevationClient(httpClient, serviceVersion); + validateGetDataForBoundingBoxWithResponse(TestUtils.getExpectedDataForBoundingBox(), 200, client.getDataForBoundingBoxWithResponse(new GeoBoundingBox(-121.668533621438f, 46.8464647986371f, + -121.658533621438f, 46.8564647986371f), 3, 3, null)); + } + + // Case 2: Respone 400, incorrect input + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.maps.elevation.TestUtils#getTestParameters") + public void testInvalidGetDataForBoundingBoxWithResponse(HttpClient httpClient, ElevationServiceVersion serviceVersion) throws IOException { + client = getElevationClient(httpClient, serviceVersion); + final HttpResponseException httpResponseException = assertThrows(HttpResponseException.class, + () -> client.getDataForBoundingBoxWithResponse(new GeoBoundingBox(-10000000f, 46.8464647986371f, + -121.658533621438f, 46.8564647986371f), 3, 3, null)); + assertEquals(400, httpResponseException.getResponse().getStatusCode()); + } +} diff --git a/sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/ElevationClientTestBase.java b/sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/ElevationClientTestBase.java new file mode 100644 index 0000000000000..9f56d754fa791 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/ElevationClientTestBase.java @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.maps.elevation; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.rest.Response; +import com.azure.core.test.InterceptorManager; +import com.azure.core.test.TestBase; +import com.azure.core.test.TestMode; +import com.azure.core.util.Configuration; +import com.azure.identity.EnvironmentCredentialBuilder; +import com.azure.maps.elevation.models.ElevationResult; + +public class ElevationClientTestBase extends TestBase { + static final String FAKE_API_KEY = "1234567890"; + + private final String endpoint = Configuration.getGlobalConfiguration().get("API-LEARN_ENDPOINT"); + Duration durationTestMode; + static InterceptorManager interceptorManagerTestBase; + + @Override + protected void beforeTest() { + if (interceptorManager.isPlaybackMode()) { + durationTestMode = Duration.ofMillis(1); + } else { + durationTestMode = TestUtils.DEFAULT_POLL_INTERVAL; + } + interceptorManagerTestBase = interceptorManager; + } + + ElevationClientBuilder getElevationAsyncClientBuilder(HttpClient httpClient, ElevationServiceVersion serviceVersion) { + ElevationClientBuilder builder = new ElevationClientBuilder() + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)) + .serviceVersion(serviceVersion); + String endpoint = getEndpoint(); + if (getEndpoint() != null) { + builder.endpoint(endpoint); + } + if (getTestMode() == TestMode.RECORD) { + builder.addPolicy(interceptorManager.getRecordPolicy()); + } + if (getTestMode() == TestMode.PLAYBACK) { + builder.credential(new AzureKeyCredential(FAKE_API_KEY)).httpClient(interceptorManager.getPlaybackClient()); + } else { + builder.credential((new AzureKeyCredential( + Configuration.getGlobalConfiguration().get("SUBSCRIPTION_KEY")))); + } + return builder; + } + + HttpPipeline getHttpPipeline(HttpClient httpClient) { + TokenCredential credential = null; + + if (!interceptorManager.isPlaybackMode()) { + credential = new EnvironmentCredentialBuilder().httpClient(httpClient).build(); + } + + final List policies = new ArrayList<>(); + if (credential != null) { + policies.add(new BearerTokenAuthenticationPolicy(credential, endpoint.replaceFirst("/$", "") + "/.default")); + } + + if (getTestMode() == TestMode.RECORD) { + policies.add(interceptorManager.getRecordPolicy()); + } + + HttpPipeline pipeline = new HttpPipelineBuilder() + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient == null ? interceptorManager.getPlaybackClient() : httpClient) + .build(); + + return pipeline; + } + + String getEndpoint() { + return interceptorManager.isPlaybackMode() + ? "https://localhost:8080" + : endpoint; + } + + static void validateGetDataForPoints(ElevationResult expected, ElevationResult actual) { + assertNotNull(actual); + assertNotNull(expected); + assertEquals(expected.getElevations().size(), actual.getElevations().size()); + } + + static void validateGetDataForPointsWithResponse(ElevationResult expected, int expectedStatusCode, Response response) { + assertNotNull(response); + assertEquals(expectedStatusCode, response.getStatusCode()); + validateGetDataForPoints(expected, response.getValue()); + } + + static void validatePostDataForPoints(ElevationResult expected, ElevationResult actual) { + assertNotNull(actual); + assertNotNull(expected); + assertEquals(expected.getElevations().size(), actual.getElevations().size()); + } + + static void validatePostDataForPointsWithResponse(ElevationResult expected, int expectedStatusCode, Response response) { + assertNotNull(response); + assertEquals(expectedStatusCode, response.getStatusCode()); + validateGetDataForPoints(expected, response.getValue()); + } + + static void validateGetDataForPolyline(ElevationResult expected, ElevationResult actual) { + assertNotNull(actual); + assertNotNull(expected); + assertEquals(expected.getElevations().size(), actual.getElevations().size()); + } + + static void validateGetDataForPolylineWithResponse(ElevationResult expected, int expectedStatusCode, Response response) { + assertNotNull(response); + assertEquals(expectedStatusCode, response.getStatusCode()); + validateGetDataForPolyline(expected, response.getValue()); + } + + static void validatePostDataForPolyline(ElevationResult expected, ElevationResult actual) { + assertNotNull(actual); + assertNotNull(expected); + assertEquals(expected.getElevations().size(), actual.getElevations().size()); + } + + static void validatePostDataForPolylineWithResponse(ElevationResult expected, int expectedStatusCode, Response response) { + assertNotNull(response); + assertEquals(expectedStatusCode, response.getStatusCode()); + validatePostDataForPolyline(expected, response.getValue()); + } + + static void validateGetDataForBoundingBox(ElevationResult expected, ElevationResult actual) { + assertNotNull(actual); + assertNotNull(expected); + assertEquals(expected.getElevations().size(), actual.getElevations().size()); + } + + static void validateGetDataForBoundingBoxWithResponse(ElevationResult expected, int expectedStatusCode, Response response) { + assertNotNull(response); + assertEquals(expectedStatusCode, response.getStatusCode()); + validateGetDataForBoundingBox(expected, response.getValue()); + } +} diff --git a/sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/TestUtils.java b/sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/TestUtils.java new file mode 100644 index 0000000000000..c697fe3439f30 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/java/com/azure/maps/elevation/TestUtils.java @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.maps.elevation; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.time.Duration; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +import com.azure.core.test.TestBase; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.core.util.serializer.TypeReference; +import com.azure.maps.elevation.models.ElevationResult; + +import org.junit.jupiter.params.provider.Arguments; + +public class TestUtils { + static final String FAKE_API_KEY = "1234567890"; + public static final Duration DEFAULT_POLL_INTERVAL = Duration.ofSeconds(30); + + /** + * Returns a stream of arguments that includes all combinations of eligible {@link HttpClient HttpClients} and + * service versions that should be tested. + * + * @return A stream of HttpClient and service version combinations to test. + */ + public static Stream getTestParameters() { + // when this issues is closed, the newer version of junit will have better support for + // cartesian product of arguments - https://github.com/junit-team/junit5/issues/1427 + List argumentsList = new ArrayList<>(); + TestBase.getHttpClients() + .forEach(httpClient -> { + Arrays.stream(ElevationServiceVersion.values()) + .forEach(serviceVersion -> argumentsList.add(Arguments.of(httpClient, serviceVersion))); + }); + return argumentsList.stream(); + } + + static ElevationResult getExpectedDataForPoints() throws IOException { + InputStream is = ClassLoader.getSystemResourceAsStream("getdataforpoints.json"); + byte[] data = toByteArray(is); + SerializerAdapter jacksonAdapter = JacksonAdapter.createDefaultSerializerAdapter(); + TypeReference interimType = new TypeReference(){}; + is.close(); + return jacksonAdapter.deserialize(data, interimType.getJavaType(), + SerializerEncoding.JSON); + } + + static ElevationResult getExpectedDataForPolyline() throws IOException { + InputStream is = ClassLoader.getSystemResourceAsStream("getdataforpolyline.json"); + byte[] data = toByteArray(is); + SerializerAdapter jacksonAdapter = JacksonAdapter.createDefaultSerializerAdapter(); + TypeReference interimType = new TypeReference(){}; + is.close(); + return jacksonAdapter.deserialize(data, interimType.getJavaType(), + SerializerEncoding.JSON); + } + + static ElevationResult getExpectedDataForBoundingBox() throws IOException { + InputStream is = ClassLoader.getSystemResourceAsStream("getdataforboundingbox.json"); + byte[] data = toByteArray(is); + SerializerAdapter jacksonAdapter = JacksonAdapter.createDefaultSerializerAdapter(); + TypeReference interimType = new TypeReference(){}; + is.close(); + return jacksonAdapter.deserialize(data, interimType.getJavaType(), + SerializerEncoding.JSON); + } + + static ElevationResult getExpectedPostDataForPoints() throws IOException { + InputStream is = ClassLoader.getSystemResourceAsStream("postdataforpoints.json"); + byte[] data = toByteArray(is); + SerializerAdapter jacksonAdapter = JacksonAdapter.createDefaultSerializerAdapter(); + TypeReference interimType = new TypeReference(){}; + is.close(); + return jacksonAdapter.deserialize(data, interimType.getJavaType(), + SerializerEncoding.JSON); + } + + static ElevationResult getExpectedPostDataForPolyline() throws IOException { + InputStream is = ClassLoader.getSystemResourceAsStream("postdataforpolyline.json"); + byte[] data = toByteArray(is); + SerializerAdapter jacksonAdapter = JacksonAdapter.createDefaultSerializerAdapter(); + TypeReference interimType = new TypeReference(){}; + is.close(); + return jacksonAdapter.deserialize(data, interimType.getJavaType(), + SerializerEncoding.JSON); + } + + // Code referenced from + // https://www.techiedelight.com/convert-inputstream-byte-array-java/#:~:text=Convert%20InputStream%20to%20byte%20array%20in%20Java%201,Commons%20IO%20...%204%204.%20Using%20sun.misc.IOUtils%20 + public static byte[] toByteArray(InputStream in) throws IOException { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int len; + // read bytes from the input stream and store them in the buffer + while ((len = in.read(buffer)) != -1) { + // write bytes from the buffer into the output stream + os.write(buffer, 0, len); + } + return os.toByteArray(); + } +} diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/getdataforboundingbox.json b/sdk/maps/azure-maps-elevation/src/test/resources/getdataforboundingbox.json new file mode 100644 index 0000000000000..4ed67f6261671 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/getdataforboundingbox.json @@ -0,0 +1,67 @@ +{ + "data": [ + { + "coordinate": { + "latitude": 46.8464647986371, + "longitude": -121.668533621438 + }, + "elevationInMeter": 2298.65819 + }, + { + "coordinate": { + "latitude": 46.8464647986371, + "longitude": -121.66353362143801 + }, + "elevationInMeter": 2257.62784 + }, + { + "coordinate": { + "latitude": 46.8464647986371, + "longitude": -121.658533621438 + }, + "elevationInMeter": 2133.17568 + }, + { + "coordinate": { + "latitude": 46.851464798637096, + "longitude": -121.668533621438 + }, + "elevationInMeter": 2370.3053 + }, + { + "coordinate": { + "latitude": 46.851464798637096, + "longitude": -121.66353362143801 + }, + "elevationInMeter": 2247.90366 + }, + { + "coordinate": { + "latitude": 46.851464798637096, + "longitude": -121.658533621438 + }, + "elevationInMeter": 2124.02787 + }, + { + "coordinate": { + "latitude": 46.8564647986371, + "longitude": -121.668533621438 + }, + "elevationInMeter": 2318.75315 + }, + { + "coordinate": { + "latitude": 46.8564647986371, + "longitude": -121.66353362143801 + }, + "elevationInMeter": 2100.20795 + }, + { + "coordinate": { + "latitude": 46.8564647986371, + "longitude": -121.658533621438 + }, + "elevationInMeter": 1988.36315 + } + ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/getdataforpoints.json b/sdk/maps/azure-maps-elevation/src/test/resources/getdataforpoints.json new file mode 100644 index 0000000000000..c07567a82985f --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/getdataforpoints.json @@ -0,0 +1,18 @@ +{ + "data": [ + { + "coordinate": { + "latitude": 46.84646479863713, + "longitude": -121.66853362143818 + }, + "elevationInMeter": 2298.65819 + }, + { + "coordinate": { + "latitude": 46.856464798637127, + "longitude": -121.68853362143818 + }, + "elevationInMeter": 2505.19454 + } + ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/getdataforpolyline.json b/sdk/maps/azure-maps-elevation/src/test/resources/getdataforpolyline.json new file mode 100644 index 0000000000000..2635606de5238 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/getdataforpolyline.json @@ -0,0 +1,39 @@ +{ + "data": [ + { + "coordinate": { + "latitude": 46.84646479863713, + "longitude": -121.66853362143818 + }, + "elevationInMeter": 2298.65819 + }, + { + "coordinate": { + "latitude": 46.848964798637127, + "longitude": -121.67103362143818 + }, + "elevationInMeter": 2466.4059 + }, + { + "coordinate": { + "latitude": 46.851464798637124, + "longitude": -121.67353362143818 + }, + "elevationInMeter": 2504.88558 + }, + { + "coordinate": { + "latitude": 46.853964798637129, + "longitude": -121.67603362143818 + }, + "elevationInMeter": 2477.8929 + }, + { + "coordinate": { + "latitude": 46.85646479863713, + "longitude": -121.67853362143818 + }, + "elevationInMeter": 2394.52901 + } + ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/postdataforpoints.json b/sdk/maps/azure-maps-elevation/src/test/resources/postdataforpoints.json new file mode 100644 index 0000000000000..5fd974ad231b5 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/postdataforpoints.json @@ -0,0 +1,18 @@ +{ + "data": [ + { + "coordinate": { + "latitude": 46.846464798637129, + "longitude": -121.66853362143819 + }, + "elevationInMeter": 2298.65819 + }, + { + "coordinate": { + "latitude": 46.856464798637127, + "longitude": -121.68853362143818 + }, + "elevationInMeter": 2505.19454 + } + ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/postdataforpolyline.json b/sdk/maps/azure-maps-elevation/src/test/resources/postdataforpolyline.json new file mode 100644 index 0000000000000..a15a0bc51b55b --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/postdataforpolyline.json @@ -0,0 +1,39 @@ +{ + "data": [ + { + "coordinate": { + "latitude": 46.846464798637129, + "longitude": -121.66853362143819 + }, + "elevationInMeter": 2298.65819 + }, + { + "coordinate": { + "latitude": 46.848964798637127, + "longitude": -121.67103362143818 + }, + "elevationInMeter": 2466.4059 + }, + { + "coordinate": { + "latitude": 46.851464798637124, + "longitude": -121.67353362143818 + }, + "elevationInMeter": 2504.88558 + }, + { + "coordinate": { + "latitude": 46.853964798637129, + "longitude": -121.67603362143818 + }, + "elevationInMeter": 2477.8929 + }, + { + "coordinate": { + "latitude": 46.856464798637127, + "longitude": -121.67853362143818 + }, + "elevationInMeter": 2394.52901 + } + ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForBoundingBoxWithResponse[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForBoundingBoxWithResponse[1].json new file mode 100644 index 0000000000000..6c65e8db66265 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForBoundingBoxWithResponse[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/lattice/json?api-version=1.0&bounds=-121.66853332519531%2C46.846466064453125%2C-121.65853118896484%2C46.85646438598633&rows=3&columns=3", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "988", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "200", + "X-MSEdge-Ref" : "Ref A: F4587CA5F82E4A75BEB49FF40B379F64 Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:22Z", + "Body" : "{\"data\":[{\"coordinate\":{\"latitude\":46.846466064453125,\"longitude\":-121.66853332519531},\"elevationInMeter\":2298.75568},{\"coordinate\":{\"latitude\":46.846466064453125,\"longitude\":-121.66353225708008},\"elevationInMeter\":2257.67204},{\"coordinate\":{\"latitude\":46.846466064453125,\"longitude\":-121.65853118896484},\"elevationInMeter\":2133.13798},{\"coordinate\":{\"latitude\":46.851465225219727,\"longitude\":-121.66853332519531},\"elevationInMeter\":2370.31014},{\"coordinate\":{\"latitude\":46.851465225219727,\"longitude\":-121.66353225708008},\"elevationInMeter\":2247.87731},{\"coordinate\":{\"latitude\":46.851465225219727,\"longitude\":-121.65853118896484},\"elevationInMeter\":2123.96752},{\"coordinate\":{\"latitude\":46.85646438598633,\"longitude\":-121.66853332519531},\"elevationInMeter\":2318.76074},{\"coordinate\":{\"latitude\":46.85646438598633,\"longitude\":-121.66353225708008},\"elevationInMeter\":2100.15878},{\"coordinate\":{\"latitude\":46.85646438598633,\"longitude\":-121.65853118896484},\"elevationInMeter\":1988.26912}]}", + "Date" : "Tue, 04 Oct 2022 23:59:24 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForBoundingBox[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForBoundingBox[1].json new file mode 100644 index 0000000000000..1c60a4a8fa711 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForBoundingBox[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/lattice/json?api-version=1.0&bounds=-121.66853332519531%2C46.846466064453125%2C-121.65853118896484%2C46.85646438598633&rows=3&columns=3", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "988", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "200", + "X-MSEdge-Ref" : "Ref A: 6FD0F2F023A743C89DDCFCC6455F7257 Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:34Z", + "Body" : "{\"data\":[{\"coordinate\":{\"latitude\":46.846466064453125,\"longitude\":-121.66853332519531},\"elevationInMeter\":2298.75568},{\"coordinate\":{\"latitude\":46.846466064453125,\"longitude\":-121.66353225708008},\"elevationInMeter\":2257.67204},{\"coordinate\":{\"latitude\":46.846466064453125,\"longitude\":-121.65853118896484},\"elevationInMeter\":2133.13798},{\"coordinate\":{\"latitude\":46.851465225219727,\"longitude\":-121.66853332519531},\"elevationInMeter\":2370.31014},{\"coordinate\":{\"latitude\":46.851465225219727,\"longitude\":-121.66353225708008},\"elevationInMeter\":2247.87731},{\"coordinate\":{\"latitude\":46.851465225219727,\"longitude\":-121.65853118896484},\"elevationInMeter\":2123.96752},{\"coordinate\":{\"latitude\":46.85646438598633,\"longitude\":-121.66853332519531},\"elevationInMeter\":2318.76074},{\"coordinate\":{\"latitude\":46.85646438598633,\"longitude\":-121.66353225708008},\"elevationInMeter\":2100.15878},{\"coordinate\":{\"latitude\":46.85646438598633,\"longitude\":-121.65853118896484},\"elevationInMeter\":1988.26912}]}", + "Date" : "Tue, 04 Oct 2022 23:59:35 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForPointsWithResponse[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForPointsWithResponse[1].json new file mode 100644 index 0000000000000..19def2c6ff9be --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForPointsWithResponse[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/point/json?api-version=1.0&points=-121.66853362143819%2C46.84646479863713%7C-121.68853362143818%2C46.85646479863713", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "226", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "200", + "X-MSEdge-Ref" : "Ref A: 07C0D7DED1774F7E9364AF6AF395A42D Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:31Z", + "Body" : "{\"data\":[{\"coordinate\":{\"latitude\":46.84646479863713,\"longitude\":-121.66853362143819},\"elevationInMeter\":2298.65819},{\"coordinate\":{\"latitude\":46.85646479863713,\"longitude\":-121.68853362143818},\"elevationInMeter\":2505.19454}]}", + "Date" : "Tue, 04 Oct 2022 23:59:33 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForPoints[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForPoints[1].json new file mode 100644 index 0000000000000..2d2b23347b082 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForPoints[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/point/json?api-version=1.0&points=-121.66853362143819%2C46.84646479863713%7C-121.68853362143818%2C46.85646479863713", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "226", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "200", + "X-MSEdge-Ref" : "Ref A: 1122E230795D4EF0AEE0EC4BA81492C6 Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:25Z", + "Body" : "{\"data\":[{\"coordinate\":{\"latitude\":46.84646479863713,\"longitude\":-121.66853362143819},\"elevationInMeter\":2298.65819},{\"coordinate\":{\"latitude\":46.85646479863713,\"longitude\":-121.68853362143818},\"elevationInMeter\":2505.19454}]}", + "Date" : "Tue, 04 Oct 2022 23:59:26 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForPolylineWithResponse[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForPolylineWithResponse[1].json new file mode 100644 index 0000000000000..3ee421f7cd571 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForPolylineWithResponse[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/line/json?api-version=1.0&lines=-121.66853362143819%2C46.84646479863713%7C-121.65853362143818%2C46.85646479863713&samples=5", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "553", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "200", + "X-MSEdge-Ref" : "Ref A: 72CC9773C6464ABCB797EFE37E41B145 Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:27Z", + "Body" : "{\"data\":[{\"coordinate\":{\"latitude\":46.84646479863713,\"longitude\":-121.66853362143819},\"elevationInMeter\":2298.65819},{\"coordinate\":{\"latitude\":46.848964798637127,\"longitude\":-121.66603362143819},\"elevationInMeter\":2287.75597},{\"coordinate\":{\"latitude\":46.851464798637124,\"longitude\":-121.66353362143818},\"elevationInMeter\":2247.90366},{\"coordinate\":{\"latitude\":46.853964798637129,\"longitude\":-121.66103362143818},\"elevationInMeter\":2042.12034},{\"coordinate\":{\"latitude\":46.85646479863713,\"longitude\":-121.65853362143818},\"elevationInMeter\":1988.36315}]}", + "Date" : "Tue, 04 Oct 2022 23:59:28 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForPolyline[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForPolyline[1].json new file mode 100644 index 0000000000000..7164e677905ad --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncGetDataForPolyline[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/line/json?api-version=1.0&lines=-121.66853362143819%2C46.84646479863713%7C-121.65853362143818%2C46.85646479863713&samples=5", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "553", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "200", + "X-MSEdge-Ref" : "Ref A: 0E49C4A2166546248B4131F2A88A68E8 Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:29Z", + "Body" : "{\"data\":[{\"coordinate\":{\"latitude\":46.84646479863713,\"longitude\":-121.66853362143819},\"elevationInMeter\":2298.65819},{\"coordinate\":{\"latitude\":46.848964798637127,\"longitude\":-121.66603362143819},\"elevationInMeter\":2287.75597},{\"coordinate\":{\"latitude\":46.851464798637124,\"longitude\":-121.66353362143818},\"elevationInMeter\":2247.90366},{\"coordinate\":{\"latitude\":46.853964798637129,\"longitude\":-121.66103362143818},\"elevationInMeter\":2042.12034},{\"coordinate\":{\"latitude\":46.85646479863713,\"longitude\":-121.65853362143818},\"elevationInMeter\":1988.36315}]}", + "Date" : "Tue, 04 Oct 2022 23:59:30 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncInvalidGetDataForBoundingBoxWithResponse[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncInvalidGetDataForBoundingBoxWithResponse[1].json new file mode 100644 index 0000000000000..7b0fc4362198c --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncInvalidGetDataForBoundingBoxWithResponse[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/lattice/json?api-version=1.0&bounds=-121.66853332519531%2C46.846466064453125%2C-1.0E7%2C46.85646438598633&rows=3&columns=3", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "189", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "400", + "X-MSEdge-Ref" : "Ref A: 149BA3FD7F3646C691B9D73D9016D288 Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:29Z", + "Body" : "{\"error\":{\"code\":\"400 BadRequest\",\"message\":\"1 errors occurred. More information provided in details.\",\"details\":[{\"message\":\"Northeast point of the bounds is invalid\",\"target\":\"Bounds\"}]}}", + "Date" : "Tue, 04 Oct 2022 23:59:28 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncInvalidGetDataForPointsWithResponse[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncInvalidGetDataForPointsWithResponse[1].json new file mode 100644 index 0000000000000..3e20b2e27aad3 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncInvalidGetDataForPointsWithResponse[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/point/json?api-version=1.0&points=-1.0E8%2C46.84646479863713%7C-121.68853362143818%2C46.85646479863713", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "216", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "400", + "X-MSEdge-Ref" : "Ref A: 4848AEF0D70943AB9B4D7B08B3F02E75 Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:22Z", + "Body" : "{\"error\":{\"code\":\"400 BadRequest\",\"message\":\"1 errors occurred. More information provided in details.\",\"details\":[{\"message\":\"Coordinate '-1.0E8,46.84646479863713' provided in points is invalid\",\"target\":\"Points\"}]}}", + "Date" : "Tue, 04 Oct 2022 23:59:21 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncInvalidGetDataForPolylineWithResponse[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncInvalidGetDataForPolylineWithResponse[1].json new file mode 100644 index 0000000000000..cbdf020f1470a --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationAsyncClientTest.testAsyncInvalidGetDataForPolylineWithResponse[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/line/json?api-version=1.0&lines=-1000000.0%2C46.84646479863713%7C-121.65853362143818%2C46.85646479863713&samples=5", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "189", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "400", + "X-MSEdge-Ref" : "Ref A: 1E3DA4CA650247F6BDEA317AAC9854A8 Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:36Z", + "Body" : "{\"error\":{\"code\":\"400 BadRequest\",\"message\":\"1 errors occurred. More information provided in details.\",\"details\":[{\"message\":\"Coordinates provided in points is invalid\",\"target\":\"Lines\"}]}}", + "Date" : "Tue, 04 Oct 2022 23:59:35 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForBoundingBoxWithResponse[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForBoundingBoxWithResponse[1].json new file mode 100644 index 0000000000000..df61c4a6f16f5 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForBoundingBoxWithResponse[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/lattice/json?api-version=1.0&bounds=-121.66853332519531%2C46.846466064453125%2C-121.65853118896484%2C46.85646438598633&rows=3&columns=3", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "988", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "200", + "X-MSEdge-Ref" : "Ref A: 3E065B846A324B9FB4298781A363CABF Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:38Z", + "Body" : "{\"data\":[{\"coordinate\":{\"latitude\":46.846466064453125,\"longitude\":-121.66853332519531},\"elevationInMeter\":2298.75568},{\"coordinate\":{\"latitude\":46.846466064453125,\"longitude\":-121.66353225708008},\"elevationInMeter\":2257.67204},{\"coordinate\":{\"latitude\":46.846466064453125,\"longitude\":-121.65853118896484},\"elevationInMeter\":2133.13798},{\"coordinate\":{\"latitude\":46.851465225219727,\"longitude\":-121.66853332519531},\"elevationInMeter\":2370.31014},{\"coordinate\":{\"latitude\":46.851465225219727,\"longitude\":-121.66353225708008},\"elevationInMeter\":2247.87731},{\"coordinate\":{\"latitude\":46.851465225219727,\"longitude\":-121.65853118896484},\"elevationInMeter\":2123.96752},{\"coordinate\":{\"latitude\":46.85646438598633,\"longitude\":-121.66853332519531},\"elevationInMeter\":2318.76074},{\"coordinate\":{\"latitude\":46.85646438598633,\"longitude\":-121.66353225708008},\"elevationInMeter\":2100.15878},{\"coordinate\":{\"latitude\":46.85646438598633,\"longitude\":-121.65853118896484},\"elevationInMeter\":1988.26912}]}", + "Date" : "Tue, 04 Oct 2022 23:59:39 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForBoundingBox[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForBoundingBox[1].json new file mode 100644 index 0000000000000..b12294fde2c0a --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForBoundingBox[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/lattice/json?api-version=1.0&bounds=-121.668533621438%2C46.8464647986371%2C-121.658533621438%2C46.8564647986371&rows=3&columns=3", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "966", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "200", + "X-MSEdge-Ref" : "Ref A: 0873D6D2F6D44256961D5506AD5B63EE Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:43Z", + "Body" : "{\"data\":[{\"coordinate\":{\"latitude\":46.8464647986371,\"longitude\":-121.668533621438},\"elevationInMeter\":2298.65819},{\"coordinate\":{\"latitude\":46.8464647986371,\"longitude\":-121.66353362143801},\"elevationInMeter\":2257.62784},{\"coordinate\":{\"latitude\":46.8464647986371,\"longitude\":-121.658533621438},\"elevationInMeter\":2133.17568},{\"coordinate\":{\"latitude\":46.851464798637096,\"longitude\":-121.668533621438},\"elevationInMeter\":2370.3053},{\"coordinate\":{\"latitude\":46.851464798637096,\"longitude\":-121.66353362143801},\"elevationInMeter\":2247.90366},{\"coordinate\":{\"latitude\":46.851464798637096,\"longitude\":-121.658533621438},\"elevationInMeter\":2124.02787},{\"coordinate\":{\"latitude\":46.8564647986371,\"longitude\":-121.668533621438},\"elevationInMeter\":2318.75315},{\"coordinate\":{\"latitude\":46.8564647986371,\"longitude\":-121.66353362143801},\"elevationInMeter\":2100.20795},{\"coordinate\":{\"latitude\":46.8564647986371,\"longitude\":-121.658533621438},\"elevationInMeter\":1988.36315}]}", + "Date" : "Tue, 04 Oct 2022 23:59:44 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForPointsWithResponse[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForPointsWithResponse[1].json new file mode 100644 index 0000000000000..9ecf387f2cc6d --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForPointsWithResponse[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/point/json?api-version=1.0&points=-121.66853362143819%2C46.84646479863713%7C-121.68853362143818%2C46.85646479863713", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "226", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "200", + "X-MSEdge-Ref" : "Ref A: C75D199676C84B528727C1C7E216D20B Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:45Z", + "Body" : "{\"data\":[{\"coordinate\":{\"latitude\":46.84646479863713,\"longitude\":-121.66853362143819},\"elevationInMeter\":2298.65819},{\"coordinate\":{\"latitude\":46.85646479863713,\"longitude\":-121.68853362143818},\"elevationInMeter\":2505.19454}]}", + "Date" : "Tue, 04 Oct 2022 23:59:46 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForPoints[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForPoints[1].json new file mode 100644 index 0000000000000..c00d62a993984 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForPoints[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/point/json?api-version=1.0&points=-121.66853362143819%2C46.84646479863713%7C-121.68853362143818%2C46.85646479863713", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "226", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "200", + "X-MSEdge-Ref" : "Ref A: 230D96E2A5234BB494A6297596C7CB50 Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:41Z", + "Body" : "{\"data\":[{\"coordinate\":{\"latitude\":46.84646479863713,\"longitude\":-121.66853362143819},\"elevationInMeter\":2298.65819},{\"coordinate\":{\"latitude\":46.85646479863713,\"longitude\":-121.68853362143818},\"elevationInMeter\":2505.19454}]}", + "Date" : "Tue, 04 Oct 2022 23:59:42 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForPolylineWithResponse[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForPolylineWithResponse[1].json new file mode 100644 index 0000000000000..d64365fafc84c --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForPolylineWithResponse[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/line/json?api-version=1.0&lines=-121.66853362143819%2C46.84646479863713%7C-121.65853362143818%2C46.85646479863713&samples=5", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "553", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "200", + "X-MSEdge-Ref" : "Ref A: A137171D520A4E3290A2678BEBA57F92 Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:47Z", + "Body" : "{\"data\":[{\"coordinate\":{\"latitude\":46.84646479863713,\"longitude\":-121.66853362143819},\"elevationInMeter\":2298.65819},{\"coordinate\":{\"latitude\":46.848964798637127,\"longitude\":-121.66603362143819},\"elevationInMeter\":2287.75597},{\"coordinate\":{\"latitude\":46.851464798637124,\"longitude\":-121.66353362143818},\"elevationInMeter\":2247.90366},{\"coordinate\":{\"latitude\":46.853964798637129,\"longitude\":-121.66103362143818},\"elevationInMeter\":2042.12034},{\"coordinate\":{\"latitude\":46.85646479863713,\"longitude\":-121.65853362143818},\"elevationInMeter\":1988.36315}]}", + "Date" : "Tue, 04 Oct 2022 23:59:48 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForPolyline[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForPolyline[1].json new file mode 100644 index 0000000000000..3de285ab5fb4e --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testGetDataForPolyline[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/line/json?api-version=1.0&lines=-121.66853362143819%2C46.84646479863713%7C-121.65853362143818%2C46.85646479863713&samples=5", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "553", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "200", + "X-MSEdge-Ref" : "Ref A: B0AFF30A5F96408687BB4B3589D9314F Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:36Z", + "Body" : "{\"data\":[{\"coordinate\":{\"latitude\":46.84646479863713,\"longitude\":-121.66853362143819},\"elevationInMeter\":2298.65819},{\"coordinate\":{\"latitude\":46.848964798637127,\"longitude\":-121.66603362143819},\"elevationInMeter\":2287.75597},{\"coordinate\":{\"latitude\":46.851464798637124,\"longitude\":-121.66353362143818},\"elevationInMeter\":2247.90366},{\"coordinate\":{\"latitude\":46.853964798637129,\"longitude\":-121.66103362143818},\"elevationInMeter\":2042.12034},{\"coordinate\":{\"latitude\":46.85646479863713,\"longitude\":-121.65853362143818},\"elevationInMeter\":1988.36315}]}", + "Date" : "Tue, 04 Oct 2022 23:59:37 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testInvalidGetDataForBoundingBoxWithResponse[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testInvalidGetDataForBoundingBoxWithResponse[1].json new file mode 100644 index 0000000000000..7c46a59fa65a3 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testInvalidGetDataForBoundingBoxWithResponse[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/lattice/json?api-version=1.0&bounds=-1.0E7%2C46.846466064453125%2C-121.65853118896484%2C46.85646438598633&rows=3&columns=3", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "189", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "400", + "X-MSEdge-Ref" : "Ref A: 5EFD261FE7434CAEB21B8158FBA1A745 Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:36Z", + "Body" : "{\"error\":{\"code\":\"400 BadRequest\",\"message\":\"1 errors occurred. More information provided in details.\",\"details\":[{\"message\":\"Southwest point of the bounds is invalid\",\"target\":\"Bounds\"}]}}", + "Date" : "Tue, 04 Oct 2022 23:59:35 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testInvalidGetDataForPointsWithResponse[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testInvalidGetDataForPointsWithResponse[1].json new file mode 100644 index 0000000000000..e80687e714eaa --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testInvalidGetDataForPointsWithResponse[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/point/json?api-version=1.0&points=-1.0E8%2C46.84646479863713%7C-121.68853362143818%2C46.85646479863713", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "216", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "400", + "X-MSEdge-Ref" : "Ref A: D72D8A07B99A4BEBA0D0758CFFE4A036 Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:36Z", + "Body" : "{\"error\":{\"code\":\"400 BadRequest\",\"message\":\"1 errors occurred. More information provided in details.\",\"details\":[{\"message\":\"Coordinate '-1.0E8,46.84646479863713' provided in points is invalid\",\"target\":\"Points\"}]}}", + "Date" : "Tue, 04 Oct 2022 23:59:35 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testInvalidGetDataForPolylineWithResponse[1].json b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testInvalidGetDataForPolylineWithResponse[1].json new file mode 100644 index 0000000000000..2bb50e6fa2f0b --- /dev/null +++ b/sdk/maps/azure-maps-elevation/src/test/resources/session-records/ElevationClientTest.testInvalidGetDataForPolylineWithResponse[1].json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.microsoft.com/elevation/line/json?api-version=1.0&lines=-1.0E9%2C46.84646479863713%7C-121.65853362143818%2C46.85646479863713&samples=5", + "Headers" : { + "User-Agent" : "azsdk-java-JavaTrafficSDK/1.0 (14.0.2; Windows 10; 10.0)" + }, + "Response" : { + "X-Cache" : "CONFIG_NOCACHE", + "content-length" : "189", + "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", + "X-Content-Type-Options" : "nosniff", + "x-ms-azuremaps-region" : "West US 2", + "retry-after" : "0", + "StatusCode" : "400", + "X-MSEdge-Ref" : "Ref A: 4D44BCA9AC2847589FA8FA49E3A4CE64 Ref B: PAOEDGE0620 Ref C: 2022-10-04T23:59:41Z", + "Body" : "{\"error\":{\"code\":\"400 BadRequest\",\"message\":\"1 errors occurred. More information provided in details.\",\"details\":[{\"message\":\"Coordinates provided in points is invalid\",\"target\":\"Lines\"}]}}", + "Date" : "Tue, 04 Oct 2022 23:59:40 GMT", + "Content-Type" : "application/json; charset=utf-8" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/swagger/README.md b/sdk/maps/azure-maps-elevation/swagger/README.md new file mode 100644 index 0000000000000..ca2e467e05a6c --- /dev/null +++ b/sdk/maps/azure-maps-elevation/swagger/README.md @@ -0,0 +1,56 @@ +# Azure Elevation + +> see https://aka.ms/autorest + +### Setup +> see https://github.com/Azure/autorest.java + +### Generation +> see https://github.com/Azure/autorest.java/releases for the latest version of autorest +```ps +cd +mvn install +autorest --java --use:@autorest/java@4.0.x +``` + +### Code generation settings + +## Java + +``` yaml +directive: + + - from: swagger-document + where: "$" + transform: > + $["securityDefinitions"] = {}; + - from: swagger-document + where: "$" + transform: > + $["security"] = []; + - from: swagger-document + where: $.paths["/elevation/line/{format}"].get + transform: > + var linesParameter = $.parameters.find(param => param.name === "lines"); + delete linesParameter["x-ms-skip-url-encoding"]; + +title: ElevationClient +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/maps/data-plane/DEM/preview/1.0/elevation.json +namespace: com.azure.maps.elevation +java: true +output-folder: ../ +license-header: MICROSOFT_MIT_SMALL +payload-flattening-threshold: 0 +add-context-parameter: true +context-client-method-parameter: true +client-logger: true +generate-client-as-impl: true +sync-methods: all +generate-sync-async-clients: false +polling: {} +models-subpackage: implementation.models +custom-types-subpackage: models +custom-types: ElevationResult +customization-jar-path: target/azure-maps-elevation-customization-1.0.0-beta.1.jar +customization-class: ElevationCustomization +``` \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/swagger/pom.xml b/sdk/maps/azure-maps-elevation/swagger/pom.xml new file mode 100644 index 0000000000000..abc3e14e04590 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/swagger/pom.xml @@ -0,0 +1,31 @@ + + + + + azure-autorest-parent + com.azure.tools + 1.0.0-beta.1 + ../../pom.xml + + + com.azure + azure-maps-elevation-customization + 1.0.0-beta.1 + 4.0.0 + + + + com.azure.tools + azure-autorest-customization + 1.0.0-beta.5 + + + junit + junit + 4.13.1 + test + + + \ No newline at end of file diff --git a/sdk/maps/azure-maps-elevation/swagger/src/main/java/ElevationCustomization.java b/sdk/maps/azure-maps-elevation/swagger/src/main/java/ElevationCustomization.java new file mode 100644 index 0000000000000..437ba3956a817 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/swagger/src/main/java/ElevationCustomization.java @@ -0,0 +1,59 @@ +import java.util.Arrays; + +import com.azure.autorest.customization.ClassCustomization; +import com.azure.autorest.customization.Customization; +import com.azure.autorest.customization.LibraryCustomization; +import com.azure.autorest.customization.MethodCustomization; +import com.azure.autorest.customization.PackageCustomization; + +import org.slf4j.Logger; + +/** + * Customization class for Queue Storage. + */ +public class ElevationCustomization extends Customization { + + @Override + public void customize(LibraryCustomization customization, Logger logger) { + PackageCustomization models = customization.getPackage("com.azure.maps.elevation.models"); + PackageCustomization implementationModels = customization.getPackage("com.azure.maps.elevation.implementation.models"); + + // customize elevation + customizeElevation(implementationModels); + + // customize elevation result + customizeElevationResult(models); + + } + + // Customizes the Elevation class + private void customizeElevation(PackageCustomization implementationModels) { + ClassCustomization classCustomization = implementationModels.getClass("Elevation"); + MethodCustomization methodCustomization = classCustomization.getMethod("getElevationInMeter"); + methodCustomization.rename("getElevationInMeters"); + } + + // Customizes the Elevation class + private void customizeElevationResult(PackageCustomization models) { + ClassCustomization classCustomization = models.getClass("ElevationResult"); + classCustomization.addConstructor( + "private ElevationResult() {\n" + + "}") + .getJavadoc() + .setDescription("Set default ElevationResult constructor to private"); + classCustomization.removeMethod("getElevations"); + classCustomization.addMethod( + "public List getElevations() {\n" + + " List toreturn = new ArrayList<>();\n" + + " for (Elevation e : this.elevations) {\n" + + " toreturn.add(new GeoPosition(e.getCoordinate().getLatitude(), e.getCoordinate().getLongitude(), (double) e.getElevationInMeters()));\n" + + " }\n" + + " return toreturn;\n" + + "}") + .getJavadoc() + .setDescription("Get the elevations property: The response for point/points elevation API. The result will be in same sequence of points listed in request.") + .setReturn("the elevations value"); + classCustomization.addImports("com.azure.core.models.GeoPosition"); + classCustomization.addImports("java.util.ArrayList"); + } +} diff --git a/sdk/maps/azure-maps-elevation/tests.yml b/sdk/maps/azure-maps-elevation/tests.yml new file mode 100644 index 0000000000000..8deb3721c7238 --- /dev/null +++ b/sdk/maps/azure-maps-elevation/tests.yml @@ -0,0 +1,7 @@ +trigger: none + +stages: + - template: /sdk/maps/maps-tests-template.yml + parameters: + PackageName: azure-maps-elevation + SafeName: azuremapselevation diff --git a/sdk/maps/pom.xml b/sdk/maps/pom.xml index e8f63d8920b8f..e778be4f8241c 100644 --- a/sdk/maps/pom.xml +++ b/sdk/maps/pom.xml @@ -15,6 +15,7 @@ azure-maps-render azure-maps-timezone azure-maps-geolocation + azure-maps-elevation azure-resourcemanager-maps