{-# 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.BatchWrite
(
BatchWrite (..),
newBatchWrite,
batchWrite_directoryArn,
batchWrite_operations,
BatchWriteResponse (..),
newBatchWriteResponse,
batchWriteResponse_responses,
batchWriteResponse_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 BatchWrite = BatchWrite'
{
BatchWrite -> Text
directoryArn :: Prelude.Text,
BatchWrite -> [BatchWriteOperation]
operations :: [BatchWriteOperation]
}
deriving (BatchWrite -> BatchWrite -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchWrite -> BatchWrite -> Bool
$c/= :: BatchWrite -> BatchWrite -> Bool
== :: BatchWrite -> BatchWrite -> Bool
$c== :: BatchWrite -> BatchWrite -> Bool
Prelude.Eq, ReadPrec [BatchWrite]
ReadPrec BatchWrite
Int -> ReadS BatchWrite
ReadS [BatchWrite]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchWrite]
$creadListPrec :: ReadPrec [BatchWrite]
readPrec :: ReadPrec BatchWrite
$creadPrec :: ReadPrec BatchWrite
readList :: ReadS [BatchWrite]
$creadList :: ReadS [BatchWrite]
readsPrec :: Int -> ReadS BatchWrite
$creadsPrec :: Int -> ReadS BatchWrite
Prelude.Read, Int -> BatchWrite -> ShowS
[BatchWrite] -> ShowS
BatchWrite -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchWrite] -> ShowS
$cshowList :: [BatchWrite] -> ShowS
show :: BatchWrite -> String
$cshow :: BatchWrite -> String
showsPrec :: Int -> BatchWrite -> ShowS
$cshowsPrec :: Int -> BatchWrite -> ShowS
Prelude.Show, forall x. Rep BatchWrite x -> BatchWrite
forall x. BatchWrite -> Rep BatchWrite x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchWrite x -> BatchWrite
$cfrom :: forall x. BatchWrite -> Rep BatchWrite x
Prelude.Generic)
newBatchWrite ::
Prelude.Text ->
BatchWrite
newBatchWrite :: Text -> BatchWrite
newBatchWrite Text
pDirectoryArn_ =
BatchWrite'
{ $sel:directoryArn:BatchWrite' :: Text
directoryArn = Text
pDirectoryArn_,
$sel:operations:BatchWrite' :: [BatchWriteOperation]
operations = forall a. Monoid a => a
Prelude.mempty
}
batchWrite_directoryArn :: Lens.Lens' BatchWrite Prelude.Text
batchWrite_directoryArn :: Lens' BatchWrite Text
batchWrite_directoryArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchWrite' {Text
directoryArn :: Text
$sel:directoryArn:BatchWrite' :: BatchWrite -> Text
directoryArn} -> Text
directoryArn) (\s :: BatchWrite
s@BatchWrite' {} Text
a -> BatchWrite
s {$sel:directoryArn:BatchWrite' :: Text
directoryArn = Text
a} :: BatchWrite)
batchWrite_operations :: Lens.Lens' BatchWrite [BatchWriteOperation]
batchWrite_operations :: Lens' BatchWrite [BatchWriteOperation]
batchWrite_operations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchWrite' {[BatchWriteOperation]
operations :: [BatchWriteOperation]
$sel:operations:BatchWrite' :: BatchWrite -> [BatchWriteOperation]
operations} -> [BatchWriteOperation]
operations) (\s :: BatchWrite
s@BatchWrite' {} [BatchWriteOperation]
a -> BatchWrite
s {$sel:operations:BatchWrite' :: [BatchWriteOperation]
operations = [BatchWriteOperation]
a} :: BatchWrite) 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 BatchWrite where
type AWSResponse BatchWrite = BatchWriteResponse
request :: (Service -> Service) -> BatchWrite -> Request BatchWrite
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy BatchWrite
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchWrite)))
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 [BatchWriteOperationResponse] -> Int -> BatchWriteResponse
BatchWriteResponse'
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 BatchWrite where
hashWithSalt :: Int -> BatchWrite -> Int
hashWithSalt Int
_salt BatchWrite' {[BatchWriteOperation]
Text
operations :: [BatchWriteOperation]
directoryArn :: Text
$sel:operations:BatchWrite' :: BatchWrite -> [BatchWriteOperation]
$sel:directoryArn:BatchWrite' :: BatchWrite -> Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
directoryArn
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [BatchWriteOperation]
operations
instance Prelude.NFData BatchWrite where
rnf :: BatchWrite -> ()
rnf BatchWrite' {[BatchWriteOperation]
Text
operations :: [BatchWriteOperation]
directoryArn :: Text
$sel:operations:BatchWrite' :: BatchWrite -> [BatchWriteOperation]
$sel:directoryArn:BatchWrite' :: BatchWrite -> Text
..} =
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 [BatchWriteOperation]
operations
instance Data.ToHeaders BatchWrite where
toHeaders :: BatchWrite -> ResponseHeaders
toHeaders BatchWrite' {[BatchWriteOperation]
Text
operations :: [BatchWriteOperation]
directoryArn :: Text
$sel:operations:BatchWrite' :: BatchWrite -> [BatchWriteOperation]
$sel:directoryArn:BatchWrite' :: BatchWrite -> Text
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[HeaderName
"x-amz-data-partition" forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# Text
directoryArn]
instance Data.ToJSON BatchWrite where
toJSON :: BatchWrite -> Value
toJSON BatchWrite' {[BatchWriteOperation]
Text
operations :: [BatchWriteOperation]
directoryArn :: Text
$sel:operations:BatchWrite' :: BatchWrite -> [BatchWriteOperation]
$sel:directoryArn:BatchWrite' :: BatchWrite -> Text
..} =
[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..= [BatchWriteOperation]
operations)]
)
instance Data.ToPath BatchWrite where
toPath :: BatchWrite -> ByteString
toPath =
forall a b. a -> b -> a
Prelude.const
ByteString
"/amazonclouddirectory/2017-01-11/batchwrite"
instance Data.ToQuery BatchWrite where
toQuery :: BatchWrite -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data BatchWriteResponse = BatchWriteResponse'
{
BatchWriteResponse -> Maybe [BatchWriteOperationResponse]
responses :: Prelude.Maybe [BatchWriteOperationResponse],
BatchWriteResponse -> Int
httpStatus :: Prelude.Int
}
deriving (BatchWriteResponse -> BatchWriteResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchWriteResponse -> BatchWriteResponse -> Bool
$c/= :: BatchWriteResponse -> BatchWriteResponse -> Bool
== :: BatchWriteResponse -> BatchWriteResponse -> Bool
$c== :: BatchWriteResponse -> BatchWriteResponse -> Bool
Prelude.Eq, ReadPrec [BatchWriteResponse]
ReadPrec BatchWriteResponse
Int -> ReadS BatchWriteResponse
ReadS [BatchWriteResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchWriteResponse]
$creadListPrec :: ReadPrec [BatchWriteResponse]
readPrec :: ReadPrec BatchWriteResponse
$creadPrec :: ReadPrec BatchWriteResponse
readList :: ReadS [BatchWriteResponse]
$creadList :: ReadS [BatchWriteResponse]
readsPrec :: Int -> ReadS BatchWriteResponse
$creadsPrec :: Int -> ReadS BatchWriteResponse
Prelude.Read, Int -> BatchWriteResponse -> ShowS
[BatchWriteResponse] -> ShowS
BatchWriteResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchWriteResponse] -> ShowS
$cshowList :: [BatchWriteResponse] -> ShowS
show :: BatchWriteResponse -> String
$cshow :: BatchWriteResponse -> String
showsPrec :: Int -> BatchWriteResponse -> ShowS
$cshowsPrec :: Int -> BatchWriteResponse -> ShowS
Prelude.Show, forall x. Rep BatchWriteResponse x -> BatchWriteResponse
forall x. BatchWriteResponse -> Rep BatchWriteResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchWriteResponse x -> BatchWriteResponse
$cfrom :: forall x. BatchWriteResponse -> Rep BatchWriteResponse x
Prelude.Generic)
newBatchWriteResponse ::
Prelude.Int ->
BatchWriteResponse
newBatchWriteResponse :: Int -> BatchWriteResponse
newBatchWriteResponse Int
pHttpStatus_ =
BatchWriteResponse'
{ $sel:responses:BatchWriteResponse' :: Maybe [BatchWriteOperationResponse]
responses = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:BatchWriteResponse' :: Int
httpStatus = Int
pHttpStatus_
}
batchWriteResponse_responses :: Lens.Lens' BatchWriteResponse (Prelude.Maybe [BatchWriteOperationResponse])
batchWriteResponse_responses :: Lens' BatchWriteResponse (Maybe [BatchWriteOperationResponse])
batchWriteResponse_responses = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchWriteResponse' {Maybe [BatchWriteOperationResponse]
responses :: Maybe [BatchWriteOperationResponse]
$sel:responses:BatchWriteResponse' :: BatchWriteResponse -> Maybe [BatchWriteOperationResponse]
responses} -> Maybe [BatchWriteOperationResponse]
responses) (\s :: BatchWriteResponse
s@BatchWriteResponse' {} Maybe [BatchWriteOperationResponse]
a -> BatchWriteResponse
s {$sel:responses:BatchWriteResponse' :: Maybe [BatchWriteOperationResponse]
responses = Maybe [BatchWriteOperationResponse]
a} :: BatchWriteResponse) 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
batchWriteResponse_httpStatus :: Lens.Lens' BatchWriteResponse Prelude.Int
batchWriteResponse_httpStatus :: Lens' BatchWriteResponse Int
batchWriteResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchWriteResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchWriteResponse' :: BatchWriteResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchWriteResponse
s@BatchWriteResponse' {} Int
a -> BatchWriteResponse
s {$sel:httpStatus:BatchWriteResponse' :: Int
httpStatus = Int
a} :: BatchWriteResponse)
instance Prelude.NFData BatchWriteResponse where
rnf :: BatchWriteResponse -> ()
rnf BatchWriteResponse' {Int
Maybe [BatchWriteOperationResponse]
httpStatus :: Int
responses :: Maybe [BatchWriteOperationResponse]
$sel:httpStatus:BatchWriteResponse' :: BatchWriteResponse -> Int
$sel:responses:BatchWriteResponse' :: BatchWriteResponse -> Maybe [BatchWriteOperationResponse]
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe [BatchWriteOperationResponse]
responses
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus