{-# 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.GetDevicePositionHistory
-- 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)
--
-- Retrieves the device position history from a tracker resource within a
-- specified range of time.
--
-- Device positions are deleted after 30 days.
--
-- This operation returns paginated results.
module Amazonka.Location.GetDevicePositionHistory
  ( -- * Creating a Request
    GetDevicePositionHistory (..),
    newGetDevicePositionHistory,

    -- * Request Lenses
    getDevicePositionHistory_nextToken,
    getDevicePositionHistory_endTimeExclusive,
    getDevicePositionHistory_startTimeInclusive,
    getDevicePositionHistory_deviceId,
    getDevicePositionHistory_trackerName,

    -- * Destructuring the Response
    GetDevicePositionHistoryResponse (..),
    newGetDevicePositionHistoryResponse,

    -- * Response Lenses
    getDevicePositionHistoryResponse_nextToken,
    getDevicePositionHistoryResponse_httpStatus,
    getDevicePositionHistoryResponse_devicePositions,
  )
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:/ 'newGetDevicePositionHistory' smart constructor.
data GetDevicePositionHistory = GetDevicePositionHistory'
  { -- | The pagination token specifying which page of results to return in the
    -- response. If no token is provided, the default page is the first page.
    --
    -- Default value: @null@
    GetDevicePositionHistory -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Specify the end time for the position history in
    -- <https://www.iso.org/iso-8601-date-and-time-format.html ISO 8601>
    -- format: @YYYY-MM-DDThh:mm:ss.sssZ@. By default, the value will be the
    -- time that the request is made.
    --
    -- Requirement:
    --
    -- -   The time specified for @EndTimeExclusive@ must be after the time for
    --     @StartTimeInclusive@.
    GetDevicePositionHistory -> Maybe POSIX
endTimeExclusive :: Prelude.Maybe Core.POSIX,
    -- | Specify the start time for the position history in
    -- <https://www.iso.org/iso-8601-date-and-time-format.html ISO 8601>
    -- format: @YYYY-MM-DDThh:mm:ss.sssZ@. By default, the value will be 24
    -- hours prior to the time that the request is made.
    --
    -- Requirement:
    --
    -- -   The time specified for @StartTimeInclusive@ must be before
    --     @EndTimeExclusive@.
    GetDevicePositionHistory -> Maybe POSIX
startTimeInclusive :: Prelude.Maybe Core.POSIX,
    -- | The device whose position history you want to retrieve.
    GetDevicePositionHistory -> Text
deviceId :: Prelude.Text,
    -- | The tracker resource receiving the request for the device position
    -- history.
    GetDevicePositionHistory -> Text
trackerName :: Prelude.Text
  }
  deriving (GetDevicePositionHistory -> GetDevicePositionHistory -> Bool
(GetDevicePositionHistory -> GetDevicePositionHistory -> Bool)
-> (GetDevicePositionHistory -> GetDevicePositionHistory -> Bool)
-> Eq GetDevicePositionHistory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDevicePositionHistory -> GetDevicePositionHistory -> Bool
$c/= :: GetDevicePositionHistory -> GetDevicePositionHistory -> Bool
== :: GetDevicePositionHistory -> GetDevicePositionHistory -> Bool
$c== :: GetDevicePositionHistory -> GetDevicePositionHistory -> Bool
Prelude.Eq, ReadPrec [GetDevicePositionHistory]
ReadPrec GetDevicePositionHistory
Int -> ReadS GetDevicePositionHistory
ReadS [GetDevicePositionHistory]
(Int -> ReadS GetDevicePositionHistory)
-> ReadS [GetDevicePositionHistory]
-> ReadPrec GetDevicePositionHistory
-> ReadPrec [GetDevicePositionHistory]
-> Read GetDevicePositionHistory
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDevicePositionHistory]
$creadListPrec :: ReadPrec [GetDevicePositionHistory]
readPrec :: ReadPrec GetDevicePositionHistory
$creadPrec :: ReadPrec GetDevicePositionHistory
readList :: ReadS [GetDevicePositionHistory]
$creadList :: ReadS [GetDevicePositionHistory]
readsPrec :: Int -> ReadS GetDevicePositionHistory
$creadsPrec :: Int -> ReadS GetDevicePositionHistory
Prelude.Read, Int -> GetDevicePositionHistory -> ShowS
[GetDevicePositionHistory] -> ShowS
GetDevicePositionHistory -> String
(Int -> GetDevicePositionHistory -> ShowS)
-> (GetDevicePositionHistory -> String)
-> ([GetDevicePositionHistory] -> ShowS)
-> Show GetDevicePositionHistory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDevicePositionHistory] -> ShowS
$cshowList :: [GetDevicePositionHistory] -> ShowS
show :: GetDevicePositionHistory -> String
$cshow :: GetDevicePositionHistory -> String
showsPrec :: Int -> GetDevicePositionHistory -> ShowS
$cshowsPrec :: Int -> GetDevicePositionHistory -> ShowS
Prelude.Show, (forall x.
 GetDevicePositionHistory -> Rep GetDevicePositionHistory x)
