{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Location.CalculateRoute
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html Calculates a route>
-- given the following required parameters: @DeparturePostiton@ and
-- @DestinationPosition@. Requires that you first
-- <https://docs.aws.amazon.com/location-routes/latest/APIReference/API_CreateRouteCalculator.html create a route calculator resource>
--
-- By default, a request that doesn\'t specify a departure time uses the
-- best time of day to travel with the best traffic conditions when
-- calculating the route.
--
-- Additional options include:
--
-- -   <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#departure-time Specifying a departure time>
--     using either @DepartureTime@ or @DepartureNow@. This calculates a
--     route based on predictive traffic data at the given time.
--
--     You can\'t specify both @DepartureTime@ and @DepartureNow@ in a
--     single request. Specifying both parameters returns an error message.
--
-- -   <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#travel-mode Specifying a travel mode>
--     using TravelMode. This lets you specify an additional route
--     preference such as @CarModeOptions@ if traveling by @Car@, or
--     @TruckModeOptions@ if traveling by @Truck@.
module Amazonka.Location.CalculateRoute
  ( -- * Creating a Request
    CalculateRoute (..),
    newCalculateRoute,

    -- * Request Lenses
    calculateRoute_distanceUnit,
    calculateRoute_truckModeOptions,
    calculateRoute_waypointPositions,
    calculateRoute_includeLegGeometry,
    calculateRoute_departNow,
    calculateRoute_travelMode,
    calculateRoute_carModeOptions,
    calculateRoute_departureTime,
    calculateRoute_calculatorName,
    calculateRoute_departurePosition,
    calculateRoute_destinationPosition,

    -- * Destructuring the Response
    CalculateRouteResponse (..),
    newCalculateRouteResponse,

    -- * Response Lenses
    calculateRouteResponse_httpStatus,
    calculateRouteResponse_legs,
    calculateRouteResponse_summary,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Location.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCalculateRoute' smart constructor.
data CalculateRoute = CalculateRoute'
  { -- | Set the unit system to specify the distance.
    --
    -- Default Value: @Kilometers@
    CalculateRoute -> Maybe DistanceUnit
distanceUnit :: Prelude.Maybe DistanceUnit,
    -- | Specifies route preferences when traveling by @Truck@, such as avoiding
    -- routes that use ferries or tolls, and truck specifications to consider
    -- when choosing an optimal road.
    --
    -- Requirements: @TravelMode@ must be specified as @Truck@.
    CalculateRoute -> Maybe CalculateRouteTruckModeOptions
truckModeOptions :: Prelude.Maybe CalculateRouteTruckModeOptions,
    -- | Specifies an ordered list of up to 23 intermediate positions to include
    -- along a route between the departure position and destination position.
    --
    -- -   For example, from the @DeparturePosition@ @[-123.115, 49.285]@, the
    --     route follows the order that the waypoint positions are given
    --     @[[-122.757, 49.0021],[-122.349, 47.620]]@
    --
    -- If you specify a waypoint position that\'s not located on a road, Amazon
    -- Location
    -- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road moves the position to the nearest road>.
    --
    -- Specifying more than 23 waypoints returns a @400 ValidationException@
    -- error.
    --
    -- If Esri is the provider for your route calculator, specifying a route
    -- that is longer than 400 km returns a @400 RoutesValidationException@
    -- error.
    --
    -- Valid Values: @[-180 to 180,-90 to 90]@
    CalculateRoute -> Maybe [Sensitive (NonEmpty Double)]
waypointPositions :: Prelude.Maybe [Core.Sensitive (Prelude.NonEmpty Prelude.Double)],
    -- | Set to include the geometry details in the result for each path between
    -- a pair of positions.
    --
    -- Default Value: @false@
    --
    -- Valid Values: @false@ | @true@
    CalculateRoute -> Maybe Bool
includeLegGeometry :: Prelude.Maybe Prelude.Bool,
    -- | Sets the time of departure as the current time. Uses the current time to
    -- calculate a route. Otherwise, the best time of day to travel with the
    -- best traffic conditions is used to calculate the route.
    --
    -- Default Value: @false@
    --
    -- Valid Values: @false@ | @true@
    CalculateRoute -> Maybe Bool
departNow :: Prelude.Maybe Prelude.Bool,
    -- | Specifies the mode of transport when calculating a route. Used in
    -- estimating the speed of travel and road compatibility.
    --
    -- The @TravelMode@ you specify determines how you specify route
    -- preferences:
    --
    -- -   If traveling by @Car@ use the @CarModeOptions@ parameter.
    --
    -- -   If traveling by @Truck@ use the @TruckModeOptions@ parameter.
    --
    -- Default Value: @Car@
    CalculateRoute -> Maybe TravelMode
travelMode :: Prelude.Maybe TravelMode,
    -- | Specifies route preferences when traveling by @Car@, such as avoiding
    -- routes that use ferries or tolls.
    --
    -- Requirements: @TravelMode@ must be specified as @Car@.
    CalculateRoute -> Maybe CalculateRouteCarModeOptions
carModeOptions :: Prelude.Maybe CalculateRouteCarModeOptions,
    -- | Specifies the desired time of departure. Uses the given time to
    -- calculate a route. Otherwise, the best time of day to travel with the
    -- best traffic conditions is used to calculate the route.
    --
    -- Setting a departure time in the past returns a @400 ValidationException@
    -- error.
    --
    -- -   In <https://www.iso.org/iso-8601-date-and-time-format.html ISO 8601>
    --     format: @YYYY-MM-DDThh:mm:ss.sssZ@. For example,
    --     @2020–07-2T12:15:20.000Z+01:00@
    CalculateRoute -> Maybe POSIX
departureTime :: Prelude.Maybe Core.POSIX,
    -- | The name of the route calculator resource that you want to use to
    -- calculate a route.
    CalculateRoute -> Text
calculatorName :: Prelude.Text,
    -- | The start position for the route. Defined in
    -- <https://earth-info.nga.mil/GandG/wgs84/index.html WGS 84> format:
    -- @[longitude, latitude]@.
    --
    -- -   For example, @[-123.115, 49.285]@
    --
    -- If you specify a departure that\'s not located on a road, Amazon
    -- Location
    -- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road moves the position to the nearest road>.
    -- If Esri is the provider for your route calculator, specifying a route
    -- that is longer than 400 km returns a @400 RoutesValidationException@
    -- error.
    --
    -- Valid Values: @[-180 to 180,-90 to 90]@
    CalculateRoute -> Sensitive (NonEmpty Double)
departurePosition :: Core.Sensitive (Prelude.NonEmpty Prelude.Double),
    -- | The finish position for the route. Defined in
    -- <https://earth-info.nga.mil/GandG/wgs84/index.html WGS 84> format:
    -- @[longitude, latitude]@.
    --
    -- -   For example, @[-122.339, 47.615]@
    --
    -- If you specify a destination that\'s not located on a road, Amazon
    -- Location
    -- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road moves the position to the nearest road>.
    --
    -- Valid Values: @[-180 to 180,-90 to 90]@
    CalculateRoute -> Sensitive (NonEmpty Double)
destinationPosition :: Core.Sensitive (Prelude.NonEmpty Prelude.Double)
  }
  deriving (CalculateRoute -> CalculateRoute -> Bool
(CalculateRoute -> CalculateRoute -> Bool)
-> (CalculateRoute -> CalculateRoute -> Bool) -> Eq CalculateRoute
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CalculateRoute -> CalculateRoute -> Bool
$c/= :: CalculateRoute -> CalculateRoute -> Bool
== :: CalculateRoute -> CalculateRoute -> Bool
$c== :: CalculateRoute -> CalculateRoute -> Bool
Prelude.Eq, Int -> CalculateRoute -> ShowS
[CalculateRoute] -> ShowS
CalculateRoute -> String
(Int -> CalculateRoute -> ShowS)
-> (CalculateRoute -> String)
-> ([CalculateRoute] -> ShowS)
-> Show CalculateRoute
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CalculateRoute] -> ShowS
$cshowList :: [CalculateRoute] -> ShowS
show :: CalculateRoute -> String
$cshow :: CalculateRoute -> String
showsPrec :: Int -> CalculateRoute -> ShowS
$cshowsPrec :: Int -> CalculateRoute -> ShowS
Prelude.Show, (forall x. CalculateRoute -> Rep CalculateRoute x)
-> (forall x. Rep CalculateRoute x -> CalculateRoute)
-> Generic CalculateRoute
forall x. Rep CalculateRoute x -> CalculateRoute
forall x. CalculateRoute -> Rep CalculateRoute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CalculateRoute x -> CalculateRoute
$cfrom :: forall x. CalculateRoute -> Rep CalculateRoute x
Prelude.Generic)

-- |
-- Create a value of 'CalculateRoute' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'distanceUnit', 'calculateRoute_distanceUnit' - Set the unit system to specify the distance.
--
-- Default Value: @Kilometers@
--
-- 'truckModeOptions', 'calculateRoute_truckModeOptions' - Specifies route preferences when traveling by @Truck@, such as avoiding
-- routes that use ferries or tolls, and truck specifications to consider
-- when choosing an optimal road.
--
-- Requirements: @TravelMode@ must be specified as @Truck@.
--
-- 'waypointPositions', 'calculateRoute_waypointPositions' - Specifies an ordered list of up to 23 intermediate positions to include
-- along a route between the departure position and destination position.
--
-- -   For example, from the @DeparturePosition@ @[-123.115, 49.285]@, the
--     route follows the order that the waypoint positions are given
--     @[[-122.757, 49.0021],[-122.349, 47.620]]@
--
-- If you specify a waypoint position that\'s not located on a road, Amazon
-- Location
-- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road moves the position to the nearest road>.
--
-- Specifying more than 23 waypoints returns a @400 ValidationException@
-- error.
--
-- If Esri is the provider for your route calculator, specifying a route
-- that is longer than 400 km returns a @400 RoutesValidationException@
-- error.
--
-- Valid Values: @[-180 to 180,-90 to 90]@
--
-- 'includeLegGeometry', 'calculateRoute_includeLegGeometry' - Set to include the geometry details in the result for each path between
-- a pair of positions.
--
-- Default Value: @false@
--
-- Valid Values: @false@ | @true@
--
-- 'departNow', 'calculateRoute_departNow' - Sets the time of departure as the current time. Uses the current time to
-- calculate a route. Otherwise, the best time of day to travel with the
-- best traffic conditions is used to calculate the route.
--
-- Default Value: @false@
--
-- Valid Values: @false@ | @true@
--
-- 'travelMode', 'calculateRoute_travelMode' - Specifies the mode of transport when calculating a route. Used in
-- estimating the speed of travel and road compatibility.
--
-- The @TravelMode@ you specify determines how you specify route
-- preferences:
--
-- -   If traveling by @Car@ use the @CarModeOptions@ parameter.
--
-- -   If traveling by @Truck@ use the @TruckModeOptions@ parameter.
--
-- Default Value: @Car@
--
-- 'carModeOptions', 'calculateRoute_carModeOptions' - Specifies route preferences when traveling by @Car@, such as avoiding
-- routes that use ferries or tolls.
--
-- Requirements: @TravelMode@ must be specified as @Car@.
--
-- 'departureTime', 'calculateRoute_departureTime' - Specifies the desired time of departure. Uses the given time to
-- calculate a route. Otherwise, the best time of day to travel with the
-- best traffic conditions is used to calculate the route.
--
-- Setting a departure time in the past returns a @400 ValidationException@
-- error.
--
-- -   In <https://www.iso.org/iso-8601-date-and-time-format.html ISO 8601>
--     format: @YYYY-MM-DDThh:mm:ss.sssZ@. For example,
--     @2020–07-2T12:15:20.000Z+01:00@
--
-- 'calculatorName', 'calculateRoute_calculatorName' - The name of the route calculator resource that you want to use to
-- calculate a route.
--
-- 'departurePosition', 'calculateRoute_departurePosition' - The start position for the route. Defined in
-- <https://earth-info.nga.mil/GandG/wgs84/index.html WGS 84> format:
-- @[longitude, latitude]@.
--
-- -   For example, @[-123.115, 49.285]@
--
-- If you specify a departure that\'s not located on a road, Amazon
-- Location
-- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road moves the position to the nearest road>.
-- If Esri is the provider for your route calculator, specifying a route
-- that is longer than 400 km returns a @400 RoutesValidationException@
-- error.
--
-- Valid Values: @[-180 to 180,-90 to 90]@
--
-- 'destinationPosition', 'calculateRoute_destinationPosition' - The finish position for the route. Defined in
-- <https://earth-info.nga.mil/GandG/wgs84/index.html WGS 84> format:
-- @[longitude, latitude]@.
--
-- -   For example, @[-122.339, 47.615]@
--
-- If you specify a destination that\'s not located on a road, Amazon
-- Location
-- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road moves the position to the nearest road>.
--
-- Valid Values: @[-180 to 180,-90 to 90]@
newCalculateRoute ::
  -- | 'calculatorName'
  Prelude.Text ->
  -- | 'departurePosition'
  Prelude.NonEmpty Prelude.Double ->
  -- | 'destinationPosition'
  Prelude.NonEmpty Prelude.Double ->
  CalculateRoute
newCalculateRoute :: Text -> NonEmpty Double -> NonEmpty Double -> CalculateRoute
newCalculateRoute
  Text
pCalculatorName_
  NonEmpty Double
pDeparturePosition_
  NonEmpty Double
pDestinationPosition_ =
    CalculateRoute' :: Maybe DistanceUnit
-> Maybe CalculateRouteTruckModeOptions
-> Maybe [Sensitive (NonEmpty Double)]
-> Maybe Bool
-> Maybe Bool
-> Maybe TravelMode
-> Maybe CalculateRouteCarModeOptions
-> Maybe POSIX
-> Text
-> Sensitive (NonEmpty Double)
-> Sensitive (NonEmpty Double)
-> CalculateRoute
CalculateRoute'
      { $sel:distanceUnit:CalculateRoute' :: Maybe DistanceUnit
distanceUnit = Maybe DistanceUnit
forall a. Maybe a
Prelude.Nothing,
        $sel:truckModeOptions:CalculateRoute' :: Maybe CalculateRouteTruckModeOptions
truckModeOptions = Maybe CalculateRouteTruckModeOptions
forall a. Maybe a
Prelude.Nothing,
        $sel:waypointPositions:CalculateRoute' :: Maybe [Sensitive (NonEmpty Double)]
waypointPositions = Maybe [Sensitive (NonEmpty Double)]
forall a. Maybe a
Prelude.Nothing,
        $sel:includeLegGeometry:CalculateRoute' :: Maybe Bool
includeLegGeometry = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:departNow:CalculateRoute' :: Maybe Bool
departNow = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:travelMode:CalculateRoute' :: Maybe TravelMode
travelMode = Maybe TravelMode
forall a. Maybe a
Prelude.Nothing,
        $sel:carModeOptions:CalculateRoute' :: Maybe CalculateRouteCarModeOptions
carModeOptions = Maybe CalculateRouteCarModeOptions
forall a. Maybe a
Prelude.Nothing,
        $sel:departureTime:CalculateRoute' :: Maybe POSIX
departureTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
        $sel:calculatorName:CalculateRoute' :: Text
calculatorName = Text
pCalculatorName_,
        $sel:departurePosition:CalculateRoute' :: Sensitive (NonEmpty Double)
departurePosition =
          Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged
     (Sensitive (NonEmpty Double))
     (Identity (Sensitive (NonEmpty Double)))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged (NonEmpty Double) (Identity (NonEmpty Double))
 -> Tagged
      (Sensitive (NonEmpty Double))
      (Identity (Sensitive (NonEmpty Double))))
-> (Tagged (NonEmpty Double) (Identity (NonEmpty Double))
    -> Tagged (NonEmpty Double) (Identity (NonEmpty Double)))
-> Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged
     (Sensitive (NonEmpty Double))
     (Identity (Sensitive (NonEmpty Double)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged (NonEmpty Double) (Identity (NonEmpty Double))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
            (Tagged (NonEmpty Double) (Identity (NonEmpty Double))
 -> Tagged
      (Sensitive (NonEmpty Double))
      (Identity (Sensitive (NonEmpty Double))))
-> NonEmpty Double -> Sensitive (NonEmpty Double)
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Double
pDeparturePosition_,
        $sel:destinationPosition:CalculateRoute' :: Sensitive (NonEmpty Double)
destinationPosition =
          Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged
     (Sensitive (NonEmpty Double))
     (Identity (Sensitive (NonEmpty Double)))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged (NonEmpty Double) (Identity (NonEmpty Double))
 -> Tagged
      (Sensitive (NonEmpty Double))
      (Identity (Sensitive (NonEmpty Double))))
-> (Tagged (NonEmpty Double) (Identity (NonEmpty Double))
    -> Tagged (NonEmpty Double) (Identity (NonEmpty Double)))
-> Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged
     (Sensitive (NonEmpty Double))
     (Identity (Sensitive (NonEmpty Double)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged (NonEmpty Double) (Identity (NonEmpty Double))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
            (Tagged (NonEmpty Double) (Identity (NonEmpty Double))
 -> Tagged
      (Sensitive (NonEmpty Double))
      (Identity (Sensitive (NonEmpty Double))))
-> NonEmpty Double -> Sensitive (NonEmpty Double)
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Double
pDestinationPosition_
      }

-- | Set the unit system to specify the distance.
--
-- Default Value: @Kilometers@
calculateRoute_distanceUnit :: Lens.Lens' CalculateRoute (Prelude.Maybe DistanceUnit)
calculateRoute_distanceUnit :: (Maybe DistanceUnit -> f (Maybe DistanceUnit))
-> CalculateRoute -> f CalculateRoute
calculateRoute_distanceUnit = (CalculateRoute -> Maybe DistanceUnit)
-> (CalculateRoute -> Maybe DistanceUnit -> CalculateRoute)
-> Lens
     CalculateRoute
     CalculateRoute
     (Maybe DistanceUnit)
     (Maybe DistanceUnit)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRoute' {Maybe DistanceUnit
distanceUnit :: Maybe DistanceUnit
$sel:distanceUnit:CalculateRoute' :: CalculateRoute -> Maybe DistanceUnit
distanceUnit} -> Maybe DistanceUnit
distanceUnit) (\s :: CalculateRoute
s@CalculateRoute' {} Maybe DistanceUnit
a -> CalculateRoute
s {$sel:distanceUnit:CalculateRoute' :: Maybe DistanceUnit
distanceUnit = Maybe DistanceUnit
a} :: CalculateRoute)

-- | Specifies route preferences when traveling by @Truck@, such as avoiding
-- routes that use ferries or tolls, and truck specifications to consider
-- when choosing an optimal road.
--
-- Requirements: @TravelMode@ must be specified as @Truck@.
calculateRoute_truckModeOptions :: Lens.Lens' CalculateRoute (Prelude.Maybe CalculateRouteTruckModeOptions)
calculateRoute_truckModeOptions :: (Maybe CalculateRouteTruckModeOptions
 -> f (Maybe CalculateRouteTruckModeOptions))
-> CalculateRoute -> f CalculateRoute
calculateRoute_truckModeOptions = (CalculateRoute -> Maybe CalculateRouteTruckModeOptions)
-> (CalculateRoute
    -> Maybe CalculateRouteTruckModeOptions -> CalculateRoute)
-> Lens
     CalculateRoute
     CalculateRoute
     (Maybe CalculateRouteTruckModeOptions)
     (Maybe CalculateRouteTruckModeOptions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRoute' {Maybe CalculateRouteTruckModeOptions
truckModeOptions :: Maybe CalculateRouteTruckModeOptions
$sel:truckModeOptions:CalculateRoute' :: CalculateRoute -> Maybe CalculateRouteTruckModeOptions
truckModeOptions} -> Maybe CalculateRouteTruckModeOptions
truckModeOptions) (\s :: CalculateRoute
s@CalculateRoute' {} Maybe CalculateRouteTruckModeOptions
a -> CalculateRoute
s {$sel:truckModeOptions:CalculateRoute' :: Maybe CalculateRouteTruckModeOptions
truckModeOptions = Maybe CalculateRouteTruckModeOptions
a} :: CalculateRoute)

