Skip to content

Commit

Permalink
update according to feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
alextts627 committed Oct 13, 2022
1 parent ee99bc4 commit 3305c04
Show file tree
Hide file tree
Showing 11 changed files with 263 additions and 237 deletions.
70 changes: 37 additions & 33 deletions sdk/maps/azure-maps-route/azure/maps/route/_route_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# --------------------------------------------------------------------------

# pylint: disable=unused-import,ungrouped-imports, R0904, C0302
from typing import Union, Any, List
from typing import Union, Any, List, Tuple
from azure.core.tracing.decorator import distributed_trace
from azure.core.credentials import AzureKeyCredential, TokenCredential
from azure.core.polling import LROPoller
Expand All @@ -27,15 +27,19 @@
class MapsRouteClient(MapsRouteClientBase):
"""Azure Maps Route REST APIs.
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential or ~azure.core.credentials.AzureKeyCredential
:keyword str base_url: Supported Maps Services or Language resource base_url
(protocol and hostname, for example: 'https://<resource-name>.mapsservices.azure.com').
:keyword str client_id: Specifies which account is intended for usage with the Azure AD security model.
It represents a unique ID for the Azure Maps account.
:param credential:
Credential needed for the client to connect to Azure.
:type credential:
~azure.core.credentials.TokenCredential or ~azure.core.credentials.AzureKeyCredential
:keyword str base_url:
Supported Maps Services or Language resource base_url
(protocol and hostname, for example: 'https://us.atlas.microsoft.com').
:keyword str client_id:
Specifies which account is intended for usage with the Azure AD security model.
It represents a unique ID for the Azure Maps account.
:keyword api_version:
The API version of the service to use for requests. It defaults to the latest service version.
Setting to an older version may result in reduced feature compatibility.
The API version of the service to use for requests. It defaults to the latest service version.
Setting to an older version may result in reduced feature compatibility.
:paramtype api_version: str
"""