-> (forall x.
    Rep GetDevicePositionHistory x -> GetDevicePositionHistory)
-> Generic GetDevicePositionHistory
forall x.
Rep GetDevicePositionHistory x -> GetDevicePositionHistory
forall x.
GetDevicePositionHistory -> Rep GetDevicePositionHistory x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetDevicePositionHistory x -> GetDevicePositionHistory
$cfrom :: forall x.
GetDevicePositionHistory -> Rep GetDevicePositionHistory x
Prelude.Generic)

-- |
-- Create a value of 'GetDevicePositionHistory' 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:
--
-- 'nextToken', 'getDevicePositionHistory_nextToken' - The pagination token specifying which page of results to return in the
-- response. If no token is provided, the default page is the first page.
--
-- Default value: @null@
--
-- 'endTimeExclusive', 'getDevicePositionHistory_endTimeExclusive' - Specify the end time for the position history in
-- <https://www.iso.org/iso-8601-date-and-time-format.html ISO 8601>
-- format: @YYYY-MM-DDThh:mm:ss.sssZ@. By default, the value will be the
-- time that the request is made.
--
-- Requirement:
--
-- -   The time specified for @EndTimeExclusive@ must be after the time for
--     @StartTimeInclusive@.
--
-- 'startTimeInclusive', 'getDevicePositionHistory_startTimeInclusive' - Specify the start time for the position history in
-- <https://www.iso.org/iso-8601-date-and-time-format.html ISO 8601>
-- format: @YYYY-MM-DDThh:mm:ss.sssZ@. By default, the value will be 24
-- hours prior to the time that the request is made.
--
-- Requirement:
--
-- -   The time specified for @StartTimeInclusive@ must be before
--     @EndTimeExclusive@.
--
-- 'deviceId', 'getDevicePositionHistory_deviceId' - The device whose position history you want to retrieve.
--
-- 'trackerName', 'getDevicePositionHistory_trackerName' - The tracker resource receiving the request for the device position
-- history.
newGetDevicePositionHistory ::
  -- | 'deviceId'
  Prelude.Text ->
  -- | 'trackerName'
  Prelude.Text ->
  GetDevicePositionHistory
newGetDevicePositionHistory :: Text -> Text -> GetDevicePositionHistory
newGetDevicePositionHistory Text
pDeviceId_ Text
pTrackerName_ =
  GetDevicePositionHistory' :: Maybe Text
-> Maybe POSIX
-> Maybe POSIX
-> Text
-> Text
-> GetDevicePositionHistory
GetDevicePositionHistory'
    { $sel:nextToken:GetDevicePositionHistory' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endTimeExclusive:GetDevicePositionHistory' :: Maybe POSIX
endTimeExclusive = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:startTimeInclusive:GetDevicePositionHistory' :: Maybe POSIX
startTimeInclusive = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceId:GetDevicePositionHistory' :: Text
deviceId = Text
pDeviceId_,
      $sel:trackerName:GetDevicePositionHistory' :: Text
trackerName = Text
pTrackerName_
    }