-- | Specifies an ordered list of up to 23 intermediate positions to include
-- along a route between the departure position and destination position.
--
-- -   For example, from the @DeparturePosition@ @[-123.115, 49.285]@, the
--     route follows the order that the waypoint positions are given
--     @[[-122.757, 49.0021],[-122.349, 47.620]]@
--
-- If you specify a waypoint position that\'s not located on a road, Amazon
-- Location
-- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road moves the position to the nearest road>.
--
-- Specifying more than 23 waypoints returns a @400 ValidationException@
-- error.
--
-- If Esri is the provider for your route calculator, specifying a route
-- that is longer than 400 km returns a @400 RoutesValidationException@
-- error.
--
-- Valid Values: @[-180 to 180,-90 to 90]@
calculateRoute_waypointPositions :: Lens.Lens' CalculateRoute (Prelude.Maybe [Prelude.NonEmpty Prelude.Double])
calculateRoute_waypointPositions :: (Maybe [NonEmpty Double] -> f (Maybe [NonEmpty Double]))
-> CalculateRoute -> f CalculateRoute
calculateRoute_waypointPositions = (CalculateRoute -> Maybe [Sensitive (NonEmpty Double)])
-> (CalculateRoute
    -> Maybe [Sensitive (NonEmpty Double)] -> CalculateRoute)
-> Lens
     CalculateRoute
     CalculateRoute
     (Maybe [Sensitive (NonEmpty Double)])
     (Maybe [Sensitive (NonEmpty Double)])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRoute' {Maybe [Sensitive (NonEmpty Double)]
waypointPositions :: Maybe [Sensitive (NonEmpty Double)]
$sel:waypointPositions:CalculateRoute' :: CalculateRoute -> Maybe [Sensitive (NonEmpty Double)]
waypointPositions} -> Maybe [Sensitive (NonEmpty Double)]
waypointPositions) (\s :: CalculateRoute
s@CalculateRoute' {} Maybe [Sensitive (NonEmpty Double)]
a -> CalculateRoute
s {$sel:waypointPositions:CalculateRoute' :: Maybe [Sensitive (NonEmpty Double)]
waypointPositions = Maybe [Sensitive (NonEmpty Double)]
a} :: CalculateRoute) ((Maybe [Sensitive (NonEmpty Double)]
  -> f (Maybe [Sensitive (NonEmpty Double)]))
 -> CalculateRoute -> f CalculateRoute)
-> ((Maybe [NonEmpty Double] -> f (Maybe [NonEmpty Double]))
    -> Maybe [Sensitive (NonEmpty Double)]
    -> f (Maybe [Sensitive (NonEmpty Double)]))
-> (Maybe [NonEmpty Double] -> f (Maybe [NonEmpty Double]))
-> CalculateRoute
-> f CalculateRoute
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [Sensitive (NonEmpty Double)]
  [Sensitive (NonEmpty Double)]
  [NonEmpty Double]
  [NonEmpty Double]
-> Iso
     (Maybe [Sensitive (NonEmpty Double)])
     (Maybe [Sensitive (NonEmpty Double)])
     (Maybe [NonEmpty Double])
     (Maybe [NonEmpty Double])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [Sensitive (NonEmpty Double)]
  [Sensitive (NonEmpty Double)]
  [NonEmpty Double]
  [NonEmpty Double]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Set to include the geometry details in the result for each path between
-- a pair of positions.
--
-- Default Value: @false@
--
-- Valid Values: @false@ | @true@
calculateRoute_includeLegGeometry :: Lens.Lens' CalculateRoute (Prelude.Maybe Prelude.Bool)
calculateRoute_includeLegGeometry :: (Maybe Bool -> f (Maybe Bool))
-> CalculateRoute -> f CalculateRoute
calculateRoute_includeLegGeometry = (CalculateRoute -> Maybe Bool)
-> (CalculateRoute -> Maybe Bool -> CalculateRoute)
-> Lens CalculateRoute CalculateRoute (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRoute' {Maybe Bool
includeLegGeometry :: Maybe Bool
$sel:includeLegGeometry:CalculateRoute' :: CalculateRoute -> Maybe Bool
includeLegGeometry} -> Maybe Bool
includeLegGeometry) (\s :: CalculateRoute
s@CalculateRoute' {} Maybe Bool
a -> CalculateRoute
s {$sel:includeLegGeometry:CalculateRoute' :: Maybe Bool
includeLegGeometry = Maybe Bool
a} :: CalculateRoute)

-- | Sets the time of departure as the current time. Uses the current time to
-- calculate a route. Otherwise, the best time of day to travel with the
-- best traffic conditions is used to calculate the route.
--
-- Default Value: @false@
--
-- Valid Values: @false@ | @true@
calculateRoute_departNow :: Lens.Lens' CalculateRoute (Prelude.Maybe Prelude.Bool)
calculateRoute_departNow :: (Maybe Bool -> f (Maybe Bool))
-> CalculateRoute -> f CalculateRoute
calculateRoute_departNow = (CalculateRoute -> Maybe Bool)
-> (CalculateRoute -> Maybe Bool -> CalculateRoute)
-> Lens CalculateRoute CalculateRoute (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRoute' {Maybe Bool
departNow :: Maybe Bool
$sel:departNow:CalculateRoute' :: CalculateRoute -> Maybe Bool
departNow} -> Maybe Bool
departNow) (\s :: CalculateRoute
s@CalculateRoute' {} Maybe Bool
a -> CalculateRoute
s {$sel:departNow:CalculateRoute' :: Maybe Bool
departNow = Maybe Bool
a} :: CalculateRoute)

-- | Specifies the mode of transport when calculating a route. Used in
-- estimating the speed of travel and road compatibility.
--
-- The @TravelMode@ you specify determines how you specify route
-- preferences:
--
-- -   If traveling by @Car@ use the @CarModeOptions@ parameter.
--
-- -   If traveling by @Truck@ use the @TruckModeOptions@ parameter.
--
-- Default Value: @Car@
calculateRoute_travelMode :: Lens.Lens' CalculateRoute (Prelude.Maybe TravelMode)
calculateRoute_travelMode :: (Maybe TravelMode -> f (Maybe TravelMode))
-> CalculateRoute -> f CalculateRoute
calculateRoute_travelMode = (CalculateRoute -> Maybe TravelMode)
-> (CalculateRoute -> Maybe TravelMode -> CalculateRoute)
-> Lens
     CalculateRoute CalculateRoute (Maybe TravelMode) (Maybe TravelMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRoute' {Maybe TravelMode
travelMode :: Maybe TravelMode
$sel:travelMode:CalculateRoute' :: CalculateRoute -> Maybe TravelMode
travelMode} -> Maybe TravelMode
travelMode) (\s :: CalculateRoute
s@CalculateRoute' {} Maybe TravelMode
a -> CalculateRoute
s {$sel:travelMode:CalculateRoute' :: Maybe TravelMode
travelMode = Maybe TravelMode
a} :: CalculateRoute)

