{-# 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.BatchUpdateDevicePosition
(
BatchUpdateDevicePosition (..),
newBatchUpdateDevicePosition,
batchUpdateDevicePosition_trackerName,
batchUpdateDevicePosition_updates,
BatchUpdateDevicePositionResponse (..),
newBatchUpdateDevicePositionResponse,
batchUpdateDevicePositionResponse_httpStatus,
batchUpdateDevicePositionResponse_errors,
)
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
data BatchUpdateDevicePosition = BatchUpdateDevicePosition'
{
BatchUpdateDevicePosition -> Text
trackerName :: Prelude.Text,
BatchUpdateDevicePosition -> NonEmpty DevicePositionUpdate
updates :: Prelude.NonEmpty DevicePositionUpdate
}
deriving (BatchUpdateDevicePosition -> BatchUpdateDevicePosition -> Bool
(BatchUpdateDevicePosition -> BatchUpdateDevicePosition -> Bool)
-> (BatchUpdateDevicePosition -> BatchUpdateDevicePosition -> Bool)
-> Eq BatchUpdateDevicePosition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchUpdateDevicePosition -> BatchUpdateDevicePosition -> Bool
$c/= :: BatchUpdateDevicePosition -> BatchUpdateDevicePosition -> Bool
== :: BatchUpdateDevicePosition -> BatchUpdateDevicePosition -> Bool
$c== :: BatchUpdateDevicePosition -> BatchUpdateDevicePosition -> Bool
Prelude.Eq, Int -> BatchUpdateDevicePosition -> ShowS
[BatchUpdateDevicePosition] -> ShowS
BatchUpdateDevicePosition -> String
(Int -> BatchUpdateDevicePosition -> ShowS)
-> (BatchUpdateDevicePosition -> String)
-> ([BatchUpdateDevicePosition] -> ShowS)
-> Show BatchUpdateDevicePosition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchUpdateDevicePosition] -> ShowS
$cshowList :: [BatchUpdateDevicePosition] -> ShowS
show :: BatchUpdateDevicePosition -> String
$cshow :: BatchUpdateDevicePosition -> String
showsPrec :: Int -> BatchUpdateDevicePosition -> ShowS
$cshowsPrec :: Int -> BatchUpdateDevicePosition -> ShowS
Prelude.Show, (forall x.
BatchUpdateDevicePosition -> Rep BatchUpdateDevicePosition x)
-> (forall x.
Rep BatchUpdateDevicePosition x -> BatchUpdateDevicePosition)
-> Generic BatchUpdateDevicePosition
forall x.
Rep BatchUpdateDevicePosition x -> BatchUpdateDevicePosition
forall x.
BatchUpdateDevicePosition -> Rep BatchUpdateDevicePosition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchUpdateDevicePosition x -> BatchUpdateDevicePosition
$cfrom :: forall x.
BatchUpdateDevicePosition -> Rep BatchUpdateDevicePosition x
Prelude.Generic)
newBatchUpdateDevicePosition ::
Prelude.Text ->
Prelude.NonEmpty DevicePositionUpdate ->
BatchUpdateDevicePosition
newBatchUpdateDevicePosition :: Text -> NonEmpty DevicePositionUpdate -> BatchUpdateDevicePosition
newBatchUpdateDevicePosition Text
pTrackerName_ NonEmpty DevicePositionUpdate
pUpdates_ =
BatchUpdateDevicePosition' :: Text -> NonEmpty DevicePositionUpdate -> BatchUpdateDevicePosition
BatchUpdateDevicePosition'
{ $sel:trackerName:BatchUpdateDevicePosition' :: Text
trackerName =
Text
pTrackerName_,
$sel:updates:BatchUpdateDevicePosition' :: NonEmpty DevicePositionUpdate
updates = Tagged
(NonEmpty DevicePositionUpdate)
(Identity (NonEmpty DevicePositionUpdate))
-> Tagged
(NonEmpty DevicePositionUpdate)
(Identity (NonEmpty DevicePositionUpdate))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
(NonEmpty DevicePositionUpdate)
(Identity (NonEmpty DevicePositionUpdate))
-> Tagged
(NonEmpty DevicePositionUpdate)
(Identity (NonEmpty DevicePositionUpdate)))
-> NonEmpty DevicePositionUpdate -> NonEmpty DevicePositionUpdate
forall t b. AReview t b -> b -> t
Lens.# NonEmpty DevicePositionUpdate
pUpdates_
}
batchUpdateDevicePosition_trackerName :: Lens.Lens' BatchUpdateDevicePosition Prelude.Text
batchUpdateDevicePosition_trackerName :: (Text -> f Text)
-> BatchUpdateDevicePosition -> f BatchUpdateDevicePosition
batchUpdateDevicePosition_trackerName = (BatchUpdateDevicePosition -> Text)
-> (BatchUpdateDevicePosition -> Text -> BatchUpdateDevicePosition)
-> Lens
BatchUpdateDevicePosition BatchUpdateDevicePosition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpdateDevicePosition' {Text
trackerName :: Text
$sel:trackerName:BatchUpdateDevicePosition' :: BatchUpdateDevicePosition -> Text
trackerName} -> Text
trackerName) (\s :: BatchUpdateDevicePosition
s@BatchUpdateDevicePosition' {} Text
a -> BatchUpdateDevicePosition
s {$sel:trackerName:BatchUpdateDevicePosition' :: Text
trackerName = Text
a} :: BatchUpdateDevicePosition)
batchUpdateDevicePosition_updates :: Lens.Lens' BatchUpdateDevicePosition (Prelude.NonEmpty DevicePositionUpdate)
batchUpdateDevicePosition_updates :: (NonEmpty DevicePositionUpdate
-> f (NonEmpty DevicePositionUpdate))
-> BatchUpdateDevicePosition -> f BatchUpdateDevicePosition
batchUpdateDevicePosition_updates = (BatchUpdateDevicePosition -> NonEmpty DevicePositionUpdate)
-> (BatchUpdateDevicePosition
-> NonEmpty DevicePositionUpdate -> BatchUpdateDevicePosition)
-> Lens
BatchUpdateDevicePosition
BatchUpdateDevicePosition
(NonEmpty DevicePositionUpdate)
(NonEmpty DevicePositionUpdate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpdateDevicePosition' {NonEmpty DevicePositionUpdate
updates :: NonEmpty DevicePositionUpdate
$sel:updates:BatchUpdateDevicePosition' :: BatchUpdateDevicePosition -> NonEmpty DevicePositionUpdate
updates} -> NonEmpty DevicePositionUpdate
updates) (\s :: BatchUpdateDevicePosition
s@BatchUpdateDevicePosition' {} NonEmpty DevicePositionUpdate
a -> BatchUpdateDevicePosition
s {$sel:updates:BatchUpdateDevicePosition' :: NonEmpty DevicePositionUpdate
updates = NonEmpty DevicePositionUpdate
a} :: BatchUpdateDevicePosition) ((NonEmpty DevicePositionUpdate
-> f (NonEmpty DevicePositionUpdate))
-> BatchUpdateDevicePosition -> f BatchUpdateDevicePosition)
-> ((NonEmpty DevicePositionUpdate
-> f (NonEmpty DevicePositionUpdate))
-> NonEmpty DevicePositionUpdate
-> f (NonEmpty DevicePositionUpdate))
-> (NonEmpty DevicePositionUpdate
-> f (NonEmpty DevicePositionUpdate))
-> BatchUpdateDevicePosition
-> f BatchUpdateDevicePosition
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty DevicePositionUpdate
-> f (NonEmpty DevicePositionUpdate))
-> NonEmpty DevicePositionUpdate
-> f (NonEmpty DevicePositionUpdate)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest BatchUpdateDevicePosition where
type
AWSResponse BatchUpdateDevicePosition =
BatchUpdateDevicePositionResponse
request :: BatchUpdateDevicePosition -> Request BatchUpdateDevicePosition
request = Service
-> BatchUpdateDevicePosition -> Request BatchUpdateDevicePosition
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy BatchUpdateDevicePosition
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse BatchUpdateDevicePosition)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse BatchUpdateDevicePosition))
-> Logger
-> Service
-> Proxy BatchUpdateDevicePosition
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse BatchUpdateDevicePosition)))
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
-> [BatchUpdateDevicePositionError]
-> BatchUpdateDevicePositionResponse
BatchUpdateDevicePositionResponse'
(Int
-> [BatchUpdateDevicePositionError]
-> BatchUpdateDevicePositionResponse)
-> Either String Int
-> Either
String
([BatchUpdateDevicePositionError]
-> BatchUpdateDevicePositionResponse)
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
([BatchUpdateDevicePositionError]
-> BatchUpdateDevicePositionResponse)
-> Either String [BatchUpdateDevicePositionError]
-> Either String BatchUpdateDevicePositionResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Either String (Maybe [BatchUpdateDevicePositionError])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Errors" Either String (Maybe [BatchUpdateDevicePositionError])
-> [BatchUpdateDevicePositionError]
-> Either String [BatchUpdateDevicePositionError]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [BatchUpdateDevicePositionError]
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable BatchUpdateDevicePosition
instance Prelude.NFData BatchUpdateDevicePosition
instance Core.ToHeaders BatchUpdateDevicePosition where
toHeaders :: BatchUpdateDevicePosition -> ResponseHeaders
toHeaders =
ResponseHeaders -> BatchUpdateDevicePosition -> 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 BatchUpdateDevicePosition where
toJSON :: BatchUpdateDevicePosition -> Value
toJSON BatchUpdateDevicePosition' {NonEmpty DevicePositionUpdate
Text
updates :: NonEmpty DevicePositionUpdate
trackerName :: Text
$sel:updates:BatchUpdateDevicePosition' :: BatchUpdateDevicePosition -> NonEmpty DevicePositionUpdate
$sel:trackerName:BatchUpdateDevicePosition' :: BatchUpdateDevicePosition -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Updates" Text -> NonEmpty DevicePositionUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty DevicePositionUpdate
updates)]
)
instance Core.ToPath BatchUpdateDevicePosition where
toPath :: BatchUpdateDevicePosition -> ByteString
toPath BatchUpdateDevicePosition' {NonEmpty DevicePositionUpdate
Text
updates :: NonEmpty DevicePositionUpdate
trackerName :: Text
$sel:updates:BatchUpdateDevicePosition' :: BatchUpdateDevicePosition -> NonEmpty DevicePositionUpdate
$sel:trackerName:BatchUpdateDevicePosition' :: BatchUpdateDevicePosition -> 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
"/positions"
]
instance Core.ToQuery BatchUpdateDevicePosition where
toQuery :: BatchUpdateDevicePosition -> QueryString
toQuery = QueryString -> BatchUpdateDevicePosition -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data BatchUpdateDevicePositionResponse = BatchUpdateDevicePositionResponse'
{
BatchUpdateDevicePositionResponse -> Int
httpStatus :: Prelude.Int,
BatchUpdateDevicePositionResponse
-> [BatchUpdateDevicePositionError]
errors :: [BatchUpdateDevicePositionError]
}
deriving (BatchUpdateDevicePositionResponse
-> BatchUpdateDevicePositionResponse -> Bool
(BatchUpdateDevicePositionResponse
-> BatchUpdateDevicePositionResponse -> Bool)
-> (BatchUpdateDevicePositionResponse
-> BatchUpdateDevicePositionResponse -> Bool)
-> Eq BatchUpdateDevicePositionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchUpdateDevicePositionResponse
-> BatchUpdateDevicePositionResponse -> Bool
$c/= :: BatchUpdateDevicePositionResponse
-> BatchUpdateDevicePositionResponse -> Bool
== :: BatchUpdateDevicePositionResponse
-> BatchUpdateDevicePositionResponse -> Bool
$c== :: BatchUpdateDevicePositionResponse
-> BatchUpdateDevicePositionResponse -> Bool
Prelude.Eq, ReadPrec [BatchUpdateDevicePositionResponse]
ReadPrec BatchUpdateDevicePositionResponse
Int -> ReadS BatchUpdateDevicePositionResponse
ReadS [BatchUpdateDevicePositionResponse]
(Int -> ReadS BatchUpdateDevicePositionResponse)
-> ReadS [BatchUpdateDevicePositionResponse]
-> ReadPrec BatchUpdateDevicePositionResponse
-> ReadPrec [BatchUpdateDevicePositionResponse]
-> Read BatchUpdateDevicePositionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchUpdateDevicePositionResponse]
$creadListPrec :: ReadPrec [BatchUpdateDevicePositionResponse]
readPrec :: ReadPrec BatchUpdateDevicePositionResponse
$creadPrec :: ReadPrec BatchUpdateDevicePositionResponse
readList :: ReadS [BatchUpdateDevicePositionResponse]
$creadList :: ReadS [BatchUpdateDevicePositionResponse]
readsPrec :: Int -> ReadS BatchUpdateDevicePositionResponse
$creadsPrec :: Int -> ReadS BatchUpdateDevicePositionResponse
Prelude.Read, Int -> BatchUpdateDevicePositionResponse -> ShowS
[BatchUpdateDevicePositionResponse] -> ShowS
BatchUpdateDevicePositionResponse -> String
(Int -> BatchUpdateDevicePositionResponse -> ShowS)
-> (BatchUpdateDevicePositionResponse -> String)
-> ([BatchUpdateDevicePositionResponse] -> ShowS)
-> Show BatchUpdateDevicePositionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchUpdateDevicePositionResponse] -> ShowS
$cshowList :: [BatchUpdateDevicePositionResponse] -> ShowS
show :: BatchUpdateDevicePositionResponse -> String
$cshow :: BatchUpdateDevicePositionResponse -> String
showsPrec :: Int -> BatchUpdateDevicePositionResponse -> ShowS
$cshowsPrec :: Int -> BatchUpdateDevicePositionResponse -> ShowS
Prelude.Show, (forall x.
BatchUpdateDevicePositionResponse
-> Rep BatchUpdateDevicePositionResponse x)
-> (forall x.
Rep BatchUpdateDevicePositionResponse x
-> BatchUpdateDevicePositionResponse)
-> Generic BatchUpdateDevicePositionResponse
forall x.
Rep BatchUpdateDevicePositionResponse x
-> BatchUpdateDevicePositionResponse
forall x.
BatchUpdateDevicePositionResponse
-> Rep BatchUpdateDevicePositionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchUpdateDevicePositionResponse x
-> BatchUpdateDevicePositionResponse
$cfrom :: forall x.
BatchUpdateDevicePositionResponse
-> Rep BatchUpdateDevicePositionResponse x
Prelude.Generic)
newBatchUpdateDevicePositionResponse ::
Prelude.Int ->
BatchUpdateDevicePositionResponse
newBatchUpdateDevicePositionResponse :: Int -> BatchUpdateDevicePositionResponse
newBatchUpdateDevicePositionResponse Int
pHttpStatus_ =
BatchUpdateDevicePositionResponse' :: Int
-> [BatchUpdateDevicePositionError]
-> BatchUpdateDevicePositionResponse
BatchUpdateDevicePositionResponse'
{ $sel:httpStatus:BatchUpdateDevicePositionResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:errors:BatchUpdateDevicePositionResponse' :: [BatchUpdateDevicePositionError]
errors = [BatchUpdateDevicePositionError]
forall a. Monoid a => a
Prelude.mempty
}
batchUpdateDevicePositionResponse_httpStatus :: Lens.Lens' BatchUpdateDevicePositionResponse Prelude.Int
batchUpdateDevicePositionResponse_httpStatus :: (Int -> f Int)
-> BatchUpdateDevicePositionResponse
-> f BatchUpdateDevicePositionResponse
batchUpdateDevicePositionResponse_httpStatus = (BatchUpdateDevicePositionResponse -> Int)
-> (BatchUpdateDevicePositionResponse
-> Int -> BatchUpdateDevicePositionResponse)
-> Lens
BatchUpdateDevicePositionResponse
BatchUpdateDevicePositionResponse
Int
Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpdateDevicePositionResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchUpdateDevicePositionResponse' :: BatchUpdateDevicePositionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchUpdateDevicePositionResponse
s@BatchUpdateDevicePositionResponse' {} Int
a -> BatchUpdateDevicePositionResponse
s {$sel:httpStatus:BatchUpdateDevicePositionResponse' :: Int
httpStatus = Int
a} :: BatchUpdateDevicePositionResponse)
batchUpdateDevicePositionResponse_errors :: Lens.Lens' BatchUpdateDevicePositionResponse [BatchUpdateDevicePositionError]
batchUpdateDevicePositionResponse_errors :: ([BatchUpdateDevicePositionError]
-> f [BatchUpdateDevicePositionError])
-> BatchUpdateDevicePositionResponse
-> f BatchUpdateDevicePositionResponse
batchUpdateDevicePositionResponse_errors = (BatchUpdateDevicePositionResponse
-> [BatchUpdateDevicePositionError])
-> (BatchUpdateDevicePositionResponse
-> [BatchUpdateDevicePositionError]
-> BatchUpdateDevicePositionResponse)
-> Lens
BatchUpdateDevicePositionResponse
BatchUpdateDevicePositionResponse
[BatchUpdateDevicePositionError]
[BatchUpdateDevicePositionError]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpdateDevicePositionResponse' {[BatchUpdateDevicePositionError]
errors :: [BatchUpdateDevicePositionError]
$sel:errors:BatchUpdateDevicePositionResponse' :: BatchUpdateDevicePositionResponse
-> [BatchUpdateDevicePositionError]
errors} -> [BatchUpdateDevicePositionError]
errors) (\s :: BatchUpdateDevicePositionResponse
s@BatchUpdateDevicePositionResponse' {} [BatchUpdateDevicePositionError]
a -> BatchUpdateDevicePositionResponse
s {$sel:errors:BatchUpdateDevicePositionResponse' :: [BatchUpdateDevicePositionError]
errors = [BatchUpdateDevicePositionError]
a} :: BatchUpdateDevicePositionResponse) (([BatchUpdateDevicePositionError]
-> f [BatchUpdateDevicePositionError])
-> BatchUpdateDevicePositionResponse
-> f BatchUpdateDevicePositionResponse)
-> (([BatchUpdateDevicePositionError]
-> f [BatchUpdateDevicePositionError])
-> [BatchUpdateDevicePositionError]
-> f [BatchUpdateDevicePositionError])
-> ([BatchUpdateDevicePositionError]
-> f [BatchUpdateDevicePositionError])
-> BatchUpdateDevicePositionResponse
-> f BatchUpdateDevicePositionResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([BatchUpdateDevicePositionError]
-> f [BatchUpdateDevicePositionError])
-> [BatchUpdateDevicePositionError]
-> f [BatchUpdateDevicePositionError]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance
Prelude.NFData
BatchUpdateDevicePositionResponse