{-# 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 #-}
module Amazonka.Location.BatchGetDevicePosition
(
BatchGetDevicePosition (..),
newBatchGetDevicePosition,
batchGetDevicePosition_deviceIds,
batchGetDevicePosition_trackerName,
BatchGetDevicePositionResponse (..),
newBatchGetDevicePositionResponse,
batchGetDevicePositionResponse_httpStatus,
batchGetDevicePositionResponse_devicePositions,
batchGetDevicePositionResponse_errors,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Location.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data BatchGetDevicePosition = BatchGetDevicePosition'
{
BatchGetDevicePosition -> NonEmpty Text
deviceIds :: Prelude.NonEmpty Prelude.Text,
BatchGetDevicePosition -> Text
trackerName :: Prelude.Text
}
deriving (BatchGetDevicePosition -> BatchGetDevicePosition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetDevicePosition -> BatchGetDevicePosition -> Bool
$c/= :: BatchGetDevicePosition -> BatchGetDevicePosition -> Bool
== :: BatchGetDevicePosition -> BatchGetDevicePosition -> Bool
$c== :: BatchGetDevicePosition -> BatchGetDevicePosition -> Bool
Prelude.Eq, ReadPrec [BatchGetDevicePosition]
ReadPrec BatchGetDevicePosition
Int -> ReadS BatchGetDevicePosition
ReadS [BatchGetDevicePosition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetDevicePosition]
$creadListPrec :: ReadPrec [BatchGetDevicePosition]
readPrec :: ReadPrec BatchGetDevicePosition
$creadPrec :: ReadPrec BatchGetDevicePosition
readList :: ReadS [BatchGetDevicePosition]
$creadList :: ReadS [BatchGetDevicePosition]
readsPrec :: Int -> ReadS BatchGetDevicePosition
$creadsPrec :: Int -> ReadS BatchGetDevicePosition
Prelude.Read, Int -> BatchGetDevicePosition -> ShowS
[BatchGetDevicePosition] -> ShowS
BatchGetDevicePosition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetDevicePosition] -> ShowS
$cshowList :: [BatchGetDevicePosition] -> ShowS
show :: BatchGetDevicePosition -> String
$cshow :: BatchGetDevicePosition -> String
showsPrec :: Int -> BatchGetDevicePosition -> ShowS
$cshowsPrec :: Int -> BatchGetDevicePosition -> ShowS
Prelude.Show, forall x. Rep BatchGetDevicePosition x -> BatchGetDevicePosition
forall x. BatchGetDevicePosition -> Rep BatchGetDevicePosition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchGetDevicePosition x -> BatchGetDevicePosition
$cfrom :: forall x. BatchGetDevicePosition -> Rep BatchGetDevicePosition x
Prelude.Generic)
newBatchGetDevicePosition ::
Prelude.NonEmpty Prelude.Text ->
Prelude.Text ->
BatchGetDevicePosition
newBatchGetDevicePosition :: NonEmpty Text -> Text -> BatchGetDevicePosition
newBatchGetDevicePosition NonEmpty Text
pDeviceIds_ Text
pTrackerName_ =
BatchGetDevicePosition'
{ $sel:deviceIds:BatchGetDevicePosition' :: NonEmpty Text
deviceIds =
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pDeviceIds_,
$sel:trackerName:BatchGetDevicePosition' :: Text
trackerName = Text
pTrackerName_
}
batchGetDevicePosition_deviceIds :: Lens.Lens' BatchGetDevicePosition (Prelude.NonEmpty Prelude.Text)
batchGetDevicePosition_deviceIds :: Lens' BatchGetDevicePosition (NonEmpty Text)
batchGetDevicePosition_deviceIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetDevicePosition' {NonEmpty Text
deviceIds :: NonEmpty Text
$sel:deviceIds:BatchGetDevicePosition' :: BatchGetDevicePosition -> NonEmpty Text
deviceIds} -> NonEmpty Text
deviceIds) (\s :: BatchGetDevicePosition
s@BatchGetDevicePosition' {} NonEmpty Text
a -> BatchGetDevicePosition
s {$sel:deviceIds:BatchGetDevicePosition' :: NonEmpty Text
deviceIds = NonEmpty Text
a} :: BatchGetDevicePosition) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
batchGetDevicePosition_trackerName :: Lens.Lens' BatchGetDevicePosition Prelude.Text
batchGetDevicePosition_trackerName :: Lens' BatchGetDevicePosition Text
batchGetDevicePosition_trackerName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetDevicePosition' {Text
trackerName :: Text
$sel:trackerName:BatchGetDevicePosition' :: BatchGetDevicePosition -> Text
trackerName} -> Text
trackerName) (\s :: BatchGetDevicePosition
s@BatchGetDevicePosition' {} Text
a -> BatchGetDevicePosition
s {$sel:trackerName:BatchGetDevicePosition' :: Text
trackerName = Text
a} :: BatchGetDevicePosition)
instance Core.AWSRequest BatchGetDevicePosition where
type
AWSResponse BatchGetDevicePosition =
BatchGetDevicePositionResponse
request :: (Service -> Service)
-> BatchGetDevicePosition -> Request BatchGetDevicePosition
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy BatchGetDevicePosition
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse BatchGetDevicePosition)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Int
-> [DevicePosition]
-> [BatchGetDevicePositionError]
-> BatchGetDevicePositionResponse
BatchGetDevicePositionResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"DevicePositions"
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Errors" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable BatchGetDevicePosition where
hashWithSalt :: Int -> BatchGetDevicePosition -> Int
hashWithSalt Int
_salt BatchGetDevicePosition' {NonEmpty Text
Text
trackerName :: Text
deviceIds :: NonEmpty Text
$sel:trackerName:BatchGetDevicePosition' :: BatchGetDevicePosition -> Text
$sel:deviceIds:BatchGetDevicePosition' :: BatchGetDevicePosition -> NonEmpty Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
deviceIds
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
trackerName
instance Prelude.NFData BatchGetDevicePosition where
rnf :: BatchGetDevicePosition -> ()
rnf BatchGetDevicePosition' {NonEmpty Text
Text
trackerName :: Text
deviceIds :: NonEmpty Text
$sel:trackerName:BatchGetDevicePosition' :: BatchGetDevicePosition -> Text
$sel:deviceIds:BatchGetDevicePosition' :: BatchGetDevicePosition -> NonEmpty Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
deviceIds
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
trackerName
instance Data.ToHeaders BatchGetDevicePosition where
toHeaders :: BatchGetDevicePosition -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON BatchGetDevicePosition where
toJSON :: BatchGetDevicePosition -> Value
toJSON BatchGetDevicePosition' {NonEmpty Text
Text
trackerName :: Text
deviceIds :: NonEmpty Text
$sel:trackerName:BatchGetDevicePosition' :: BatchGetDevicePosition -> Text
$sel:deviceIds:BatchGetDevicePosition' :: BatchGetDevicePosition -> NonEmpty Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[forall a. a -> Maybe a
Prelude.Just (Key
"DeviceIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
deviceIds)]
)
instance Data.ToPath BatchGetDevicePosition where
toPath :: BatchGetDevicePosition -> ByteString
toPath BatchGetDevicePosition' {NonEmpty Text
Text
trackerName :: Text
deviceIds :: NonEmpty Text
$sel:trackerName:BatchGetDevicePosition' :: BatchGetDevicePosition -> Text
$sel:deviceIds:BatchGetDevicePosition' :: BatchGetDevicePosition -> NonEmpty Text
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/tracking/v0/trackers/",
forall a. ToByteString a => a -> ByteString
Data.toBS Text
trackerName,
ByteString
"/get-positions"
]
instance Data.ToQuery BatchGetDevicePosition where
toQuery :: BatchGetDevicePosition -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data BatchGetDevicePositionResponse = BatchGetDevicePositionResponse'
{
BatchGetDevicePositionResponse -> Int
httpStatus :: Prelude.Int,
BatchGetDevicePositionResponse -> [DevicePosition]
devicePositions :: [DevicePosition],
BatchGetDevicePositionResponse -> [BatchGetDevicePositionError]
errors :: [BatchGetDevicePositionError]
}
deriving (BatchGetDevicePositionResponse
-> BatchGetDevicePositionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetDevicePositionResponse
-> BatchGetDevicePositionResponse -> Bool
$c/= :: BatchGetDevicePositionResponse
-> BatchGetDevicePositionResponse -> Bool
== :: BatchGetDevicePositionResponse
-> BatchGetDevicePositionResponse -> Bool
$c== :: BatchGetDevicePositionResponse
-> BatchGetDevicePositionResponse -> Bool
Prelude.Eq, Int -> BatchGetDevicePositionResponse -> ShowS
[BatchGetDevicePositionResponse] -> ShowS
BatchGetDevicePositionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetDevicePositionResponse] -> ShowS
$cshowList :: [BatchGetDevicePositionResponse] -> ShowS
show :: BatchGetDevicePositionResponse -> String
$cshow :: BatchGetDevicePositionResponse -> String
showsPrec :: Int -> BatchGetDevicePositionResponse -> ShowS
$cshowsPrec :: Int -> BatchGetDevicePositionResponse -> ShowS
Prelude.Show, forall x.
Rep BatchGetDevicePositionResponse x
-> BatchGetDevicePositionResponse
forall x.
BatchGetDevicePositionResponse
-> Rep BatchGetDevicePositionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchGetDevicePositionResponse x
-> BatchGetDevicePositionResponse
$cfrom :: forall x.
BatchGetDevicePositionResponse
-> Rep BatchGetDevicePositionResponse x
Prelude.Generic)
newBatchGetDevicePositionResponse ::
Prelude.Int ->
BatchGetDevicePositionResponse
newBatchGetDevicePositionResponse :: Int -> BatchGetDevicePositionResponse
newBatchGetDevicePositionResponse Int
pHttpStatus_ =
BatchGetDevicePositionResponse'
{ $sel:httpStatus:BatchGetDevicePositionResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:devicePositions:BatchGetDevicePositionResponse' :: [DevicePosition]
devicePositions = forall a. Monoid a => a
Prelude.mempty,
$sel:errors:BatchGetDevicePositionResponse' :: [BatchGetDevicePositionError]
errors = forall a. Monoid a => a
Prelude.mempty
}
batchGetDevicePositionResponse_httpStatus :: Lens.Lens' BatchGetDevicePositionResponse Prelude.Int
batchGetDevicePositionResponse_httpStatus :: Lens' BatchGetDevicePositionResponse Int
batchGetDevicePositionResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetDevicePositionResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchGetDevicePositionResponse' :: BatchGetDevicePositionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchGetDevicePositionResponse
s@BatchGetDevicePositionResponse' {} Int
a -> BatchGetDevicePositionResponse
s {$sel:httpStatus:BatchGetDevicePositionResponse' :: Int
httpStatus = Int
a} :: BatchGetDevicePositionResponse)
batchGetDevicePositionResponse_devicePositions :: Lens.Lens' BatchGetDevicePositionResponse [DevicePosition]
batchGetDevicePositionResponse_devicePositions :: Lens' BatchGetDevicePositionResponse [DevicePosition]
batchGetDevicePositionResponse_devicePositions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetDevicePositionResponse' {[DevicePosition]
devicePositions :: [DevicePosition]
$sel:devicePositions:BatchGetDevicePositionResponse' :: BatchGetDevicePositionResponse -> [DevicePosition]
devicePositions} -> [DevicePosition]
devicePositions) (\s :: BatchGetDevicePositionResponse
s@BatchGetDevicePositionResponse' {} [DevicePosition]
a -> BatchGetDevicePositionResponse
s {$sel:devicePositions:BatchGetDevicePositionResponse' :: [DevicePosition]
devicePositions = [DevicePosition]
a} :: BatchGetDevicePositionResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
batchGetDevicePositionResponse_errors :: Lens.Lens' BatchGetDevicePositionResponse [BatchGetDevicePositionError]
batchGetDevicePositionResponse_errors :: Lens' BatchGetDevicePositionResponse [BatchGetDevicePositionError]
batchGetDevicePositionResponse_errors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetDevicePositionResponse' {[BatchGetDevicePositionError]
errors :: [BatchGetDevicePositionError]
$sel:errors:BatchGetDevicePositionResponse' :: BatchGetDevicePositionResponse -> [BatchGetDevicePositionError]
errors} -> [BatchGetDevicePositionError]
errors) (\s :: BatchGetDevicePositionResponse
s@BatchGetDevicePositionResponse' {} [BatchGetDevicePositionError]
a -> BatchGetDevicePositionResponse
s {$sel:errors:BatchGetDevicePositionResponse' :: [BatchGetDevicePositionError]
errors = [BatchGetDevicePositionError]
a} :: BatchGetDevicePositionResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance
Prelude.NFData
BatchGetDevicePositionResponse
where
rnf :: BatchGetDevicePositionResponse -> ()
rnf BatchGetDevicePositionResponse' {Int
[BatchGetDevicePositionError]
[DevicePosition]
errors :: [BatchGetDevicePositionError]
devicePositions :: [DevicePosition]
httpStatus :: Int
$sel:errors:BatchGetDevicePositionResponse' :: BatchGetDevicePositionResponse -> [BatchGetDevicePositionError]
$sel:devicePositions:BatchGetDevicePositionResponse' :: BatchGetDevicePositionResponse -> [DevicePosition]
$sel:httpStatus:BatchGetDevicePositionResponse' :: BatchGetDevicePositionResponse -> Int
..} =
forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [DevicePosition]
devicePositions
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [BatchGetDevicePositionError]
errors