-- | Specifies route preferences when traveling by @Car@, such as avoiding
-- routes that use ferries or tolls.
--
-- Requirements: @TravelMode@ must be specified as @Car@.
calculateRoute_carModeOptions :: Lens.Lens' CalculateRoute (Prelude.Maybe CalculateRouteCarModeOptions)
calculateRoute_carModeOptions :: (Maybe CalculateRouteCarModeOptions
 -> f (Maybe CalculateRouteCarModeOptions))
-> CalculateRoute -> f CalculateRoute
calculateRoute_carModeOptions = (CalculateRoute -> Maybe CalculateRouteCarModeOptions)
-> (CalculateRoute
    -> Maybe CalculateRouteCarModeOptions -> CalculateRoute)
-> Lens
     CalculateRoute
     CalculateRoute
     (Maybe CalculateRouteCarModeOptions)
     (Maybe CalculateRouteCarModeOptions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRoute' {Maybe CalculateRouteCarModeOptions
carModeOptions :: Maybe CalculateRouteCarModeOptions
$sel:carModeOptions:CalculateRoute' :: CalculateRoute -> Maybe CalculateRouteCarModeOptions
carModeOptions} -> Maybe CalculateRouteCarModeOptions
carModeOptions) (\s :: CalculateRoute
s@CalculateRoute' {} Maybe CalculateRouteCarModeOptions
a -> CalculateRoute
s {$sel:carModeOptions:CalculateRoute' :: Maybe CalculateRouteCarModeOptions
carModeOptions = Maybe CalculateRouteCarModeOptions
a} :: CalculateRoute)

-- | Specifies the desired time of departure. Uses the given time to
-- calculate a route. Otherwise, the best time of day to travel with the
-- best traffic conditions is used to calculate the route.
--
-- Setting a departure time in the past returns a @400 ValidationException@
-- error.
--
-- -   In <https://www.iso.org/iso-8601-date-and-time-format.html ISO 8601>
--     format: @YYYY-MM-DDThh:mm:ss.sssZ@. For example,
--     @2020–07-2T12:15:20.000Z+01:00@
calculateRoute_departureTime :: Lens.Lens' CalculateRoute (Prelude.Maybe Prelude.UTCTime)
calculateRoute_departureTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> CalculateRoute -> f CalculateRoute
calculateRoute_departureTime = (CalculateRoute -> Maybe POSIX)
-> (CalculateRoute -> Maybe POSIX -> CalculateRoute)
-> Lens CalculateRoute CalculateRoute (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRoute' {Maybe POSIX
departureTime :: Maybe POSIX
$sel:departureTime:CalculateRoute' :: CalculateRoute -> Maybe POSIX
departureTime} -> Maybe POSIX
departureTime) (\s :: CalculateRoute
s@CalculateRoute' {} Maybe POSIX
a -> CalculateRoute
s {$sel:departureTime:CalculateRoute' :: Maybe POSIX
departureTime = Maybe POSIX
a} :: CalculateRoute) ((Maybe POSIX -> f (Maybe POSIX))
 -> CalculateRoute -> f CalculateRoute)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> CalculateRoute
-> f CalculateRoute
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The name of the route calculator resource that you want to use to
-- calculate a route.
calculateRoute_calculatorName :: Lens.Lens' CalculateRoute Prelude.Text
calculateRoute_calculatorName :: (Text -> f Text) -> CalculateRoute -> f CalculateRoute
calculateRoute_calculatorName = (CalculateRoute -> Text)
-> (CalculateRoute -> Text -> CalculateRoute)
-> Lens CalculateRoute CalculateRoute Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRoute' {Text
calculatorName :: Text
$sel:calculatorName:CalculateRoute' :: CalculateRoute -> Text
calculatorName} -> Text
calculatorName) (\s :: CalculateRoute
s@CalculateRoute' {} Text
a -> CalculateRoute
s {$sel:calculatorName:CalculateRoute' :: Text
calculatorName = Text
a} :: CalculateRoute)

-- | The start position for the route. Defined in
-- <https://earth-info.nga.mil/GandG/wgs84/index.html WGS 84> format:
-- @[longitude, latitude]@.
--
-- -   For example, @[-123.115, 49.285]@
--
-- If you specify a departure that\'s not located on a road, Amazon
-- Location
-- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road moves the position to the nearest road>.
-- If Esri is the provider for your route calculator, specifying a route
-- that is longer than 400 km returns a @400 RoutesValidationException@
-- error.
--
-- Valid Values: @[-180 to 180,-90 to 90]@
calculateRoute_departurePosition :: Lens.Lens' CalculateRoute (Prelude.NonEmpty Prelude.Double)
calculateRoute_departurePosition :: (NonEmpty Double -> f (NonEmpty Double))
-> CalculateRoute -> f CalculateRoute
calculateRoute_departurePosition = (CalculateRoute -> Sensitive (NonEmpty Double))
-> (CalculateRoute
    -> Sensitive (NonEmpty Double) -> CalculateRoute)
-> Lens
     CalculateRoute
     CalculateRoute
     (Sensitive (NonEmpty Double))
     (Sensitive (NonEmpty Double))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRoute' {Sensitive (NonEmpty Double)
departurePosition :: Sensitive (NonEmpty Double)
$sel:departurePosition:CalculateRoute' :: CalculateRoute -> Sensitive (NonEmpty Double)
departurePosition} -> Sensitive (NonEmpty Double)
departurePosition) (\s :: CalculateRoute
s@CalculateRoute' {} Sensitive (NonEmpty Double)
a -> CalculateRoute
s {$sel:departurePosition:CalculateRoute' :: Sensitive (NonEmpty Double)
departurePosition = Sensitive (NonEmpty Double)
a} :: CalculateRoute) ((Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
 -> CalculateRoute -> f CalculateRoute)
-> ((NonEmpty Double -> f (NonEmpty Double))
    -> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
-> (NonEmpty Double -> f (NonEmpty Double))
-> CalculateRoute
-> f CalculateRoute
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Double -> f (NonEmpty Double))
-> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double))
forall a. Iso' (Sensitive a) a
Core._Sensitive ((NonEmpty Double -> f (NonEmpty Double))
 -> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
-> ((NonEmpty Double -> f (NonEmpty Double))
    -> NonEmpty Double -> f (NonEmpty Double))
-> (NonEmpty Double -> f (NonEmpty Double))
-> Sensitive (NonEmpty Double)
-> f (Sensitive (NonEmpty Double))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Double -> f (NonEmpty Double))
-> NonEmpty Double -> f (NonEmpty Double)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The finish position for the route. Defined in
-- <https://earth-info.nga.mil/GandG/wgs84/index.html WGS 84> format:
-- @[longitude, latitude]@.
--
-- -   For example, @[-122.339, 47.615]@
--
-- If you specify a destination that\'s not located on a road, Amazon
-- Location
-- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road moves the position to the nearest road>.
--
-- Valid Values: @[-180 to 180,-90 to 90]@
calculateRoute_destinationPosition :: Lens.Lens' CalculateRoute (Prelude.NonEmpty Prelude.Double)
calculateRoute_destinationPosition :: (NonEmpty Double -> f (NonEmpty Double))
-> CalculateRoute -> f CalculateRoute
calculateRoute_destinationPosition = (CalculateRoute -> Sensitive (NonEmpty Double))
-> (CalculateRoute
    -> Sensitive (NonEmpty Double) -> CalculateRoute)
-> Lens
     CalculateRoute
     CalculateRoute
     (Sensitive (NonEmpty Double))
     (Sensitive (NonEmpty Double))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRoute' {Sensitive (NonEmpty Double)
destinationPosition :: Sensitive (NonEmpty Double)
$sel:destinationPosition:CalculateRoute' :: CalculateRoute -> Sensitive (NonEmpty Double)
destinationPosition} -> Sensitive (NonEmpty Double)
destinationPosition) (\s :: CalculateRoute
s@CalculateRoute' {} Sensitive (NonEmpty Double)
a -> CalculateRoute
s {$sel:destinationPosition:CalculateRoute' :: Sensitive (NonEmpty Double)
destinationPosition = Sensitive (NonEmpty Double)
a} :: CalculateRoute) ((Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
 -> CalculateRoute -> f CalculateRoute)
-> ((NonEmpty Double -> f (NonEmpty Double))
    -> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
-> (NonEmpty Double -> f (NonEmpty Double))
-> CalculateRoute
-> f CalculateRoute
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Double -> f (NonEmpty Double))
-> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double))
forall a. Iso' (Sensitive a) a
Core._Sensitive ((NonEmpty Double -> f (NonEmpty Double))
 -> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
-> ((NonEmpty Double -> f (NonEmpty Double))
    -> NonEmpty Double -> f (NonEmpty Double))
-> (NonEmpty Double -> f (NonEmpty Double))
-> Sensitive (NonEmpty Double)
-> f (Sensitive (NonEmpty Double))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Double -> f (NonEmpty Double))
-> NonEmpty Double -> f (NonEmpty Double)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest CalculateRoute where
  type
    AWSResponse CalculateRoute =
      CalculateRouteResponse
  request :: CalculateRoute -> Request CalculateRoute
request = Service -> CalculateRoute -> Request CalculateRoute
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CalculateRoute
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CalculateRoute)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CalculateRoute))
-> Logger
-> Service
-> Proxy CalculateRoute
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CalculateRoute)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> [Leg] -> CalculateRouteSummary -> CalculateRouteResponse
CalculateRouteResponse'
            (Int -> [Leg] -> CalculateRouteSummary -> CalculateRouteResponse)
-> Either String Int
-> Either
     String ([Leg] -> CalculateRouteSummary -> CalculateRouteResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either
  String ([Leg] -> CalculateRouteSummary -> CalculateRouteResponse)
-> Either String [Leg]
-> Either String (CalculateRouteSummary -> CalculateRouteResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe [Leg])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Legs" Either String (Maybe [Leg]) -> [Leg] -> Either String [Leg]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Leg]
forall a. Monoid a => a
Prelude.mempty)
            Either String (CalculateRouteSummary -> CalculateRouteResponse)
-> Either String CalculateRouteSummary
-> Either String CalculateRouteResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String CalculateRouteSummary
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"Summary")
      )

instance Prelude.Hashable CalculateRoute

instance Prelude.NFData CalculateRoute

instance Core.ToHeaders CalculateRoute where
  toHeaders :: CalculateRoute -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CalculateRoute -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CalculateRoute where
  toJSON :: CalculateRoute -> Value
toJSON CalculateRoute' {Maybe Bool
Maybe [Sensitive (NonEmpty Double)]
Maybe POSIX
Maybe CalculateRouteCarModeOptions
Maybe DistanceUnit
Maybe TravelMode
Maybe CalculateRouteTruckModeOptions
Text
Sensitive (NonEmpty Double)
destinationPosition :: Sensitive (NonEmpty Double)
departurePosition :: Sensitive (NonEmpty Double)
calculatorName :: Text
departureTime :: Maybe POSIX
carModeOptions :: Maybe CalculateRouteCarModeOptions
travelMode :: Maybe TravelMode
departNow :: Maybe Bool
includeLegGeometry :: Maybe Bool
waypointPositions :: Maybe [Sensitive (NonEmpty Double)]
truckModeOptions :: Maybe CalculateRouteTruckModeOptions
distanceUnit :: Maybe DistanceUnit
$sel:destinationPosition:CalculateRoute' :: CalculateRoute -> Sensitive (NonEmpty Double)
$sel:departurePosition:CalculateRoute' :: CalculateRoute -> Sensitive (NonEmpty Double)
$sel:calculatorName:CalculateRoute' :: CalculateRoute -> Text
$sel:departureTime:CalculateRoute' :: CalculateRoute -> Maybe POSIX
$sel:carModeOptions:CalculateRoute' :: CalculateRoute -> Maybe CalculateRouteCarModeOptions
$sel:travelMode:CalculateRoute' :: CalculateRoute -> Maybe TravelMode
$sel:departNow:CalculateRoute' :: CalculateRoute -> Maybe Bool
$sel:includeLegGeometry:CalculateRoute' :: CalculateRoute -> Maybe Bool
$sel:waypointPositions:CalculateRoute' :: CalculateRoute -> Maybe [Sensitive (NonEmpty Double)]
$sel:truckModeOptions:CalculateRoute' :: CalculateRoute -> Maybe CalculateRouteTruckModeOptions
$sel:distanceUnit:CalculateRoute' :: CalculateRoute -> Maybe DistanceUnit
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DistanceUnit" Text -> DistanceUnit -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DistanceUnit -> Pair) -> Maybe DistanceUnit -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DistanceUnit
distanceUnit,
            (Text
"TruckModeOptions" Text -> CalculateRouteTruckModeOptions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CalculateRouteTruckModeOptions -> Pair)
-> Maybe CalculateRouteTruckModeOptions -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CalculateRouteTruckModeOptions
truckModeOptions,
            (Text
"WaypointPositions" Text -> [Sensitive (NonEmpty Double)] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Sensitive (NonEmpty Double)] -> Pair)
-> Maybe [Sensitive (NonEmpty Double)] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Sensitive (NonEmpty Double)]
waypointPositions,
            (Text
"IncludeLegGeometry" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
includeLegGeometry,
            (Text
"DepartNow" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
departNow,
            (Text
"TravelMode" Text -> TravelMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TravelMode -> Pair) -> Maybe TravelMode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TravelMode
travelMode,
            (Text
"CarModeOptions" Text -> CalculateRouteCarModeOptions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CalculateRouteCarModeOptions -> Pair)
-> Maybe CalculateRouteCarModeOptions -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CalculateRouteCarModeOptions
carModeOptions,
            (Text
"DepartureTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
departureTime,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"DeparturePosition" Text -> Sensitive (NonEmpty Double) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive (NonEmpty Double)
departurePosition),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"DestinationPosition" Text -> Sensitive (NonEmpty Double) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive (NonEmpty Double)
destinationPosition)
          ]
      )

instance Core.ToPath CalculateRoute where
  toPath :: CalculateRoute -> ByteString
toPath CalculateRoute' {Maybe Bool
Maybe [Sensitive (NonEmpty Double)]
Maybe POSIX
Maybe CalculateRouteCarModeOptions
Maybe DistanceUnit
Maybe TravelMode
Maybe CalculateRouteTruckModeOptions
Text
Sensitive (NonEmpty Double)
destinationPosition :: Sensitive (NonEmpty Double)
departurePosition :: Sensitive (NonEmpty Double)
calculatorName :: Text
departureTime :: Maybe POSIX
carModeOptions :: Maybe CalculateRouteCarModeOptions
travelMode :: Maybe TravelMode
departNow :: Maybe Bool
includeLegGeometry :: Maybe Bool
waypointPositions :: Maybe [Sensitive (NonEmpty Double)]
truckModeOptions :: Maybe CalculateRouteTruckModeOptions
distanceUnit :: Maybe DistanceUnit
$sel:destinationPosition:CalculateRoute' :: CalculateRoute -> Sensitive (NonEmpty Double)
$sel:departurePosition:CalculateRoute' :: CalculateRoute -> Sensitive (NonEmpty Double)
$sel:calculatorName:CalculateRoute' :: CalculateRoute -> Text
$sel:departureTime:CalculateRoute' :: CalculateRoute -> Maybe POSIX
$sel:carModeOptions:CalculateRoute' :: CalculateRoute -> Maybe CalculateRouteCarModeOptions
$sel:travelMode:CalculateRoute' :: CalculateRoute -> Maybe TravelMode
$sel:departNow:CalculateRoute' :: CalculateRoute -> Maybe Bool
$sel:includeLegGeometry:CalculateRoute' :: CalculateRoute -> Maybe Bool
$sel:waypointPositions:CalculateRoute' :: CalculateRoute -> Maybe [Sensitive (NonEmpty Double)]
$sel:truckModeOptions:CalculateRoute' :: CalculateRoute -> Maybe CalculateRouteTruckModeOptions
$sel:distanceUnit:CalculateRoute' :: CalculateRoute -> Maybe DistanceUnit
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/routes/v0/calculators/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
calculatorName,
        ByteString
"/calculate/route"
      ]

instance Core.ToQuery CalculateRoute where
  toQuery :: CalculateRoute -> QueryString
toQuery = QueryString -> CalculateRoute -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | Returns the result of the route calculation. Metadata includes legs and
-- route summary.
--
-- /See:/ 'newCalculateRouteResponse' smart constructor.
data CalculateRouteResponse = CalculateRouteResponse'
  { -- | The response's http status code.
    CalculateRouteResponse -> Int
httpStatus :: Prelude.Int,
    -- | Contains details about each path between a pair of positions included
    -- along a route such as: @StartPosition@, @EndPosition@, @Distance@,
    -- @DurationSeconds@, @Geometry@, and @Steps@. The number of legs returned
    -- corresponds to one fewer than the total number of positions in the
    -- request.
    --
    -- For example, a route with a departure position and destination position
    -- returns one leg with the positions
    -- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road snapped to a nearby road>:
    --
    -- -   The @StartPosition@ is the departure position.
    --
    -- -   The @EndPosition@ is the destination position.
    --
    -- A route with a waypoint between the departure and destination position
    -- returns two legs with the positions snapped to a nearby road:
    --
    -- -   Leg 1: The @StartPosition@ is the departure position . The
    --     @EndPosition@ is the waypoint positon.
    --
    -- -   Leg 2: The @StartPosition@ is the waypoint position. The
    --     @EndPosition@ is the destination position.
    CalculateRouteResponse -> [Leg]
legs :: [Leg],
    -- | Contains information about the whole route, such as: @RouteBBox@,
    -- @DataSource@, @Distance@, @DistanceUnit@, and @DurationSeconds@.
    CalculateRouteResponse -> CalculateRouteSummary
summary :: CalculateRouteSummary
  }
  deriving (CalculateRouteResponse -> CalculateRouteResponse -> Bool
(CalculateRouteResponse -> CalculateRouteResponse -> Bool)
-> (CalculateRouteResponse -> CalculateRouteResponse -> Bool)
-> Eq CalculateRouteResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CalculateRouteResponse -> CalculateRouteResponse -> Bool
$c/= :: CalculateRouteResponse -> CalculateRouteResponse -> Bool
== :: CalculateRouteResponse -> CalculateRouteResponse -> Bool
$c== :: CalculateRouteResponse -> CalculateRouteResponse -> Bool
Prelude.Eq, Int -> CalculateRouteResponse -> ShowS
[CalculateRouteResponse] -> ShowS
CalculateRouteResponse -> String
(Int -> CalculateRouteResponse -> ShowS)
-> (CalculateRouteResponse -> String)
-> ([CalculateRouteResponse] -> ShowS)
-> Show CalculateRouteResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CalculateRouteResponse] -> ShowS
$cshowList :: [CalculateRouteResponse] -> ShowS
show :: CalculateRouteResponse -> String
$cshow :: CalculateRouteResponse -> String
showsPrec :: Int -> CalculateRouteResponse -> ShowS
$cshowsPrec :: Int -> CalculateRouteResponse -> ShowS
Prelude.Show, (forall x. CalculateRouteResponse -> Rep CalculateRouteResponse x)
-> (forall x.
    Rep CalculateRouteResponse x -> CalculateRouteResponse)
