{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
{ $sel:consistencyLevel:BatchRead' :: Maybe ConsistencyLevel
consistencyLevel = forall a. Maybe a
Prelude.Nothing,
$sel:directoryArn:BatchRead' :: Text
directoryArn = Text
pDirectoryArn_,
$sel:operations:BatchRead' :: [BatchReadOperation]
operations = forall a. Monoid a => a
Prelude.mempty
}
batchRead_consistencyLevel :: Lens.Lens' BatchRead (Prelude.Maybe ConsistencyLevel)
batchRead_consistencyLevel :: Lens' BatchRead (Maybe ConsistencyLevel)
batchRead_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 :: Lens' BatchRead Text
batchRead_directoryArn = 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 :: Lens' BatchRead [BatchReadOperation]
batchRead_operations = 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) 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 Core.AWSRequest BatchRead where
type AWSResponse BatchRead = BatchReadResponse
request :: (Service -> Service) -> BatchRead -> Request BatchRead
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 BatchRead
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchRead)))
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 ->
Maybe [BatchReadOperationResponse] -> Int -> BatchReadResponse
BatchReadResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Responses" 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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable BatchRead where
hashWithSalt :: Int -> BatchRead -> Int
hashWithSalt Int
_salt 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
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ConsistencyLevel
consistencyLevel
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
directoryArn
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [BatchReadOperation]
operations
instance Prelude.NFData BatchRead where
rnf :: BatchRead -> ()
rnf 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
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe ConsistencyLevel
consistencyLevel
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
directoryArn
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [BatchReadOperation]
operations
instance Data.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
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"x-amz-consistency-level" forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# Maybe ConsistencyLevel
consistencyLevel,
HeaderName
"x-amz-data-partition" forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# Text
directoryArn
]
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[forall a. a -> Maybe a
Prelude.Just (Key
"Operations" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [BatchReadOperation]
operations)]
)
instance Data.ToPath BatchRead where
toPath :: BatchRead -> ByteString
toPath =
forall a b. a -> b -> a
Prelude.const
ByteString
"/amazonclouddirectory/2017-01-11/batchread"
instance Data.ToQuery BatchRead where
toQuery :: BatchRead -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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'
{ $sel:responses:BatchReadResponse' :: Maybe [BatchReadOperationResponse]
responses = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:BatchReadResponse' :: Int
httpStatus = Int
pHttpStatus_
}
batchReadResponse_responses :: Lens.Lens' BatchReadResponse (Prelude.Maybe [BatchReadOperationResponse])
batchReadResponse_responses :: Lens' BatchReadResponse (Maybe [BatchReadOperationResponse])
batchReadResponse_responses = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' BatchReadResponse Int
batchReadResponse_httpStatus = 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 where
rnf :: BatchReadResponse -> ()
rnf BatchReadResponse' {Int
Maybe [BatchReadOperationResponse]
httpStatus :: Int
responses :: Maybe [BatchReadOperationResponse]
$sel:httpStatus:BatchReadResponse' :: BatchReadResponse -> Int
$sel:responses:BatchReadResponse' :: BatchReadResponse -> Maybe [BatchReadOperationResponse]
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe [BatchReadOperationResponse]
responses
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus