{-# 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.CloudDirectory.BatchRead
(
BatchRead (..),
newBatchRead,
batchRead_consistencyLevel,
batchRead_directoryArn,
batchRead_operations,
BatchReadResponse (..),
newBatchReadResponse,
batchReadResponse_responses,
batchReadResponse_httpStatus,
)
where
import Amazonka.CloudDirectory.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data BatchRead = BatchRead'
{
BatchRead -> Maybe ConsistencyLevel
consistencyLevel :: Prelude.Maybe ConsistencyLevel,
BatchRead -> Text
directoryArn :: Prelude.Text,
BatchRead -> [BatchReadOperation]
operations :: [BatchReadOperation]
}
deriving (BatchRead -> BatchRead -> Bool
(BatchRead -> BatchRead -> Bool)
-> (BatchRead -> BatchRead -> Bool) -> Eq BatchRead
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchRead -> BatchRead -> Bool
$c/= :: BatchRead -> BatchRead -> Bool
== :: BatchRead -> BatchRead -> Bool
$c== :: BatchRead -> BatchRead -> Bool
Prelude.Eq, ReadPrec [BatchRead]
ReadPrec BatchRead
Int -> ReadS BatchRead
ReadS [BatchRead]
(Int -> ReadS BatchRead)
-> ReadS [BatchRead]
-> ReadPrec BatchRead
-> ReadPrec [BatchRead]
-> Read BatchRead
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchRead]
$creadListPrec :: ReadPrec [BatchRead]
readPrec :: ReadPrec BatchRead
$creadPrec :: ReadPrec BatchRead
readList :: ReadS [BatchRead]
$creadList :: ReadS [BatchRead]
readsPrec :: Int -> ReadS BatchRead
$creadsPrec :: Int -> ReadS BatchRead
Prelude.Read, Int -> BatchRead -> ShowS
[BatchRead] -> ShowS
BatchRead -> String
(Int -> BatchRead -> ShowS)
-> (BatchRead -> String)
-> ([BatchRead] -> ShowS)
-> Show BatchRead
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchRead] -> ShowS
$cshowList :: [BatchRead] -> ShowS
show :: BatchRead -> String
$cshow :: BatchRead -> String
showsPrec :: Int -> BatchRead -> ShowS
$cshowsPrec :: Int -> BatchRead -> ShowS
Prelude.Show, (forall x. BatchRead -> Rep BatchRead x)
-> (forall x. Rep BatchRead x -> BatchRead) -> Generic BatchRead
forall x. Rep BatchRead x -> BatchRead
forall x. BatchRead -> Rep BatchRead x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchRead x -> BatchRead
$cfrom :: forall x. BatchRead -> Rep BatchRead x
Prelude.Generic)
newBatchRead ::
Prelude.Text ->
BatchRead
newBatchRead :: Text -> BatchRead
newBatchRead Text
pDirectoryArn_ =
BatchRead' :: Maybe ConsistencyLevel -> Text -> [BatchReadOperation] -> BatchRead
BatchRead'
{ $sel:consistencyLevel:BatchRead' :: Maybe ConsistencyLevel
consistencyLevel = Maybe ConsistencyLevel
forall a. Maybe a
Prelude.Nothing,
$sel:directoryArn:BatchRead' :: Text
directoryArn = Text
pDirectoryArn_,
$sel:operations:BatchRead' :: [BatchReadOperation]
operations = [BatchReadOperation]
forall a. Monoid a => a
Prelude.mempty
}
batchRead_consistencyLevel :: Lens.Lens' BatchRead (Prelude.Maybe ConsistencyLevel)
batchRead_consistencyLevel :: (Maybe ConsistencyLevel -> f (Maybe ConsistencyLevel))
-> BatchRead -> f BatchRead
batchRead_consistencyLevel = (BatchRead -> Maybe ConsistencyLevel)
-> (BatchRead -> Maybe ConsistencyLevel -> BatchRead)
-> Lens
BatchRead
BatchRead
(Maybe ConsistencyLevel)
(Maybe ConsistencyLevel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchRead' {Maybe ConsistencyLevel
consistencyLevel :: Maybe ConsistencyLevel
$sel:consistencyLevel:BatchRead' :: BatchRead -> Maybe ConsistencyLevel
consistencyLevel} -> Maybe ConsistencyLevel
consistencyLevel) (\s :: BatchRead
s@BatchRead' {} Maybe ConsistencyLevel
a -> BatchRead
s {$sel:consistencyLevel:BatchRead' :: Maybe ConsistencyLevel
consistencyLevel = Maybe ConsistencyLevel
a} :: BatchRead)
batchRead_directoryArn :: Lens.Lens' BatchRead Prelude.Text
batchRead_directoryArn :: (Text -> f Text) -> BatchRead -> f BatchRead
batchRead_directoryArn = (BatchRead -> Text)
-> (BatchRead -> Text -> BatchRead)
-> Lens BatchRead BatchRead Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchRead' {Text
directoryArn :: Text
$sel:directoryArn:BatchRead' :: BatchRead -> Text
directoryArn} -> Text
directoryArn) (\s :: BatchRead
s@BatchRead' {} Text
a -> BatchRead
s {$sel:directoryArn:BatchRead' :: Text
directoryArn = Text
a} :: BatchRead)
batchRead_operations :: Lens.Lens' BatchRead [BatchReadOperation]
batchRead_operations :: ([BatchReadOperation] -> f [BatchReadOperation])
-> BatchRead -> f BatchRead
batchRead_operations = (BatchRead -> [BatchReadOperation])
-> (BatchRead -> [BatchReadOperation] -> BatchRead)
-> Lens
BatchRead BatchRead [BatchReadOperation] [BatchReadOperation]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchRead' {[BatchReadOperation]
operations :: [BatchReadOperation]
$sel:operations:BatchRead' :: BatchRead -> [BatchReadOperation]
operations} -> [BatchReadOperation]
operations) (\s :: BatchRead
s@BatchRead' {} [BatchReadOperation]
a -> BatchRead
s {$sel:operations:BatchRead' :: [BatchReadOperation]
operations = [BatchReadOperation]
a} :: BatchRead) (([BatchReadOperation] -> f [BatchReadOperation])
-> BatchRead -> f BatchRead)
-> (([BatchReadOperation] -> f [BatchReadOperation])
-> [BatchReadOperation] -> f [BatchReadOperation])
-> ([BatchReadOperation] -> f [BatchReadOperation])
-> BatchRead
-> f BatchRead
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([BatchReadOperation] -> f [BatchReadOperation])
-> [BatchReadOperation] -> f [BatchReadOperation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest BatchRead where
type AWSResponse BatchRead = BatchReadResponse
request :: BatchRead -> Request BatchRead
request = Service -> BatchRead -> Request BatchRead
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy BatchRead
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchRead)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse BatchRead))
-> Logger
-> Service
-> Proxy BatchRead
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchRead)))
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 [BatchReadOperationResponse] -> Int -> BatchReadResponse
BatchReadResponse'
(Maybe [BatchReadOperationResponse] -> Int -> BatchReadResponse)
-> Either String (Maybe [BatchReadOperationResponse])
-> Either String (Int -> BatchReadResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text
-> Either String (Maybe (Maybe [BatchReadOperationResponse]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Responses" Either String (Maybe (Maybe [BatchReadOperationResponse]))
-> Maybe [BatchReadOperationResponse]
-> Either String (Maybe [BatchReadOperationResponse])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [BatchReadOperationResponse]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> BatchReadResponse)
-> Either String Int -> Either String BatchReadResponse
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))
)
instance Prelude.Hashable BatchRead
instance Prelude.NFData BatchRead
instance Core.ToHeaders BatchRead where
toHeaders :: BatchRead -> ResponseHeaders
toHeaders BatchRead' {[BatchReadOperation]
Maybe ConsistencyLevel
Text
operations :: [BatchReadOperation]
directoryArn :: Text
consistencyLevel :: Maybe ConsistencyLevel
$sel:operations:BatchRead' :: BatchRead -> [BatchReadOperation]
$sel:directoryArn:BatchRead' :: BatchRead -> Text
$sel:consistencyLevel:BatchRead' :: BatchRead -> Maybe ConsistencyLevel
..} =
[ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"x-amz-consistency-level" HeaderName -> Maybe ConsistencyLevel -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe ConsistencyLevel
consistencyLevel,
HeaderName
"x-amz-data-partition" HeaderName -> Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Text
directoryArn
]
instance Core.ToJSON BatchRead where
toJSON :: BatchRead -> Value
toJSON BatchRead' {[BatchReadOperation]
Maybe ConsistencyLevel
Text
operations :: [BatchReadOperation]
directoryArn :: Text
consistencyLevel :: Maybe ConsistencyLevel
$sel:operations:BatchRead' :: BatchRead -> [BatchReadOperation]
$sel:directoryArn:BatchRead' :: BatchRead -> Text
$sel:consistencyLevel:BatchRead' :: BatchRead -> Maybe ConsistencyLevel
..} =
[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
"Operations" Text -> [BatchReadOperation] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [BatchReadOperation]
operations)]
)
instance Core.ToPath BatchRead where
toPath :: BatchRead -> ByteString
toPath =
ByteString -> BatchRead -> ByteString
forall a b. a -> b -> a
Prelude.const
ByteString
"/amazonclouddirectory/2017-01-11/batchread"
instance Core.ToQuery BatchRead where
toQuery :: BatchRead -> QueryString
toQuery = QueryString -> BatchRead -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data BatchReadResponse = BatchReadResponse'
{
BatchReadResponse -> Maybe [BatchReadOperationResponse]
responses :: Prelude.Maybe [BatchReadOperationResponse],
BatchReadResponse -> Int
httpStatus :: Prelude.Int
}
deriving (BatchReadResponse -> BatchReadResponse -> Bool
(BatchReadResponse -> BatchReadResponse -> Bool)
-> (BatchReadResponse -> BatchReadResponse -> Bool)
-> Eq BatchReadResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchReadResponse -> BatchReadResponse -> Bool
$c/= :: BatchReadResponse -> BatchReadResponse -> Bool
== :: BatchReadResponse -> BatchReadResponse -> Bool
$c== :: BatchReadResponse -> BatchReadResponse -> Bool
Prelude.Eq, ReadPrec [BatchReadResponse]
ReadPrec BatchReadResponse
Int -> ReadS BatchReadResponse
ReadS [BatchReadResponse]
(Int -> ReadS BatchReadResponse)
-> ReadS [BatchReadResponse]
-> ReadPrec BatchReadResponse
-> ReadPrec [BatchReadResponse]
-> Read BatchReadResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchReadResponse]
$creadListPrec :: ReadPrec [BatchReadResponse]
readPrec :: ReadPrec BatchReadResponse
$creadPrec :: ReadPrec BatchReadResponse
readList :: ReadS [BatchReadResponse]
$creadList :: ReadS [BatchReadResponse]
readsPrec :: Int -> ReadS BatchReadResponse
$creadsPrec :: Int -> ReadS BatchReadResponse
Prelude.Read, Int -> BatchReadResponse -> ShowS
[BatchReadResponse] -> ShowS
BatchReadResponse -> String
(Int -> BatchReadResponse -> ShowS)
-> (BatchReadResponse -> String)
-> ([BatchReadResponse] -> ShowS)
-> Show BatchReadResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchReadResponse] -> ShowS
$cshowList :: [BatchReadResponse] -> ShowS
show :: BatchReadResponse -> String
$cshow :: BatchReadResponse -> String
showsPrec :: Int -> BatchReadResponse -> ShowS
$cshowsPrec :: Int -> BatchReadResponse -> ShowS
Prelude.Show, (forall x. BatchReadResponse -> Rep BatchReadResponse x)
-> (forall x. Rep BatchReadResponse x -> BatchReadResponse)
-> Generic BatchReadResponse
forall x. Rep BatchReadResponse x -> BatchReadResponse
forall x. BatchReadResponse -> Rep BatchReadResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchReadResponse x -> BatchReadResponse
$cfrom :: forall x. BatchReadResponse -> Rep BatchReadResponse x
Prelude.Generic)
newBatchReadResponse ::
Prelude.Int ->
BatchReadResponse
newBatchReadResponse :: Int -> BatchReadResponse
newBatchReadResponse Int
pHttpStatus_ =
BatchReadResponse' :: Maybe [BatchReadOperationResponse] -> Int -> BatchReadResponse
BatchReadResponse'
{ $sel:responses:BatchReadResponse' :: Maybe [BatchReadOperationResponse]
responses = Maybe [BatchReadOperationResponse]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:BatchReadResponse' :: Int
httpStatus = Int
pHttpStatus_
}
batchReadResponse_responses :: Lens.Lens' BatchReadResponse (Prelude.Maybe [BatchReadOperationResponse])
batchReadResponse_responses :: (Maybe [BatchReadOperationResponse]
-> f (Maybe [BatchReadOperationResponse]))
-> BatchReadResponse -> f BatchReadResponse
batchReadResponse_responses = (BatchReadResponse -> Maybe [BatchReadOperationResponse])
-> (BatchReadResponse
-> Maybe [BatchReadOperationResponse] -> BatchReadResponse)
-> Lens
BatchReadResponse
BatchReadResponse
(Maybe [BatchReadOperationResponse])
(Maybe [BatchReadOperationResponse])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchReadResponse' {Maybe [BatchReadOperationResponse]
responses :: Maybe [BatchReadOperationResponse]
$sel:responses:BatchReadResponse' :: BatchReadResponse -> Maybe [BatchReadOperationResponse]
responses} -> Maybe [BatchReadOperationResponse]
responses) (\s :: BatchReadResponse
s@BatchReadResponse' {} Maybe [BatchReadOperationResponse]
a -> BatchReadResponse
s {$sel:responses:BatchReadResponse' :: Maybe [BatchReadOperationResponse]
responses = Maybe [BatchReadOperationResponse]
a} :: BatchReadResponse) ((Maybe [BatchReadOperationResponse]
-> f (Maybe [BatchReadOperationResponse]))
-> BatchReadResponse -> f BatchReadResponse)
-> ((Maybe [BatchReadOperationResponse]
-> f (Maybe [BatchReadOperationResponse]))
-> Maybe [BatchReadOperationResponse]
-> f (Maybe [BatchReadOperationResponse]))
-> (Maybe [BatchReadOperationResponse]
-> f (Maybe [BatchReadOperationResponse]))
-> BatchReadResponse
-> f BatchReadResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[BatchReadOperationResponse]
[BatchReadOperationResponse]
[BatchReadOperationResponse]
[BatchReadOperationResponse]
-> Iso
(Maybe [BatchReadOperationResponse])
(Maybe [BatchReadOperationResponse])
(Maybe [BatchReadOperationResponse])
(Maybe [BatchReadOperationResponse])
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
[BatchReadOperationResponse]
[BatchReadOperationResponse]
[BatchReadOperationResponse]
[BatchReadOperationResponse]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
batchReadResponse_httpStatus :: Lens.Lens' BatchReadResponse Prelude.Int
batchReadResponse_httpStatus :: (Int -> f Int) -> BatchReadResponse -> f BatchReadResponse
batchReadResponse_httpStatus = (BatchReadResponse -> Int)
-> (BatchReadResponse -> Int -> BatchReadResponse)
-> Lens BatchReadResponse BatchReadResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchReadResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchReadResponse' :: BatchReadResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchReadResponse
s@BatchReadResponse' {} Int
a -> BatchReadResponse
s {$sel:httpStatus:BatchReadResponse' :: Int
httpStatus = Int
a} :: BatchReadResponse)
instance Prelude.NFData BatchReadResponse