-- | The pagination token specifying which page of results to return in the
-- response. If no token is provided, the default page is the first page.
--
-- Default value: @null@
getDevicePositionHistory_nextToken :: Lens.Lens' GetDevicePositionHistory (Prelude.Maybe Prelude.Text)
getDevicePositionHistory_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetDevicePositionHistory -> f GetDevicePositionHistory
getDevicePositionHistory_nextToken = (GetDevicePositionHistory -> Maybe Text)
-> (GetDevicePositionHistory
    -> Maybe Text -> GetDevicePositionHistory)
-> Lens
     GetDevicePositionHistory
     GetDevicePositionHistory
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevicePositionHistory' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetDevicePositionHistory' :: GetDevicePositionHistory -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetDevicePositionHistory
s@GetDevicePositionHistory' {} Maybe Text
a -> GetDevicePositionHistory
s {$sel:nextToken:GetDevicePositionHistory' :: Maybe Text
nextToken = Maybe Text
a} :: GetDevicePositionHistory)

-- | Specify the end time for the position history in
-- <https://www.iso.org/iso-8601-date-and-time-format.html ISO 8601>
-- format: @YYYY-MM-DDThh:mm:ss.sssZ@. By default, the value will be the
-- time that the request is made.
--
-- Requirement:
--
-- -   The time specified for @EndTimeExclusive@ must be after the time for
--     @StartTimeInclusive@.
getDevicePositionHistory_endTimeExclusive :: Lens.Lens' GetDevicePositionHistory (Prelude.Maybe Prelude.UTCTime)
getDevicePositionHistory_endTimeExclusive :: (Maybe UTCTime -> f (Maybe UTCTime))
-> GetDevicePositionHistory -> f GetDevicePositionHistory
getDevicePositionHistory_endTimeExclusive = (GetDevicePositionHistory -> Maybe POSIX)
-> (GetDevicePositionHistory
    -> Maybe POSIX -> GetDevicePositionHistory)
-> Lens
     GetDevicePositionHistory
     GetDevicePositionHistory
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevicePositionHistory' {Maybe POSIX
endTimeExclusive :: Maybe POSIX
$sel:endTimeExclusive:GetDevicePositionHistory' :: GetDevicePositionHistory -> Maybe POSIX
endTimeExclusive} -> Maybe POSIX
endTimeExclusive) (\s :: GetDevicePositionHistory
s@GetDevicePositionHistory' {} Maybe POSIX
a -> GetDevicePositionHistory
s {$sel:endTimeExclusive:GetDevicePositionHistory' :: Maybe POSIX
endTimeExclusive = Maybe POSIX
a} :: GetDevicePositionHistory) ((Maybe POSIX -> f (Maybe POSIX))
 -> GetDevicePositionHistory -> f GetDevicePositionHistory)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> GetDevicePositionHistory
-> f GetDevicePositionHistory
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

-- | Specify the start time for the position history in
-- <https://www.iso.org/iso-8601-date-and-time-format.html ISO 8601>
-- format: @YYYY-MM-DDThh:mm:ss.sssZ@. By default, the value will be 24
-- hours prior to the time that the request is made.
--
-- Requirement:
--
-- -   The time specified for @StartTimeInclusive@ must be before
--     @EndTimeExclusive@.
getDevicePositionHistory_startTimeInclusive :: Lens.Lens' GetDevicePositionHistory (Prelude.Maybe Prelude.UTCTime)
getDevicePositionHistory_startTimeInclusive :: (Maybe UTCTime -> f (Maybe UTCTime))
-> GetDevicePositionHistory -> f GetDevicePositionHistory
getDevicePositionHistory_startTimeInclusive = (GetDevicePositionHistory -> Maybe POSIX)
-> (GetDevicePositionHistory
    -> Maybe POSIX -> GetDevicePositionHistory)
-> Lens
     GetDevicePositionHistory
     GetDevicePositionHistory
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevicePositionHistory' {Maybe POSIX
startTimeInclusive :: Maybe POSIX
$sel:startTimeInclusive:GetDevicePositionHistory' :: GetDevicePositionHistory -> Maybe POSIX
startTimeInclusive} -> Maybe POSIX
startTimeInclusive) (\s :: GetDevicePositionHistory
s@GetDevicePositionHistory' {} Maybe POSIX
a -> GetDevicePositionHistory
s {$sel:startTimeInclusive:GetDevicePositionHistory' :: Maybe POSIX
startTimeInclusive = Maybe POSIX
a} :: GetDevicePositionHistory) ((Maybe POSIX -> f (Maybe POSIX))
 -> GetDevicePositionHistory -> f GetDevicePositionHistory)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> GetDevicePositionHistory
-> f GetDevicePositionHistory
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 device whose position history you want to retrieve.
getDevicePositionHistory_deviceId :: Lens.Lens' GetDevicePositionHistory Prelude.Text
getDevicePositionHistory_deviceId :: (Text -> f Text)
-> GetDevicePositionHistory -> f GetDevicePositionHistory
getDevicePositionHistory_deviceId = (GetDevicePositionHistory -> Text)
-> (GetDevicePositionHistory -> Text -> GetDevicePositionHistory)
-> Lens GetDevicePositionHistory GetDevicePositionHistory Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevicePositionHistory' {Text
deviceId :: Text
$sel:deviceId:GetDevicePositionHistory' :: GetDevicePositionHistory -> Text
deviceId} -> Text
deviceId) (\s :: GetDevicePositionHistory
s@GetDevicePositionHistory' {} Text
a -> GetDevicePositionHistory
s {$sel:deviceId:GetDevicePositionHistory' :: Text
deviceId = Text
a} :: GetDevicePositionHistory)

-- | The tracker resource receiving the request for the device position
-- history.
getDevicePositionHistory_trackerName :: Lens.Lens' GetDevicePositionHistory Prelude.Text
getDevicePositionHistory_trackerName :: (Text -> f Text)
-> GetDevicePositionHistory -> f GetDevicePositionHistory
getDevicePositionHistory_trackerName = (GetDevicePositionHistory -> Text)
-> (GetDevicePositionHistory -> Text -> GetDevicePositionHistory)
-> Lens GetDevicePositionHistory GetDevicePositionHistory Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevicePositionHistory' {Text
trackerName :: Text
$sel:trackerName:GetDevicePositionHistory' :: GetDevicePositionHistory -> Text
trackerName} -> Text
trackerName) (\s :: GetDevicePositionHistory
s@GetDevicePositionHistory' {} Text
a -> GetDevicePositionHistory
s {$sel:trackerName:GetDevicePositionHistory' :: Text
trackerName = Text
a} :: GetDevicePositionHistory)

instance Core.AWSPager GetDevicePositionHistory where
  page :: GetDevicePositionHistory
-> AWSResponse GetDevicePositionHistory
-> Maybe GetDevicePositionHistory
page GetDevicePositionHistory
rq AWSResponse GetDevicePositionHistory
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetDevicePositionHistory
GetDevicePositionHistoryResponse
rs
            GetDevicePositionHistoryResponse
-> Getting (First Text) GetDevicePositionHistoryResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetDevicePositionHistoryResponse
-> Const (First Text) GetDevicePositionHistoryResponse
Lens' GetDevicePositionHistoryResponse (Maybe Text)
getDevicePositionHistoryResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetDevicePositionHistoryResponse
 -> Const (First Text) GetDevicePositionHistoryResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetDevicePositionHistoryResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe GetDevicePositionHistory
forall a. Maybe a
Prelude.Nothing
    | [DevicePosition] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetDevicePositionHistory
GetDevicePositionHistoryResponse
rs
            GetDevicePositionHistoryResponse
-> Getting
     [DevicePosition] GetDevicePositionHistoryResponse [DevicePosition]
-> [DevicePosition]
forall s a. s -> Getting a s a -> a
Lens.^. Getting
  [DevicePosition] GetDevicePositionHistoryResponse [DevicePosition]