Expand All @@ -53,7 +57,7 @@ def __init__(
@distributed_trace
def get_route_directions(
self,
route_points: List[LatLon],
route_points: Union[List[LatLon], List[Tuple]],
**kwargs: Any
) -> RouteDirections:
"""
Expand All @@ -66,7 +70,7 @@ def get_route_directions(
instructions is also available, depending on the options selected.
:param route_points: The Coordinate from which the range calculation should start, coordinates as (lat, lon)
:type route_points: List[LatLon]
:type route_points: List[LatLon] or List[Tuple]
:keyword supporting_points: A GeoJSON Geometry collection representing sequence of coordinates
used as input for route reconstruction and for calculating zero or more alternative routes to
this reference route.
Expand Down Expand Up @@ -302,7 +306,7 @@ def get_route_directions(
@distributed_trace
def get_route_range(
self,
coordinates: LatLon,
coordinates: Union[LatLon, Tuple],
**kwargs: Any
) -> RouteRangeResult:

Expand Down Expand Up @@ -472,44 +476,44 @@ def get_route_range(
@distributed_trace
def get_route_directions_batch_sync(
self,
route_directions_batch_queries: List[str],
queries: List[str],
**kwargs: Any
) -> RouteDirectionsBatchResult:

"""Sends batches of route directions requests.
The method return the result directly.
:param route_directions_batch_queries: The list of route directions queries/requests to
:param queries: The list of route directions queries/requests to
process. The list can contain a max of 700 queries for async and 100 queries for sync version
and must contain at least 1 query. Required.
:type route_directions_batch_queries: List[str]
:type queries: List[str]
:return: RouteDirectionsBatchResult
:rtype: ~azure.maps.route.models.RouteDirectionsBatchResult
:rtype: RouteDirectionsBatchResult
:raises ~azure.core.exceptions.HttpResponseError:
"""
batch_items = [{"query": f"?query={query}"} for query
in route_directions_batch_queries] if route_directions_batch_queries else []
return self._route_client.request_route_directions_batch_sync(
in queries] if queries else []
result = self._route_client.request_route_directions_batch_sync(
format=ResponseFormat.JSON,
route_directions_batch_queries={"batch_items": batch_items},
**kwargs
)

return RouteDirectionsBatchResult(summary=result.batch_summary, items=result.batch_items)

@distributed_trace
def begin_route_directions_batch(
self,
route_directions_batch_queries: List[str],
queries: List[str],
**kwargs: Any
) -> LROPoller[RouteDirectionsBatchResult]:

"""Sends batches of route direction queries.
The method returns a poller for retrieving the result later.
:param route_directions_batch_queries: The list of route directions queries/requests to
:param queries: The list of route directions queries/requests to
process. The list can contain a max of 700 queries for async and 100 queries for sync version
and must contain at least 1 query. Required.
:type route_directions_batch_queries: List[str]
:type queries: List[str]
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be LROBasePolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
Expand All @@ -518,11 +522,11 @@ def begin_route_directions_batch(
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns RouteDirectionsBatchResult
:rtype: ~azure.core.polling.LROPoller[~azure.maps.route.models.RouteDirectionsBatchResult]
:rtype: ~azure.core.polling.LROPoller[RouteDirectionsBatchResult]
:raises ~azure.core.exceptions.HttpResponseError:
"""
batch_items = [{"query": f"?query={query}"} for query
in route_directions_batch_queries] if route_directions_batch_queries else []
in queries] if queries else []

poller = self._route_client.begin_request_route_directions_batch(
format=ResponseFormat.JSON,
Expand Down Expand Up @@ -552,7 +556,7 @@ def get_route_directions_batch(
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns RouteDirectionsBatchResult
:rtype: ~azure.core.polling.LROPoller[~azure.maps.route.models.RouteDirectionsBatchResult]
:rtype: ~azure.core.polling.LROPoller[RouteDirectionsBatchResult]
:raises ~azure.core.exceptions.HttpResponseError:
"""

Expand All @@ -567,7 +571,7 @@ def get_route_directions_batch(
@distributed_trace
def get_route_matrix(
self,
route_matrix_query: RouteMatrixQuery,
query: RouteMatrixQuery,
**kwargs: Any
) -> RouteMatrixResult:

Expand All @@ -578,12 +582,12 @@ def get_route_matrix(
The maximum size of a matrix for this method is 100
(the number of origins multiplied by the number of destinations)
:param route_matrix_query: The matrix of origin and destination coordinates to compute the
:param query: The matrix of origin and destination coordinates to compute the
route distance, travel time and other summary for each cell of the matrix based on the input
parameters. The minimum and the maximum cell count supported are 1 and **700** for async and
**100** for sync respectively. For example, it can be 35 origins and 20 destinations or 25
origins and 25 destinations for async API. Is either a model type or a IO type. Required.
:type route_matrix_query: ~azure.maps.route.models.RouteMatrixQuery or IO
:type query: ~azure.maps.route.models.RouteMatrixQuery or IO
:param format: Desired format of the response. Only ``json`` format is supported. "json"
Default value is "json".
:type format: str or ~azure.maps.route.models.JsonFormat
Expand Down Expand Up @@ -678,15 +682,15 @@ def get_route_matrix(
"""
return self._route_client.request_route_matrix_sync(
format=ResponseFormat.JSON,
route_matrix_query=route_matrix_query,
route_matrix_query=query,
**kwargs
)


@distributed_trace
def begin_route_matrix_batch(
self,
route_matrix_query: RouteMatrixQuery,
query: RouteMatrixQuery,
**kwargs: Any
) -> LROPoller[RouteMatrixResult]:

Expand All @@ -697,12 +701,12 @@ def begin_route_matrix_batch(
The maximum size of a matrix for this method is 700
(the number of origins multiplied by the number of destinations)
:param route_matrix_query: The matrix of origin and destination coordinates to compute the
:param query: The matrix of origin and destination coordinates to compute the
route distance, travel time and other summary for each cell of the matrix based on the input
parameters. The minimum and the maximum cell count supported are 1 and **700** for async and
**100** for sync respectively. For example, it can be 35 origins and 20 destinations or 25
origins and 25 destinations for async API. Required.
:type route_matrix_query: ~azure.maps.route.models.RouteMatrixQuery
:type query: ~azure.maps.route.models.RouteMatrixQuery
:param format: Desired format of the response. Only ``json`` format is supported. "json"
Default value is "json".
:type format: str or ~azure.maps.route.models.JsonFormat
Expand Down Expand Up @@ -805,7 +809,7 @@ def begin_route_matrix_batch(

poller = self._route_client.begin_request_route_matrix(
format=ResponseFormat.JSON,
route_matrix_query=route_matrix_query,
route_matrix_query=query,
**kwargs
)
return poller
Expand Down
Loading

0 comments on commit 3305c04

Please sign in to comment.