From 746e980ad7976e329d695404e1155b4c8cc09f71 Mon Sep 17 00:00:00 2001 From: Alex Tsao Date: Fri, 14 Oct 2022 02:35:19 +0800 Subject: [PATCH] Add overload methods --- .../azure/maps/route/_route_client.py | 163 +++++++-------- .../maps/route/aio/_route_client_async.py | 163 +++++++-------- .../azure/maps/route/models/__init__.py | 10 +- .../azure/maps/route/models/_models.py | 195 +++++++++++++++++- .../azure/maps/search/models/__init__.py | 12 +- .../azure/maps/search/models/_models.py | 73 +++++++ 6 files changed, 428 insertions(+), 188 deletions(-) diff --git a/sdk/maps/azure-maps-route/azure/maps/route/_route_client.py b/sdk/maps/azure-maps-route/azure/maps/route/_route_client.py index 655ec4016410..78d2b5e7816f 100644 --- a/sdk/maps/azure-maps-route/azure/maps/route/_route_client.py +++ b/sdk/maps/azure-maps-route/azure/maps/route/_route_client.py @@ -4,8 +4,8 @@ # license information. # -------------------------------------------------------------------------- -# pylint: disable=unused-import,ungrouped-imports, R0904, C0302 -from typing import Union, Any, List, Tuple +# pylint: disable=unused-import,ungrouped-imports, R0904, C0302, W0212 +from typing import Union, Any, List, Tuple, overload from azure.core.tracing.decorator import distributed_trace from azure.core.credentials import AzureKeyCredential, TokenCredential from azure.core.polling import LROPoller @@ -24,6 +24,12 @@ ResponseFormat ) +def get_batch_id_from_poller(polling_method): + if hasattr(polling_method, "_operation"): + operation=polling_method._operation + return operation._location_url.split('/')[-1].split('?')[0] + return None + # By default, use the latest supported API version class MapsRouteClient(MapsRouteClientBase): """Azure Maps Route REST APIs. @@ -501,73 +507,68 @@ def get_route_directions_batch_sync( ) return RouteDirectionsBatchResult(summary=result.batch_summary, items=result.batch_items) - @distributed_trace - def begin_route_directions_batch( + @overload + def begin_get_route_directions_batch( + self, + batch_id: str, + **kwargs: Any + ) -> LROPoller[RouteDirectionsBatchResult]: + pass + + @overload + def begin_get_route_directions_batch( self, queries: List[str], **kwargs: Any ) -> LROPoller[RouteDirectionsBatchResult]: + pass + + @distributed_trace + def begin_get_route_directions_batch( + self, + **kwargs: Any + ) -> LROPoller[RouteDirectionsBatchResult]: """Sends batches of route direction queries. The method returns a poller for retrieving the result later. - :param queries: The list of route directions queries/requests to + :keyword 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 queries: List[str] + :paramtype queries: List[str] + :keyword batch_id: Batch id for querying the operation. Required. + :paramtype batch_id: 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 polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod + :paramtype polling: bool :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[RouteDirectionsBatchResult] :raises ~azure.core.exceptions.HttpResponseError: """ + queries=kwargs.pop('queries', None) + batch_id=kwargs.pop('batch_id', None) + + if batch_id: + poller = self._route_client.begin_get_route_directions_batch( + format=ResponseFormat.JSON, + batch_id=batch_id, + **kwargs + ) + return poller + batch_items = [{"query": f"?query={query}"} for query in queries] if queries else [] - - poller = self._route_client.begin_request_route_directions_batch( + batch_poller = self._route_client.begin_request_route_directions_batch( format=ResponseFormat.JSON, route_directions_batch_queries={"batch_items": batch_items}, **kwargs ) - return poller - - - @distributed_trace - def get_route_directions_batch( - self, - batch_id: str, - **kwargs: Any - )-> LROPoller[RouteDirectionsBatchResult]: - - """Retrieves the result of a previous route direction batch request. - The method returns a poller for retrieving the result. - - :param batch_id: Batch id for querying the operation. Required. - :type batch_id: 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 - polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :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[RouteDirectionsBatchResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - poller = self._route_client.begin_get_route_directions_batch( - format=ResponseFormat.JSON, - batch_id=batch_id, - **kwargs - ) - return poller - + batch_poller.batch_id = get_batch_id_from_poller(batch_poller.polling_method()) + return batch_poller @distributed_trace def get_route_matrix( @@ -589,9 +590,6 @@ def get_route_matrix( **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 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 :keyword wait_for_results: Boolean to indicate whether to execute the request synchronously. If set to true, user will get a 200 response if the request is finished under 120 seconds. Otherwise, user will get a 202 response right away. Please refer to the API description for @@ -687,11 +685,25 @@ def get_route_matrix( **kwargs ) + @overload + def begin_get_route_matrix_batch( + self, + query: RouteMatrixQuery, + **kwargs: Any + ) -> LROPoller[RouteMatrixResult]: + pass + + @overload + def begin_get_route_matrix_batch( + self, + matrix_id: str, + **kwargs: Any + ) -> LROPoller[RouteMatrixResult]: + pass @distributed_trace - def begin_route_matrix_batch( + def begin_get_route_matrix_batch( self, - query: RouteMatrixQuery, **kwargs: Any ) -> LROPoller[RouteMatrixResult]: @@ -702,15 +714,15 @@ 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 query: The matrix of origin and destination coordinates to compute the + :keyword 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 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 + :paramtype query: ~azure.maps.route.models.RouteMatrixQuery + :keyword matrix_id: Matrix id received after the Matrix Route request was accepted successfully. + Required. + :paramtype matrix_id: str :keyword wait_for_results: Boolean to indicate whether to execute the request synchronously. If set to true, user will get a 200 response if the request is finished under 120 seconds. Otherwise, user will get a 202 response right away. Please refer to the API description for @@ -800,13 +812,21 @@ def begin_route_matrix_batch( :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 polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod + :paramtype polling: bool :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 RouteMatrixResult :rtype: ~azure.core.polling.LROPoller[~azure.maps.route.models.RouteMatrixResult] :raises ~azure.core.exceptions.HttpResponseError: """ + query=kwargs.pop('query', None) + matrix_id = kwargs.pop('matrix_id', None) + + if matrix_id: + return self._route_client.begin_get_route_matrix( + matrix_id=matrix_id, + **kwargs + ) poller = self._route_client.begin_request_route_matrix( format=ResponseFormat.JSON, @@ -814,38 +834,3 @@ def begin_route_matrix_batch( **kwargs ) return poller - - - @distributed_trace - def get_route_matrix_batch( - self, - matrix_id: str, - **kwargs: Any - ) -> LROPoller[RouteMatrixResult]: - - """If the Matrix Route request was accepted successfully, the Location header in the response - contains the URL to download the results of the request. - - Retrieves the result of a previous route matrix request. - The method returns a poller for retrieving the result. - - :param matrix_id: Matrix id received after the Matrix Route request was accepted successfully. - Required. - :type matrix_id: 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 - polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :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 RouteMatrixResult - :rtype: ~azure.core.polling.LROPoller[~azure.maps.route.models.RouteMatrixResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - poller = self._route_client.begin_get_route_matrix( - matrix_id=matrix_id, - **kwargs - ) - - return poller diff --git a/sdk/maps/azure-maps-route/azure/maps/route/aio/_route_client_async.py b/sdk/maps/azure-maps-route/azure/maps/route/aio/_route_client_async.py index ebd02a79a4ea..89bd54f2a0fa 100644 --- a/sdk/maps/azure-maps-route/azure/maps/route/aio/_route_client_async.py +++ b/sdk/maps/azure-maps-route/azure/maps/route/aio/_route_client_async.py @@ -4,8 +4,8 @@ # license information. # -------------------------------------------------------------------------- -# pylint: disable=unused-import,ungrouped-imports, R0904, C0302 -from typing import Any, List, Union, Tuple +# pylint: disable=unused-import,ungrouped-imports, R0904, C0302, W0212 +from typing import Any, List, Union, Tuple, overload from azure.core.polling import AsyncLROPoller from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.credentials import AzureKeyCredential @@ -25,6 +25,12 @@ ResponseFormat ) +def get_batch_id_from_poller(polling_method): + if hasattr(polling_method, "_operation"): + operation=polling_method._operation + return operation._location_url.split('/')[-1].split('?')[0] + return None + # By default, use the latest supported API version class MapsRouteClient(AsyncMapsRouteClientBase): """Azure Maps Route REST APIs. @@ -501,73 +507,68 @@ async def get_route_directions_batch_sync( ) return RouteDirectionsBatchResult(summary=result.batch_summary, items=result.batch_items) - @distributed_trace_async - async def begin_route_directions_batch( + @overload + def begin_get_route_directions_batch( + self, + batch_id: str, + **kwargs: Any + ) -> AsyncLROPoller[RouteDirectionsBatchResult]: + pass + + @overload + def begin_get_route_directions_batch( self, queries: List[str], **kwargs: Any ) -> AsyncLROPoller[RouteDirectionsBatchResult]: + pass + + @distributed_trace_async + async def begin_get_route_directions_batch( + self, + **kwargs: Any + ) -> AsyncLROPoller[RouteDirectionsBatchResult]: """Sends batches of route direction queries. The method returns a poller for retrieving the result later. - :param queries: The list of route directions queries/requests to + :keyword 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 queries: List[str] + :paramtype queries: List[str] + :keyword batch_id: Batch id for querying the operation. Required. + :paramtype batch_id: 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 polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod + :paramtype polling: bool :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of AsyncLROPoller that returns RouteDirectionsBatchResult :rtype: ~azure.core.polling.AsyncLROPoller[RouteDirectionsBatchResult] :raises ~azure.core.exceptions.HttpResponseError: """ + queries=kwargs.pop('queries', None) + batch_id=kwargs.pop('batch_id', None) + + if batch_id: + poller = await self._route_client.begin_get_route_directions_batch( + format=ResponseFormat.JSON, + batch_id=batch_id, + **kwargs + ) + return poller + batch_items = [{"query": f"?query={query}"} for query in queries] if queries else [] - - poller = await self._route_client.begin_request_route_directions_batch( + batch_poller = await self._route_client.begin_request_route_directions_batch( format=ResponseFormat.JSON, route_directions_batch_queries={"batch_items": batch_items}, **kwargs ) - return poller - - - @distributed_trace_async - async def get_route_directions_batch( - self, - batch_id: str, - **kwargs: Any - )-> AsyncLROPoller[RouteDirectionsBatchResult]: - - """Retrieves the result of a previous route direction batch request. - The method returns a poller for retrieving the result. - - :param batch_id: Batch id for querying the operation. Required. - :type batch_id: 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 - polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns RouteDirectionsBatchResult - :rtype: ~azure.core.polling.AsyncLROPoller[RouteDirectionsBatchResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - poller = await self._route_client.begin_get_route_directions_batch( - format=ResponseFormat.JSON, - batch_id=batch_id, - **kwargs - ) - return poller - + batch_poller.batch_id = get_batch_id_from_poller(batch_poller.polling_method()) + return batch_poller @distributed_trace_async async def get_route_matrix( @@ -589,9 +590,6 @@ async def get_route_matrix( **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 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 :keyword wait_for_results: Boolean to indicate whether to execute the request synchronously. If set to true, user will get a 200 response if the request is finished under 120 seconds. Otherwise, user will get a 202 response right away. Please refer to the API description for @@ -687,11 +685,25 @@ async def get_route_matrix( **kwargs ) + @overload + async def begin_get_route_matrix_batch( + self, + query: RouteMatrixQuery, + **kwargs: Any + ) -> AsyncLROPoller[RouteMatrixResult]: + pass + + @overload + async def begin_get_route_matrix_batch( + self, + matrix_id: str, + **kwargs: Any + ) -> AsyncLROPoller[RouteMatrixResult]: + pass @distributed_trace_async - async def begin_route_matrix_batch( + async def begin_get_route_matrix_batch( self, - query: RouteMatrixQuery, **kwargs: Any ) -> AsyncLROPoller[RouteMatrixResult]: @@ -702,15 +714,15 @@ async 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 query: The matrix of origin and destination coordinates to compute the + :keyword 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 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 + :paramtype query: ~azure.maps.route.models.RouteMatrixQuery + :keyword matrix_id: Matrix id received after the Matrix Route request was accepted successfully. + Required. + :paramtype matrix_id: str :keyword wait_for_results: Boolean to indicate whether to execute the request synchronously. If set to true, user will get a 200 response if the request is finished under 120 seconds. Otherwise, user will get a 202 response right away. Please refer to the API description for @@ -800,13 +812,21 @@ async def begin_route_matrix_batch( :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 polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod + :paramtype polling: bool :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of AsyncLROPoller that returns RouteMatrixResult :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) + + if matrix_id: + return await self._route_client.begin_get_route_matrix( + matrix_id=matrix_id, + **kwargs + ) poller = await self._route_client.begin_request_route_matrix( format=ResponseFormat.JSON, @@ -814,38 +834,3 @@ async def begin_route_matrix_batch( **kwargs ) return poller - - - @distributed_trace_async - async def get_route_matrix_batch( - self, - matrix_id: str, - **kwargs: Any - ) -> AsyncLROPoller[RouteMatrixResult]: - - """If the Matrix Route request was accepted successfully, the Location header in the response - contains the URL to download the results of the request. - - Retrieves the result of a previous route matrix request. - The method returns a poller for retrieving the result. - - :param matrix_id: Matrix id received after the Matrix Route request was accepted successfully. - Required. - :type matrix_id: 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 - polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns RouteMatrixResult - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.maps.route.models.RouteMatrixResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - poller = await self._route_client.begin_get_route_matrix( - matrix_id=matrix_id, - **kwargs - ) - - return poller diff --git a/sdk/maps/azure-maps-route/azure/maps/route/models/__init__.py b/sdk/maps/azure-maps-route/azure/maps/route/models/__init__.py index 427e9b0818c4..bfd5b8a14025 100644 --- a/sdk/maps/azure-maps-route/azure/maps/route/models/__init__.py +++ b/sdk/maps/azure-maps-route/azure/maps/route/models/__init__.py @@ -21,7 +21,11 @@ RouteSummary, RouteGuidance, Route, - RouteSectionTec + RouteSectionTec, + BatchResultSummary, + GuidanceInstructionType, + JunctionType, + RouteLegSummary ) from ._models import ( @@ -51,6 +55,10 @@ 'RouteRangeResult', 'LatLon', 'BoundingBox', + 'BatchResultSummary', + 'JunctionType', + 'GuidanceInstructionType', + 'RouteLegSummary', 'RouteDirections', 'RouteInstructionsType', 'ComputeTravelTime', diff --git a/sdk/maps/azure-maps-route/azure/maps/route/models/_models.py b/sdk/maps/azure-maps-route/azure/maps/route/models/_models.py index 6ed5309f9d5b..95c30e9b03b5 100644 --- a/sdk/maps/azure-maps-route/azure/maps/route/models/_models.py +++ b/sdk/maps/azure-maps-route/azure/maps/route/models/_models.py @@ -3,7 +3,7 @@ # Licensed under the MIT License. # ------------------------------------ -# pylint: disable=unused-import,ungrouped-imports, super-init-not-called +# pylint: disable=unused-import,ungrouped-imports, super-init-not-called, W0212, C0302 from typing import List, Optional, Union, NamedTuple from enum import Enum, EnumMeta from six import with_metaclass @@ -16,7 +16,8 @@ BatchResultSummary, ErrorDetail, RouteReport, - RouteSectionTec + RouteSectionTec, + GuidanceInstructionType ) class LatLon(NamedTuple): @@ -49,7 +50,8 @@ class BoundingBox(NamedTuple): # cSpell:disable class RouteSection(object): - """Route sections contain additional information about parts of a route. Each section contains at least the elements ``startPointIndex``\ , ``endPointIndex``\ , and ``sectionType``. + """Route sections contain additional information about parts of a route. + Each section contains at least the elements ``startPointIndex``, ``endPointIndex``, and ``sectionType``. Variables are only populated by the server, and will be ignored when sending a request. @@ -222,11 +224,10 @@ class RouteDirectionsBatchResult(object): """ def __init__( self, - summary: BatchResultSummary = None, - items: List[RouteDirectionsBatchItem] = None + **kwargs ): - self.summary = summary - self.items = items + self.summary = kwargs.get('summary', None) + self.items = kwargs.get('items', None) class RouteLeg(GenRouteLeg): """A description of a part of a route, comprised of a list of points. @@ -975,4 +976,182 @@ class TravelMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: The returned routes are optimized for pedestrians, including the use of sidewalks. PEDESTRIAN = "pedestrian" #: The given mode of transport is not possible in this section - OTHER = "other" \ No newline at end of file + OTHER = "other" + +class RouteInstruction(object): # pylint: disable=too-many-instance-attributes + """A set of attributes describing a maneuver, e.g. 'Turn right', 'Keep left', + 'Take the ferry', 'Take the motorway', 'Arrive'. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar route_offset_in_meters: Distance from the start of the route to the point of the + instruction. + :vartype route_offset_in_meters: int + :ivar travel_time_in_seconds: Estimated travel time up to the point corresponding to + routeOffsetInMeters. + :vartype travel_time_in_seconds: int + :ivar point: A location represented as a latitude and longitude. + :vartype point: LatLon + :ivar point_index: The index of the point in the list of polyline "points" corresponding to the + point of the instruction. + :vartype point_index: int + :ivar instruction_type: Type of the instruction, e.g., turn or change of road form. Known + values are: "TURN", "ROAD_CHANGE", "LOCATION_DEPARTURE", "LOCATION_ARRIVAL", "DIRECTION_INFO", + and "LOCATION_WAYPOINT". + :vartype instruction_type: str or ~azure.maps.route.models.GuidanceInstructionType + :ivar road_numbers: 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"]. + :vartype road_numbers: list[str] + :ivar exit_number: 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". + :vartype exit_number: str + :ivar street: Street name of the next significant road segment after the maneuver, or of the + street that should be followed. + :vartype street: str + :ivar signpost_text: The text on a signpost which is most relevant to the maneuver, or to the + direction that should be followed. + :vartype signpost_text: str + :ivar country_code: 3-character `ISO 3166-1 `_ + alpha-3 country code. E.g. USA. + :vartype country_code: str + :ivar state_code: A subdivision (e.g., state) of the country, represented by the second part of + an `ISO 3166-2 `_ code. This is only available for + some countries like the US, Canada, and Mexico. + :vartype state_code: str + :ivar junction_type: The type of the junction where the maneuver takes place. For larger + roundabouts, two separate instructions are generated for entering and leaving the roundabout. + Known values are: "REGULAR", "ROUNDABOUT", and "BIFURCATION". + :vartype junction_type: str or ~azure.maps.route.models.JunctionType + :ivar turn_angle_in_degrees: Indicates the direction of an instruction. If junctionType + indicates a turn instruction: + + + * 180 = U-turn + * [-179, -1] = Left turn + * 0 = Straight on (a '0 degree' turn) + * [1, 179] = Right turn + + If junctionType indicates a bifurcation instruction: + + + * <0 - keep left + * >0 - keep right. + :vartype turn_angle_in_degrees: int + :ivar roundabout_exit_number: This indicates which exit to take at a roundabout. + :vartype roundabout_exit_number: str + :ivar possible_combine_with_next: 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". + :vartype possible_combine_with_next: bool + :ivar driving_side: Indicates left-hand vs. right-hand side driving at the point of the + maneuver. Known values are: "LEFT" and "RIGHT". + :vartype driving_side: str or ~azure.maps.route.models.DrivingSide + :ivar maneuver: A code identifying the maneuver. Known values are: "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", and "WAYPOINT_REACHED". + :vartype maneuver: str or ~azure.maps.route.models.GuidanceManeuver + :ivar message: A human-readable message for the maneuver. + :vartype message: str + :ivar combined_message: 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: + + .. code-block:: + + 10. Turn left onto Einsteinweg/A10/E22 towards Ring Amsterdam + 11. Follow Einsteinweg/A10/E22 towards Ring Amsterdam + + The possibleCombineWithNext flag on instruction 10 is true. This indicates to the clients of + coded guidance that it can be combined with instruction 11. The instructions will be combined + automatically for clients requesting human-readable guidance. The combinedMessage field + contains the combined message: + + .. code-block:: + + Turn left onto Einsteinweg/A10/E22 towards Ring Amsterdam + then follow Einsteinweg/A10/E22 towards Ring Amsterdam. + :vartype combined_message: str + """ + + _validation = { + "route_offset_in_meters": {"readonly": True}, + "travel_time_in_seconds": {"readonly": True}, + "point_index": {"readonly": True}, + "road_numbers": {"readonly": True}, + "exit_number": {"readonly": True}, + "street": {"readonly": True}, + "signpost_text": {"readonly": True}, + "country_code": {"readonly": True}, + "state_code": {"readonly": True}, + "junction_type": {"readonly": True}, + "turn_angle_in_degrees": {"readonly": True}, + "roundabout_exit_number": {"readonly": True}, + "possible_combine_with_next": {"readonly": True}, + "driving_side": {"readonly": True}, + "maneuver": {"readonly": True}, + "message": {"readonly": True}, + "combined_message": {"readonly": True}, + } + + _attribute_map = { + "route_offset_in_meters": {"key": "routeOffsetInMeters", "type": "int"}, + "travel_time_in_seconds": {"key": "travelTimeInSeconds", "type": "int"}, + "point": {"key": "point", "type": "LatLongPair"}, + "point_index": {"key": "pointIndex", "type": "int"}, + "instruction_type": {"key": "instructionType", "type": "str"}, + "road_numbers": {"key": "roadNumbers", "type": "[str]"}, + "exit_number": {"key": "exitNumber", "type": "str"}, + "street": {"key": "street", "type": "str"}, + "signpost_text": {"key": "signpostText", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "state_code": {"key": "stateCode", "type": "str"}, + "junction_type": {"key": "junctionType", "type": "str"}, + "turn_angle_in_degrees": {"key": "turnAngleInDecimalDegrees", "type": "int"}, + "roundabout_exit_number": {"key": "roundaboutExitNumber", "type": "str"}, + "possible_combine_with_next": {"key": "possibleCombineWithNext", "type": "bool"}, + "driving_side": {"key": "drivingSide", "type": "str"}, + "maneuver": {"key": "maneuver", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "combined_message": {"key": "combinedMessage", "type": "str"}, + } + + def __init__( + self, + *, + point: Optional["LatLon"] = None, + instruction_type: Optional[Union[str, "GuidanceInstructionType"]] = None, + **kwargs + ): + """ + :keyword point: A location represented as a latitude and longitude. + :paramtype point: ~azure.maps.route.models.LatLongPair + :keyword instruction_type: Type of the instruction, e.g., turn or change of road form. Known + values are: "TURN", "ROAD_CHANGE", "LOCATION_DEPARTURE", "LOCATION_ARRIVAL", "DIRECTION_INFO", + and "LOCATION_WAYPOINT". + :paramtype instruction_type: str or ~azure.maps.route.models.GuidanceInstructionType + """ + super().__init__(**kwargs) + self.route_offset_in_meters = None + self.travel_time_in_seconds = None + self.point = point + self.point_index = None + self.instruction_type = instruction_type + self.road_numbers = None + self.exit_number = None + self.street = None + self.signpost_text = None + self.country_code = None + self.state_code = None + self.junction_type = None + self.turn_angle_in_degrees = None + self.roundabout_exit_number = None + self.possible_combine_with_next = None + self.driving_side = None + self.maneuver = None + self.message = None + self.combined_message = None diff --git a/sdk/maps/azure-maps-search/azure/maps/search/models/__init__.py b/sdk/maps/azure-maps-search/azure/maps/search/models/__init__.py index 28edc0322185..11712513be79 100644 --- a/sdk/maps/azure-maps-search/azure/maps/search/models/__init__.py +++ b/sdk/maps/azure-maps-search/azure/maps/search/models/__init__.py @@ -12,6 +12,8 @@ OperatingHoursRange, RoadUseType, PointOfInterestExtendedPostalCodes, + GeoJsonFeatureCollectionData, + GeoJsonGeometryCollectionData, ) from ._models import ( @@ -30,7 +32,10 @@ SearchAlongRouteOptions, SearchAddressBatchResult, ReverseSearchAddressResult, - ReverseSearchAddressBatchProcessResult + ReverseSearchAddressBatchProcessResult, + GeoJsonMultiLineStringData, + GeoJsonMultiPolygonData, + GeoJsonMultiPointData ) @@ -63,4 +68,9 @@ 'OperatingHoursRange', 'GeoJsonObject', 'PointOfInterestExtendedPostalCodes', + 'GeoJsonFeatureCollectionData', + 'GeoJsonGeometryCollectionData', + 'GeoJsonMultiLineStringData', + 'GeoJsonMultiPolygonData', + 'GeoJsonMultiPointData' ] diff --git a/sdk/maps/azure-maps-search/azure/maps/search/models/_models.py b/sdk/maps/azure-maps-search/azure/maps/search/models/_models.py index f2808ee58e39..194e2f2c6e8c 100644 --- a/sdk/maps/azure-maps-search/azure/maps/search/models/_models.py +++ b/sdk/maps/azure-maps-search/azure/maps/search/models/_models.py @@ -1237,3 +1237,76 @@ def __init__( ): self.summary = summary self.items = items + +class GeoJsonMultiLineStringData(object): + """GeoJsonMultiLineStringData. + + All required parameters must be populated in order to send to Azure. + + :param coordinates: Required. Coordinates for the ``GeoJson MultiLineString`` geometry. + :type coordinates: list[list[list[LatLon]]] + """ + + _validation = { + 'coordinates': {'required': True}, + } + + _attribute_map = { + 'coordinates': {'key': 'coordinates', 'type': '[[[LatLon]]]'}, + } + + def __init__( + self, + **kwargs + ): + super(GeoJsonMultiLineStringData, self).__init__(**kwargs) + self.coordinates = kwargs['coordinates'] + +class GeoJsonMultiPointData(object): + """Data contained by a ``GeoJson MultiPoint``. + + All required parameters must be populated in order to send to Azure. + + :param coordinates: Required. Coordinates for the ``GeoJson MultiPoint`` geometry. + :type coordinates: list[list[LatLon]] + """ + + _validation = { + 'coordinates': {'required': True}, + } + + _attribute_map = { + 'coordinates': {'key': 'coordinates', 'type': '[[LatLon]]'}, + } + + def __init__( + self, + **kwargs + ): + super(GeoJsonMultiPointData, self).__init__(**kwargs) + self.coordinates = kwargs['coordinates'] + +class GeoJsonMultiPolygonData(object): + """GeoJsonMultiPolygonData. + + All required parameters must be populated in order to send to Azure. + + :param coordinates: Required. Contains a list of valid ``GeoJSON Polygon`` objects. **Note** + that coordinates in GeoJSON are in x, y order (longitude, latitude). + :type coordinates: list[list[list[list[LatLon]]]] + """ + + _validation = { + 'coordinates': {'required': True}, + } + + _attribute_map = { + 'coordinates': {'key': 'coordinates', 'type': '[[[[LatLon]]]]'}, + } + + def __init__( + self, + **kwargs + ): + super(GeoJsonMultiPolygonData, self).__init__(**kwargs) + self.coordinates = kwargs['coordinates']