-> Generic CalculateRouteResponse
forall x. Rep CalculateRouteResponse x -> CalculateRouteResponse
forall x. CalculateRouteResponse -> Rep CalculateRouteResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CalculateRouteResponse x -> CalculateRouteResponse
$cfrom :: forall x. CalculateRouteResponse -> Rep CalculateRouteResponse x
Prelude.Generic)

-- |
-- Create a value of 'CalculateRouteResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'httpStatus', 'calculateRouteResponse_httpStatus' - The response's http status code.
--
-- 'legs', 'calculateRouteResponse_legs' - Contains details about each path between a pair of positions included
-- along a route such as: @StartPosition@, @EndPosition@, @Distance@,
-- @DurationSeconds@, @Geometry@, and @Steps@. The number of legs returned
-- corresponds to one fewer than the total number of positions in the
-- request.
--
-- For example, a route with a departure position and destination position
-- returns one leg with the positions
-- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road snapped to a nearby road>:
--
-- -   The @StartPosition@ is the departure position.
--
-- -   The @EndPosition@ is the destination position.
--
-- A route with a waypoint between the departure and destination position
-- returns two legs with the positions snapped to a nearby road:
--
-- -   Leg 1: The @StartPosition@ is the departure position . The
--     @EndPosition@ is the waypoint positon.
--
-- -   Leg 2: The @StartPosition@ is the waypoint position. The
--     @EndPosition@ is the destination position.
--
-- 'summary', 'calculateRouteResponse_summary' - Contains information about the whole route, such as: @RouteBBox@,
-- @DataSource@, @Distance@, @DistanceUnit@, and @DurationSeconds@.
newCalculateRouteResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'summary'
  CalculateRouteSummary ->
  CalculateRouteResponse
newCalculateRouteResponse :: Int -> CalculateRouteSummary -> CalculateRouteResponse
newCalculateRouteResponse Int
pHttpStatus_ CalculateRouteSummary
pSummary_ =
  CalculateRouteResponse' :: Int -> [Leg] -> CalculateRouteSummary -> CalculateRouteResponse
CalculateRouteResponse'
    { $sel:httpStatus:CalculateRouteResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:legs:CalculateRouteResponse' :: [Leg]
legs = [Leg]
forall a. Monoid a => a
Prelude.mempty,
      $sel:summary:CalculateRouteResponse' :: CalculateRouteSummary
summary = CalculateRouteSummary
pSummary_
    }

-- | The response's http status code.
calculateRouteResponse_httpStatus :: Lens.Lens' CalculateRouteResponse Prelude.Int
calculateRouteResponse_httpStatus :: (Int -> f Int)
-> CalculateRouteResponse -> f CalculateRouteResponse
calculateRouteResponse_httpStatus = (CalculateRouteResponse -> Int)
-> (CalculateRouteResponse -> Int -> CalculateRouteResponse)
-> Lens CalculateRouteResponse CalculateRouteResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRouteResponse' {Int
httpStatus :: Int
$sel:httpStatus:CalculateRouteResponse' :: CalculateRouteResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CalculateRouteResponse
s@CalculateRouteResponse' {} Int
a -> CalculateRouteResponse
s {$sel:httpStatus:CalculateRouteResponse' :: Int
httpStatus = Int
a} :: CalculateRouteResponse)

-- | Contains details about each path between a pair of positions included
-- along a route such as: @StartPosition@, @EndPosition@, @Distance@,
-- @DurationSeconds@, @Geometry@, and @Steps@. The number of legs returned
-- corresponds to one fewer than the total number of positions in the
-- request.
--
-- For example, a route with a departure position and destination position
-- returns one leg with the positions
-- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road snapped to a nearby road>:
--
-- -   The @StartPosition@ is the departure position.
--
-- -   The @EndPosition@ is the destination position.
--
-- A route with a waypoint between the departure and destination position
-- returns two legs with the positions snapped to a nearby road:
--
-- -   Leg 1: The @StartPosition@ is the departure position . The
--     @EndPosition@ is the waypoint positon.
--
-- -   Leg 2: The @StartPosition@ is the waypoint position. The
--     @EndPosition@ is the destination position.
calculateRouteResponse_legs :: Lens.Lens' CalculateRouteResponse [Leg]
calculateRouteResponse_legs :: ([Leg] -> f [Leg])
-> CalculateRouteResponse -> f CalculateRouteResponse
calculateRouteResponse_legs = (CalculateRouteResponse -> [Leg])
-> (CalculateRouteResponse -> [Leg] -> CalculateRouteResponse)
-> Lens CalculateRouteResponse CalculateRouteResponse [Leg] [Leg]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRouteResponse' {[Leg]
legs :: [Leg]
$sel:legs:CalculateRouteResponse' :: CalculateRouteResponse -> [Leg]
legs} -> [Leg]
legs) (\s :: CalculateRouteResponse
s@CalculateRouteResponse' {} [Leg]
a -> CalculateRouteResponse
s {$sel:legs:CalculateRouteResponse' :: [Leg]
legs = [Leg]
a} :: CalculateRouteResponse) (([Leg] -> f [Leg])
 -> CalculateRouteResponse -> f CalculateRouteResponse)
-> (([Leg] -> f [Leg]) -> [Leg] -> f [Leg])
-> ([Leg] -> f [Leg])
-> CalculateRouteResponse
-> f CalculateRouteResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Leg] -> f [Leg]) -> [Leg] -> f [Leg]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Contains information about the whole route, such as: @RouteBBox@,
-- @DataSource@, @Distance@, @DistanceUnit@, and @DurationSeconds@.
calculateRouteResponse_summary :: Lens.Lens' CalculateRouteResponse CalculateRouteSummary
calculateRouteResponse_summary :: (CalculateRouteSummary -> f CalculateRouteSummary)
-> CalculateRouteResponse -> f CalculateRouteResponse
calculateRouteResponse_summary = (CalculateRouteResponse -> CalculateRouteSummary)
-> (CalculateRouteResponse
    -> CalculateRouteSummary -> CalculateRouteResponse)
-> Lens
     CalculateRouteResponse
     CalculateRouteResponse
     CalculateRouteSummary
     CalculateRouteSummary
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRouteResponse' {CalculateRouteSummary
summary :: CalculateRouteSummary
$sel:summary:CalculateRouteResponse' :: CalculateRouteResponse -> CalculateRouteSummary
summary} -> CalculateRouteSummary
summary) (\s :: CalculateRouteResponse
s@CalculateRouteResponse' {} CalculateRouteSummary
a -> CalculateRouteResponse
s {$sel:summary:CalculateRouteResponse' :: CalculateRouteSummary
summary = CalculateRouteSummary
a} :: CalculateRouteResponse)

instance Prelude.NFData CalculateRouteResponse