From b6cfcc635bb1b2b63b9a4ec58f093a81a5e43df4 Mon Sep 17 00:00:00 2001 From: Lazar <163033155+Lakicar95@users.noreply.github.com> Date: Tue, 19 Nov 2024 01:32:11 +0100 Subject: [PATCH] Update Route SDK for metadata accuracy, v2 alignment, and latest TypeScript SDK compatibility (#31562) --- sdk/maps/maps-route-rest/CHANGELOG.md | 8 +- .../{src => }/generated/clientDefinitions.ts | 144 ++++++---- .../{src => }/generated/index.ts | 1 + .../{src => }/generated/isUnexpected.ts | 97 ++++--- sdk/maps/maps-route-rest/generated/logger.ts | 5 + .../generated/mapsRouteClient.ts | 68 +++++ .../{src => }/generated/models.ts | 4 +- .../{src => }/generated/outputModels.ts | 148 +++++----- .../{src => }/generated/parameters.ts | 213 ++++++++++---- .../generated/pollingHelper.ts | 205 ++++++++++++++ .../{src => }/generated/responses.ts | 260 ++++++++++-------- .../generated/serializeHelper.ts | 16 ++ sdk/maps/maps-route-rest/package.json | 5 +- .../maps-route-rest/review/maps-route.api.md | 199 ++++++++------ sdk/maps/maps-route-rest/samples-dev/lro.ts | 2 +- .../maps-route-rest/samples-dev/resumeLro.ts | 9 +- .../samples/v1-beta/typescript/src/lro.ts | 2 +- .../samples/v1-beta/typescript/src/matrix.ts | 2 +- .../samples/v1-beta/typescript/src/range.ts | 2 +- .../v1-beta/typescript/src/resumeLro.ts | 8 +- .../src/generated/mapsRouteClient.ts | 40 --- .../src/generated/pollingHelper.ts | 75 ----- sdk/maps/maps-route-rest/src/helpers.ts | 2 +- sdk/maps/maps-route-rest/src/index.ts | 2 +- sdk/maps/maps-route-rest/src/mapsRoute.ts | 4 +- sdk/maps/maps-route-rest/swagger/README.md | 6 +- .../test/public/mapsRouteClient.spec.ts | 42 +-- .../test/public/utils/recordedClient.ts | 2 +- 28 files changed, 974 insertions(+), 597 deletions(-) rename sdk/maps/maps-route-rest/{src => }/generated/clientDefinitions.ts (75%) rename sdk/maps/maps-route-rest/{src => }/generated/index.ts (92%) rename sdk/maps/maps-route-rest/{src => }/generated/isUnexpected.ts (65%) create mode 100644 sdk/maps/maps-route-rest/generated/logger.ts create mode 100644 sdk/maps/maps-route-rest/generated/mapsRouteClient.ts rename sdk/maps/maps-route-rest/{src => }/generated/models.ts (93%) rename sdk/maps/maps-route-rest/{src => }/generated/outputModels.ts (81%) rename sdk/maps/maps-route-rest/{src => }/generated/parameters.ts (86%) create mode 100644 sdk/maps/maps-route-rest/generated/pollingHelper.ts rename sdk/maps/maps-route-rest/{src => }/generated/responses.ts (75%) create mode 100644 sdk/maps/maps-route-rest/generated/serializeHelper.ts delete mode 100644 sdk/maps/maps-route-rest/src/generated/mapsRouteClient.ts delete mode 100644 sdk/maps/maps-route-rest/src/generated/pollingHelper.ts diff --git a/sdk/maps/maps-route-rest/CHANGELOG.md b/sdk/maps/maps-route-rest/CHANGELOG.md index df8641c468bb..7ea24208c09e 100644 --- a/sdk/maps/maps-route-rest/CHANGELOG.md +++ b/sdk/maps/maps-route-rest/CHANGELOG.md @@ -1,17 +1,15 @@ # Release History -## 1.0.0-beta.4 (Unreleased) - -### Features Added +## 1.0.0-beta.4 (2024-12-10) ### Breaking Changes +- Poller creation is now asynchronous, requiring an await statement. The resumeFrom parameter has been replaced with restoreFrom, and state serialization is now also asynchronous. + ### Bugs Fixed - Fix the Microsoft Entra ID authentication when providing `baseUrl`. -### Other Changes - ## 1.0.0-beta.3 (2024-01-09) ### Features Added diff --git a/sdk/maps/maps-route-rest/src/generated/clientDefinitions.ts b/sdk/maps/maps-route-rest/generated/clientDefinitions.ts similarity index 75% rename from sdk/maps/maps-route-rest/src/generated/clientDefinitions.ts rename to sdk/maps/maps-route-rest/generated/clientDefinitions.ts index 2bec63dc425b..8bc63ee74e09 100644 --- a/sdk/maps/maps-route-rest/src/generated/clientDefinitions.ts +++ b/sdk/maps/maps-route-rest/generated/clientDefinitions.ts @@ -10,7 +10,7 @@ import { RouteGetRouteRangeParameters, RouteRequestRouteDirectionsBatchParameters, RouteGetRouteDirectionsBatchParameters, - RouteRequestRouteDirectionsBatchSyncParameters + RouteRequestRouteDirectionsBatchSyncParameters, } from "./parameters"; import { RouteRequestRouteMatrix200Response, @@ -32,16 +32,14 @@ import { RouteGetRouteDirectionsBatch202Response, RouteRequestRouteDirectionsBatchSync200Response, RouteRequestRouteDirectionsBatchSync408Response, - RouteRequestRouteDirectionsBatchSyncDefaultResponse + RouteRequestRouteDirectionsBatchSyncDefaultResponse, } from "./responses"; import { Client, StreamableMethod } from "@azure-rest/core-client"; export interface RequestRouteMatrix { /** * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * - * The Matrix Routing service allows calculation of a matrix of route summaries for a set of routes defined by origin and destination locations by using an asynchronous (async) or synchronous (sync) POST request. For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. + * The `Post Route Matrix` API is an HTTP `POST` request that allows calculation of a matrix of route summaries for a set of routes defined by origin and destination locations by using an asynchronous (async) request. To make a synchronous (sync) request, see [Post Route Matrix Sync](/rest/api/maps/route/post-route-matrix-sync). For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. * * * For each route, the travel times and distances are returned. You can use the computed costs to determine which detailed routes to calculate using the Route Directions API. @@ -49,6 +47,9 @@ export interface RequestRouteMatrix { * * The maximum size of a matrix for async request is **700** and for sync request it's **100** (the number of origins multiplied by the number of destinations). * + * > [!NOTE] + * > All origins and destinations should be contained in an axis-aligned 400 km x 400 km bounding box. Otherwise some matrix cells will be resolved as OUT_OF_REGION. + * * * * ### Submit Synchronous Route Matrix Request @@ -65,7 +66,7 @@ export interface RequestRouteMatrix { * The maximum size of a matrix for this API is **700** (the number of origins multiplied by the number of destinations). With that constraint in mind, examples of possible matrix dimensions are: 50x10, 10x10, 28x25. 10x70 (it does not need to be square). * * - * The asynchronous responses are stored for **14** days. The redirect URL returns a 404 response if used after the expiration period. + * The asynchronous responses are stored for **24** hours. The redirect URL returns a 404 response if used after the expiration period. * * * @@ -109,14 +110,58 @@ export interface RequestRouteMatrix { * > HTTP `200 OK` - Matrix request successfully processed. The response body contains all of the results. */ post( - options: RouteRequestRouteMatrixParameters + options: RouteRequestRouteMatrixParameters, ): StreamableMethod< RouteRequestRouteMatrix200Response | RouteRequestRouteMatrix202Response >; /** - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). * - * If the Matrix Route request was accepted successfully, the Location header in the response contains the URL to download the results of the request. This status URI looks like the following: + * The `Get Route Matrix` API is an HTTP `GET` request that computes the travel time and distance for all possible pairs in a list of origins and destinations. Unlike the [Get Route Directions](/rest/api/maps/route/get-route-directions) API, which provide detailed route instructions, this API focuses on efficiency by giving you the cost (travel time and distance) of routing from each origin to every destination. For more information, see [Best practices for Azure Maps Route service](/azure/azure-maps/how-to-use-best-practices-for-routing). + * + * For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. + * + * + * For each route, the travel times and distances are returned. You can use the computed costs to determine which detailed routes to calculate using the Route Directions API. + * + * + * The maximum size of a matrix for async request is **700** and for sync request it's **100** (the number of origins multiplied by the number of destinations). + * + * + * + * ### Submit Synchronous Route Matrix Request + * If your scenario requires synchronous requests and the maximum size of the matrix is less than or equal to 100, you might want to make synchronous request. The maximum size of a matrix for this API is **100** (the number of origins multiplied by the number of destinations). With that constraint in mind, examples of possible matrix dimensions are: 10x10, 6x8, 9x8 (it does not need to be square). + * + * ``` + * GET https://atlas.microsoft.com/route/matrix/sync/json?api-version=1.0&subscription-key={subscription-key} + * ``` + * + * ### Submit Asynchronous Route Matrix Request + * The Asynchronous API is appropriate for processing big volumes of relatively complex routing requests. When you make a request by using async request, by default the service returns a 202 response code along a redirect URL in the Location field of the response header. This URL should be checked periodically until the response data or error information is available. If `waitForResults` parameter in the request is set to true, user will get a 200 response if the request is finished under 120 seconds. + * + * + * The maximum size of a matrix for this API is **700** (the number of origins multiplied by the number of destinations). With that constraint in mind, examples of possible matrix dimensions are: 50x10, 10x10, 28x25. 10x70 (it does not need to be square). + * + * + * The asynchronous responses are stored for **24** hours. The redirect URL returns a 404 response if used after the expiration period. + * + * + * + * + * ``` + * GET https://atlas.microsoft.com/route/matrix/json?api-version=1.0&subscription-key={subscription-key} + * ``` + * + * Here's a typical sequence of asynchronous operations: + * 1. Client sends a Route Matrix GET request to Azure Maps + * + * 2. The server will respond with one of the following: + * + * > HTTP `202 Accepted` - Route Matrix request has been accepted. + * + * > HTTP `Error` - There was an error processing your Route Matrix request. This could either be a 400 Bad Request or any other Error status code. + * + * + * 3. If the Matrix Route request was accepted successfully, the Location header in the response contains the URL to download the results of the request. This status URI looks like the following: * * ``` * GET https://atlas.microsoft.com/route/matrix/{matrixId}?api-version=1.0?subscription-key={subscription-key} @@ -126,7 +171,7 @@ export interface RequestRouteMatrix { * 4. Client issues a GET request on the download URL obtained in Step 3 to download the results * * ### Download Sync Results - * When you make a POST request for Route Matrix Sync API, the service returns 200 response code for successful request and a response array. The response body will contain the data and there will be no possibility to retrieve the results later. + * When you make a GET request for Route Matrix Sync API, the service returns 200 response code for successful request and a response array. The response body will contain the data and there will be no possibility to retrieve the results later. * * ### Download Async Results * When a request issues a `202 Accepted` response, the request is being processed using our async pipeline. You will be given a URL to check the progress of your async request in the location header of the response. This status URI looks like the following: @@ -141,7 +186,7 @@ export interface RequestRouteMatrix { * > HTTP `200 OK` - Matrix request successfully processed. The response body contains all of the results. */ get( - options?: RouteGetRouteMatrixParameters + options?: RouteGetRouteMatrixParameters, ): StreamableMethod< RouteGetRouteMatrix200Response | RouteGetRouteMatrix202Response >; @@ -150,9 +195,7 @@ export interface RequestRouteMatrix { export interface RequestRouteMatrixSync { /** * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * - * The Matrix Routing service allows calculation of a matrix of route summaries for a set of routes defined by origin and destination locations by using an asynchronous (async) or synchronous (sync) POST request. For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. + * The `Post Route Matrix Sync` API is an HTTP `POST` request that allows calculation of a matrix of route summaries for a set of routes defined by origin and destination locations by using a single synchronous (sync) request. To make an asynchronous (async) request, see [Post Route Matrix](/rest/api/maps/route/post-route-matrix). For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. * * * For each route, the travel times and distances are returned. You can use the computed costs to determine which detailed routes to calculate using the Route Directions API. @@ -176,7 +219,7 @@ export interface RequestRouteMatrixSync { * The maximum size of a matrix for this API is **700** (the number of origins multiplied by the number of destinations). With that constraint in mind, examples of possible matrix dimensions are: 50x10, 10x10, 28x25. 10x70 (it does not need to be square). * * - * The asynchronous responses are stored for **14** days. The redirect URL returns a 404 response if used after the expiration period. + * The asynchronous responses are stored for **24** hours. The redirect URL returns a 404 response if used after the expiration period. * * * @@ -220,7 +263,7 @@ export interface RequestRouteMatrixSync { * > HTTP `200 OK` - Matrix request successfully processed. The response body contains all of the results. */ post( - options: RouteRequestRouteMatrixSyncParameters + options: RouteRequestRouteMatrixSyncParameters, ): StreamableMethod< | RouteRequestRouteMatrixSync200Response | RouteRequestRouteMatrixSync408Response @@ -230,32 +273,28 @@ export interface RequestRouteMatrixSync { export interface GetRouteDirections { /** - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * * - * Returns a route between an origin and a destination, passing through waypoints if they are specified. The route will take into account factors such as current traffic and the typical road speeds on the requested day of the week and time of day. + * The `Get Route Directions` API is an HTTP `GET` request that returns a route between an origin and a destination, passing through waypoints if specified. The route takes into account factors such as current traffic and the typical road speeds on the requested day of the week and time of day. * * Information returned includes the distance, estimated travel time, and a representation of the route geometry. Additional routing information such as optimized waypoint order or turn by turn instructions is also available, depending on the options selected. * - * Routing service provides a set of parameters for a detailed description of vehicle-specific Consumption Model. Please check [Consumption Model](https://docs.microsoft.com/azure/azure-maps/consumption-model) for detailed explanation of the concepts and parameters involved. + * Routing service provides a set of parameters for a detailed description of a vehicle-specific consumption model. For more information, see [Consumption Model](/azure/azure-maps/consumption-model). */ get( - options: RouteGetRouteDirectionsParameters + options: RouteGetRouteDirectionsParameters, ): StreamableMethod< RouteGetRouteDirections200Response | RouteGetRouteDirectionsDefaultResponse >; /** - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * * - * Returns a route between an origin and a destination, passing through waypoints if they are specified. The route will take into account factors such as current traffic and the typical road speeds on the requested day of the week and time of day. + * The `Post Route Directions` API is an HTTP `POST` request that returns a route between an origin and a destination, passing through waypoints if they are specified. The route will take into account factors such as current traffic and the typical road speeds on the requested day of the week and time of day. * * Information returned includes the distance, estimated travel time, and a representation of the route geometry. Additional routing information such as optimized waypoint order or turn by turn instructions is also available, depending on the options selected. * * Routing service provides a set of parameters for a detailed description of a vehicle-specific Consumption Model. Please check [Consumption Model](https://docs.microsoft.com/azure/azure-maps/consumption-model) for detailed explanation of the concepts and parameters involved. */ post( - options: RouteGetRouteDirectionsWithAdditionalParametersParameters + options: RouteGetRouteDirectionsWithAdditionalParametersParameters, ): StreamableMethod< | RouteGetRouteDirectionsWithAdditionalParameters200Response | RouteGetRouteDirectionsWithAdditionalParametersDefaultResponse @@ -264,17 +303,13 @@ export interface GetRouteDirections { export interface GetRouteRange { /** - * __Route Range (Isochrone) API__ * + * The `Get Route Range` (Isochrone) API is an HTTP `GET` request that will calculate a set of locations that can be reached from the origin point based on fuel, energy, time or distance budget that is specified. A polygon boundary (or Isochrone) is returned in a counterclockwise orientation as well as the precise polygon center which was the result of the origin point. * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * - * This service will calculate a set of locations that can be reached from the origin point based on fuel, energy, time or distance budget that is specified. A polygon boundary (or Isochrone) is returned in a counterclockwise orientation as well as the precise polygon center which was the result of the origin point. - * - * The returned polygon can be used for further processing such as [Search Inside Geometry](https://docs.microsoft.com/rest/api/maps/search/postsearchinsidegeometry) to search for POIs within the provided Isochrone. + * The returned polygon can be used for further processing such as [Search Inside Geometry](/rest/api/maps/search/post-search-inside-geometry) to search for POIs within the provided isochrone. */ get( - options: RouteGetRouteRangeParameters + options: RouteGetRouteRangeParameters, ): StreamableMethod< RouteGetRouteRange200Response | RouteGetRouteRangeDefaultResponse >; @@ -282,14 +317,9 @@ export interface GetRouteRange { export interface RequestRouteDirectionsBatch { /** - * **Route Directions Batch API** - * - * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). * + * The `Post Route Directions Batch` API is an HTTP `POST` request that sends batches of queries to the [Get Route Directions](/rest/api/maps/route/get-route-directions) API using a single asynchronous request. You can call `Route Directions Batch` API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. To call the `Post Route Directions Batch` API in a synchronous request, see [Post Route Directions Batch Sync](/rest/api/maps/route/post-route-directions-batch-sync). * - * - * The Route Directions Batch API sends batches of queries to [Route Directions API](https://docs.microsoft.com/rest/api/maps/route/getroutedirections) using just a single API call. You can call Route Directions Batch API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. * ### Submit Asynchronous Batch Request * The Asynchronous API is appropriate for processing big volumes of relatively complex route requests * - It allows the retrieval of results in a separate call (multiple downloads are possible). @@ -297,10 +327,13 @@ export interface RequestRouteDirectionsBatch { * - The number of batch items is limited to **700** for this API. * * When you make a request by using async request, by default the service returns a 202 response code along a redirect URL in the Location field of the response header. This URL should be checked periodically until the response data or error information is available. - * The asynchronous responses are stored for **14** days. The redirect URL returns a 404 response if used after the expiration period. + * The asynchronous responses are stored for **24** hours. The redirect URL returns a 404 response if used after the expiration period. * - * Please note that asynchronous batch request is a long-running request. Here's a typical sequence of operations: - * 1. Client sends a Route Directions Batch `POST` request to Azure Maps + * Please note that asynchronous batch request is a long-running operation. Here's a typical sequence of operations: + * 1. Client sends a Route Directions Batch `POST` request to Azure Maps. + * ``` + * POST https://atlas.microsoft.com/route/directions/batch/json?api-version=1.0&subscription-key={subscription-key} + * ``` * 2. The server will respond with one of the following: * * > HTTP `202 Accepted` - Batch request has been accepted. @@ -309,9 +342,9 @@ export interface RequestRouteDirectionsBatch { * * 3. If the batch request was accepted successfully, the `Location` header in the response contains the URL to download the results of the batch request. * This status URI looks like following: - * - * ``` GET https://atlas.microsoft.com/route/directions/batch/{batch-id}?api-version=1.0 ``` - * Note:- Please remember to add AUTH information (subscription-key/azure_auth - See [Security](#security)) to the _status URI_ before running it.
+ * ``` + * GET https://atlas.microsoft.com/route/directions/batch/{batch-id}?api-version=1.0&subscription-key={subscription-key} + * ``` * 4. Client issues a `GET` request on the _download URL_ obtained in Step 3 to download the batch results. * * ### POST Body for Batch Request @@ -433,13 +466,14 @@ export interface RequestRouteDirectionsBatch { * ``` */ post( - options: RouteRequestRouteDirectionsBatchParameters + options: RouteRequestRouteDirectionsBatchParameters, ): StreamableMethod< | RouteRequestRouteDirectionsBatch200Response | RouteRequestRouteDirectionsBatch202Response >; /** - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + * The `Get Route Directions Batch` API is an HTTP `GET` request that sends batches of queries to the [Get Route Directions](/rest/api/maps/route/get-route-directions) API using a single request. You can call `Get Route Directions Batch` API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. * * ### Download Asynchronous Batch Results * To download the async batch results you will issue a `GET` request to the batch download endpoint. This _download URL_ can be obtained from the `Location` header of a successful `POST` batch request and looks like the following: @@ -540,7 +574,7 @@ export interface RequestRouteDirectionsBatch { * ``` */ get( - options?: RouteGetRouteDirectionsBatchParameters + options?: RouteGetRouteDirectionsBatchParameters, ): StreamableMethod< | RouteGetRouteDirectionsBatch200Response | RouteGetRouteDirectionsBatch202Response @@ -549,14 +583,8 @@ export interface RequestRouteDirectionsBatch { export interface RequestRouteDirectionsBatchSync { /** - * **Route Directions Batch API** - * - * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * - * * - * The Route Directions Batch API sends batches of queries to [Route Directions API](https://docs.microsoft.com/rest/api/maps/route/getroutedirections) using just a single API call. You can call Route Directions Batch API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. + * The `Post Route Directions Batch Sync` API is an HTTP `POST` request that sends batches of queries to the [Get Route Directions](/rest/api/maps/route/get-route-directions) API using a single synchronous request. You can call `Route Directions Batch` API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. To call the `Post Route Directions Batch` API in a asynchronous request, see [Post Route Directions Batch](/rest/api/maps/route/post-route-directions-batch). * ### Submit Synchronous Batch Request * The Synchronous API is recommended for lightweight batch requests. When the service receives a request, it will respond as soon as the batch items are calculated and there will be no possibility to retrieve the results later. The Synchronous API will return a timeout error (a 408 response) if the request takes longer than 60 seconds. The number of batch items is limited to **100** for this API. * ``` @@ -645,7 +673,7 @@ export interface RequestRouteDirectionsBatchSync { * ``` */ post( - options: RouteRequestRouteDirectionsBatchSyncParameters + options: RouteRequestRouteDirectionsBatchSyncParameters, ): StreamableMethod< | RouteRequestRouteDirectionsBatchSync200Response | RouteRequestRouteDirectionsBatchSync408Response @@ -661,19 +689,19 @@ export interface Routes { /** Resource for '/route/directions/\{format\}' has methods for the following verbs: get, post */ ( path: "/route/directions/{format}", - format: "json" | "xml" + format: "json" | "xml", ): GetRouteDirections; /** Resource for '/route/range/\{format\}' has methods for the following verbs: get */ (path: "/route/range/{format}", format: "json" | "xml"): GetRouteRange; /** Resource for '/route/directions/batch/\{format\}' has methods for the following verbs: post, get */ ( path: "/route/directions/batch/{format}", - format: "json" + format: "json", ): RequestRouteDirectionsBatch; /** Resource for '/route/directions/batch/sync/\{format\}' has methods for the following verbs: post */ ( path: "/route/directions/batch/sync/{format}", - format: "json" + format: "json", ): RequestRouteDirectionsBatchSync; } diff --git a/sdk/maps/maps-route-rest/src/generated/index.ts b/sdk/maps/maps-route-rest/generated/index.ts similarity index 92% rename from sdk/maps/maps-route-rest/src/generated/index.ts rename to sdk/maps/maps-route-rest/generated/index.ts index 319f352415ae..19cb44d10b30 100644 --- a/sdk/maps/maps-route-rest/src/generated/index.ts +++ b/sdk/maps/maps-route-rest/generated/index.ts @@ -11,5 +11,6 @@ export * from "./isUnexpected"; export * from "./models"; export * from "./outputModels"; export * from "./pollingHelper"; +export * from "./serializeHelper"; export default MapsRouteClient; diff --git a/sdk/maps/maps-route-rest/src/generated/isUnexpected.ts b/sdk/maps/maps-route-rest/generated/isUnexpected.ts similarity index 65% rename from sdk/maps/maps-route-rest/src/generated/isUnexpected.ts rename to sdk/maps/maps-route-rest/generated/isUnexpected.ts index 70e131f17979..d7e2b34863c7 100644 --- a/sdk/maps/maps-route-rest/src/generated/isUnexpected.ts +++ b/sdk/maps/maps-route-rest/generated/isUnexpected.ts @@ -13,45 +13,45 @@ import { RouteGetRouteRangeDefaultResponse, RouteRequestRouteDirectionsBatchSync200Response, RouteRequestRouteDirectionsBatchSync408Response, - RouteRequestRouteDirectionsBatchSyncDefaultResponse + RouteRequestRouteDirectionsBatchSyncDefaultResponse, } from "./responses"; const responseMap: Record = { - "POST /route/matrix/{format}": ["200", "202"], "GET /route/matrix/{format}": ["200", "202"], + "POST /route/matrix/{format}": ["200", "202"], "POST /route/matrix/sync/{format}": ["200"], "GET /route/directions/{format}": ["200"], "POST /route/directions/{format}": ["200"], "GET /route/range/{format}": ["200"], - "POST /route/directions/batch/{format}": ["200", "202"], "GET /route/directions/batch/{format}": ["200", "202"], - "POST /route/directions/batch/sync/{format}": ["200"] + "POST /route/directions/batch/{format}": ["200", "202"], + "POST /route/directions/batch/sync/{format}": ["200"], }; export function isUnexpected( response: | RouteRequestRouteMatrixSync200Response | RouteRequestRouteMatrixSync408Response - | RouteRequestRouteMatrixSyncDefaultResponse + | RouteRequestRouteMatrixSyncDefaultResponse, ): response is RouteRequestRouteMatrixSync408Response; export function isUnexpected( response: | RouteGetRouteDirections200Response - | RouteGetRouteDirectionsDefaultResponse + | RouteGetRouteDirectionsDefaultResponse, ): response is RouteGetRouteDirectionsDefaultResponse; export function isUnexpected( response: | RouteGetRouteDirectionsWithAdditionalParameters200Response - | RouteGetRouteDirectionsWithAdditionalParametersDefaultResponse + | RouteGetRouteDirectionsWithAdditionalParametersDefaultResponse, ): response is RouteGetRouteDirectionsWithAdditionalParametersDefaultResponse; export function isUnexpected( - response: RouteGetRouteRange200Response | RouteGetRouteRangeDefaultResponse + response: RouteGetRouteRange200Response | RouteGetRouteRangeDefaultResponse, ): response is RouteGetRouteRangeDefaultResponse; export function isUnexpected( response: | RouteRequestRouteDirectionsBatchSync200Response | RouteRequestRouteDirectionsBatchSync408Response - | RouteRequestRouteDirectionsBatchSyncDefaultResponse + | RouteRequestRouteDirectionsBatchSyncDefaultResponse, ): response is RouteRequestRouteDirectionsBatchSync408Response; export function isUnexpected( response: @@ -66,7 +66,7 @@ export function isUnexpected( | RouteGetRouteRangeDefaultResponse | RouteRequestRouteDirectionsBatchSync200Response | RouteRequestRouteDirectionsBatchSync408Response - | RouteRequestRouteDirectionsBatchSyncDefaultResponse + | RouteRequestRouteDirectionsBatchSyncDefaultResponse, ): response is | RouteRequestRouteMatrixSync408Response | RouteRequestRouteMatrixSyncDefaultResponse @@ -80,14 +80,20 @@ export function isUnexpected( const method = response.request.method; let pathDetails = responseMap[`${method} ${url.pathname}`]; if (!pathDetails) { - pathDetails = geParametrizedPathSuccess(method, url.pathname); + pathDetails = getParametrizedPathSuccess(method, url.pathname); } return !pathDetails.includes(response.status); } -function geParametrizedPathSuccess(method: string, path: string): string[] { +function getParametrizedPathSuccess(method: string, path: string): string[] { const pathParts = path.split("/"); + // Traverse list to match the longest candidate + // matchedLen: the length of candidate path + // matchedValue: the matched status code array + let matchedLen = -1, + matchedValue: string[] = []; + // Iterate the responseMap to find a match for (const [key, value] of Object.entries(responseMap)) { // Extracting the path from the map key which is in format @@ -99,49 +105,52 @@ function geParametrizedPathSuccess(method: string, path: string): string[] { // Get each part of the url path const candidateParts = candidatePath.split("/"); - // If the candidate and actual paths don't match in size - // we move on to the next candidate path - if ( - candidateParts.length === pathParts.length && - hasParametrizedPath(key) + // track if we have found a match to return the values found. + let found = true; + for ( + let i = candidateParts.length - 1, j = pathParts.length - 1; + i >= 1 && j >= 1; + i--, j-- ) { - // track if we have found a match to return the values found. - let found = true; - for (let i = 0; i < candidateParts.length; i++) { - if ( - candidateParts[i]?.startsWith("{") && - candidateParts[i]?.endsWith("}") - ) { - // If the current part of the candidate is a "template" part - // it is a match with the actual path part on hand - // skip as the parameterized part can match anything - continue; - } + if ( + candidateParts[i]?.startsWith("{") && + candidateParts[i]?.indexOf("}") !== -1 + ) { + const start = candidateParts[i]!.indexOf("}") + 1, + end = candidateParts[i]?.length; + // If the current part of the candidate is a "template" part + // Try to use the suffix of pattern to match the path + // {guid} ==> $ + // {guid}:export ==> :export$ + const isMatched = new RegExp( + `${candidateParts[i]?.slice(start, end)}`, + ).test(pathParts[j] || ""); - // If the candidate part is not a template and - // the parts don't match mark the candidate as not found - // to move on with the next candidate path. - if (candidateParts[i] !== pathParts[i]) { + if (!isMatched) { found = false; break; } + continue; } - // We finished evaluating the current candidate parts - // if all parts matched we return the success values form - // the path mapping. - if (found) { - return value; + // If the candidate part is not a template and + // the parts don't match mark the candidate as not found + // to move on with the next candidate path. + if (candidateParts[i] !== pathParts[j]) { + found = false; + break; } } - } - // No match was found, return an empty array. - return []; -} + // We finished evaluating the current candidate parts + // Update the matched value if and only if we found the longer pattern + if (found && candidatePath.length > matchedLen) { + matchedLen = candidatePath.length; + matchedValue = value; + } + } -function hasParametrizedPath(path: string): boolean { - return path.includes("/{"); + return matchedValue; } function getPathFromMapKey(mapKey: string): string { diff --git a/sdk/maps/maps-route-rest/generated/logger.ts b/sdk/maps/maps-route-rest/generated/logger.ts new file mode 100644 index 000000000000..ddecb3ca6580 --- /dev/null +++ b/sdk/maps/maps-route-rest/generated/logger.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createClientLogger } from "@azure/logger"; +export const logger = createClientLogger("maps-route"); diff --git a/sdk/maps/maps-route-rest/generated/mapsRouteClient.ts b/sdk/maps/maps-route-rest/generated/mapsRouteClient.ts new file mode 100644 index 000000000000..a7479f4e3a7e --- /dev/null +++ b/sdk/maps/maps-route-rest/generated/mapsRouteClient.ts @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { getClient, ClientOptions } from "@azure-rest/core-client"; +import { logger } from "./logger"; +import { KeyCredential } from "@azure/core-auth"; +import { MapsRouteClient } from "./clientDefinitions"; + +/** The optional parameters for the client */ +export interface MapsRouteClientOptions extends ClientOptions { + /** The api version option of the client */ + apiVersion?: string; +} + +/** + * Initialize a new instance of `MapsRouteClient` + * @param credentials - uniquely identify client credential + * @param options - the parameter for all optional parameters + */ +export default function createClient( + credentials: KeyCredential, + { apiVersion = "1.0", ...options }: MapsRouteClientOptions = {}, +): MapsRouteClient { + const endpointUrl = + options.endpoint ?? options.baseUrl ?? `https://atlas.microsoft.com`; + const userAgentInfo = `azsdk-js-maps-route-rest/1.0.0-beta.4`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}` + : `${userAgentInfo}`; + options = { + ...options, + userAgentOptions: { + userAgentPrefix, + }, + loggingOptions: { + logger: options.loggingOptions?.logger ?? logger.info, + }, + credentials: { + apiKeyHeaderName: + options.credentials?.apiKeyHeaderName ?? "subscription-key", + }, + }; + const client = getClient( + endpointUrl, + credentials, + options, + ) as MapsRouteClient; + + client.pipeline.removePolicy({ name: "ApiVersionPolicy" }); + client.pipeline.addPolicy({ + name: "ClientApiVersionPolicy", + sendRequest: (req, next) => { + // Use the apiVersion defined in request url directly + // Append one if there is no apiVersion and we have one at client options + const url = new URL(req.url); + if (!url.searchParams.get("api-version") && apiVersion) { + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; + } + + return next(req); + }, + }); + + return client; +} diff --git a/sdk/maps/maps-route-rest/src/generated/models.ts b/sdk/maps/maps-route-rest/generated/models.ts similarity index 93% rename from sdk/maps/maps-route-rest/src/generated/models.ts rename to sdk/maps/maps-route-rest/generated/models.ts index c87f088f0c53..4431efd2086b 100644 --- a/sdk/maps/maps-route-rest/src/generated/models.ts +++ b/sdk/maps/maps-route-rest/generated/models.ts @@ -64,9 +64,9 @@ export interface RouteDirectionParameters { * ignored for the calculation of the reference route's travel time and traffic delay. */ supportingPoints?: Record; - /** This is a list of 3-character, ISO 3166-1, alpha-3 country codes of countries in which all toll roads with vignettes are to be avoided, e.g. "AUS,CHE". Toll roads with vignettes in countries not in the list are unaffected. Note: It is an error to specify both **avoidVignette** and **allowVignette**. */ + /** This is a list of 3-character, ISO 3166-1, alpha-3 country codes of countries/regions in which all toll roads with vignettes are to be avoided, e.g. "AUS,CHE". Toll roads with vignettes in countries/regions not in the list are unaffected. Note: It is an error to specify both **avoidVignette** and **allowVignette**. */ avoidVignette?: Array; - /** This is a list of 3-character, ISO 3166-1, alpha-3 country codes of countries in which toll roads with vignettes are allowed, e.g. "AUS,CHE". Specifying **allowVignette** with some countries X is equivalent to specifying **avoidVignette** with all countries but X. Specifying **allowVignette** with an empty list is the same as avoiding all toll roads with vignettes. Note: It is an error to specify both **avoidVignette** and **allowVignette**. */ + /** This is a list of 3-character, ISO 3166-1, alpha-3 country codes of countries/regions in which toll roads with vignettes are allowed, e.g. "AUS,CHE". Specifying **allowVignette** with some countries/regions X is equivalent to specifying **avoidVignette** with all countries/regions but X. Specifying **allowVignette** with an empty list is the same as avoiding all toll roads with vignettes. Note: It is an error to specify both **avoidVignette** and **allowVignette**. */ allowVignette?: Array; /** A GeoJSON MultiPolygon representing list of areas to avoid. Only rectangle polygons are supported. The maximum size of a rectangle is about 160x160 km. Maximum number of avoided areas is **10**. It cannot cross the 180th meridian. It must be between -80 and +80 degrees of latitude. */ avoidAreas?: GeoJsonMultiPolygon; diff --git a/sdk/maps/maps-route-rest/src/generated/outputModels.ts b/sdk/maps/maps-route-rest/generated/outputModels.ts similarity index 81% rename from sdk/maps/maps-route-rest/src/generated/outputModels.ts rename to sdk/maps/maps-route-rest/generated/outputModels.ts index 21c02bbd7e21..e5c169e5885f 100644 --- a/sdk/maps/maps-route-rest/src/generated/outputModels.ts +++ b/sdk/maps/maps-route-rest/generated/outputModels.ts @@ -4,47 +4,47 @@ /** This object is returned from a successful Route Matrix call. For ex, if 2 origins and 3 destinations are provided, there are going to 2 arrays with 3 elements in each. Each element's content depends on the options provided in the query. */ export interface RouteMatrixResultOutput { /** Format Version property */ - formatVersion?: string; + readonly formatVersion?: string; /** Results as a 2 dimensional array of route summaries. */ - matrix: Array>; + readonly matrix: Array>; /** Summary object */ - summary: RouteMatrixSummaryOutput; + readonly summary: RouteMatrixSummaryOutput; } /** Matrix result object */ export interface RouteMatrixOutput { /** StatusCode property for the current cell in the input matrix. */ - statusCode: number; + readonly statusCode: number; /** Response object of the current cell in the input matrix. */ - response?: RouteMatrixResultResponseOutput; + readonly response?: RouteMatrixResultResponseOutput; } /** Response object of the current cell in the input matrix. */ export interface RouteMatrixResultResponseOutput { /** Summary object */ - routeSummary?: RouteSummaryOutput; + readonly routeSummary?: RouteSummaryOutput; } /** Summary object */ export interface RouteSummaryOutput { /** Length In Meters property */ - lengthInMeters: number; + readonly lengthInMeters: number; /** Estimated travel time in seconds property that includes the delay due to real-time traffic. Note that even when traffic=false travelTimeInSeconds still includes the delay due to traffic. If DepartAt is in the future, travel time is calculated using time-dependent historic traffic data. */ - travelTimeInSeconds: number; + readonly travelTimeInSeconds: number; /** Estimated delay in seconds caused by the real-time incident(s) according to traffic information. For routes planned with departure time in the future, delays is always 0. To return additional travel times using different types of traffic information, parameter computeTravelTimeFor=all needs to be added. */ - trafficDelayInSeconds: number; - /** The estimated departure time for the route or leg. */ - departureTime: string; - /** The estimated arrival time for the route or leg. */ - arrivalTime: string; + readonly trafficDelayInSeconds: number; + /** The estimated departure time for the route or leg. Time is in UTC. */ + readonly departureTime: string; + /** The estimated arrival time for the route or leg. Time is in UTC. */ + readonly arrivalTime: string; } /** Summary object */ export interface RouteMatrixSummaryOutput { /** Number of successful routes in the response. */ - successfulRoutes: number; + readonly successfulRoutes: number; /** Total number of routes requested. Number of cells in the input matrix. */ - totalRoutes: number; + readonly totalRoutes: number; } /** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). */ @@ -56,17 +56,17 @@ export interface ErrorResponseOutput { /** The error detail. */ export interface ErrorDetailOutput { /** The error code. */ - code?: string; + readonly code?: string; /** The error message. */ - message?: string; + readonly message?: string; } /** This object is returned from a successful Route Directions call */ export interface RouteDirectionsOutput { /** Format Version property */ - formatVersion?: string; + readonly formatVersion?: string; /** Routes array */ - routes: Array; + readonly routes: Array; /** * Optimized sequence of waypoints. It shows the index from the user provided waypoint sequence for the original and optimized list. For instance, a response: * @@ -80,28 +80,28 @@ export interface RouteDirectionsOutput { * * means that the original sequence is [0, 1, 2] and optimized sequence is [1, 2, 0]. Since the index starts by 0 the original is "first, second, third" while the optimized is "second, third, first". */ - optimizedWaypoints?: Array; + readonly optimizedWaypoints?: Array; /** Reports the effective settings used in the current call. */ report?: RouteReportOutput; } export interface RouteOutput { /** Summary object */ - summary: RouteSummaryOutput; + readonly summary: RouteSummaryOutput; /** Legs array */ - legs: Array; + readonly legs: Array; /** Sections array */ - sections?: Array; + readonly sections?: Array; /** Contains guidance related elements. This field is present only when guidance was requested and is available. */ - guidance?: RouteGuidanceOutput; + readonly guidance?: RouteGuidanceOutput; } /** A description of a part of a route, comprised of a list of points. Each additional waypoint provided in the request will result in an additional leg in the returned route. */ export interface RouteLegOutput { /** Summary object */ - summary: RouteSummaryOutput; + readonly summary: RouteSummaryOutput; /** Points array */ - points: Array; + readonly points: Array; } /** A location represented as a latitude and longitude. */ @@ -115,11 +115,11 @@ export interface LatLongPairOutput { /** Route sections contain additional information about parts of a route. Each section contains at least the elements `startPointIndex`, `endPointIndex`, and `sectionType`. */ export interface RouteSectionOutput { /** Index of the first point (offset 0) in the route this section applies to. */ - startPointIndex: number; + readonly startPointIndex: number; /** Index of the last point (offset 0) in the route this section applies to. */ - endPointIndex: number; + readonly endPointIndex: number; /** Section types of the reported route response */ - sectionType: + readonly sectionType: | "CAR_TRAIN" | "COUNTRY" | "FERRY" @@ -133,7 +133,7 @@ export interface RouteSectionOutput { | "CARPOOL" | "URBAN"; /** Travel mode for the calculated route. The value will be set to `other` if the requested mode of transport is not possible in this section */ - travelMode?: + readonly travelMode?: | "car" | "truck" | "taxi" @@ -144,13 +144,13 @@ export interface RouteSectionOutput { | "pedestrian" | "other"; /** Type of the incident. Can currently be JAM, ROAD_WORK, ROAD_CLOSURE, or OTHER. See "tec" for detailed information. */ - simpleCategory?: "JAM" | "ROAD_WORK" | "ROAD_CLOSURE" | "OTHER"; + readonly simpleCategory?: "JAM" | "ROAD_WORK" | "ROAD_CLOSURE" | "OTHER"; /** Effective speed of the incident in km/h, averaged over its entire length. */ - effectiveSpeedInKmh?: number; + readonly effectiveSpeedInKmh?: number; /** Delay in seconds caused by the incident. */ - delayInSeconds?: number; + readonly delayInSeconds?: number; /** The magnitude of delay caused by the incident. These values correspond to the values of the response field ty of the [Get Traffic Incident Detail API](https://docs.microsoft.com/rest/api/maps/traffic/gettrafficincidentdetail). */ - magnitudeOfDelay?: "0" | "1" | "2" | "3" | "4"; + readonly magnitudeOfDelay?: "0" | "1" | "2" | "3" | "4"; /** Details of the traffic event, using definitions in the [TPEG2-TEC](https://www.iso.org/standard/63116.html) standard. Can contain effectCode and causes elements. */ tec?: RouteSectionTecOutput; } @@ -158,7 +158,7 @@ export interface RouteSectionOutput { /** Details of the traffic event, using definitions in the [TPEG2-TEC](https://www.iso.org/standard/63116.html) standard. Can contain effectCode and causes elements. */ export interface RouteSectionTecOutput { /** The effect on the traffic flow. Contains a value in the tec001:EffectCode table, as defined in the [TPEG2-TEC](https://www.iso.org/standard/63116.html) standard. Can be used to color-code traffic events according to severity. */ - effectCode?: number; + readonly effectCode?: number; /** Causes array */ causes?: Array; } @@ -166,29 +166,29 @@ export interface RouteSectionTecOutput { /** The cause of the traffic event. Can contain mainCauseCode and subCauseCode elements. Can be used to define iconography and descriptions. */ export interface RouteSectionTecCauseOutput { /** The main cause of the traffic event. Contains a value in the tec002:CauseCode table, as defined in the [TPEG2-TEC](https://www.iso.org/standard/63116.html) standard. */ - mainCauseCode?: number; + readonly mainCauseCode?: number; /** The subcause of the traffic event. Contains a value in the sub cause table defined by the mainCauseCode, as defined in the [TPEG2-TEC](https://www.iso.org/standard/63116.html) standard. */ - subCauseCode?: number; + readonly subCauseCode?: number; } /** Contains guidance related elements. This field is present only when guidance was requested and is available. */ export interface RouteGuidanceOutput { /** A list of instructions describing maneuvers. */ - instructions: Array; + readonly instructions: Array; /** Groups a sequence of instruction elements which are related to each other. */ - instructionGroups: Array; + readonly instructionGroups: Array; } /** A set of attributes describing a maneuver, e.g. 'Turn right', 'Keep left', 'Take the ferry', 'Take the motorway', 'Arrive'. */ export interface RouteInstructionOutput { /** Distance from the start of the route to the point of the instruction. */ - routeOffsetInMeters?: number; + readonly routeOffsetInMeters?: number; /** Estimated travel time up to the point corresponding to routeOffsetInMeters. */ - travelTimeInSeconds?: number; + readonly travelTimeInSeconds?: number; /** A location represented as a latitude and longitude. */ point?: LatLongPairOutput; /** The index of the point in the list of polyline "points" corresponding to the point of the instruction. */ - pointIndex?: number; + readonly pointIndex?: number; /** Type of the instruction, e.g., turn or change of road form. */ instructionType?: | "TURN" @@ -198,19 +198,19 @@ export interface RouteInstructionOutput { | "DIRECTION_INFO" | "LOCATION_WAYPOINT"; /** The road number(s) of the next significant road segment(s) after the maneuver, or of the road(s) to be followed. Example: ["E34", "N205"] */ - roadNumbers?: Array; + readonly roadNumbers?: Array; /** The number(s) of a highway exit taken by the current maneuver. If an exit has multiple exit numbers, they will be separated by "," and possibly aggregated by "-", e.g., "10, 13-15". */ - exitNumber?: string; + readonly exitNumber?: string; /** Street name of the next significant road segment after the maneuver, or of the street that should be followed. */ - street?: string; + readonly street?: string; /** The text on a signpost which is most relevant to the maneuver, or to the direction that should be followed. */ - signpostText?: string; + readonly signpostText?: string; /** 3-character [ISO 3166-1](https://www.iso.org/iso-3166-country-codes.html) alpha-3 country code. E.g. USA. */ - countryCode?: string; - /** A subdivision (e.g., state) of the country, represented by the second part of an [ISO 3166-2](https://www.iso.org/standard/63546.html) code. This is only available for some countries like the US, Canada, and Mexico. */ - stateCode?: string; + readonly countryCode?: string; + /** A subdivision (e.g., state) of the country, represented by the second part of an [ISO 3166-2](https://www.iso.org/standard/63546.html) code. This is only available for some countries/regions like the US, Canada, and Mexico. */ + readonly stateCode?: string; /** The type of the junction where the maneuver takes place. For larger roundabouts, two separate instructions are generated for entering and leaving the roundabout. */ - junctionType?: "REGULAR" | "ROUNDABOUT" | "BIFURCATION"; + readonly junctionType?: "REGULAR" | "ROUNDABOUT" | "BIFURCATION"; /** * Indicates the direction of an instruction. If junctionType indicates a turn instruction: * @@ -224,15 +224,15 @@ export interface RouteInstructionOutput { * * <0 - keep left * * \>0 - keep right */ - turnAngleInDecimalDegrees?: number; + readonly turnAngleInDecimalDegrees?: number; /** This indicates which exit to take at a roundabout. */ - roundaboutExitNumber?: string; + readonly roundaboutExitNumber?: number; /** It is possible to optionally combine the instruction with the next one. This can be used to build messages like "Turn left and then turn right". */ - possibleCombineWithNext?: boolean; + readonly possibleCombineWithNext?: boolean; /** Indicates left-hand vs. right-hand side driving at the point of the maneuver. */ - drivingSide?: "LEFT" | "RIGHT"; + readonly drivingSide?: "LEFT" | "RIGHT"; /** A code identifying the maneuver. */ - maneuver?: + readonly maneuver?: | "ARRIVE" | "ARRIVE_LEFT" | "ARRIVE_RIGHT" @@ -267,7 +267,7 @@ export interface RouteInstructionOutput { | "WAYPOINT_RIGHT" | "WAYPOINT_REACHED"; /** A human-readable message for the maneuver. */ - message?: string; + readonly message?: string; /** * A human-readable message for the maneuver combined with the message from the next instruction. Sometimes it is possible to combine two successive instructions into a single instruction making it easier to follow. When this is the case the possibleCombineWithNext flag will be true. For example: * @@ -283,47 +283,47 @@ export interface RouteInstructionOutput { * then follow Einsteinweg/A10/E22 towards Ring Amsterdam. * ``` */ - combinedMessage?: string; + readonly combinedMessage?: string; } /** Groups a sequence of instruction elements which are related to each other. The sequence range is constrained with firstInstructionIndex and lastInstructionIndex. When human-readable text messages are requested for guidance (instructionType=text or tagged), then the instructionGroup has a summary message returned when available. */ export interface RouteInstructionGroupOutput { /** Index of the first instruction in the instructions and belonging to this group. */ - firstInstructionIndex?: number; + readonly firstInstructionIndex?: number; /** Index of the last instruction in the instructions and belonging to this group. */ - lastInstructionIndex?: number; + readonly lastInstructionIndex?: number; /** Length of the group. */ - groupLengthInMeters?: number; + readonly groupLengthInMeters?: number; /** Summary message when human-readable text messages are requested for guidance (instructionType=text or tagged). */ - groupMessage?: string; + readonly groupMessage?: string; } /** Optimized way point object. */ export interface RouteOptimizedWaypointOutput { /** Way point index provided by the user. */ - providedIndex: number; + readonly providedIndex: number; /** Optimized way point index from the system. */ - optimizedIndex: number; + readonly optimizedIndex: number; } /** Reports the effective settings used in the current call. */ export interface RouteReportOutput { /** Effective parameters or data used when calling this Route API. */ - effectiveSettings: Array; + readonly effectiveSettings: Array; } /** Effective parameter or data used when calling this Route API. */ export interface EffectiveSettingOutput { /** Name of the parameter used. */ - key: string; + readonly key: string; /** Value of the parameter used. */ - value: string; + readonly value: string; } /** This object is returned from a successful Route Reachable Range call */ export interface RouteRangeResultOutput { /** Format Version property */ - formatVersion?: string; + readonly formatVersion?: string; /** Reachable Range */ reachableRange: RouteRangeOutput; /** Reports the effective settings used in the current call. */ @@ -335,19 +335,19 @@ export interface RouteRangeOutput { /** Center point of the reachable range */ center: LatLongPairOutput; /** Polygon boundary of the reachable range represented as a list of points. */ - boundary: Array; + readonly boundary: Array; } /** This object is returned from a successful Route Directions Batch service call. */ export interface RouteDirectionsBatchResultOutput extends BatchResultOutput { /** Array containing the batch results. */ - batchItems: Array; + readonly batchItems: Array; } /** An item returned from Route Directions Batch service call. */ export interface RouteDirectionsBatchItemOutput extends BatchResultItemOutput { /** The result of the query. RouteDirections if the query completed successfully, ErrorResponse otherwise. */ - response: RouteDirectionsBatchItemResponseOutput; + readonly response: RouteDirectionsBatchItemResponseOutput; } /** The result of the query. RouteDirections if the query completed successfully, ErrorResponse otherwise. */ @@ -358,19 +358,19 @@ export interface RouteDirectionsBatchItemResponseOutput /** An item returned from Batch API. Extend with 'response' property. */ export interface BatchResultItemOutput { /** HTTP request status code. */ - statusCode: number; + readonly statusCode: number; } /** This object is returned from a successful Batch service call. Extend with 'batchItems' property. */ export interface BatchResultOutput { /** Summary of the results for the batch request */ - summary: BatchResultSummaryOutput; + readonly summary: BatchResultSummaryOutput; } /** Summary of the results for the batch request */ export interface BatchResultSummaryOutput { /** Number of successful requests in the batch */ - successfulRequests: number; + readonly successfulRequests: number; /** Total number of requests in the batch */ - totalRequests: number; + readonly totalRequests: number; } diff --git a/sdk/maps/maps-route-rest/src/generated/parameters.ts b/sdk/maps/maps-route-rest/generated/parameters.ts similarity index 86% rename from sdk/maps/maps-route-rest/src/generated/parameters.ts rename to sdk/maps/maps-route-rest/generated/parameters.ts index f4b5e5641bbb..c00343031472 100644 --- a/sdk/maps/maps-route-rest/src/generated/parameters.ts +++ b/sdk/maps/maps-route-rest/generated/parameters.ts @@ -5,7 +5,7 @@ import { RequestParameters } from "@azure-rest/core-client"; import { RouteMatrixQuery, RouteDirectionParameters, - BatchRequest + BatchRequest, } from "./models"; export interface RouteRequestRouteMatrixBodyParam { @@ -18,8 +18,8 @@ export interface RouteRequestRouteMatrixQueryParamProperties { waitForResults?: boolean; /** Specifies whether to return additional travel times using different types of traffic information (none, historic, live) as well as the default best-estimate travel time. */ computeTravelTimeFor?: "none" | "all"; - /** Specifies which of the section types is reported in the route response.

For example if sectionType = pedestrian the sections which are suited for pedestrians only are returned. Multiple types can be used. The default sectionType refers to the travelMode input. By default travelMode is set to car */ - sectionType?: + /** Specifies which of the section types is reported in the route response.

For example if sectionType = pedestrian the sections which are suited for pedestrians only are returned. Can be specified multiple times in one request, for example, '§ionType=carTrain§ionType=pedestrian§ionType=motorway'. The default sectionType refers to the travelMode input. By default travelMode is set to car */ + sectionType?: Array< | "carTrain" | "country" | "ferry" @@ -31,10 +31,29 @@ export interface RouteRequestRouteMatrixQueryParamProperties { | "travelMode" | "tunnel" | "carpool" - | "urban"; - /** The date and time of arrival at the destination point. It must be specified as a dateTime. When a time zone offset is not specified it will be assumed to be that of the destination point. The arriveAt value must be in the future. The arriveAt parameter cannot be used in conjunction with departAt, minDeviationDistance or minDeviationTime. */ + | "urban" + >; + /** + * The date and time of arrival at the destination point formatted as a `dateTime` value as defined in [RFC 3339, section 5.6](https://www.rfc-editor.org/rfc/rfc3339#section-5.6), with an optional time zone offset. When a time zone offset is not specified it will be assumed to be that of the destination point. + * + * Examples: + * * 2023-12-19T16:39:57 + * * 2023-12-19T16:39:57-08:00 + * + * The `arriveAt` parameter cannot be used in conjunction with `departAt`, `minDeviationDistance` or `minDeviationTime`. + */ arriveAt?: Date | string; - /** The date and time of departure from the origin point. Departure times apart from now must be specified as a dateTime. When a time zone offset is not specified, it will be assumed to be that of the origin point. The departAt value must be in the future in the date-time format (1996-12-19T16:39:57-08:00). */ + /** + * The date and time of departure from the origin point formatted as a `dateTime` value as defined in [RFC 3339, section 5.6](https://www.rfc-editor.org/rfc/rfc3339#section-5.6), with an optional time zone offset. When a time zone offset is not specified, it will be assumed to be that of the origin point. + * * Default value: now + * * Other value: `dateTime` + * + * Examples: + * * 2023-12-19T16:39:57 + * * 2023-12-19T16:39:57-08:00 + * + * The `departAt` parameter cannot be used in conjunction with `arriveAt`. + */ departAt?: Date | string; /** Weight per axle of the vehicle in kg. A value of 0 means that weight restrictions per axle are not considered. */ vehicleAxleWeight?: number; @@ -58,7 +77,7 @@ export interface RouteRequestRouteMatrixQueryParamProperties { windingness?: "low" | "normal" | "high"; /** Degree of hilliness for thrilling route. This parameter can only be used in conjunction with `routeType`=thrilling. */ hilliness?: "low" | "normal" | "high"; - /** The mode of travel for the requested route. If not defined, default is 'car'. Note that the requested travelMode may not be available for the entire route. Where the requested travelMode is not available for a particular section, the travelMode element of the response for that section will be "other". Note that travel modes bus, motorcycle, taxi and van are BETA functionality. Full restriction data is not available in all areas. In **calculateReachableRange** requests, the values bicycle and pedestrian must not be used. */ + /** The mode of travel for the requested route. If not defined, default is 'car'. Note that the requested travelMode may not be available for the entire route. Where the requested travelMode is not available for a particular section, the travelMode element of the response for that section will be "other". Note that travel modes bus, motorcycle, taxi and van are BETA functionality. Full restriction data is not available in all areas. */ travelMode?: | "car" | "truck" @@ -68,7 +87,7 @@ export interface RouteRequestRouteMatrixQueryParamProperties { | "motorcycle" | "bicycle" | "pedestrian"; - /** Specifies something that the route calculation should try to avoid when determining the route. Can be specified multiple times in one request, for example, '&avoid=motorways&avoid=tollRoads&avoid=ferries'. In calculateReachableRange requests, the value alreadyUsedRoads must not be used. */ + /** Specifies something that the route calculation should try to avoid when determining the route. Can be specified multiple times in one request, for example, '&avoid=motorways&avoid=tollRoads&avoid=ferries'. In Route Range requests, the value alreadyUsedRoads must not be used. */ avoid?: Array< | "tollRoads" | "motorways" @@ -87,7 +106,7 @@ export interface RouteRequestRouteMatrixQueryParamProperties { traffic?: boolean; /** The type of route requested. */ routeType?: "fastest" | "shortest" | "eco" | "thrilling"; - /** Types of cargo that may be classified as hazardous materials and restricted from some roads. Available vehicleLoadType values are US Hazmat classes 1 through 9, plus generic classifications for use in other countries. Values beginning with USHazmat are for US routing while otherHazmat should be used for all other countries. vehicleLoadType can be specified multiple times. This parameter is currently only considered for travelMode=truck. */ + /** Types of cargo that may be classified as hazardous materials and restricted from some roads. Available vehicleLoadType values are US Hazmat classes 1 through 9, plus generic classifications for use in other countries/regions. Values beginning with USHazmat are for US routing while otherHazmat should be used for all other countries/regions. vehicleLoadType can be specified multiple times. This parameter is currently only considered for travelMode=truck. */ vehicleLoadType?: | "USHazmatClass1" | "USHazmatClass2" @@ -112,10 +131,11 @@ export interface RouteRequestRouteMatrixMediaTypesParam { contentType?: "application/json"; } -export type RouteRequestRouteMatrixParameters = RouteRequestRouteMatrixQueryParam & - RouteRequestRouteMatrixMediaTypesParam & - RouteRequestRouteMatrixBodyParam & - RequestParameters; +export type RouteRequestRouteMatrixParameters = + RouteRequestRouteMatrixQueryParam & + RouteRequestRouteMatrixMediaTypesParam & + RouteRequestRouteMatrixBodyParam & + RequestParameters; export type RouteGetRouteMatrixParameters = RequestParameters; export interface RouteRequestRouteMatrixSyncBodyParam { @@ -128,8 +148,8 @@ export interface RouteRequestRouteMatrixSyncQueryParamProperties { waitForResults?: boolean; /** Specifies whether to return additional travel times using different types of traffic information (none, historic, live) as well as the default best-estimate travel time. */ computeTravelTimeFor?: "none" | "all"; - /** Specifies which of the section types is reported in the route response.

For example if sectionType = pedestrian the sections which are suited for pedestrians only are returned. Multiple types can be used. The default sectionType refers to the travelMode input. By default travelMode is set to car */ - sectionType?: + /** Specifies which of the section types is reported in the route response.

For example if sectionType = pedestrian the sections which are suited for pedestrians only are returned. Can be specified multiple times in one request, for example, '§ionType=carTrain§ionType=pedestrian§ionType=motorway'. The default sectionType refers to the travelMode input. By default travelMode is set to car */ + sectionType?: Array< | "carTrain" | "country" | "ferry" @@ -141,10 +161,29 @@ export interface RouteRequestRouteMatrixSyncQueryParamProperties { | "travelMode" | "tunnel" | "carpool" - | "urban"; - /** The date and time of arrival at the destination point. It must be specified as a dateTime. When a time zone offset is not specified it will be assumed to be that of the destination point. The arriveAt value must be in the future. The arriveAt parameter cannot be used in conjunction with departAt, minDeviationDistance or minDeviationTime. */ + | "urban" + >; + /** + * The date and time of arrival at the destination point formatted as a `dateTime` value as defined in [RFC 3339, section 5.6](https://www.rfc-editor.org/rfc/rfc3339#section-5.6), with an optional time zone offset. When a time zone offset is not specified it will be assumed to be that of the destination point. + * + * Examples: + * * 2023-12-19T16:39:57 + * * 2023-12-19T16:39:57-08:00 + * + * The `arriveAt` parameter cannot be used in conjunction with `departAt`, `minDeviationDistance` or `minDeviationTime`. + */ arriveAt?: Date | string; - /** The date and time of departure from the origin point. Departure times apart from now must be specified as a dateTime. When a time zone offset is not specified, it will be assumed to be that of the origin point. The departAt value must be in the future in the date-time format (1996-12-19T16:39:57-08:00). */ + /** + * The date and time of departure from the origin point formatted as a `dateTime` value as defined in [RFC 3339, section 5.6](https://www.rfc-editor.org/rfc/rfc3339#section-5.6), with an optional time zone offset. When a time zone offset is not specified, it will be assumed to be that of the origin point. + * * Default value: now + * * Other value: `dateTime` + * + * Examples: + * * 2023-12-19T16:39:57 + * * 2023-12-19T16:39:57-08:00 + * + * The `departAt` parameter cannot be used in conjunction with `arriveAt`. + */ departAt?: Date | string; /** Weight per axle of the vehicle in kg. A value of 0 means that weight restrictions per axle are not considered. */ vehicleAxleWeight?: number; @@ -168,7 +207,7 @@ export interface RouteRequestRouteMatrixSyncQueryParamProperties { windingness?: "low" | "normal" | "high"; /** Degree of hilliness for thrilling route. This parameter can only be used in conjunction with `routeType`=thrilling. */ hilliness?: "low" | "normal" | "high"; - /** The mode of travel for the requested route. If not defined, default is 'car'. Note that the requested travelMode may not be available for the entire route. Where the requested travelMode is not available for a particular section, the travelMode element of the response for that section will be "other". Note that travel modes bus, motorcycle, taxi and van are BETA functionality. Full restriction data is not available in all areas. In **calculateReachableRange** requests, the values bicycle and pedestrian must not be used. */ + /** The mode of travel for the requested route. If not defined, default is 'car'. Note that the requested travelMode may not be available for the entire route. Where the requested travelMode is not available for a particular section, the travelMode element of the response for that section will be "other". Note that travel modes bus, motorcycle, taxi and van are BETA functionality. Full restriction data is not available in all areas. */ travelMode?: | "car" | "truck" @@ -178,7 +217,7 @@ export interface RouteRequestRouteMatrixSyncQueryParamProperties { | "motorcycle" | "bicycle" | "pedestrian"; - /** Specifies something that the route calculation should try to avoid when determining the route. Can be specified multiple times in one request, for example, '&avoid=motorways&avoid=tollRoads&avoid=ferries'. In calculateReachableRange requests, the value alreadyUsedRoads must not be used. */ + /** Specifies something that the route calculation should try to avoid when determining the route. Can be specified multiple times in one request, for example, '&avoid=motorways&avoid=tollRoads&avoid=ferries'. In Route Range requests, the value alreadyUsedRoads must not be used. */ avoid?: Array< | "tollRoads" | "motorways" @@ -197,7 +236,7 @@ export interface RouteRequestRouteMatrixSyncQueryParamProperties { traffic?: boolean; /** The type of route requested. */ routeType?: "fastest" | "shortest" | "eco" | "thrilling"; - /** Types of cargo that may be classified as hazardous materials and restricted from some roads. Available vehicleLoadType values are US Hazmat classes 1 through 9, plus generic classifications for use in other countries. Values beginning with USHazmat are for US routing while otherHazmat should be used for all other countries. vehicleLoadType can be specified multiple times. This parameter is currently only considered for travelMode=truck. */ + /** Types of cargo that may be classified as hazardous materials and restricted from some roads. Available vehicleLoadType values are US Hazmat classes 1 through 9, plus generic classifications for use in other countries/regions. Values beginning with USHazmat are for US routing while otherHazmat should be used for all other countries/regions. vehicleLoadType can be specified multiple times. This parameter is currently only considered for travelMode=truck. */ vehicleLoadType?: | "USHazmatClass1" | "USHazmatClass2" @@ -222,10 +261,11 @@ export interface RouteRequestRouteMatrixSyncMediaTypesParam { contentType?: "application/json"; } -export type RouteRequestRouteMatrixSyncParameters = RouteRequestRouteMatrixSyncQueryParam & - RouteRequestRouteMatrixSyncMediaTypesParam & - RouteRequestRouteMatrixSyncBodyParam & - RequestParameters; +export type RouteRequestRouteMatrixSyncParameters = + RouteRequestRouteMatrixSyncQueryParam & + RouteRequestRouteMatrixSyncMediaTypesParam & + RouteRequestRouteMatrixSyncBodyParam & + RequestParameters; export interface RouteGetRouteDirectionsQueryParamProperties { /** The Coordinates through which the route is calculated, delimited by a colon. A minimum of two coordinates is required. The first one is the origin and the last is the destination of the route. Optional coordinates in-between act as WayPoints in the route. You can pass up to 150 WayPoints. */ @@ -236,9 +276,27 @@ export interface RouteGetRouteDirectionsQueryParamProperties { alternativeType?: "anyRoute" | "betterRoute"; /** All alternative routes returned will follow the reference route (see section POST Requests) from the origin point of the calculateRoute request for at least this number of meters. Can only be used when reconstructing a route. The minDeviationDistance parameter cannot be used in conjunction with arriveAt */ minDeviationDistance?: number; - /** The date and time of arrival at the destination point. It must be specified as a dateTime. When a time zone offset is not specified it will be assumed to be that of the destination point. The arriveAt value must be in the future. The arriveAt parameter cannot be used in conjunction with departAt, minDeviationDistance or minDeviationTime. */ + /** + * The date and time of arrival at the destination point formatted as a `dateTime` value as defined in [RFC 3339, section 5.6](https://www.rfc-editor.org/rfc/rfc3339#section-5.6), with an optional time zone offset. When a time zone offset is not specified it will be assumed to be that of the destination point. + * + * Examples: + * * 2023-12-19T16:39:57 + * * 2023-12-19T16:39:57-08:00 + * + * The `arriveAt` parameter cannot be used in conjunction with `departAt`, `minDeviationDistance` or `minDeviationTime`. + */ arriveAt?: Date | string; - /** The date and time of departure from the origin point. Departure times apart from now must be specified as a dateTime. When a time zone offset is not specified, it will be assumed to be that of the origin point. The departAt value must be in the future in the date-time format (1996-12-19T16:39:57-08:00). */ + /** + * The date and time of departure from the origin point formatted as a `dateTime` value as defined in [RFC 3339, section 5.6](https://www.rfc-editor.org/rfc/rfc3339#section-5.6), with an optional time zone offset. When a time zone offset is not specified, it will be assumed to be that of the origin point. + * * Default value: now + * * Other value: `dateTime` + * + * Examples: + * * 2023-12-19T16:39:57 + * * 2023-12-19T16:39:57-08:00 + * + * The `departAt` parameter cannot be used in conjunction with `arriveAt`. + */ departAt?: Date | string; /** * All alternative routes returned will follow the reference route (see section POST Requests) from the origin point of the calculateRoute request for at least this number of seconds. Can only be used when reconstructing a route. The minDeviationTime parameter cannot be used in conjunction with arriveAt. Default value is 0. Setting )minDeviationTime_ to a value greater than zero has the following consequences: @@ -259,7 +317,7 @@ export interface RouteGetRouteDirectionsQueryParamProperties { * - The _vehicleHeading_ is ignored. */ minDeviationTime?: number; - /** If specified, guidance instructions will be returned. Note that the instructionsType parameter cannot be used in conjunction with routeRepresentation=none */ + /** If specified, guidance instructions will be returned. Note that the instructionsType parameter cannot be used in conjunction with routeRepresentation=none. */ instructionsType?: "coded" | "text" | "tagged"; /** * The language parameter determines the language of the guidance messages. Proper nouns (the names of streets, plazas, etc.) are returned in the specified language, or if that is not available, they are returned in an available language that is close to it. Allowed values are (a subset of) the IETF language tags. The currently supported languages are listed in the [Supported languages section](https://docs.microsoft.com/azure/azure-maps/supported-languages). @@ -269,7 +327,7 @@ export interface RouteGetRouteDirectionsQueryParamProperties { language?: string; /** Re-order the route waypoints using a fast heuristic algorithm to reduce the route length. Yields best results when used in conjunction with routeType _shortest_. Notice that origin and destination are excluded from the optimized waypoint indices. To include origin and destination in the response, please increase all the indices by 1 to account for the origin, and then add the destination as the final index. Possible values are true or false. True computes a better order if possible, but is not allowed to be used in conjunction with maxAlternatives value greater than 0 or in conjunction with circle waypoints. False will use the locations in the given order and not allowed to be used in conjunction with routeRepresentation _none_. */ computeBestOrder?: boolean; - /** Specifies the representation of the set of routes provided as response. This parameter value can only be used in conjunction with computeBestOrder=true. */ + /** Specifies the representation of the set of routes provided as response. */ routeRepresentation?: "polyline" | "summaryOnly" | "none"; /** Specifies whether to return additional travel times using different types of traffic information (none, historic, live) as well as the default best-estimate travel time. */ computeTravelTimeFor?: "none" | "all"; @@ -277,8 +335,8 @@ export interface RouteGetRouteDirectionsQueryParamProperties { vehicleHeading?: number; /** Specifies which data should be reported for diagnosis purposes. The only possible value is _effectiveSettings_. Reports the effective parameters or data used when calling the API. In the case of defaulted parameters the default will be reflected where the parameter was not specified by the caller. */ report?: "effectiveSettings"; - /** Specifies which of the section types is reported in the route response.

For example if sectionType = pedestrian the sections which are suited for pedestrians only are returned. Multiple types can be used. The default sectionType refers to the travelMode input. By default travelMode is set to car */ - sectionType?: + /** Specifies which of the section types is reported in the route response.

For example if sectionType = pedestrian the sections which are suited for pedestrians only are returned. Can be specified multiple times in one request, for example, '§ionType=carTrain§ionType=pedestrian§ionType=motorway'. The default sectionType refers to the travelMode input. By default travelMode is set to car */ + sectionType?: Array< | "carTrain" | "country" | "ferry" @@ -290,7 +348,8 @@ export interface RouteGetRouteDirectionsQueryParamProperties { | "travelMode" | "tunnel" | "carpool" - | "urban"; + | "urban" + >; /** Weight per axle of the vehicle in kg. A value of 0 means that weight restrictions per axle are not considered. */ vehicleAxleWeight?: number; /** Width of the vehicle in meters. A value of 0 means that width restrictions are not considered. */ @@ -327,7 +386,7 @@ export interface RouteGetRouteDirectionsQueryParamProperties { windingness?: "low" | "normal" | "high"; /** Degree of hilliness for thrilling route. This parameter can only be used in conjunction with `routeType`=thrilling. */ hilliness?: "low" | "normal" | "high"; - /** The mode of travel for the requested route. If not defined, default is 'car'. Note that the requested travelMode may not be available for the entire route. Where the requested travelMode is not available for a particular section, the travelMode element of the response for that section will be "other". Note that travel modes bus, motorcycle, taxi and van are BETA functionality. Full restriction data is not available in all areas. In **calculateReachableRange** requests, the values bicycle and pedestrian must not be used. */ + /** The mode of travel for the requested route. If not defined, default is 'car'. Note that the requested travelMode may not be available for the entire route. Where the requested travelMode is not available for a particular section, the travelMode element of the response for that section will be "other". Note that travel modes bus, motorcycle, taxi and van are BETA functionality. Full restriction data is not available in all areas. */ travelMode?: | "car" | "truck" @@ -337,7 +396,7 @@ export interface RouteGetRouteDirectionsQueryParamProperties { | "motorcycle" | "bicycle" | "pedestrian"; - /** Specifies something that the route calculation should try to avoid when determining the route. Can be specified multiple times in one request, for example, '&avoid=motorways&avoid=tollRoads&avoid=ferries'. In calculateReachableRange requests, the value alreadyUsedRoads must not be used. */ + /** Specifies something that the route calculation should try to avoid when determining the route. Can be specified multiple times in one request, for example, '&avoid=motorways&avoid=tollRoads&avoid=ferries'. In Route Range requests, the value alreadyUsedRoads must not be used. */ avoid?: Array< | "tollRoads" | "motorways" @@ -356,7 +415,7 @@ export interface RouteGetRouteDirectionsQueryParamProperties { traffic?: boolean; /** The type of route requested. */ routeType?: "fastest" | "shortest" | "eco" | "thrilling"; - /** Types of cargo that may be classified as hazardous materials and restricted from some roads. Available vehicleLoadType values are US Hazmat classes 1 through 9, plus generic classifications for use in other countries. Values beginning with USHazmat are for US routing while otherHazmat should be used for all other countries. vehicleLoadType can be specified multiple times. This parameter is currently only considered for travelMode=truck. */ + /** Types of cargo that may be classified as hazardous materials and restricted from some roads. Available vehicleLoadType values are US Hazmat classes 1 through 9, plus generic classifications for use in other countries/regions. Values beginning with USHazmat are for US routing while otherHazmat should be used for all other countries/regions. vehicleLoadType can be specified multiple times. This parameter is currently only considered for travelMode=truck. */ vehicleLoadType?: | "USHazmatClass1" | "USHazmatClass2" @@ -513,8 +572,8 @@ export interface RouteGetRouteDirectionsQueryParam { queryParameters: RouteGetRouteDirectionsQueryParamProperties; } -export type RouteGetRouteDirectionsParameters = RouteGetRouteDirectionsQueryParam & - RequestParameters; +export type RouteGetRouteDirectionsParameters = + RouteGetRouteDirectionsQueryParam & RequestParameters; export interface RouteGetRouteDirectionsWithAdditionalParametersBodyParam { /** @@ -559,13 +618,13 @@ export interface RouteGetRouteDirectionsWithAdditionalParametersQueryParamProper * - The _vehicleHeading_ is ignored. */ minDeviationTime?: number; - /** If specified, guidance instructions will be returned. Note that the instructionsType parameter cannot be used in conjunction with routeRepresentation=none */ + /** If specified, guidance instructions will be returned. Note that the instructionsType parameter cannot be used in conjunction with routeRepresentation=none. */ instructionsType?: "coded" | "text" | "tagged"; /** The language parameter determines the language of the guidance messages. It does not affect proper nouns (the names of streets, plazas, etc.) It has no effect when instructionsType=coded. Allowed values are (a subset of) the IETF language tags described */ language?: string; /** Re-order the route waypoints using a fast heuristic algorithm to reduce the route length. Yields best results when used in conjunction with routeType _shortest_. Notice that origin and destination are excluded from the optimized waypoint indices. To include origin and destination in the response, please increase all the indices by 1 to account for the origin, and then add the destination as the final index. Possible values are true or false. True computes a better order if possible, but is not allowed to be used in conjunction with maxAlternatives value greater than 0 or in conjunction with circle waypoints. False will use the locations in the given order and not allowed to be used in conjunction with routeRepresentation _none_. */ computeBestOrder?: boolean; - /** Specifies the representation of the set of routes provided as response. This parameter value can only be used in conjunction with computeBestOrder=true. */ + /** Specifies the representation of the set of routes provided as response. */ routeRepresentation?: "polyline" | "summaryOnly" | "none"; /** Specifies whether to return additional travel times using different types of traffic information (none, historic, live) as well as the default best-estimate travel time. */ computeTravelTimeFor?: "none" | "all"; @@ -573,8 +632,8 @@ export interface RouteGetRouteDirectionsWithAdditionalParametersQueryParamProper vehicleHeading?: number; /** Specifies which data should be reported for diagnosis purposes. The only possible value is _effectiveSettings_. Reports the effective parameters or data used when calling the API. In the case of defaulted parameters the default will be reflected where the parameter was not specified by the caller. */ report?: "effectiveSettings"; - /** Specifies which of the section types is reported in the route response.

For example if sectionType = pedestrian the sections which are suited for pedestrians only are returned. Multiple types can be used. The default sectionType refers to the travelMode input. By default travelMode is set to car */ - sectionType?: + /** Specifies which of the section types is reported in the route response.

For example if sectionType = pedestrian the sections which are suited for pedestrians only are returned. Can be specified multiple times in one request, for example, '§ionType=carTrain§ionType=pedestrian§ionType=motorway'. The default sectionType refers to the travelMode input. By default travelMode is set to car */ + sectionType?: Array< | "carTrain" | "country" | "ferry" @@ -586,10 +645,29 @@ export interface RouteGetRouteDirectionsWithAdditionalParametersQueryParamProper | "travelMode" | "tunnel" | "carpool" - | "urban"; - /** The date and time of arrival at the destination point. It must be specified as a dateTime. When a time zone offset is not specified it will be assumed to be that of the destination point. The arriveAt value must be in the future. The arriveAt parameter cannot be used in conjunction with departAt, minDeviationDistance or minDeviationTime. */ + | "urban" + >; + /** + * The date and time of arrival at the destination point formatted as a `dateTime` value as defined in [RFC 3339, section 5.6](https://www.rfc-editor.org/rfc/rfc3339#section-5.6), with an optional time zone offset. When a time zone offset is not specified it will be assumed to be that of the destination point. + * + * Examples: + * * 2023-12-19T16:39:57 + * * 2023-12-19T16:39:57-08:00 + * + * The `arriveAt` parameter cannot be used in conjunction with `departAt`, `minDeviationDistance` or `minDeviationTime`. + */ arriveAt?: Date | string; - /** The date and time of departure from the origin point. Departure times apart from now must be specified as a dateTime. When a time zone offset is not specified, it will be assumed to be that of the origin point. The departAt value must be in the future in the date-time format (1996-12-19T16:39:57-08:00). */ + /** + * The date and time of departure from the origin point formatted as a `dateTime` value as defined in [RFC 3339, section 5.6](https://www.rfc-editor.org/rfc/rfc3339#section-5.6), with an optional time zone offset. When a time zone offset is not specified, it will be assumed to be that of the origin point. + * * Default value: now + * * Other value: `dateTime` + * + * Examples: + * * 2023-12-19T16:39:57 + * * 2023-12-19T16:39:57-08:00 + * + * The `departAt` parameter cannot be used in conjunction with `arriveAt`. + */ departAt?: Date | string; /** Weight per axle of the vehicle in kg. A value of 0 means that weight restrictions per axle are not considered. */ vehicleAxleWeight?: number; @@ -627,7 +705,7 @@ export interface RouteGetRouteDirectionsWithAdditionalParametersQueryParamProper windingness?: "low" | "normal" | "high"; /** Degree of hilliness for thrilling route. This parameter can only be used in conjunction with `routeType`=thrilling. */ hilliness?: "low" | "normal" | "high"; - /** The mode of travel for the requested route. If not defined, default is 'car'. Note that the requested travelMode may not be available for the entire route. Where the requested travelMode is not available for a particular section, the travelMode element of the response for that section will be "other". Note that travel modes bus, motorcycle, taxi and van are BETA functionality. Full restriction data is not available in all areas. In **calculateReachableRange** requests, the values bicycle and pedestrian must not be used. */ + /** The mode of travel for the requested route. If not defined, default is 'car'. Note that the requested travelMode may not be available for the entire route. Where the requested travelMode is not available for a particular section, the travelMode element of the response for that section will be "other". Note that travel modes bus, motorcycle, taxi and van are BETA functionality. Full restriction data is not available in all areas. */ travelMode?: | "car" | "truck" @@ -637,7 +715,7 @@ export interface RouteGetRouteDirectionsWithAdditionalParametersQueryParamProper | "motorcycle" | "bicycle" | "pedestrian"; - /** Specifies something that the route calculation should try to avoid when determining the route. Can be specified multiple times in one request, for example, '&avoid=motorways&avoid=tollRoads&avoid=ferries'. In calculateReachableRange requests, the value alreadyUsedRoads must not be used. */ + /** Specifies something that the route calculation should try to avoid when determining the route. Can be specified multiple times in one request, for example, '&avoid=motorways&avoid=tollRoads&avoid=ferries'. In Route Range requests, the value alreadyUsedRoads must not be used. */ avoid?: Array< | "tollRoads" | "motorways" @@ -656,7 +734,7 @@ export interface RouteGetRouteDirectionsWithAdditionalParametersQueryParamProper traffic?: boolean; /** The type of route requested. */ routeType?: "fastest" | "shortest" | "eco" | "thrilling"; - /** Types of cargo that may be classified as hazardous materials and restricted from some roads. Available vehicleLoadType values are US Hazmat classes 1 through 9, plus generic classifications for use in other countries. Values beginning with USHazmat are for US routing while otherHazmat should be used for all other countries. vehicleLoadType can be specified multiple times. This parameter is currently only considered for travelMode=truck. */ + /** Types of cargo that may be classified as hazardous materials and restricted from some roads. Available vehicleLoadType values are US Hazmat classes 1 through 9, plus generic classifications for use in other countries/regions. Values beginning with USHazmat are for US routing while otherHazmat should be used for all other countries/regions. vehicleLoadType can be specified multiple times. This parameter is currently only considered for travelMode=truck. */ vehicleLoadType?: | "USHazmatClass1" | "USHazmatClass2" @@ -818,10 +896,11 @@ export interface RouteGetRouteDirectionsWithAdditionalParametersMediaTypesParam contentType?: "application/json"; } -export type RouteGetRouteDirectionsWithAdditionalParametersParameters = RouteGetRouteDirectionsWithAdditionalParametersQueryParam & - RouteGetRouteDirectionsWithAdditionalParametersMediaTypesParam & - RouteGetRouteDirectionsWithAdditionalParametersBodyParam & - RequestParameters; +export type RouteGetRouteDirectionsWithAdditionalParametersParameters = + RouteGetRouteDirectionsWithAdditionalParametersQueryParam & + RouteGetRouteDirectionsWithAdditionalParametersMediaTypesParam & + RouteGetRouteDirectionsWithAdditionalParametersBodyParam & + RequestParameters; export interface RouteGetRouteRangeQueryParamProperties { /** The Coordinate from which the range calculation should start. */ @@ -834,7 +913,17 @@ export interface RouteGetRouteRangeQueryParamProperties { timeBudgetInSec?: number; /** Distance budget in meters that determines maximal range which can be travelled using driving distance. The Consumption Model will only affect the range when routeType is eco.
Exactly one budget (fuelBudgetInLiters, energyBudgetInkWh, timeBudgetInSec, or distanceBudgetInMeters) must be used. */ distanceBudgetInMeters?: number; - /** The date and time of departure from the origin point. Departure times apart from now must be specified as a dateTime. When a time zone offset is not specified, it will be assumed to be that of the origin point. The departAt value must be in the future in the date-time format (1996-12-19T16:39:57-08:00). */ + /** + * The date and time of departure from the origin point formatted as a `dateTime` value as defined in [RFC 3339, section 5.6](https://www.rfc-editor.org/rfc/rfc3339#section-5.6), with an optional time zone offset. When a time zone offset is not specified, it will be assumed to be that of the origin point. + * * Default value: now + * * Other value: `dateTime` + * + * Examples: + * * 2023-12-19T16:39:57 + * * 2023-12-19T16:39:57-08:00 + * + * The `departAt` parameter cannot be used in conjunction with `arriveAt`. + */ departAt?: Date | string; /** The type of route requested. */ routeType?: "fastest" | "shortest" | "eco" | "thrilling"; @@ -845,7 +934,7 @@ export interface RouteGetRouteRangeQueryParamProperties { * during routing, the effect of historic traffic on effective road speeds is still incorporated. */ traffic?: boolean; - /** Specifies something that the route calculation should try to avoid when determining the route. Can be specified multiple times in one request, for example, '&avoid=motorways&avoid=tollRoads&avoid=ferries'. In calculateReachableRange requests, the value alreadyUsedRoads must not be used. */ + /** Specifies something that the route calculation should try to avoid when determining the route. Can be specified multiple times in one request, for example, '&avoid=motorways&avoid=tollRoads&avoid=ferries'. In Route Range requests, the value alreadyUsedRoads must not be used. */ avoid?: Array< | "tollRoads" | "motorways" @@ -855,7 +944,7 @@ export interface RouteGetRouteRangeQueryParamProperties { | "alreadyUsedRoads" | "borderCrossings" >; - /** The mode of travel for the requested route. If not defined, default is 'car'. Note that the requested travelMode may not be available for the entire route. Where the requested travelMode is not available for a particular section, the travelMode element of the response for that section will be "other". Note that travel modes bus, motorcycle, taxi and van are BETA functionality. Full restriction data is not available in all areas. In **calculateReachableRange** requests, the values bicycle and pedestrian must not be used. */ + /** The mode of travel for the requested route. If not defined, default is 'car'. Note that the requested travelMode may not be available for the entire route. Where the requested travelMode is not available for a particular section, the travelMode element of the response for that section will be "other". Note that travel modes bus, motorcycle, taxi and van are BETA functionality. Full restriction data is not available in all areas. */ travelMode?: | "car" | "truck" @@ -901,7 +990,7 @@ export interface RouteGetRouteRangeQueryParamProperties { vehicleWeight?: number; /** Whether the vehicle is used for commercial purposes. Commercial vehicles may not be allowed to drive on some roads. */ vehicleCommercial?: boolean; - /** Types of cargo that may be classified as hazardous materials and restricted from some roads. Available vehicleLoadType values are US Hazmat classes 1 through 9, plus generic classifications for use in other countries. Values beginning with USHazmat are for US routing while otherHazmat should be used for all other countries. vehicleLoadType can be specified multiple times. This parameter is currently only considered for travelMode=truck. */ + /** Types of cargo that may be classified as hazardous materials and restricted from some roads. Available vehicleLoadType values are US Hazmat classes 1 through 9, plus generic classifications for use in other countries/regions. Values beginning with USHazmat are for US routing while otherHazmat should be used for all other countries/regions. vehicleLoadType can be specified multiple times. This parameter is currently only considered for travelMode=truck. */ vehicleLoadType?: | "USHazmatClass1" | "USHazmatClass2" @@ -1071,9 +1160,10 @@ export interface RouteRequestRouteDirectionsBatchMediaTypesParam { contentType?: "application/json"; } -export type RouteRequestRouteDirectionsBatchParameters = RouteRequestRouteDirectionsBatchMediaTypesParam & - RouteRequestRouteDirectionsBatchBodyParam & - RequestParameters; +export type RouteRequestRouteDirectionsBatchParameters = + RouteRequestRouteDirectionsBatchMediaTypesParam & + RouteRequestRouteDirectionsBatchBodyParam & + RequestParameters; export type RouteGetRouteDirectionsBatchParameters = RequestParameters; export interface RouteRequestRouteDirectionsBatchSyncBodyParam { @@ -1086,6 +1176,7 @@ export interface RouteRequestRouteDirectionsBatchSyncMediaTypesParam { contentType?: "application/json"; } -export type RouteRequestRouteDirectionsBatchSyncParameters = RouteRequestRouteDirectionsBatchSyncMediaTypesParam & - RouteRequestRouteDirectionsBatchSyncBodyParam & - RequestParameters; +export type RouteRequestRouteDirectionsBatchSyncParameters = + RouteRequestRouteDirectionsBatchSyncMediaTypesParam & + RouteRequestRouteDirectionsBatchSyncBodyParam & + RequestParameters; diff --git a/sdk/maps/maps-route-rest/generated/pollingHelper.ts b/sdk/maps/maps-route-rest/generated/pollingHelper.ts new file mode 100644 index 000000000000..131043e0b2d0 --- /dev/null +++ b/sdk/maps/maps-route-rest/generated/pollingHelper.ts @@ -0,0 +1,205 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { Client, HttpResponse } from "@azure-rest/core-client"; +import { AbortSignalLike } from "@azure/abort-controller"; +import { + CancelOnProgress, + CreateHttpPollerOptions, + RunningOperation, + OperationResponse, + OperationState, + createHttpPoller, +} from "@azure/core-lro"; + +/** + * A simple poller that can be used to poll a long running operation. + */ +export interface SimplePollerLike< + TState extends OperationState, + TResult, +> { + /** + * Returns true if the poller has finished polling. + */ + isDone(): boolean; + /** + * Returns the state of the operation. + */ + getOperationState(): TState; + /** + * Returns the result value of the operation, + * regardless of the state of the poller. + * It can return undefined or an incomplete form of the final TResult value + * depending on the implementation. + */ + getResult(): TResult | undefined; + /** + * Returns a promise that will resolve once a single polling request finishes. + * It does this by calling the update method of the Poller's operation. + */ + poll(options?: { abortSignal?: AbortSignalLike }): Promise; + /** + * Returns a promise that will resolve once the underlying operation is completed. + */ + pollUntilDone(pollOptions?: { + abortSignal?: AbortSignalLike; + }): Promise; + /** + * Invokes the provided callback after each polling is completed, + * sending the current state of the poller's operation. + * + * It returns a method that can be used to stop receiving updates on the given callback function. + */ + onProgress(callback: (state: TState) => void): CancelOnProgress; + + /** + * Returns a promise that could be used for serialized version of the poller's operation + * by invoking the operation's serialize method. + */ + serialize(): Promise; + + /** + * Wait the poller to be submitted. + */ + submitted(): Promise; + + /** + * Returns a string representation of the poller's operation. Similar to serialize but returns a string. + * @deprecated Use serialize() instead. + */ + toString(): string; + + /** + * Stops the poller from continuing to poll. Please note this will only stop the client-side polling + * @deprecated Use abortSignal to stop polling instead. + */ + stopPolling(): void; + + /** + * Returns true if the poller is stopped. + * @deprecated Use abortSignal status to track this instead. + */ + isStopped(): boolean; +} + +/** + * Helper function that builds a Poller object to help polling a long running operation. + * @param client - Client to use for sending the request to get additional pages. + * @param initialResponse - The initial response. + * @param options - Options to set a resume state or custom polling interval. + * @returns - A poller object to poll for operation state updates and eventually get the final response. + */ +export async function getLongRunningPoller( + client: Client, + initialResponse: TResult, + options: CreateHttpPollerOptions> = {}, +): Promise, TResult>> { + const abortController = new AbortController(); + const poller: RunningOperation = { + sendInitialRequest: async () => { + // In the case of Rest Clients we are building the LRO poller object from a response that's the reason + // we are not triggering the initial request here, just extracting the information from the + // response we were provided. + return getLroResponse(initialResponse); + }, + sendPollRequest: async ( + path: string, + pollOptions?: { abortSignal?: AbortSignalLike }, + ) => { + // This is the callback that is going to be called to poll the service + // to get the latest status. We use the client provided and the polling path + // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location + // depending on the lro pattern that the service implements. If non is provided we default to the initial path. + function abortListener(): void { + abortController.abort(); + } + const inputAbortSignal = pollOptions?.abortSignal; + const abortSignal = abortController.signal; + if (inputAbortSignal?.aborted) { + abortController.abort(); + } else if (!abortSignal.aborted) { + inputAbortSignal?.addEventListener("abort", abortListener, { + once: true, + }); + } + let response; + try { + response = await client + .pathUnchecked(path ?? initialResponse.request.url) + .get({ abortSignal }); + } finally { + inputAbortSignal?.removeEventListener("abort", abortListener); + } + const lroResponse = getLroResponse(response as TResult); + lroResponse.rawResponse.headers["x-ms-original-url"] = + initialResponse.request.url; + return lroResponse; + }, + }; + + options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true; + const httpPoller = createHttpPoller(poller, options); + const simplePoller: SimplePollerLike, TResult> = { + isDone() { + return httpPoller.isDone; + }, + isStopped() { + return abortController.signal.aborted; + }, + getOperationState() { + if (!httpPoller.operationState) { + throw new Error( + "Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().", + ); + } + return httpPoller.operationState; + }, + getResult() { + return httpPoller.result; + }, + toString() { + if (!httpPoller.operationState) { + throw new Error( + "Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().", + ); + } + return JSON.stringify({ + state: httpPoller.operationState, + }); + }, + stopPolling() { + abortController.abort(); + }, + onProgress: httpPoller.onProgress, + poll: httpPoller.poll, + pollUntilDone: httpPoller.pollUntilDone, + serialize: httpPoller.serialize, + submitted: httpPoller.submitted, + }; + return simplePoller; +} + +/** + * Converts a Rest Client response to a response that the LRO implementation understands + * @param response - a rest client http response + * @returns - An LRO response that the LRO implementation understands + */ +function getLroResponse( + response: TResult, +): OperationResponse { + if (Number.isNaN(response.status)) { + throw new TypeError( + `Status code of the response is not a number. Value: ${response.status}`, + ); + } + + return { + flatResponse: response, + rawResponse: { + ...response, + statusCode: Number.parseInt(response.status), + body: response.body, + }, + }; +} diff --git a/sdk/maps/maps-route-rest/src/generated/responses.ts b/sdk/maps/maps-route-rest/generated/responses.ts similarity index 75% rename from sdk/maps/maps-route-rest/src/generated/responses.ts rename to sdk/maps/maps-route-rest/generated/responses.ts index 2616076effd2..6b744305eb4d 100644 --- a/sdk/maps/maps-route-rest/src/generated/responses.ts +++ b/sdk/maps/maps-route-rest/generated/responses.ts @@ -8,14 +8,12 @@ import { ErrorResponseOutput, RouteDirectionsOutput, RouteRangeResultOutput, - RouteDirectionsBatchResultOutput + RouteDirectionsBatchResultOutput, } from "./outputModels"; /** * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * - * The Matrix Routing service allows calculation of a matrix of route summaries for a set of routes defined by origin and destination locations by using an asynchronous (async) or synchronous (sync) POST request. For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. + * The `Post Route Matrix` API is an HTTP `POST` request that allows calculation of a matrix of route summaries for a set of routes defined by origin and destination locations by using an asynchronous (async) request. To make a synchronous (sync) request, see [Post Route Matrix Sync](/rest/api/maps/route/post-route-matrix-sync). For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. * * * For each route, the travel times and distances are returned. You can use the computed costs to determine which detailed routes to calculate using the Route Directions API. @@ -23,6 +21,9 @@ import { * * The maximum size of a matrix for async request is **700** and for sync request it's **100** (the number of origins multiplied by the number of destinations). * + * > [!NOTE] + * > All origins and destinations should be contained in an axis-aligned 400 km x 400 km bounding box. Otherwise some matrix cells will be resolved as OUT_OF_REGION. + * * * * ### Submit Synchronous Route Matrix Request @@ -39,7 +40,7 @@ import { * The maximum size of a matrix for this API is **700** (the number of origins multiplied by the number of destinations). With that constraint in mind, examples of possible matrix dimensions are: 50x10, 10x10, 28x25. 10x70 (it does not need to be square). * * - * The asynchronous responses are stored for **14** days. The redirect URL returns a 404 response if used after the expiration period. + * The asynchronous responses are stored for **24** hours. The redirect URL returns a 404 response if used after the expiration period. * * * @@ -88,15 +89,13 @@ export interface RouteRequestRouteMatrix200Response extends HttpResponse { } export interface RouteRequestRouteMatrix202Headers { - /** New URL to check for the results of the long running process. */ + /** New URL to check for the results of the long-running operation. */ location?: string; } /** * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * - * The Matrix Routing service allows calculation of a matrix of route summaries for a set of routes defined by origin and destination locations by using an asynchronous (async) or synchronous (sync) POST request. For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. + * The `Post Route Matrix` API is an HTTP `POST` request that allows calculation of a matrix of route summaries for a set of routes defined by origin and destination locations by using an asynchronous (async) request. To make a synchronous (sync) request, see [Post Route Matrix Sync](/rest/api/maps/route/post-route-matrix-sync). For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. * * * For each route, the travel times and distances are returned. You can use the computed costs to determine which detailed routes to calculate using the Route Directions API. @@ -104,6 +103,9 @@ export interface RouteRequestRouteMatrix202Headers { * * The maximum size of a matrix for async request is **700** and for sync request it's **100** (the number of origins multiplied by the number of destinations). * + * > [!NOTE] + * > All origins and destinations should be contained in an axis-aligned 400 km x 400 km bounding box. Otherwise some matrix cells will be resolved as OUT_OF_REGION. + * * * * ### Submit Synchronous Route Matrix Request @@ -120,7 +122,7 @@ export interface RouteRequestRouteMatrix202Headers { * The maximum size of a matrix for this API is **700** (the number of origins multiplied by the number of destinations). With that constraint in mind, examples of possible matrix dimensions are: 50x10, 10x10, 28x25. 10x70 (it does not need to be square). * * - * The asynchronous responses are stored for **14** days. The redirect URL returns a 404 response if used after the expiration period. + * The asynchronous responses are stored for **24** hours. The redirect URL returns a 404 response if used after the expiration period. * * * @@ -165,14 +167,57 @@ export interface RouteRequestRouteMatrix202Headers { */ export interface RouteRequestRouteMatrix202Response extends HttpResponse { status: "202"; - body: Record; headers: RawHttpHeaders & RouteRequestRouteMatrix202Headers; } /** - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). * - * If the Matrix Route request was accepted successfully, the Location header in the response contains the URL to download the results of the request. This status URI looks like the following: + * The `Get Route Matrix` API is an HTTP `GET` request that computes the travel time and distance for all possible pairs in a list of origins and destinations. Unlike the [Get Route Directions](/rest/api/maps/route/get-route-directions) API, which provide detailed route instructions, this API focuses on efficiency by giving you the cost (travel time and distance) of routing from each origin to every destination. For more information, see [Best practices for Azure Maps Route service](/azure/azure-maps/how-to-use-best-practices-for-routing). + * + * For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. + * + * + * For each route, the travel times and distances are returned. You can use the computed costs to determine which detailed routes to calculate using the Route Directions API. + * + * + * The maximum size of a matrix for async request is **700** and for sync request it's **100** (the number of origins multiplied by the number of destinations). + * + * + * + * ### Submit Synchronous Route Matrix Request + * If your scenario requires synchronous requests and the maximum size of the matrix is less than or equal to 100, you might want to make synchronous request. The maximum size of a matrix for this API is **100** (the number of origins multiplied by the number of destinations). With that constraint in mind, examples of possible matrix dimensions are: 10x10, 6x8, 9x8 (it does not need to be square). + * + * ``` + * GET https://atlas.microsoft.com/route/matrix/sync/json?api-version=1.0&subscription-key={subscription-key} + * ``` + * + * ### Submit Asynchronous Route Matrix Request + * The Asynchronous API is appropriate for processing big volumes of relatively complex routing requests. When you make a request by using async request, by default the service returns a 202 response code along a redirect URL in the Location field of the response header. This URL should be checked periodically until the response data or error information is available. If `waitForResults` parameter in the request is set to true, user will get a 200 response if the request is finished under 120 seconds. + * + * + * The maximum size of a matrix for this API is **700** (the number of origins multiplied by the number of destinations). With that constraint in mind, examples of possible matrix dimensions are: 50x10, 10x10, 28x25. 10x70 (it does not need to be square). + * + * + * The asynchronous responses are stored for **24** hours. The redirect URL returns a 404 response if used after the expiration period. + * + * + * + * + * ``` + * GET https://atlas.microsoft.com/route/matrix/json?api-version=1.0&subscription-key={subscription-key} + * ``` + * + * Here's a typical sequence of asynchronous operations: + * 1. Client sends a Route Matrix GET request to Azure Maps + * + * 2. The server will respond with one of the following: + * + * > HTTP `202 Accepted` - Route Matrix request has been accepted. + * + * > HTTP `Error` - There was an error processing your Route Matrix request. This could either be a 400 Bad Request or any other Error status code. + * + * + * 3. If the Matrix Route request was accepted successfully, the Location header in the response contains the URL to download the results of the request. This status URI looks like the following: * * ``` * GET https://atlas.microsoft.com/route/matrix/{matrixId}?api-version=1.0?subscription-key={subscription-key} @@ -182,7 +227,7 @@ export interface RouteRequestRouteMatrix202Response extends HttpResponse { * 4. Client issues a GET request on the download URL obtained in Step 3 to download the results * * ### Download Sync Results - * When you make a POST request for Route Matrix Sync API, the service returns 200 response code for successful request and a response array. The response body will contain the data and there will be no possibility to retrieve the results later. + * When you make a GET request for Route Matrix Sync API, the service returns 200 response code for successful request and a response array. The response body will contain the data and there will be no possibility to retrieve the results later. * * ### Download Async Results * When a request issues a `202 Accepted` response, the request is being processed using our async pipeline. You will be given a URL to check the progress of your async request in the location header of the response. This status URI looks like the following: @@ -202,14 +247,58 @@ export interface RouteGetRouteMatrix200Response extends HttpResponse { } export interface RouteGetRouteMatrix202Headers { - /** New URL to check for the results of the long running process. */ + /** New URL to check for the results of the long-running operation. */ location?: string; } /** - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). * - * If the Matrix Route request was accepted successfully, the Location header in the response contains the URL to download the results of the request. This status URI looks like the following: + * The `Get Route Matrix` API is an HTTP `GET` request that computes the travel time and distance for all possible pairs in a list of origins and destinations. Unlike the [Get Route Directions](/rest/api/maps/route/get-route-directions) API, which provide detailed route instructions, this API focuses on efficiency by giving you the cost (travel time and distance) of routing from each origin to every destination. For more information, see [Best practices for Azure Maps Route service](/azure/azure-maps/how-to-use-best-practices-for-routing). + * + * For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. + * + * + * For each route, the travel times and distances are returned. You can use the computed costs to determine which detailed routes to calculate using the Route Directions API. + * + * + * The maximum size of a matrix for async request is **700** and for sync request it's **100** (the number of origins multiplied by the number of destinations). + * + * + * + * ### Submit Synchronous Route Matrix Request + * If your scenario requires synchronous requests and the maximum size of the matrix is less than or equal to 100, you might want to make synchronous request. The maximum size of a matrix for this API is **100** (the number of origins multiplied by the number of destinations). With that constraint in mind, examples of possible matrix dimensions are: 10x10, 6x8, 9x8 (it does not need to be square). + * + * ``` + * GET https://atlas.microsoft.com/route/matrix/sync/json?api-version=1.0&subscription-key={subscription-key} + * ``` + * + * ### Submit Asynchronous Route Matrix Request + * The Asynchronous API is appropriate for processing big volumes of relatively complex routing requests. When you make a request by using async request, by default the service returns a 202 response code along a redirect URL in the Location field of the response header. This URL should be checked periodically until the response data or error information is available. If `waitForResults` parameter in the request is set to true, user will get a 200 response if the request is finished under 120 seconds. + * + * + * The maximum size of a matrix for this API is **700** (the number of origins multiplied by the number of destinations). With that constraint in mind, examples of possible matrix dimensions are: 50x10, 10x10, 28x25. 10x70 (it does not need to be square). + * + * + * The asynchronous responses are stored for **24** hours. The redirect URL returns a 404 response if used after the expiration period. + * + * + * + * + * ``` + * GET https://atlas.microsoft.com/route/matrix/json?api-version=1.0&subscription-key={subscription-key} + * ``` + * + * Here's a typical sequence of asynchronous operations: + * 1. Client sends a Route Matrix GET request to Azure Maps + * + * 2. The server will respond with one of the following: + * + * > HTTP `202 Accepted` - Route Matrix request has been accepted. + * + * > HTTP `Error` - There was an error processing your Route Matrix request. This could either be a 400 Bad Request or any other Error status code. + * + * + * 3. If the Matrix Route request was accepted successfully, the Location header in the response contains the URL to download the results of the request. This status URI looks like the following: * * ``` * GET https://atlas.microsoft.com/route/matrix/{matrixId}?api-version=1.0?subscription-key={subscription-key} @@ -219,7 +308,7 @@ export interface RouteGetRouteMatrix202Headers { * 4. Client issues a GET request on the download URL obtained in Step 3 to download the results * * ### Download Sync Results - * When you make a POST request for Route Matrix Sync API, the service returns 200 response code for successful request and a response array. The response body will contain the data and there will be no possibility to retrieve the results later. + * When you make a GET request for Route Matrix Sync API, the service returns 200 response code for successful request and a response array. The response body will contain the data and there will be no possibility to retrieve the results later. * * ### Download Async Results * When a request issues a `202 Accepted` response, the request is being processed using our async pipeline. You will be given a URL to check the progress of your async request in the location header of the response. This status URI looks like the following: @@ -235,15 +324,12 @@ export interface RouteGetRouteMatrix202Headers { */ export interface RouteGetRouteMatrix202Response extends HttpResponse { status: "202"; - body: Record; headers: RawHttpHeaders & RouteGetRouteMatrix202Headers; } /** * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * - * The Matrix Routing service allows calculation of a matrix of route summaries for a set of routes defined by origin and destination locations by using an asynchronous (async) or synchronous (sync) POST request. For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. + * The `Post Route Matrix Sync` API is an HTTP `POST` request that allows calculation of a matrix of route summaries for a set of routes defined by origin and destination locations by using a single synchronous (sync) request. To make an asynchronous (async) request, see [Post Route Matrix](/rest/api/maps/route/post-route-matrix). For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. * * * For each route, the travel times and distances are returned. You can use the computed costs to determine which detailed routes to calculate using the Route Directions API. @@ -267,7 +353,7 @@ export interface RouteGetRouteMatrix202Response extends HttpResponse { * The maximum size of a matrix for this API is **700** (the number of origins multiplied by the number of destinations). With that constraint in mind, examples of possible matrix dimensions are: 50x10, 10x10, 28x25. 10x70 (it does not need to be square). * * - * The asynchronous responses are stored for **14** days. The redirect URL returns a 404 response if used after the expiration period. + * The asynchronous responses are stored for **24** hours. The redirect URL returns a 404 response if used after the expiration period. * * * @@ -317,9 +403,7 @@ export interface RouteRequestRouteMatrixSync200Response extends HttpResponse { /** * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * - * The Matrix Routing service allows calculation of a matrix of route summaries for a set of routes defined by origin and destination locations by using an asynchronous (async) or synchronous (sync) POST request. For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. + * The `Post Route Matrix Sync` API is an HTTP `POST` request that allows calculation of a matrix of route summaries for a set of routes defined by origin and destination locations by using a single synchronous (sync) request. To make an asynchronous (async) request, see [Post Route Matrix](/rest/api/maps/route/post-route-matrix). For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. * * * For each route, the travel times and distances are returned. You can use the computed costs to determine which detailed routes to calculate using the Route Directions API. @@ -343,7 +427,7 @@ export interface RouteRequestRouteMatrixSync200Response extends HttpResponse { * The maximum size of a matrix for this API is **700** (the number of origins multiplied by the number of destinations). With that constraint in mind, examples of possible matrix dimensions are: 50x10, 10x10, 28x25. 10x70 (it does not need to be square). * * - * The asynchronous responses are stored for **14** days. The redirect URL returns a 404 response if used after the expiration period. + * The asynchronous responses are stored for **24** hours. The redirect URL returns a 404 response if used after the expiration period. * * * @@ -393,9 +477,7 @@ export interface RouteRequestRouteMatrixSync408Response extends HttpResponse { /** * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * - * The Matrix Routing service allows calculation of a matrix of route summaries for a set of routes defined by origin and destination locations by using an asynchronous (async) or synchronous (sync) POST request. For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. + * The `Post Route Matrix Sync` API is an HTTP `POST` request that allows calculation of a matrix of route summaries for a set of routes defined by origin and destination locations by using a single synchronous (sync) request. To make an asynchronous (async) request, see [Post Route Matrix](/rest/api/maps/route/post-route-matrix). For every given origin, the service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. As an example, let's say a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call Matrix Route API. * * * For each route, the travel times and distances are returned. You can use the computed costs to determine which detailed routes to calculate using the Route Directions API. @@ -419,7 +501,7 @@ export interface RouteRequestRouteMatrixSync408Response extends HttpResponse { * The maximum size of a matrix for this API is **700** (the number of origins multiplied by the number of destinations). With that constraint in mind, examples of possible matrix dimensions are: 50x10, 10x10, 28x25. 10x70 (it does not need to be square). * * - * The asynchronous responses are stored for **14** days. The redirect URL returns a 404 response if used after the expiration period. + * The asynchronous responses are stored for **24** hours. The redirect URL returns a 404 response if used after the expiration period. * * * @@ -469,14 +551,12 @@ export interface RouteRequestRouteMatrixSyncDefaultResponse } /** - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * * - * Returns a route between an origin and a destination, passing through waypoints if they are specified. The route will take into account factors such as current traffic and the typical road speeds on the requested day of the week and time of day. + * The `Get Route Directions` API is an HTTP `GET` request that returns a route between an origin and a destination, passing through waypoints if specified. The route takes into account factors such as current traffic and the typical road speeds on the requested day of the week and time of day. * * Information returned includes the distance, estimated travel time, and a representation of the route geometry. Additional routing information such as optimized waypoint order or turn by turn instructions is also available, depending on the options selected. * - * Routing service provides a set of parameters for a detailed description of vehicle-specific Consumption Model. Please check [Consumption Model](https://docs.microsoft.com/azure/azure-maps/consumption-model) for detailed explanation of the concepts and parameters involved. + * Routing service provides a set of parameters for a detailed description of a vehicle-specific consumption model. For more information, see [Consumption Model](/azure/azure-maps/consumption-model). */ export interface RouteGetRouteDirections200Response extends HttpResponse { status: "200"; @@ -484,14 +564,12 @@ export interface RouteGetRouteDirections200Response extends HttpResponse { } /** - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). * - * - * Returns a route between an origin and a destination, passing through waypoints if they are specified. The route will take into account factors such as current traffic and the typical road speeds on the requested day of the week and time of day. + * The `Get Route Directions` API is an HTTP `GET` request that returns a route between an origin and a destination, passing through waypoints if specified. The route takes into account factors such as current traffic and the typical road speeds on the requested day of the week and time of day. * * Information returned includes the distance, estimated travel time, and a representation of the route geometry. Additional routing information such as optimized waypoint order or turn by turn instructions is also available, depending on the options selected. * - * Routing service provides a set of parameters for a detailed description of vehicle-specific Consumption Model. Please check [Consumption Model](https://docs.microsoft.com/azure/azure-maps/consumption-model) for detailed explanation of the concepts and parameters involved. + * Routing service provides a set of parameters for a detailed description of a vehicle-specific consumption model. For more information, see [Consumption Model](/azure/azure-maps/consumption-model). */ export interface RouteGetRouteDirectionsDefaultResponse extends HttpResponse { status: string; @@ -499,10 +577,8 @@ export interface RouteGetRouteDirectionsDefaultResponse extends HttpResponse { } /** - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * * - * Returns a route between an origin and a destination, passing through waypoints if they are specified. The route will take into account factors such as current traffic and the typical road speeds on the requested day of the week and time of day. + * The `Post Route Directions` API is an HTTP `POST` request that returns a route between an origin and a destination, passing through waypoints if they are specified. The route will take into account factors such as current traffic and the typical road speeds on the requested day of the week and time of day. * * Information returned includes the distance, estimated travel time, and a representation of the route geometry. Additional routing information such as optimized waypoint order or turn by turn instructions is also available, depending on the options selected. * @@ -515,10 +591,8 @@ export interface RouteGetRouteDirectionsWithAdditionalParameters200Response } /** - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). * - * - * Returns a route between an origin and a destination, passing through waypoints if they are specified. The route will take into account factors such as current traffic and the typical road speeds on the requested day of the week and time of day. + * The `Post Route Directions` API is an HTTP `POST` request that returns a route between an origin and a destination, passing through waypoints if they are specified. The route will take into account factors such as current traffic and the typical road speeds on the requested day of the week and time of day. * * Information returned includes the distance, estimated travel time, and a representation of the route geometry. Additional routing information such as optimized waypoint order or turn by turn instructions is also available, depending on the options selected. * @@ -531,14 +605,10 @@ export interface RouteGetRouteDirectionsWithAdditionalParametersDefaultResponse } /** - * __Route Range (Isochrone) API__ - * * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * The `Get Route Range` (Isochrone) API is an HTTP `GET` request that will calculate a set of locations that can be reached from the origin point based on fuel, energy, time or distance budget that is specified. A polygon boundary (or Isochrone) is returned in a counterclockwise orientation as well as the precise polygon center which was the result of the origin point. * - * This service will calculate a set of locations that can be reached from the origin point based on fuel, energy, time or distance budget that is specified. A polygon boundary (or Isochrone) is returned in a counterclockwise orientation as well as the precise polygon center which was the result of the origin point. - * - * The returned polygon can be used for further processing such as [Search Inside Geometry](https://docs.microsoft.com/rest/api/maps/search/postsearchinsidegeometry) to search for POIs within the provided Isochrone. + * The returned polygon can be used for further processing such as [Search Inside Geometry](/rest/api/maps/search/post-search-inside-geometry) to search for POIs within the provided isochrone. */ export interface RouteGetRouteRange200Response extends HttpResponse { status: "200"; @@ -546,14 +616,10 @@ export interface RouteGetRouteRange200Response extends HttpResponse { } /** - * __Route Range (Isochrone) API__ - * * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * The `Get Route Range` (Isochrone) API is an HTTP `GET` request that will calculate a set of locations that can be reached from the origin point based on fuel, energy, time or distance budget that is specified. A polygon boundary (or Isochrone) is returned in a counterclockwise orientation as well as the precise polygon center which was the result of the origin point. * - * This service will calculate a set of locations that can be reached from the origin point based on fuel, energy, time or distance budget that is specified. A polygon boundary (or Isochrone) is returned in a counterclockwise orientation as well as the precise polygon center which was the result of the origin point. - * - * The returned polygon can be used for further processing such as [Search Inside Geometry](https://docs.microsoft.com/rest/api/maps/search/postsearchinsidegeometry) to search for POIs within the provided Isochrone. + * The returned polygon can be used for further processing such as [Search Inside Geometry](/rest/api/maps/search/post-search-inside-geometry) to search for POIs within the provided isochrone. */ export interface RouteGetRouteRangeDefaultResponse extends HttpResponse { status: string; @@ -561,14 +627,9 @@ export interface RouteGetRouteRangeDefaultResponse extends HttpResponse { } /** - * **Route Directions Batch API** - * - * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * * + * The `Post Route Directions Batch` API is an HTTP `POST` request that sends batches of queries to the [Get Route Directions](/rest/api/maps/route/get-route-directions) API using a single asynchronous request. You can call `Route Directions Batch` API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. To call the `Post Route Directions Batch` API in a synchronous request, see [Post Route Directions Batch Sync](/rest/api/maps/route/post-route-directions-batch-sync). * - * The Route Directions Batch API sends batches of queries to [Route Directions API](https://docs.microsoft.com/rest/api/maps/route/getroutedirections) using just a single API call. You can call Route Directions Batch API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. * ### Submit Asynchronous Batch Request * The Asynchronous API is appropriate for processing big volumes of relatively complex route requests * - It allows the retrieval of results in a separate call (multiple downloads are possible). @@ -576,10 +637,13 @@ export interface RouteGetRouteRangeDefaultResponse extends HttpResponse { * - The number of batch items is limited to **700** for this API. * * When you make a request by using async request, by default the service returns a 202 response code along a redirect URL in the Location field of the response header. This URL should be checked periodically until the response data or error information is available. - * The asynchronous responses are stored for **14** days. The redirect URL returns a 404 response if used after the expiration period. + * The asynchronous responses are stored for **24** hours. The redirect URL returns a 404 response if used after the expiration period. * - * Please note that asynchronous batch request is a long-running request. Here's a typical sequence of operations: - * 1. Client sends a Route Directions Batch `POST` request to Azure Maps + * Please note that asynchronous batch request is a long-running operation. Here's a typical sequence of operations: + * 1. Client sends a Route Directions Batch `POST` request to Azure Maps. + * ``` + * POST https://atlas.microsoft.com/route/directions/batch/json?api-version=1.0&subscription-key={subscription-key} + * ``` * 2. The server will respond with one of the following: * * > HTTP `202 Accepted` - Batch request has been accepted. @@ -588,9 +652,9 @@ export interface RouteGetRouteRangeDefaultResponse extends HttpResponse { * * 3. If the batch request was accepted successfully, the `Location` header in the response contains the URL to download the results of the batch request. * This status URI looks like following: - * - * ``` GET https://atlas.microsoft.com/route/directions/batch/{batch-id}?api-version=1.0 ``` - * Note:- Please remember to add AUTH information (subscription-key/azure_auth - See [Security](#security)) to the _status URI_ before running it.
+ * ``` + * GET https://atlas.microsoft.com/route/directions/batch/{batch-id}?api-version=1.0&subscription-key={subscription-key} + * ``` * 4. Client issues a `GET` request on the _download URL_ obtained in Step 3 to download the batch results. * * ### POST Body for Batch Request @@ -718,19 +782,14 @@ export interface RouteRequestRouteDirectionsBatch200Response } export interface RouteRequestRouteDirectionsBatch202Headers { - /** New URL to check for the results of the long running process. */ + /** New URL to check for the results of the long-running operation. */ location?: string; } /** - * **Route Directions Batch API** - * - * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * * + * The `Post Route Directions Batch` API is an HTTP `POST` request that sends batches of queries to the [Get Route Directions](/rest/api/maps/route/get-route-directions) API using a single asynchronous request. You can call `Route Directions Batch` API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. To call the `Post Route Directions Batch` API in a synchronous request, see [Post Route Directions Batch Sync](/rest/api/maps/route/post-route-directions-batch-sync). * - * The Route Directions Batch API sends batches of queries to [Route Directions API](https://docs.microsoft.com/rest/api/maps/route/getroutedirections) using just a single API call. You can call Route Directions Batch API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. * ### Submit Asynchronous Batch Request * The Asynchronous API is appropriate for processing big volumes of relatively complex route requests * - It allows the retrieval of results in a separate call (multiple downloads are possible). @@ -738,10 +797,13 @@ export interface RouteRequestRouteDirectionsBatch202Headers { * - The number of batch items is limited to **700** for this API. * * When you make a request by using async request, by default the service returns a 202 response code along a redirect URL in the Location field of the response header. This URL should be checked periodically until the response data or error information is available. - * The asynchronous responses are stored for **14** days. The redirect URL returns a 404 response if used after the expiration period. + * The asynchronous responses are stored for **24** hours. The redirect URL returns a 404 response if used after the expiration period. * - * Please note that asynchronous batch request is a long-running request. Here's a typical sequence of operations: - * 1. Client sends a Route Directions Batch `POST` request to Azure Maps + * Please note that asynchronous batch request is a long-running operation. Here's a typical sequence of operations: + * 1. Client sends a Route Directions Batch `POST` request to Azure Maps. + * ``` + * POST https://atlas.microsoft.com/route/directions/batch/json?api-version=1.0&subscription-key={subscription-key} + * ``` * 2. The server will respond with one of the following: * * > HTTP `202 Accepted` - Batch request has been accepted. @@ -750,9 +812,9 @@ export interface RouteRequestRouteDirectionsBatch202Headers { * * 3. If the batch request was accepted successfully, the `Location` header in the response contains the URL to download the results of the batch request. * This status URI looks like following: - * - * ``` GET https://atlas.microsoft.com/route/directions/batch/{batch-id}?api-version=1.0 ``` - * Note:- Please remember to add AUTH information (subscription-key/azure_auth - See [Security](#security)) to the _status URI_ before running it.
+ * ``` + * GET https://atlas.microsoft.com/route/directions/batch/{batch-id}?api-version=1.0&subscription-key={subscription-key} + * ``` * 4. Client issues a `GET` request on the _download URL_ obtained in Step 3 to download the batch results. * * ### POST Body for Batch Request @@ -876,12 +938,12 @@ export interface RouteRequestRouteDirectionsBatch202Headers { export interface RouteRequestRouteDirectionsBatch202Response extends HttpResponse { status: "202"; - body: Record; headers: RawHttpHeaders & RouteRequestRouteDirectionsBatch202Headers; } /** - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + * The `Get Route Directions Batch` API is an HTTP `GET` request that sends batches of queries to the [Get Route Directions](/rest/api/maps/route/get-route-directions) API using a single request. You can call `Get Route Directions Batch` API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. * * ### Download Asynchronous Batch Results * To download the async batch results you will issue a `GET` request to the batch download endpoint. This _download URL_ can be obtained from the `Location` header of a successful `POST` batch request and looks like the following: @@ -987,12 +1049,13 @@ export interface RouteGetRouteDirectionsBatch200Response extends HttpResponse { } export interface RouteGetRouteDirectionsBatch202Headers { - /** New URL to check for the results of the long running process. */ + /** New URL to check for the results of the long-running operation. */ location?: string; } /** - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). + * + * The `Get Route Directions Batch` API is an HTTP `GET` request that sends batches of queries to the [Get Route Directions](/rest/api/maps/route/get-route-directions) API using a single request. You can call `Get Route Directions Batch` API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. * * ### Download Asynchronous Batch Results * To download the async batch results you will issue a `GET` request to the batch download endpoint. This _download URL_ can be obtained from the `Location` header of a successful `POST` batch request and looks like the following: @@ -1094,19 +1157,12 @@ export interface RouteGetRouteDirectionsBatch202Headers { */ export interface RouteGetRouteDirectionsBatch202Response extends HttpResponse { status: "202"; - body: Record; headers: RawHttpHeaders & RouteGetRouteDirectionsBatch202Headers; } /** - * **Route Directions Batch API** - * * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * - * - * - * The Route Directions Batch API sends batches of queries to [Route Directions API](https://docs.microsoft.com/rest/api/maps/route/getroutedirections) using just a single API call. You can call Route Directions Batch API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. + * The `Post Route Directions Batch Sync` API is an HTTP `POST` request that sends batches of queries to the [Get Route Directions](/rest/api/maps/route/get-route-directions) API using a single synchronous request. You can call `Route Directions Batch` API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. To call the `Post Route Directions Batch` API in a asynchronous request, see [Post Route Directions Batch](/rest/api/maps/route/post-route-directions-batch). * ### Submit Synchronous Batch Request * The Synchronous API is recommended for lightweight batch requests. When the service receives a request, it will respond as soon as the batch items are calculated and there will be no possibility to retrieve the results later. The Synchronous API will return a timeout error (a 408 response) if the request takes longer than 60 seconds. The number of batch items is limited to **100** for this API. * ``` @@ -1201,14 +1257,8 @@ export interface RouteRequestRouteDirectionsBatchSync200Response } /** - * **Route Directions Batch API** - * * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * - * - * - * The Route Directions Batch API sends batches of queries to [Route Directions API](https://docs.microsoft.com/rest/api/maps/route/getroutedirections) using just a single API call. You can call Route Directions Batch API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. + * The `Post Route Directions Batch Sync` API is an HTTP `POST` request that sends batches of queries to the [Get Route Directions](/rest/api/maps/route/get-route-directions) API using a single synchronous request. You can call `Route Directions Batch` API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. To call the `Post Route Directions Batch` API in a asynchronous request, see [Post Route Directions Batch](/rest/api/maps/route/post-route-directions-batch). * ### Submit Synchronous Batch Request * The Synchronous API is recommended for lightweight batch requests. When the service receives a request, it will respond as soon as the batch items are calculated and there will be no possibility to retrieve the results later. The Synchronous API will return a timeout error (a 408 response) if the request takes longer than 60 seconds. The number of batch items is limited to **100** for this API. * ``` @@ -1303,14 +1353,8 @@ export interface RouteRequestRouteDirectionsBatchSync408Response } /** - * **Route Directions Batch API** - * - * - * **Applies to**: see pricing [tiers](https://aka.ms/AzureMapsPricingTier). - * - * * - * The Route Directions Batch API sends batches of queries to [Route Directions API](https://docs.microsoft.com/rest/api/maps/route/getroutedirections) using just a single API call. You can call Route Directions Batch API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. + * The `Post Route Directions Batch Sync` API is an HTTP `POST` request that sends batches of queries to the [Get Route Directions](/rest/api/maps/route/get-route-directions) API using a single synchronous request. You can call `Route Directions Batch` API to run either asynchronously (async) or synchronously (sync). The async API allows caller to batch up to **700** queries and sync API up to **100** queries. To call the `Post Route Directions Batch` API in a asynchronous request, see [Post Route Directions Batch](/rest/api/maps/route/post-route-directions-batch). * ### Submit Synchronous Batch Request * The Synchronous API is recommended for lightweight batch requests. When the service receives a request, it will respond as soon as the batch items are calculated and there will be no possibility to retrieve the results later. The Synchronous API will return a timeout error (a 408 response) if the request takes longer than 60 seconds. The number of batch items is limited to **100** for this API. * ``` diff --git a/sdk/maps/maps-route-rest/generated/serializeHelper.ts b/sdk/maps/maps-route-rest/generated/serializeHelper.ts new file mode 100644 index 000000000000..a19f11ca222a --- /dev/null +++ b/sdk/maps/maps-route-rest/generated/serializeHelper.ts @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export function buildMultiCollection( + items: string[], + parameterName: string, +): string { + return items + .map((item, index) => { + if (index === 0) { + return item; + } + return `${parameterName}=${item}`; + }) + .join("&"); +} diff --git a/sdk/maps/maps-route-rest/package.json b/sdk/maps/maps-route-rest/package.json index fd669c6d8c68..627d43e0205b 100644 --- a/sdk/maps/maps-route-rest/package.json +++ b/sdk/maps/maps-route-rest/package.json @@ -86,11 +86,12 @@ "dependencies": { "@azure-rest/core-client": "^1.0.0", "@azure/core-auth": "^1.3.0", - "@azure/core-lro": "^2.2.0", + "@azure/core-lro": "^3.1.0", "@azure/core-rest-pipeline": "^1.8.0", "@azure/logger": "^1.0.0", "@azure/maps-common": "1.0.0-beta.2", - "tslib": "^2.4.0" + "tslib": "^2.4.0", + "@azure/abort-controller": "^2.1.2" }, "devDependencies": { "@azure-tools/test-credential": "^1.0.0", diff --git a/sdk/maps/maps-route-rest/review/maps-route.api.md b/sdk/maps/maps-route-rest/review/maps-route.api.md index 49783e02fc99..7d6f27f25bc5 100644 --- a/sdk/maps/maps-route-rest/review/maps-route.api.md +++ b/sdk/maps/maps-route-rest/review/maps-route.api.md @@ -4,15 +4,16 @@ ```ts +import { AbortSignalLike } from '@azure/abort-controller'; import type { AzureKeyCredential } from '@azure/core-auth'; import type { AzureSASCredential } from '@azure/core-auth'; +import { CancelOnProgress } from '@azure/core-lro'; import { Client } from '@azure-rest/core-client'; -import type { ClientOptions } from '@azure-rest/core-client'; +import { ClientOptions } from '@azure-rest/core-client'; +import { CreateHttpPollerOptions } from '@azure/core-lro'; import { HttpResponse } from '@azure-rest/core-client'; import type { LatLon } from '@azure/maps-common'; -import { LroEngineOptions } from '@azure/core-lro'; -import { PollerLike } from '@azure/core-lro'; -import { PollOperationState } from '@azure/core-lro'; +import { OperationState } from '@azure/core-lro'; import { RawHttpHeaders } from '@azure/core-rest-pipeline'; import { RequestParameters } from '@azure-rest/core-client'; import { StreamableMethod } from '@azure-rest/core-client'; @@ -30,33 +31,36 @@ export interface BatchRequestItem { // @public export interface BatchResultItemOutput { - statusCode: number; + readonly statusCode: number; } // @public export interface BatchResultOutput { - summary: BatchResultSummaryOutput; + readonly summary: BatchResultSummaryOutput; } // @public export interface BatchResultSummaryOutput { - successfulRequests: number; - totalRequests: number; + readonly successfulRequests: number; + readonly totalRequests: number; } +// @public (undocumented) +export function buildMultiCollection(items: string[], parameterName: string): string; + // @public export function createRouteDirectionsBatchRequest(queryParamProperties: RouteGetRouteDirectionsQueryParamProperties[]): BatchRequest; // @public export interface EffectiveSettingOutput { - key: string; - value: string; + readonly key: string; + readonly value: string; } // @public export interface ErrorDetailOutput { - code?: string; - message?: string; + readonly code?: string; + readonly message?: string; } // @public @@ -185,7 +189,7 @@ export interface GeoJsonPolygonData { } // @public -export function getLongRunningPoller(client: Client, initialResponse: TResult, options?: LroEngineOptions>): PollerLike, TResult>; +export function getLongRunningPoller(client: Client, initialResponse: TResult, options?: CreateHttpPollerOptions>): Promise, TResult>>; // @public (undocumented) export interface GetRouteDirections { @@ -234,6 +238,11 @@ export type MapsRouteClient = Client & { path: Routes; }; +// @public +export interface MapsRouteClientOptions extends ClientOptions { + apiVersion?: string; +} + // @public (undocumented) export interface RequestRouteDirectionsBatch { get(options?: RouteGetRouteDirectionsBatchParameters): StreamableMethod; @@ -266,7 +275,7 @@ export interface RouteDirectionParameters { // @public export interface RouteDirectionsBatchItemOutput extends BatchResultItemOutput { - response: RouteDirectionsBatchItemResponseOutput; + readonly response: RouteDirectionsBatchItemResponseOutput; } // @public @@ -275,15 +284,15 @@ export interface RouteDirectionsBatchItemResponseOutput extends RouteDirectionsO // @public export interface RouteDirectionsBatchResultOutput extends BatchResultOutput { - batchItems: Array; + readonly batchItems: Array; } // @public export interface RouteDirectionsOutput { - formatVersion?: string; - optimizedWaypoints?: Array; + readonly formatVersion?: string; + readonly optimizedWaypoints?: Array; report?: RouteReportOutput; - routes: Array; + readonly routes: Array; } // @public @@ -309,8 +318,6 @@ export interface RouteGetRouteDirectionsBatch202Headers { // @public export interface RouteGetRouteDirectionsBatch202Response extends HttpResponse { - // (undocumented) - body: Record; // (undocumented) headers: RawHttpHeaders & RouteGetRouteDirectionsBatch202Headers; // (undocumented) @@ -366,7 +373,7 @@ export interface RouteGetRouteDirectionsQueryParamProperties { report?: "effectiveSettings"; routeRepresentation?: "polyline" | "summaryOnly" | "none"; routeType?: "fastest" | "shortest" | "eco" | "thrilling"; - sectionType?: "carTrain" | "country" | "ferry" | "motorway" | "pedestrian" | "tollRoad" | "tollVignette" | "traffic" | "travelMode" | "tunnel" | "carpool" | "urban"; + sectionType?: Array<"carTrain" | "country" | "ferry" | "motorway" | "pedestrian" | "tollRoad" | "tollVignette" | "traffic" | "travelMode" | "tunnel" | "carpool" | "urban">; traffic?: boolean; travelMode?: "car" | "truck" | "taxi" | "bus" | "van" | "motorcycle" | "bicycle" | "pedestrian"; uphillEfficiency?: number; @@ -447,7 +454,7 @@ export interface RouteGetRouteDirectionsWithAdditionalParametersQueryParamProper report?: "effectiveSettings"; routeRepresentation?: "polyline" | "summaryOnly" | "none"; routeType?: "fastest" | "shortest" | "eco" | "thrilling"; - sectionType?: "carTrain" | "country" | "ferry" | "motorway" | "pedestrian" | "tollRoad" | "tollVignette" | "traffic" | "travelMode" | "tunnel" | "carpool" | "urban"; + sectionType?: Array<"carTrain" | "country" | "ferry" | "motorway" | "pedestrian" | "tollRoad" | "tollVignette" | "traffic" | "travelMode" | "tunnel" | "carpool" | "urban">; traffic?: boolean; travelMode?: "car" | "truck" | "taxi" | "bus" | "van" | "motorcycle" | "bicycle" | "pedestrian"; uphillEfficiency?: number; @@ -479,8 +486,6 @@ export interface RouteGetRouteMatrix202Headers { // @public export interface RouteGetRouteMatrix202Response extends HttpResponse { - // (undocumented) - body: Record; // (undocumented) headers: RawHttpHeaders & RouteGetRouteMatrix202Headers; // (undocumented) @@ -554,51 +559,51 @@ export interface RouteGetRouteRangeQueryParamProperties { // @public export interface RouteGuidanceOutput { - instructionGroups: Array; - instructions: Array; + readonly instructionGroups: Array; + readonly instructions: Array; } // @public export interface RouteInstructionGroupOutput { - firstInstructionIndex?: number; - groupLengthInMeters?: number; - groupMessage?: string; - lastInstructionIndex?: number; + readonly firstInstructionIndex?: number; + readonly groupLengthInMeters?: number; + readonly groupMessage?: string; + readonly lastInstructionIndex?: number; } // @public export interface RouteInstructionOutput { - combinedMessage?: string; - countryCode?: string; - drivingSide?: "LEFT" | "RIGHT"; - exitNumber?: string; + readonly combinedMessage?: string; + readonly countryCode?: string; + readonly drivingSide?: "LEFT" | "RIGHT"; + readonly exitNumber?: string; instructionType?: "TURN" | "ROAD_CHANGE" | "LOCATION_DEPARTURE" | "LOCATION_ARRIVAL" | "DIRECTION_INFO" | "LOCATION_WAYPOINT"; - junctionType?: "REGULAR" | "ROUNDABOUT" | "BIFURCATION"; - maneuver?: "ARRIVE" | "ARRIVE_LEFT" | "ARRIVE_RIGHT" | "DEPART" | "STRAIGHT" | "KEEP_RIGHT" | "BEAR_RIGHT" | "TURN_RIGHT" | "SHARP_RIGHT" | "KEEP_LEFT" | "BEAR_LEFT" | "TURN_LEFT" | "SHARP_LEFT" | "MAKE_UTURN" | "ENTER_MOTORWAY" | "ENTER_FREEWAY" | "ENTER_HIGHWAY" | "TAKE_EXIT" | "MOTORWAY_EXIT_LEFT" | "MOTORWAY_EXIT_RIGHT" | "TAKE_FERRY" | "ROUNDABOUT_CROSS" | "ROUNDABOUT_RIGHT" | "ROUNDABOUT_LEFT" | "ROUNDABOUT_BACK" | "TRY_MAKE_UTURN" | "FOLLOW" | "SWITCH_PARALLEL_ROAD" | "SWITCH_MAIN_ROAD" | "ENTRANCE_RAMP" | "WAYPOINT_LEFT" | "WAYPOINT_RIGHT" | "WAYPOINT_REACHED"; - message?: string; + readonly junctionType?: "REGULAR" | "ROUNDABOUT" | "BIFURCATION"; + readonly maneuver?: "ARRIVE" | "ARRIVE_LEFT" | "ARRIVE_RIGHT" | "DEPART" | "STRAIGHT" | "KEEP_RIGHT" | "BEAR_RIGHT" | "TURN_RIGHT" | "SHARP_RIGHT" | "KEEP_LEFT" | "BEAR_LEFT" | "TURN_LEFT" | "SHARP_LEFT" | "MAKE_UTURN" | "ENTER_MOTORWAY" | "ENTER_FREEWAY" | "ENTER_HIGHWAY" | "TAKE_EXIT" | "MOTORWAY_EXIT_LEFT" | "MOTORWAY_EXIT_RIGHT" | "TAKE_FERRY" | "ROUNDABOUT_CROSS" | "ROUNDABOUT_RIGHT" | "ROUNDABOUT_LEFT" | "ROUNDABOUT_BACK" | "TRY_MAKE_UTURN" | "FOLLOW" | "SWITCH_PARALLEL_ROAD" | "SWITCH_MAIN_ROAD" | "ENTRANCE_RAMP" | "WAYPOINT_LEFT" | "WAYPOINT_RIGHT" | "WAYPOINT_REACHED"; + readonly message?: string; point?: LatLongPairOutput; - pointIndex?: number; - possibleCombineWithNext?: boolean; - roadNumbers?: Array; - roundaboutExitNumber?: string; - routeOffsetInMeters?: number; - signpostText?: string; - stateCode?: string; - street?: string; - travelTimeInSeconds?: number; - turnAngleInDecimalDegrees?: number; + readonly pointIndex?: number; + readonly possibleCombineWithNext?: boolean; + readonly roadNumbers?: Array; + readonly roundaboutExitNumber?: number; + readonly routeOffsetInMeters?: number; + readonly signpostText?: string; + readonly stateCode?: string; + readonly street?: string; + readonly travelTimeInSeconds?: number; + readonly turnAngleInDecimalDegrees?: number; } // @public export interface RouteLegOutput { - points: Array; - summary: RouteSummaryOutput; + readonly points: Array; + readonly summary: RouteSummaryOutput; } // @public export interface RouteMatrixOutput { - response?: RouteMatrixResultResponseOutput; - statusCode: number; + readonly response?: RouteMatrixResultResponseOutput; + readonly statusCode: number; } // @public @@ -609,52 +614,52 @@ export interface RouteMatrixQuery { // @public export interface RouteMatrixResultOutput { - formatVersion?: string; - matrix: Array>; - summary: RouteMatrixSummaryOutput; + readonly formatVersion?: string; + readonly matrix: Array>; + readonly summary: RouteMatrixSummaryOutput; } // @public export interface RouteMatrixResultResponseOutput { - routeSummary?: RouteSummaryOutput; + readonly routeSummary?: RouteSummaryOutput; } // @public export interface RouteMatrixSummaryOutput { - successfulRoutes: number; - totalRoutes: number; + readonly successfulRoutes: number; + readonly totalRoutes: number; } // @public export interface RouteOptimizedWaypointOutput { - optimizedIndex: number; - providedIndex: number; + readonly optimizedIndex: number; + readonly providedIndex: number; } // @public (undocumented) export interface RouteOutput { - guidance?: RouteGuidanceOutput; - legs: Array; - sections?: Array; - summary: RouteSummaryOutput; + readonly guidance?: RouteGuidanceOutput; + readonly legs: Array; + readonly sections?: Array; + readonly summary: RouteSummaryOutput; } // @public export interface RouteRangeOutput { - boundary: Array; + readonly boundary: Array; center: LatLongPairOutput; } // @public export interface RouteRangeResultOutput { - formatVersion?: string; + readonly formatVersion?: string; reachableRange: RouteRangeOutput; report?: RouteReportOutput; } // @public export interface RouteReportOutput { - effectiveSettings: Array; + readonly effectiveSettings: Array; } // @public @@ -672,8 +677,6 @@ export interface RouteRequestRouteDirectionsBatch202Headers { // @public export interface RouteRequestRouteDirectionsBatch202Response extends HttpResponse { - // (undocumented) - body: Record; // (undocumented) headers: RawHttpHeaders & RouteRequestRouteDirectionsBatch202Headers; // (undocumented) @@ -745,8 +748,6 @@ export interface RouteRequestRouteMatrix202Headers { // @public export interface RouteRequestRouteMatrix202Response extends HttpResponse { - // (undocumented) - body: Record; // (undocumented) headers: RawHttpHeaders & RouteRequestRouteMatrix202Headers; // (undocumented) @@ -780,7 +781,7 @@ export interface RouteRequestRouteMatrixQueryParamProperties { departAt?: Date | string; hilliness?: "low" | "normal" | "high"; routeType?: "fastest" | "shortest" | "eco" | "thrilling"; - sectionType?: "carTrain" | "country" | "ferry" | "motorway" | "pedestrian" | "tollRoad" | "tollVignette" | "traffic" | "travelMode" | "tunnel" | "carpool" | "urban"; + sectionType?: Array<"carTrain" | "country" | "ferry" | "motorway" | "pedestrian" | "tollRoad" | "tollVignette" | "traffic" | "travelMode" | "tunnel" | "carpool" | "urban">; traffic?: boolean; travelMode?: "car" | "truck" | "taxi" | "bus" | "van" | "motorcycle" | "bicycle" | "pedestrian"; vehicleAxleWeight?: number; @@ -845,7 +846,7 @@ export interface RouteRequestRouteMatrixSyncQueryParamProperties { departAt?: Date | string; hilliness?: "low" | "normal" | "high"; routeType?: "fastest" | "shortest" | "eco" | "thrilling"; - sectionType?: "carTrain" | "country" | "ferry" | "motorway" | "pedestrian" | "tollRoad" | "tollVignette" | "traffic" | "travelMode" | "tunnel" | "carpool" | "urban"; + sectionType?: Array<"carTrain" | "country" | "ferry" | "motorway" | "pedestrian" | "tollRoad" | "tollVignette" | "traffic" | "travelMode" | "tunnel" | "carpool" | "urban">; traffic?: boolean; travelMode?: "car" | "truck" | "taxi" | "bus" | "van" | "motorcycle" | "bicycle" | "pedestrian"; vehicleAxleWeight?: number; @@ -871,36 +872,58 @@ export interface Routes { // @public export interface RouteSectionOutput { - delayInSeconds?: number; - effectiveSpeedInKmh?: number; - endPointIndex: number; - magnitudeOfDelay?: "0" | "1" | "2" | "3" | "4"; - sectionType: "CAR_TRAIN" | "COUNTRY" | "FERRY" | "MOTORWAY" | "PEDESTRIAN" | "TOLL_ROAD" | "TOLL_VIGNETTE" | "TRAFFIC" | "TRAVEL_MODE" | "TUNNEL" | "CARPOOL" | "URBAN"; - simpleCategory?: "JAM" | "ROAD_WORK" | "ROAD_CLOSURE" | "OTHER"; - startPointIndex: number; + readonly delayInSeconds?: number; + readonly effectiveSpeedInKmh?: number; + readonly endPointIndex: number; + readonly magnitudeOfDelay?: "0" | "1" | "2" | "3" | "4"; + readonly sectionType: "CAR_TRAIN" | "COUNTRY" | "FERRY" | "MOTORWAY" | "PEDESTRIAN" | "TOLL_ROAD" | "TOLL_VIGNETTE" | "TRAFFIC" | "TRAVEL_MODE" | "TUNNEL" | "CARPOOL" | "URBAN"; + readonly simpleCategory?: "JAM" | "ROAD_WORK" | "ROAD_CLOSURE" | "OTHER"; + readonly startPointIndex: number; tec?: RouteSectionTecOutput; - travelMode?: "car" | "truck" | "taxi" | "bus" | "van" | "motorcycle" | "bicycle" | "pedestrian" | "other"; + readonly travelMode?: "car" | "truck" | "taxi" | "bus" | "van" | "motorcycle" | "bicycle" | "pedestrian" | "other"; } // @public export interface RouteSectionTecCauseOutput { - mainCauseCode?: number; - subCauseCode?: number; + readonly mainCauseCode?: number; + readonly subCauseCode?: number; } // @public export interface RouteSectionTecOutput { causes?: Array; - effectCode?: number; + readonly effectCode?: number; } // @public export interface RouteSummaryOutput { - arrivalTime: string; - departureTime: string; - lengthInMeters: number; - trafficDelayInSeconds: number; - travelTimeInSeconds: number; + readonly arrivalTime: string; + readonly departureTime: string; + readonly lengthInMeters: number; + readonly trafficDelayInSeconds: number; + readonly travelTimeInSeconds: number; +} + +// @public +export interface SimplePollerLike, TResult> { + getOperationState(): TState; + getResult(): TResult | undefined; + isDone(): boolean; + // @deprecated + isStopped(): boolean; + onProgress(callback: (state: TState) => void): CancelOnProgress; + poll(options?: { + abortSignal?: AbortSignalLike; + }): Promise; + pollUntilDone(pollOptions?: { + abortSignal?: AbortSignalLike; + }): Promise; + serialize(): Promise; + // @deprecated + stopPolling(): void; + submitted(): Promise; + // @deprecated + toString(): string; } // @public diff --git a/sdk/maps/maps-route-rest/samples-dev/lro.ts b/sdk/maps/maps-route-rest/samples-dev/lro.ts index 4024666d8973..c262d1cd3185 100644 --- a/sdk/maps/maps-route-rest/samples-dev/lro.ts +++ b/sdk/maps/maps-route-rest/samples-dev/lro.ts @@ -67,7 +67,7 @@ async function main(): Promise { body: request, }); - const poller = getLongRunningPoller(client, response); + const poller = await getLongRunningPoller(client, response); /** Wait until the total request is done */ const finalResult = await poller.pollUntilDone(); logBatchResponse(finalResult as RouteGetRouteDirectionsBatch200Response); diff --git a/sdk/maps/maps-route-rest/samples-dev/resumeLro.ts b/sdk/maps/maps-route-rest/samples-dev/resumeLro.ts index ae149cf459f1..0003a7632b2d 100644 --- a/sdk/maps/maps-route-rest/samples-dev/resumeLro.ts +++ b/sdk/maps/maps-route-rest/samples-dev/resumeLro.ts @@ -70,14 +70,13 @@ async function main(): Promise { body: request, }); - const initialPoller = getLongRunningPoller(client, initialResponse); + const initialPoller = await getLongRunningPoller(client, initialResponse); /* We can get a partial of the results first */ - await initialPoller.poll(); /** Serialized the current operation for future poller */ - const serializedState = initialPoller.toString(); + const serializedState = await initialPoller.serialize(); /** Use the `resumeFrom` option to rehydrate the previous operation */ - const rehydratedPoller = getLongRunningPoller(client, initialResponse, { - resumeFrom: serializedState, + const rehydratedPoller = await getLongRunningPoller(client, initialResponse, { + restoreFrom: serializedState, }); const { body: { summary, batchItems }, diff --git a/sdk/maps/maps-route-rest/samples/v1-beta/typescript/src/lro.ts b/sdk/maps/maps-route-rest/samples/v1-beta/typescript/src/lro.ts index 4024666d8973..c262d1cd3185 100644 --- a/sdk/maps/maps-route-rest/samples/v1-beta/typescript/src/lro.ts +++ b/sdk/maps/maps-route-rest/samples/v1-beta/typescript/src/lro.ts @@ -67,7 +67,7 @@ async function main(): Promise { body: request, }); - const poller = getLongRunningPoller(client, response); + const poller = await getLongRunningPoller(client, response); /** Wait until the total request is done */ const finalResult = await poller.pollUntilDone(); logBatchResponse(finalResult as RouteGetRouteDirectionsBatch200Response); diff --git a/sdk/maps/maps-route-rest/samples/v1-beta/typescript/src/matrix.ts b/sdk/maps/maps-route-rest/samples/v1-beta/typescript/src/matrix.ts index 19b651ed9852..a03cd7f6a1e0 100644 --- a/sdk/maps/maps-route-rest/samples/v1-beta/typescript/src/matrix.ts +++ b/sdk/maps/maps-route-rest/samples/v1-beta/typescript/src/matrix.ts @@ -73,7 +73,7 @@ async function main(): Promise { ); matrix.forEach((row) => { row.forEach((cell) => { - if(cell.response) console.dir(cell.response.routeSummary); + if (cell.response) console.dir(cell.response.routeSummary); }); }); } diff --git a/sdk/maps/maps-route-rest/samples/v1-beta/typescript/src/range.ts b/sdk/maps/maps-route-rest/samples/v1-beta/typescript/src/range.ts index c2a03c580ab4..e15398c7ebdf 100644 --- a/sdk/maps/maps-route-rest/samples/v1-beta/typescript/src/range.ts +++ b/sdk/maps/maps-route-rest/samples/v1-beta/typescript/src/range.ts @@ -12,7 +12,7 @@ import MapsRoute, { isUnexpected } from "@azure-rest/maps-route"; import * as dotenv from "dotenv"; dotenv.config(); -async function main():Promise { +async function main(): Promise { /** * Azure Maps supports two ways to authenticate requests: * - Shared Key authentication (subscription-key) diff --git a/sdk/maps/maps-route-rest/samples/v1-beta/typescript/src/resumeLro.ts b/sdk/maps/maps-route-rest/samples/v1-beta/typescript/src/resumeLro.ts index a06c9fd9f322..7a348a14f1aa 100644 --- a/sdk/maps/maps-route-rest/samples/v1-beta/typescript/src/resumeLro.ts +++ b/sdk/maps/maps-route-rest/samples/v1-beta/typescript/src/resumeLro.ts @@ -70,14 +70,14 @@ async function main(): Promise { body: request, }); - const initialPoller = getLongRunningPoller(client, initialResponse); + const initialPoller = await getLongRunningPoller(client, initialResponse); /* We can get a partial of the results first */ await initialPoller.poll(); /** Serialized the current operation for future poller */ - const serializedState = initialPoller.toString(); + const serializedState = await initialPoller.serialize(); /** Use the `resumeFrom` option to rehydrate the previous operation */ - const rehydratedPoller = getLongRunningPoller(client, initialResponse, { - resumeFrom: serializedState, + const rehydratedPoller = await getLongRunningPoller(client, initialResponse, { + restoreFrom: serializedState, }); const { body: { summary, batchItems }, diff --git a/sdk/maps/maps-route-rest/src/generated/mapsRouteClient.ts b/sdk/maps/maps-route-rest/src/generated/mapsRouteClient.ts deleted file mode 100644 index 52612ede8616..000000000000 --- a/sdk/maps/maps-route-rest/src/generated/mapsRouteClient.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { getClient, ClientOptions } from "@azure-rest/core-client"; -import { KeyCredential } from "@azure/core-auth"; -import { MapsRouteClient } from "./clientDefinitions"; - -/** - * Initialize a new instance of the class MapsRouteClient class. - * @param credentials type: KeyCredential - */ -export default function createClient( - credentials: KeyCredential, - options: ClientOptions = {} -): MapsRouteClient { - const baseUrl = options.baseUrl ?? `https://atlas.microsoft.com`; - options.apiVersion = options.apiVersion ?? "1.0"; - options = { - ...options, - credentials: { - apiKeyHeaderName: "subscription-key" - } - }; - - const userAgentInfo = `azsdk-js-maps-route-rest/1.0.0-beta.1`; - const userAgentPrefix = - options.userAgentOptions && options.userAgentOptions.userAgentPrefix - ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}` - : `${userAgentInfo}`; - options = { - ...options, - userAgentOptions: { - userAgentPrefix - } - }; - - const client = getClient(baseUrl, credentials, options) as MapsRouteClient; - - return client; -} diff --git a/sdk/maps/maps-route-rest/src/generated/pollingHelper.ts b/sdk/maps/maps-route-rest/src/generated/pollingHelper.ts deleted file mode 100644 index 8e3cd945ae46..000000000000 --- a/sdk/maps/maps-route-rest/src/generated/pollingHelper.ts +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { Client, HttpResponse } from "@azure-rest/core-client"; -import { - LongRunningOperation, - LroEngine, - LroEngineOptions, - LroResponse, - PollerLike, - PollOperationState -} from "@azure/core-lro"; - -/** - * Helper function that builds a Poller object to help polling a long running operation. - * @param client - Client to use for sending the request to get additional pages. - * @param initialResponse - The initial response. - * @param options - Options to set a resume state or custom polling interval. - * @returns - A poller object to poll for operation state updates and eventually get the final response. - */ -export function getLongRunningPoller( - client: Client, - initialResponse: TResult, - options: LroEngineOptions> = {} -): PollerLike, TResult> { - const poller: LongRunningOperation = { - requestMethod: initialResponse.request.method, - requestPath: initialResponse.request.url, - sendInitialRequest: async () => { - // In the case of Rest Clients we are building the LRO poller object from a response that's the reason - // we are not triggering the initial request here, just extracting the information from the - // response we were provided. - return getLroResponse(initialResponse); - }, - sendPollRequest: async (path) => { - // This is the callback that is going to be called to poll the service - // to get the latest status. We use the client provided and the polling path - // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location - // depending on the lro pattern that the service implements. If non is provided we default to the initial path. - const response = await client - .pathUnchecked(path ?? initialResponse.request.url) - .get(); - const lroResponse = getLroResponse(response as TResult); - lroResponse.rawResponse.headers["x-ms-original-url"] = - initialResponse.request.url; - return lroResponse; - } - }; - - return new LroEngine(poller, options); -} - -/** - * Converts a Rest Client response to a response that the LRO engine knows about - * @param response - a rest client http response - * @returns - An LRO response that the LRO engine can work with - */ -function getLroResponse( - response: TResult -): LroResponse { - if (Number.isNaN(response.status)) { - throw new TypeError( - `Status code of the response is not a number. Value: ${response.status}` - ); - } - - return { - flatResponse: response, - rawResponse: { - ...response, - statusCode: Number.parseInt(response.status), - body: response.body - } - }; -} diff --git a/sdk/maps/maps-route-rest/src/helpers.ts b/sdk/maps/maps-route-rest/src/helpers.ts index 5057188daa74..882a71abacf7 100644 --- a/sdk/maps/maps-route-rest/src/helpers.ts +++ b/sdk/maps/maps-route-rest/src/helpers.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import type { LatLon } from "@azure/maps-common"; -import type { BatchRequest, RouteGetRouteDirectionsQueryParamProperties } from "./generated"; +import type { BatchRequest, RouteGetRouteDirectionsQueryParamProperties } from "../generated"; function toLatLonString(coordinates: LatLon): string { return `${coordinates[0]},${coordinates[1]}`; diff --git a/sdk/maps/maps-route-rest/src/index.ts b/sdk/maps/maps-route-rest/src/index.ts index b4ee3027f76c..8f0915b943f7 100644 --- a/sdk/maps/maps-route-rest/src/index.ts +++ b/sdk/maps/maps-route-rest/src/index.ts @@ -3,7 +3,7 @@ import MapsRoute from "./mapsRoute"; -export * from "./generated"; +export * from "../generated"; export * from "./helpers"; export default MapsRoute; diff --git a/sdk/maps/maps-route-rest/src/mapsRoute.ts b/sdk/maps/maps-route-rest/src/mapsRoute.ts index dee3cdbc8718..32bc1d95c6ee 100644 --- a/sdk/maps/maps-route-rest/src/mapsRoute.ts +++ b/sdk/maps/maps-route-rest/src/mapsRoute.ts @@ -5,8 +5,8 @@ import type { ClientOptions } from "@azure-rest/core-client"; import type { AzureKeyCredential, AzureSASCredential, TokenCredential } from "@azure/core-auth"; import { isSASCredential, isTokenCredential } from "@azure/core-auth"; import { createMapsClientIdPolicy } from "@azure/maps-common"; -import type { MapsRouteClient } from "./generated"; -import createClient from "./generated"; +import type { MapsRouteClient } from "../generated"; +import createClient from "../generated"; import { bearerTokenAuthenticationPolicy } from "@azure/core-rest-pipeline"; /** diff --git a/sdk/maps/maps-route-rest/swagger/README.md b/sdk/maps/maps-route-rest/swagger/README.md index 49c90304b73e..d1db6ad21a31 100644 --- a/sdk/maps/maps-route-rest/swagger/README.md +++ b/sdk/maps/maps-route-rest/swagger/README.md @@ -8,6 +8,8 @@ The configuration is following the [RLC quick start guide](https://github.com/Az For the configuration property, please refer to [Index of AutoRestFlag](https://github.com/Azure/autorest/blob/main/docs/generate/flags.md). ```yaml +flavor: azure +openapi-type: data-plane package-name: "@azure-rest/maps-route" title: MapsRouteClient description: Azure Maps Route Client @@ -20,7 +22,7 @@ generate-metadata: false generate-test: false license-header: MICROSOFT_MIT_NO_VERSION output-folder: ../ -source-code-folder-path: ./src/generated +source-code-folder-path: ./generated input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/maps/data-plane/Route/preview/1.0/route.json package-version: 1.0.0-beta.4 rest-level-client: true @@ -29,7 +31,7 @@ rest-level-client: true security: AzureKey security-header-name: subscription-key use-extension: - "@autorest/typescript": "6.0.0-rc.3" + "@autorest/typescript": "6.0.28" ``` ## Customization for Track 2 Generator diff --git a/sdk/maps/maps-route-rest/test/public/mapsRouteClient.spec.ts b/sdk/maps/maps-route-rest/test/public/mapsRouteClient.spec.ts index 90b0caf37e9f..b39f2d0a7aa6 100644 --- a/sdk/maps/maps-route-rest/test/public/mapsRouteClient.spec.ts +++ b/sdk/maps/maps-route-rest/test/public/mapsRouteClient.spec.ts @@ -13,8 +13,8 @@ import type { RouteGetRouteDirectionsBatch200Response, RouteGetRouteDirectionsQueryParamProperties, RouteGetRouteMatrix200Response, -} from "../../src/generated"; -import { getLongRunningPoller, isUnexpected } from "../../src/generated"; +} from "../../generated"; +import { getLongRunningPoller, isUnexpected } from "../../generated"; import type { LatLon } from "@azure/maps-common"; describe("Endpoint can be overwritten", function (this: Suite) { @@ -225,7 +225,7 @@ describe("LRO", function (this: Suite) { const initialResponse = await client.path("/route/directions/batch/{format}", "json").post({ body: createRouteDirectionsBatchRequest(batchRequests), }); - const poller = getLongRunningPoller(client, initialResponse, { + const poller = await getLongRunningPoller(client, initialResponse, { intervalInMs: pollingInterval, }); @@ -272,14 +272,14 @@ describe("LRO", function (this: Suite) { const initialResponse = await client.path("/route/directions/batch/{format}", "json").post({ body: createRouteDirectionsBatchRequest(batchRequests), }); - const originalPoller = getLongRunningPoller(client, initialResponse, { + const originalPoller = await getLongRunningPoller(client, initialResponse, { intervalInMs: pollingInterval, }); - const serializedState = originalPoller.toString(); + const serializedState = await originalPoller.serialize(); // Use serialized state to retrieve the result - const rehydratedPoller = getLongRunningPoller(client, initialResponse, { - resumeFrom: serializedState, + const rehydratedPoller = await getLongRunningPoller(client, initialResponse, { + restoreFrom: serializedState, intervalInMs: pollingInterval, }); const batchResult = @@ -324,15 +324,16 @@ describe("LRO", function (this: Suite) { const initialResponse = await client.path("/route/directions/batch/{format}", "json").post({ body: createRouteDirectionsBatchRequest(batchRequests), }); - const originalPoller = getLongRunningPoller(client, initialResponse, { + const originalPoller = await getLongRunningPoller(client, initialResponse, { intervalInMs: pollingInterval, }); const originalResult = await originalPoller.pollUntilDone(); // Use serialized state to retrieve the result - const serializedState = originalPoller.toString(); - const rehydratedPoller = getLongRunningPoller(client, initialResponse, { - resumeFrom: serializedState, + const serializedState = await originalPoller.serialize(); + + const rehydratedPoller = await getLongRunningPoller(client, initialResponse, { + restoreFrom: serializedState, intervalInMs: pollingInterval, }); const rehydratedResult = await rehydratedPoller.pollUntilDone(); @@ -363,7 +364,7 @@ describe("LRO", function (this: Suite) { const initialResponse = await client .path("/route/matrix/{format}", "json") .post({ body: routeMatrixQuery }); - const poller = getLongRunningPoller(client, initialResponse, { + const poller = await getLongRunningPoller(client, initialResponse, { intervalInMs: pollingInterval, }); const routeMatrixResult = (await poller.pollUntilDone()) as RouteGetRouteMatrix200Response; @@ -397,15 +398,15 @@ describe("LRO", function (this: Suite) { const initialResponse = await client.path("/route/matrix/{format}", "json").post({ body: routeMatrixQuery, }); - const originalPoller = getLongRunningPoller(client, initialResponse, { + const originalPoller = await getLongRunningPoller(client, initialResponse, { intervalInMs: pollingInterval, }); - const serializedState = originalPoller.toString(); + const serializedState = await originalPoller.serialize(); // Use saved batchId to retrieve the result - const rehydratedPoller = getLongRunningPoller(client, initialResponse, { + const rehydratedPoller = await getLongRunningPoller(client, initialResponse, { intervalInMs: pollingInterval, - resumeFrom: serializedState, + restoreFrom: serializedState, }); const routeMatrixResult = (await rehydratedPoller.pollUntilDone()) as RouteGetRouteMatrix200Response; @@ -437,16 +438,17 @@ describe("LRO", function (this: Suite) { const initialResponse = await client.path("/route/matrix/{format}", "json").post({ body: routeMatrixQuery, }); - const originalPoller = getLongRunningPoller(client, initialResponse, { + const originalPoller = await getLongRunningPoller(client, initialResponse, { intervalInMs: pollingInterval, }); const originalResult = await originalPoller.pollUntilDone(); // Use serialized state to retrieve the result - const serializedState = originalPoller.toString(); - const rehydratedPoller = getLongRunningPoller(client, initialResponse, { + const serializedState = await originalPoller.serialize(); + + const rehydratedPoller = await getLongRunningPoller(client, initialResponse, { intervalInMs: pollingInterval, - resumeFrom: serializedState, + restoreFrom: serializedState, }); const rehydratedResult = await rehydratedPoller.pollUntilDone(); diff --git a/sdk/maps/maps-route-rest/test/public/utils/recordedClient.ts b/sdk/maps/maps-route-rest/test/public/utils/recordedClient.ts index 67d28f41a749..83470adf451d 100644 --- a/sdk/maps/maps-route-rest/test/public/utils/recordedClient.ts +++ b/sdk/maps/maps-route-rest/test/public/utils/recordedClient.ts @@ -9,7 +9,7 @@ import { createClientLogger } from "@azure/logger"; import { createTestCredential } from "@azure-tools/test-credential"; import MapsRoute from "../../../src/mapsRoute"; import type { ClientOptions } from "@azure-rest/core-client"; -import type { MapsRouteClient } from "../../../src/generated"; +import type { MapsRouteClient } from "../../../generated"; const envSetupForPlayback: Record = { MAPS_RESOURCE_CLIENT_ID: "azure_maps_client_id",