Skip to content

Commit

Permalink
Update Route changelog for the release (Azure#38361)
Browse files Browse the repository at this point in the history
* Update changelog

* Apply formatting
  • Loading branch information
Lakicar95 authored Nov 8, 2024
1 parent 2139c12 commit dad2f74
Show file tree
Hide file tree
Showing 25 changed files with 187 additions and 266 deletions.
6 changes: 5 additions & 1 deletion sdk/maps/azure-maps-route/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Release History

## 1.0.0b2 (2024-05-15)
## 1.0.0b2 (2024-11-06)

### Breaking Changes

- Updated `get_route_matrix` to accept a `RouteMatrixQuery` object instead of a dictionary.

### Other Changes

Expand Down
5 changes: 1 addition & 4 deletions sdk/maps/azure-maps-route/azure/maps/route/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ def __init__(
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
super().__init__(
client=self._client,
config=self._config,
serializer=self._serialize,
deserializer=self._deserialize
client=self._client, config=self._config, serializer=self._serialize, deserializer=self._deserialize
)

def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
Expand Down
12 changes: 4 additions & 8 deletions sdk/maps/azure-maps-route/azure/maps/route/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,25 @@ def patch_sdk():
https://aka.ms/azsdk/python/dpcodegen/python/customize
"""


# To check the credential is either AzureKeyCredential or TokenCredential
def _authentication_policy(credential):
authentication_policy = None
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if isinstance(credential, AzureKeyCredential):
authentication_policy = AzureKeyCredentialPolicy(
name="subscription-key", credential=credential
)
authentication_policy = AzureKeyCredentialPolicy(name="subscription-key", credential=credential)
elif credential is not None and not hasattr(credential, "get_token"):
raise TypeError(
"Unsupported credential: {}. Use an instance of AzureKeyCredential "
"or a token credential from azure.identity".format(type(credential))
)
return authentication_policy


# pylint: disable=C4748
class MapsRouteClient(MapsRouteClientGenerated):
def __init__(
self,
credential: Union[AzureKeyCredential, TokenCredential],
**kwargs: Any
) -> None:
def __init__(self, credential: Union[AzureKeyCredential, TokenCredential], **kwargs: Any) -> None:

super().__init__(
credential=credential, # type: ignore
Expand Down
5 changes: 1 addition & 4 deletions sdk/maps/azure-maps-route/azure/maps/route/aio/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ def __init__(
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
super().__init__(
client=self._client,
config=self._config,
serializer=self._serialize,
deserializer=self._deserialize
client=self._client, config=self._config, serializer=self._serialize, deserializer=self._deserialize
)

def send_request(
Expand Down
12 changes: 4 additions & 8 deletions sdk/maps/azure-maps-route/azure/maps/route/aio/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,25 @@ def patch_sdk():
https://aka.ms/azsdk/python/dpcodegen/python/customize
"""


# To check the credential is either AzureKeyCredential or TokenCredential
def _authentication_policy(credential):
authentication_policy = None
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if isinstance(credential, AzureKeyCredential):
authentication_policy = AzureKeyCredentialPolicy(
name="subscription-key", credential=credential
)
authentication_policy = AzureKeyCredentialPolicy(name="subscription-key", credential=credential)
elif credential is not None and not hasattr(credential, "get_token"):
raise TypeError(
"Unsupported credential: {}. Use an instance of AzureKeyCredential "
"or a token credential from azure.identity".format(type(credential))
)
return authentication_policy


# pylint: disable=C4748
class MapsRouteClient(MapsRouteClientGenerated):
def __init__(
self,
credential: Union[AzureKeyCredential, AsyncTokenCredential],
**kwargs: Any
) -> None:
def __init__(self, credential: Union[AzureKeyCredential, AsyncTokenCredential], **kwargs: Any) -> None:

super().__init__(
credential=credential, # type: ignore
Expand Down
101 changes: 31 additions & 70 deletions sdk/maps/azure-maps-route/azure/maps/route/aio/operations/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
RouteMatrixQuery,
RouteMatrixResult,
BatchRequest,
BatchRequestItem
BatchRequestItem,
)
from ._operations import RouteOperations as RouteOperationsGenerated

Expand All @@ -36,12 +36,12 @@ def patch_sdk():
you can't accomplish using the techniques described in
https://aka.ms/azsdk/python/dpcodegen/python/customize
"""


class RouteOperations(RouteOperationsGenerated):
@distributed_trace_async
async def get_route_directions( # type: ignore
self,
route_points: Union[List[LatLongPair], List[Tuple]],
**kwargs: Any
async def get_route_directions( # type: ignore
self, route_points: Union[List[LatLongPair], List[Tuple]], **kwargs: Any
) -> RouteDirections:
"""
Returns a route between an origin and a destination, passing through waypoints if they are
Expand Down Expand Up @@ -269,38 +269,31 @@ async def get_route_directions( # type: ignore
coordinates.append(f"{route_point[0]},{route_point[1]}")
query_items = ":".join(coordinates)

supporting_points = kwargs.pop('supporting_points', None)
avoid_vignette = kwargs.pop('avoid_vignette', None)
allow_vignette = kwargs.pop('allow_vignette', None)
avoid_areas = kwargs.pop('avoid_areas', None)
supporting_points = kwargs.pop("supporting_points", None)
avoid_vignette = kwargs.pop("avoid_vignette", None)
allow_vignette = kwargs.pop("allow_vignette", None)
avoid_areas = kwargs.pop("avoid_areas", None)

if supporting_points or avoid_areas or allow_vignette or avoid_vignette:
route_directions_body = RouteDirectionParameters(
supporting_points=supporting_points,
avoid_vignette=avoid_vignette,
allow_vignette=allow_vignette,
avoid_areas=avoid_areas
avoid_areas=avoid_areas,
)
return await super().get_route_directions_with_additional_parameters(
route_direction_parameters=route_directions_body,
format=ResponseFormat.JSON,
route_points=query_items,
**kwargs
**kwargs,
)
return await super().get_route_directions(
format=ResponseFormat.JSON,
route_points=query_items,
**kwargs
)
return await super().get_route_directions(format=ResponseFormat.JSON, route_points=query_items, **kwargs)

# cSpell:disable
@distributed_trace_async
async def get_route_range( # type: ignore
self,
coordinates: Union[LatLongPair, Tuple[float, float]],
**kwargs: Any
async def get_route_range( # type: ignore
self, coordinates: Union[LatLongPair, Tuple[float, float]], **kwargs: Any
) -> RouteRangeResult:

"""**Route Range (Isochrone) API**
This service will calculate a set of locations that can be reached from the origin point based
Expand Down Expand Up @@ -461,20 +454,10 @@ async def get_route_range( # type: ignore
elif isinstance(coordinates, LatLongPair) and coordinates.latitude and coordinates.longitude:
query = [coordinates.latitude, coordinates.longitude]

return await super().get_route_range(
format=ResponseFormat.JSON,
query=query,
**kwargs
)

return await super().get_route_range(format=ResponseFormat.JSON, query=query, **kwargs)

@distributed_trace_async
async def get_route_directions_batch_sync(
self,
queries: List[str],
**kwargs: Any
) -> RouteDirectionsBatchResult:

async def get_route_directions_batch_sync(self, queries: List[str], **kwargs: Any) -> RouteDirectionsBatchResult:
"""Sends batches of route directions requests.
The method return the result directly.
Expand All @@ -491,15 +474,13 @@ async def get_route_directions_batch_sync(
route_directions_batch_queries=BatchRequest(
batch_items=[BatchRequestItem(query=f"?query={query}") for query in queries] if queries else []
),
**kwargs
**kwargs,
)

@distributed_trace_async
async def begin_get_route_directions_batch( # type: ignore
self,
**kwargs: Any
async def begin_get_route_directions_batch( # type: ignore
self, **kwargs: Any
) -> AsyncLROPoller[RouteDirectionsBatchResult]:

"""Sends batches of route direction queries.
The method returns a poller for retrieving the result later.
Expand All @@ -520,14 +501,12 @@ async def begin_get_route_directions_batch( # type: ignore
:rtype: ~azure.core.polling.AsyncLROPoller[RouteDirectionsBatchResult]
:raises ~azure.core.exceptions.HttpResponseError:
"""
queries=kwargs.pop('queries', None)
batch_id=kwargs.pop('batch_id', None)
queries = kwargs.pop("queries", None)
batch_id = kwargs.pop("batch_id", None)

if batch_id:
poller = await super().begin_get_route_directions_batch(
format=ResponseFormat.JSON,
batch_id=batch_id,
**kwargs
format=ResponseFormat.JSON, batch_id=batch_id, **kwargs
)
return poller

Expand All @@ -536,25 +515,20 @@ async def begin_get_route_directions_batch( # type: ignore
route_directions_batch_queries=BatchRequest(
batch_items=[BatchRequestItem(query=f"?query={query}") for query in queries] if queries else []
),
**kwargs
**kwargs,
)

polling_method = batch_poller.polling_method()
if hasattr(polling_method, "_operation"):
operation = polling_method._operation
batch_poller.batch_id = operation._location_url.split('/')[-1].split('?')[0]
batch_poller.batch_id = operation._location_url.split("/")[-1].split("?")[0]
else:
batch_poller.batch_id = None

return batch_poller

@distributed_trace_async
async def get_route_matrix(
self,
query: RouteMatrixQuery,
**kwargs: Any
) -> RouteMatrixResult:

async def get_route_matrix(self, query: RouteMatrixQuery, **kwargs: Any) -> RouteMatrixResult:
"""
Calculates a matrix of route summaries for a set of routes defined by origin and destination locations.
The method return the result directly.
Expand Down Expand Up @@ -659,18 +633,10 @@ async def get_route_matrix(
:rtype: ~azure.maps.route.models.RouteMatrixResult
:raises ~azure.core.exceptions.HttpResponseError:
"""
return await super().request_route_matrix_sync(
format=ResponseFormat.JSON,
route_matrix_query=query,
**kwargs
)
return await super().request_route_matrix_sync(format=ResponseFormat.JSON, route_matrix_query=query, **kwargs)

@distributed_trace_async
async def begin_get_route_matrix_batch(
self,
**kwargs: Any
) -> AsyncLROPoller[RouteMatrixResult]:

async def begin_get_route_matrix_batch(self, **kwargs: Any) -> AsyncLROPoller[RouteMatrixResult]:
"""
Calculates a matrix of route summaries for a set of routes defined by origin and destination locations.
The method returns a poller for retrieving the result later.
Expand Down Expand Up @@ -785,18 +751,13 @@ async def begin_get_route_matrix_batch(
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.maps.route.models.RouteMatrixResult]
:raises ~azure.core.exceptions.HttpResponseError:
"""
query=kwargs.pop('query', None)
matrix_id = kwargs.pop('matrix_id', None)
query = kwargs.pop("query", None)
matrix_id = kwargs.pop("matrix_id", None)

if matrix_id:
return await super().begin_get_route_matrix(
matrix_id=matrix_id,
**kwargs
)
return await super().begin_get_route_matrix(matrix_id=matrix_id, **kwargs)

poller = await super().begin_request_route_matrix(
format=ResponseFormat.JSON,
route_matrix_query=query,
**kwargs
format=ResponseFormat.JSON, route_matrix_query=query, **kwargs
)
return poller
8 changes: 4 additions & 4 deletions sdk/maps/azure-maps-route/azure/maps/route/models/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

if TYPE_CHECKING:
from .. import models as _models
JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object
JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object


class BatchRequest(_serialization.Model):
Expand Down Expand Up @@ -429,7 +429,7 @@ def __init__(
self.properties = properties
self.id = id
self.feature_type = feature_type
self.type: str = "Feature" # type: ignore
self.type: str = "Feature" # type: ignore


class GeoJsonFeatureCollectionData(_serialization.Model):
Expand Down Expand Up @@ -491,7 +491,7 @@ def __init__(self, *, features: List["_models.GeoJsonFeature"], **kwargs: Any) -
"""
super().__init__(features=features, **kwargs)
self.features = features
self.type: str = "FeatureCollection" # type: ignore
self.type: str = "FeatureCollection" # type: ignore


class GeoJsonGeometry(GeoJsonObject):
Expand Down Expand Up @@ -537,7 +537,7 @@ class GeoJsonGeometry(GeoJsonObject):
def __init__(self, **kwargs: Any) -> None:
""" """
super().__init__(**kwargs)
self.type: str = "GeoJsonGeometry" # type: ignore
self.type: str = "GeoJsonGeometry" # type: ignore


class GeoJsonGeometryCollectionData(_serialization.Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4375,7 +4375,7 @@ def get_route_directions_with_additional_parameters( # pylint: disable=name-too
consider 60 km/hour as this is the current situation. If the maximum speed of the vehicle is
provided as 80 km/hour but the current traffic flow is 60 km/hour, then routing engine will
again use 60 km/hour. Default value is 0.
:paramtype vehicle_max_speed: int
:keyword vehicle_weight: Weight of the vehicle in kilograms.
Expand Down
Loading

0 comments on commit dad2f74

Please sign in to comment.