Lens' GetDevicePositionHistoryResponse [DevicePosition]
getDevicePositionHistoryResponse_devicePositions
        ) =
      Maybe GetDevicePositionHistory
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      GetDevicePositionHistory -> Maybe GetDevicePositionHistory
forall a. a -> Maybe a
Prelude.Just (GetDevicePositionHistory -> Maybe GetDevicePositionHistory)
-> GetDevicePositionHistory -> Maybe GetDevicePositionHistory
forall a b. (a -> b) -> a -> b
Prelude.$
        GetDevicePositionHistory
rq
          GetDevicePositionHistory
-> (GetDevicePositionHistory -> GetDevicePositionHistory)
-> GetDevicePositionHistory
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> GetDevicePositionHistory -> Identity GetDevicePositionHistory
Lens
  GetDevicePositionHistory
  GetDevicePositionHistory
  (Maybe Text)
  (Maybe Text)
getDevicePositionHistory_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> GetDevicePositionHistory -> Identity GetDevicePositionHistory)
-> Maybe Text
-> GetDevicePositionHistory
-> GetDevicePositionHistory
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetDevicePositionHistory
GetDevicePositionHistoryResponse
rs
          GetDevicePositionHistoryResponse
-> Getting (First Text) GetDevicePositionHistoryResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetDevicePositionHistoryResponse
-> Const (First Text) GetDevicePositionHistoryResponse
Lens' GetDevicePositionHistoryResponse (Maybe Text)
getDevicePositionHistoryResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetDevicePositionHistoryResponse
 -> Const (First Text) GetDevicePositionHistoryResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetDevicePositionHistoryResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest GetDevicePositionHistory where
  type
    AWSResponse GetDevicePositionHistory =
      GetDevicePositionHistoryResponse
  request :: GetDevicePositionHistory -> Request GetDevicePositionHistory
request = Service
-> GetDevicePositionHistory -> Request GetDevicePositionHistory
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDevicePositionHistory
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDevicePositionHistory)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetDevicePositionHistory))
-> Logger
-> Service
-> Proxy GetDevicePositionHistory
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDevicePositionHistory)))
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 ->
          Maybe Text
-> Int -> [DevicePosition] -> GetDevicePositionHistoryResponse
GetDevicePositionHistoryResponse'
            (Maybe Text
 -> Int -> [DevicePosition] -> GetDevicePositionHistoryResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Int -> [DevicePosition] -> GetDevicePositionHistoryResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either
  String
  (Int -> [DevicePosition] -> GetDevicePositionHistoryResponse)
-> Either String Int
-> Either
     String ([DevicePosition] -> GetDevicePositionHistoryResponse)
forall (f :: * -> *) a b. Applicative f => 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 ([DevicePosition] -> GetDevicePositionHistoryResponse)
-> Either String [DevicePosition]
-> Either String GetDevicePositionHistoryResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe [DevicePosition])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"DevicePositions"
                            Either String (Maybe [DevicePosition])
-> [DevicePosition] -> Either String [DevicePosition]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [DevicePosition]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable GetDevicePositionHistory

instance Prelude.NFData GetDevicePositionHistory

instance Core.ToHeaders GetDevicePositionHistory where
  toHeaders :: GetDevicePositionHistory -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetDevicePositionHistory -> 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 GetDevicePositionHistory where
  toJSON :: GetDevicePositionHistory -> Value
toJSON GetDevicePositionHistory' {Maybe Text
Maybe POSIX
Text
trackerName :: Text
deviceId :: Text
startTimeInclusive :: Maybe POSIX
endTimeExclusive :: Maybe POSIX
nextToken :: Maybe Text
$sel:trackerName:GetDevicePositionHistory' :: GetDevicePositionHistory -> Text
$sel:deviceId:GetDevicePositionHistory' :: GetDevicePositionHistory -> Text
$sel:startTimeInclusive:GetDevicePositionHistory' :: GetDevicePositionHistory -> Maybe POSIX
$sel:endTimeExclusive:GetDevicePositionHistory' :: GetDevicePositionHistory -> Maybe POSIX
$sel:nextToken:GetDevicePositionHistory' :: GetDevicePositionHistory -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"EndTimeExclusive" 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
endTimeExclusive,
            (Text
"StartTimeInclusive" 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
startTimeInclusive
          ]
      )

instance Core.ToPath GetDevicePositionHistory where
  toPath :: GetDevicePositionHistory -> ByteString
toPath GetDevicePositionHistory' {Maybe Text
Maybe POSIX
Text
trackerName :: Text
deviceId :: Text
startTimeInclusive :: Maybe POSIX
endTimeExclusive :: Maybe POSIX
nextToken :: Maybe Text
$sel:trackerName:GetDevicePositionHistory' :: GetDevicePositionHistory -> Text
$sel:deviceId:GetDevicePositionHistory' :: GetDevicePositionHistory -> Text
$sel:startTimeInclusive:GetDevicePositionHistory' :: GetDevicePositionHistory -> Maybe POSIX
$sel:endTimeExclusive:GetDevicePositionHistory' :: GetDevicePositionHistory -> Maybe POSIX
$sel:nextToken:GetDevicePositionHistory' :: GetDevicePositionHistory -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/tracking/v0/trackers/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
trackerName,
        ByteString
"/devices/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
deviceId,
        ByteString
"/list-positions"
      ]

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

-- | /See:/ 'newGetDevicePositionHistoryResponse' smart constructor.
data GetDevicePositionHistoryResponse = GetDevicePositionHistoryResponse'
  { -- | A pagination token indicating there are additional pages available. You
    -- can use the token in a following request to fetch the next set of
    -- results.
    GetDevicePositionHistoryResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetDevicePositionHistoryResponse -> Int
httpStatus :: Prelude.Int,
    -- | Contains the position history details for the requested device.
    GetDevicePositionHistoryResponse -> [DevicePosition]
devicePositions :: [DevicePosition]
  }
  deriving (GetDevicePositionHistoryResponse
-> GetDevicePositionHistoryResponse -> Bool
(GetDevicePositionHistoryResponse
 -> GetDevicePositionHistoryResponse -> Bool)
-> (GetDevicePositionHistoryResponse
    -> GetDevicePositionHistoryResponse -> Bool)
-> Eq GetDevicePositionHistoryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDevicePositionHistoryResponse
-> GetDevicePositionHistoryResponse -> Bool
$c/= :: GetDevicePositionHistoryResponse
-> GetDevicePositionHistoryResponse -> Bool
== :: GetDevicePositionHistoryResponse
-> GetDevicePositionHistoryResponse -> Bool
$c== :: GetDevicePositionHistoryResponse
-> GetDevicePositionHistoryResponse -> Bool
Prelude.Eq, Int -> GetDevicePositionHistoryResponse -> ShowS
[GetDevicePositionHistoryResponse] -> ShowS
GetDevicePositionHistoryResponse -> String
(Int -> GetDevicePositionHistoryResponse -> ShowS)
-> (GetDevicePositionHistoryResponse -> String)
-> ([GetDevicePositionHistoryResponse] -> ShowS)
-> Show GetDevicePositionHistoryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDevicePositionHistoryResponse] -> ShowS
$cshowList :: [GetDevicePositionHistoryResponse] -> ShowS
show :: GetDevicePositionHistoryResponse -> String
$cshow :: GetDevicePositionHistoryResponse -> String
showsPrec :: Int -> GetDevicePositionHistoryResponse -> ShowS
$cshowsPrec :: Int -> GetDevicePositionHistoryResponse -> ShowS
Prelude.Show, (forall x.
 GetDevicePositionHistoryResponse
 -> Rep GetDevicePositionHistoryResponse x)
-> (forall x.
    Rep GetDevicePositionHistoryResponse x
    -> GetDevicePositionHistoryResponse)
-> Generic GetDevicePositionHistoryResponse
forall x.
Rep GetDevicePositionHistoryResponse x
-> GetDevicePositionHistoryResponse
forall x.
GetDevicePositionHistoryResponse
-> Rep GetDevicePositionHistoryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetDevicePositionHistoryResponse x
-> GetDevicePositionHistoryResponse
$cfrom :: forall x.
GetDevicePositionHistoryResponse
-> Rep GetDevicePositionHistoryResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDevicePositionHistoryResponse' 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:
--
-- 'nextToken', 'getDevicePositionHistoryResponse_nextToken' - A pagination token indicating there are additional pages available. You
-- can use the token in a following request to fetch the next set of
-- results.
--
-- 'httpStatus', 'getDevicePositionHistoryResponse_httpStatus' - The response's http status code.
--
-- 'devicePositions', 'getDevicePositionHistoryResponse_devicePositions' - Contains the position history details for the requested device.
newGetDevicePositionHistoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDevicePositionHistoryResponse
newGetDevicePositionHistoryResponse :: Int -> GetDevicePositionHistoryResponse
newGetDevicePositionHistoryResponse Int
pHttpStatus_ =
  GetDevicePositionHistoryResponse' :: Maybe Text
-> Int -> [DevicePosition] -> GetDevicePositionHistoryResponse
GetDevicePositionHistoryResponse'
    { $sel:nextToken:GetDevicePositionHistoryResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDevicePositionHistoryResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:devicePositions:GetDevicePositionHistoryResponse' :: [DevicePosition]
devicePositions = [DevicePosition]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A pagination token indicating there are additional pages available. You
-- can use the token in a following request to fetch the next set of
-- results.
getDevicePositionHistoryResponse_nextToken :: Lens.Lens' GetDevicePositionHistoryResponse (Prelude.Maybe Prelude.Text)
getDevicePositionHistoryResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetDevicePositionHistoryResponse
-> f GetDevicePositionHistoryResponse
getDevicePositionHistoryResponse_nextToken = (GetDevicePositionHistoryResponse -> Maybe Text)
-> (GetDevicePositionHistoryResponse
    -> Maybe Text -> GetDevicePositionHistoryResponse)
-> Lens' GetDevicePositionHistoryResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevicePositionHistoryResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetDevicePositionHistoryResponse' :: GetDevicePositionHistoryResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetDevicePositionHistoryResponse
s@GetDevicePositionHistoryResponse' {} Maybe Text
a -> GetDevicePositionHistoryResponse
s {$sel:nextToken:GetDevicePositionHistoryResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetDevicePositionHistoryResponse)

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

-- | Contains the position history details for the requested device.
getDevicePositionHistoryResponse_devicePositions :: Lens.Lens' GetDevicePositionHistoryResponse [DevicePosition]
getDevicePositionHistoryResponse_devicePositions :: ([DevicePosition] -> f [DevicePosition])
-> GetDevicePositionHistoryResponse
-> f GetDevicePositionHistoryResponse
getDevicePositionHistoryResponse_devicePositions = (GetDevicePositionHistoryResponse -> [DevicePosition])
-> (GetDevicePositionHistoryResponse
    -> [DevicePosition] -> GetDevicePositionHistoryResponse)
-> Lens' GetDevicePositionHistoryResponse [DevicePosition]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevicePositionHistoryResponse' {[DevicePosition]
devicePositions :: [DevicePosition]
$sel:devicePositions:GetDevicePositionHistoryResponse' :: GetDevicePositionHistoryResponse -> [DevicePosition]
devicePositions} -> [DevicePosition]
devicePositions) (\s :: GetDevicePositionHistoryResponse
s@GetDevicePositionHistoryResponse' {} [DevicePosition]
a -> GetDevicePositionHistoryResponse
s {$sel:devicePositions:GetDevicePositionHistoryResponse' :: [DevicePosition]
devicePositions = [DevicePosition]
a} :: GetDevicePositionHistoryResponse) (([DevicePosition] -> f [DevicePosition])
 -> GetDevicePositionHistoryResponse
 -> f GetDevicePositionHistoryResponse)
-> (([DevicePosition] -> f [DevicePosition])
    -> [DevicePosition] -> f [DevicePosition])
-> ([DevicePosition] -> f [DevicePosition])
-> GetDevicePositionHistoryResponse
-> f GetDevicePositionHistoryResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([DevicePosition] -> f [DevicePosition])
-> [DevicePosition] -> f [DevicePosition]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Prelude.NFData
    GetDevicePositionHistoryResponse