{-# 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.CreateObject
(
CreateObject (..),
newCreateObject,
createObject_parentReference,
createObject_objectAttributeList,
createObject_linkName,
createObject_directoryArn,
createObject_schemaFacets,
CreateObjectResponse (..),
newCreateObjectResponse,
createObjectResponse_objectIdentifier,
createObjectResponse_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 CreateObject = CreateObject'
{
CreateObject -> Maybe ObjectReference
parentReference :: Prelude.Maybe ObjectReference,
CreateObject -> Maybe [AttributeKeyAndValue]
objectAttributeList :: Prelude.Maybe [AttributeKeyAndValue],
CreateObject -> Maybe Text
linkName :: Prelude.Maybe Prelude.Text,
CreateObject -> Text
directoryArn :: Prelude.Text,
CreateObject -> [SchemaFacet]
schemaFacets :: [SchemaFacet]
}
deriving (CreateObject -> CreateObject -> Bool
(CreateObject -> CreateObject -> Bool)
-> (CreateObject -> CreateObject -> Bool) -> Eq CreateObject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateObject -> CreateObject -> Bool
$c/= :: CreateObject -> CreateObject -> Bool
== :: CreateObject -> CreateObject -> Bool
$c== :: CreateObject -> CreateObject -> Bool
Prelude.Eq, ReadPrec [CreateObject]
ReadPrec CreateObject
Int -> ReadS CreateObject
ReadS [CreateObject]
(Int -> ReadS CreateObject)
-> ReadS [CreateObject]
-> ReadPrec CreateObject
-> ReadPrec [CreateObject]
-> Read CreateObject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateObject]
$creadListPrec :: ReadPrec [CreateObject]
readPrec :: ReadPrec CreateObject
$creadPrec :: ReadPrec CreateObject
readList :: ReadS [CreateObject]
$creadList :: ReadS [CreateObject]
readsPrec :: Int -> ReadS CreateObject
$creadsPrec :: Int -> ReadS CreateObject
Prelude.Read, Int -> CreateObject -> ShowS
[CreateObject] -> ShowS
CreateObject -> String
(Int -> CreateObject -> ShowS)
-> (CreateObject -> String)
-> ([CreateObject] -> ShowS)
-> Show CreateObject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateObject] -> ShowS
$cshowList :: [CreateObject] -> ShowS
show :: CreateObject -> String
$cshow :: CreateObject -> String
showsPrec :: Int -> CreateObject -> ShowS
$cshowsPrec :: Int -> CreateObject -> ShowS
Prelude.Show, (forall x. CreateObject -> Rep CreateObject x)
-> (forall x. Rep CreateObject x -> CreateObject)
-> Generic CreateObject
forall x. Rep CreateObject x -> CreateObject
forall x. CreateObject -> Rep CreateObject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateObject x -> CreateObject
$cfrom :: forall x. CreateObject -> Rep CreateObject x
Prelude.Generic)
newCreateObject ::
Prelude.Text ->
CreateObject
newCreateObject :: Text -> CreateObject
newCreateObject Text
pDirectoryArn_ =
CreateObject' :: Maybe ObjectReference
-> Maybe [AttributeKeyAndValue]
-> Maybe Text
-> Text
-> [SchemaFacet]
-> CreateObject
CreateObject'
{ $sel:parentReference:CreateObject' :: Maybe ObjectReference
parentReference = Maybe ObjectReference
forall a. Maybe a
Prelude.Nothing,
$sel:objectAttributeList:CreateObject' :: Maybe [AttributeKeyAndValue]
objectAttributeList = Maybe [AttributeKeyAndValue]
forall a. Maybe a
Prelude.Nothing,
$sel:linkName:CreateObject' :: Maybe Text
linkName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:directoryArn:CreateObject' :: Text
directoryArn = Text
pDirectoryArn_,
$sel:schemaFacets:CreateObject' :: [SchemaFacet]
schemaFacets = [SchemaFacet]
forall a. Monoid a => a
Prelude.mempty
}
createObject_parentReference :: Lens.Lens' CreateObject (Prelude.Maybe ObjectReference)
createObject_parentReference :: (Maybe ObjectReference -> f (Maybe ObjectReference))
-> CreateObject -> f CreateObject
createObject_parentReference = (CreateObject -> Maybe ObjectReference)
-> (CreateObject -> Maybe ObjectReference -> CreateObject)
-> Lens
CreateObject
CreateObject
(Maybe ObjectReference)
(Maybe ObjectReference)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateObject' {Maybe ObjectReference
parentReference :: Maybe ObjectReference
$sel:parentReference:CreateObject' :: CreateObject -> Maybe ObjectReference
parentReference} -> Maybe ObjectReference
parentReference) (\s :: CreateObject
s@CreateObject' {} Maybe ObjectReference
a -> CreateObject
s {$sel:parentReference:CreateObject' :: Maybe ObjectReference
parentReference = Maybe ObjectReference
a} :: CreateObject)
createObject_objectAttributeList :: Lens.Lens' CreateObject (Prelude.Maybe [AttributeKeyAndValue])
createObject_objectAttributeList :: (Maybe [AttributeKeyAndValue] -> f (Maybe [AttributeKeyAndValue]))
-> CreateObject -> f CreateObject
createObject_objectAttributeList = (CreateObject -> Maybe [AttributeKeyAndValue])
-> (CreateObject -> Maybe [AttributeKeyAndValue] -> CreateObject)
-> Lens
CreateObject
CreateObject
(Maybe [AttributeKeyAndValue])
(Maybe [AttributeKeyAndValue])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateObject' {Maybe [AttributeKeyAndValue]
objectAttributeList :: Maybe [AttributeKeyAndValue]
$sel:objectAttributeList:CreateObject' :: CreateObject -> Maybe [AttributeKeyAndValue]
objectAttributeList} -> Maybe [AttributeKeyAndValue]
objectAttributeList) (\s :: CreateObject
s@CreateObject' {} Maybe [AttributeKeyAndValue]
a -> CreateObject
s {$sel:objectAttributeList:CreateObject' :: Maybe [AttributeKeyAndValue]
objectAttributeList = Maybe [AttributeKeyAndValue]
a} :: CreateObject) ((Maybe [AttributeKeyAndValue] -> f (Maybe [AttributeKeyAndValue]))
-> CreateObject -> f CreateObject)
-> ((Maybe [AttributeKeyAndValue]
-> f (Maybe [AttributeKeyAndValue]))
-> Maybe [AttributeKeyAndValue]
-> f (Maybe [AttributeKeyAndValue]))
-> (Maybe [AttributeKeyAndValue]
-> f (Maybe [AttributeKeyAndValue]))
-> CreateObject
-> f CreateObject
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[AttributeKeyAndValue]
[AttributeKeyAndValue]
[AttributeKeyAndValue]
[AttributeKeyAndValue]
-> Iso
(Maybe [AttributeKeyAndValue])
(Maybe [AttributeKeyAndValue])
(Maybe [AttributeKeyAndValue])
(Maybe [AttributeKeyAndValue])
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
[AttributeKeyAndValue]
[AttributeKeyAndValue]
[AttributeKeyAndValue]
[AttributeKeyAndValue]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createObject_linkName :: Lens.Lens' CreateObject (Prelude.Maybe Prelude.Text)
createObject_linkName :: (Maybe Text -> f (Maybe Text)) -> CreateObject -> f CreateObject
createObject_linkName = (CreateObject -> Maybe Text)
-> (CreateObject -> Maybe Text -> CreateObject)
-> Lens CreateObject CreateObject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateObject' {Maybe Text
linkName :: Maybe Text
$sel:linkName:CreateObject' :: CreateObject -> Maybe Text
linkName} -> Maybe Text
linkName) (\s :: CreateObject
s@CreateObject' {} Maybe Text
a -> CreateObject
s {$sel:linkName:CreateObject' :: Maybe Text
linkName = Maybe Text
a} :: CreateObject)
createObject_directoryArn :: Lens.Lens' CreateObject Prelude.Text
createObject_directoryArn :: (Text -> f Text) -> CreateObject -> f CreateObject
createObject_directoryArn = (CreateObject -> Text)
-> (CreateObject -> Text -> CreateObject)
-> Lens CreateObject CreateObject Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateObject' {Text
directoryArn :: Text
$sel:directoryArn:CreateObject' :: CreateObject -> Text
directoryArn} -> Text
directoryArn) (\s :: CreateObject
s@CreateObject' {} Text
a -> CreateObject
s {$sel:directoryArn:CreateObject' :: Text
directoryArn = Text
a} :: CreateObject)
createObject_schemaFacets :: Lens.Lens' CreateObject [SchemaFacet]
createObject_schemaFacets :: ([SchemaFacet] -> f [SchemaFacet])
-> CreateObject -> f CreateObject
createObject_schemaFacets = (CreateObject -> [SchemaFacet])
-> (CreateObject -> [SchemaFacet] -> CreateObject)
-> Lens CreateObject CreateObject [SchemaFacet] [SchemaFacet]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateObject' {[SchemaFacet]
schemaFacets :: [SchemaFacet]
$sel:schemaFacets:CreateObject' :: CreateObject -> [SchemaFacet]
schemaFacets} -> [SchemaFacet]
schemaFacets) (\s :: CreateObject
s@CreateObject' {} [SchemaFacet]
a -> CreateObject
s {$sel:schemaFacets:CreateObject' :: [SchemaFacet]
schemaFacets = [SchemaFacet]
a} :: CreateObject) (([SchemaFacet] -> f [SchemaFacet])
-> CreateObject -> f CreateObject)
-> (([SchemaFacet] -> f [SchemaFacet])
-> [SchemaFacet] -> f [SchemaFacet])
-> ([SchemaFacet] -> f [SchemaFacet])
-> CreateObject
-> f CreateObject
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([SchemaFacet] -> f [SchemaFacet])
-> [SchemaFacet] -> f [SchemaFacet]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest CreateObject where
type AWSResponse CreateObject = CreateObjectResponse
request :: CreateObject -> Request CreateObject
request = Service -> CreateObject -> Request CreateObject
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateObject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateObject)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateObject))
-> Logger
-> Service
-> Proxy CreateObject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateObject)))
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 Text -> Int -> CreateObjectResponse
CreateObjectResponse'
(Maybe Text -> Int -> CreateObjectResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateObjectResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ObjectIdentifier")
Either String (Int -> CreateObjectResponse)
-> Either String Int -> Either String CreateObjectResponse
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 CreateObject
instance Prelude.NFData CreateObject
instance Core.ToHeaders CreateObject where
toHeaders :: CreateObject -> ResponseHeaders
toHeaders CreateObject' {[SchemaFacet]
Maybe [AttributeKeyAndValue]
Maybe Text
Maybe ObjectReference
Text
schemaFacets :: [SchemaFacet]
directoryArn :: Text
linkName :: Maybe Text
objectAttributeList :: Maybe [AttributeKeyAndValue]
parentReference :: Maybe ObjectReference
$sel:schemaFacets:CreateObject' :: CreateObject -> [SchemaFacet]
$sel:directoryArn:CreateObject' :: CreateObject -> Text
$sel:linkName:CreateObject' :: CreateObject -> Maybe Text
$sel:objectAttributeList:CreateObject' :: CreateObject -> Maybe [AttributeKeyAndValue]
$sel:parentReference:CreateObject' :: CreateObject -> Maybe ObjectReference
..} =
[ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[HeaderName
"x-amz-data-partition" HeaderName -> Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Text
directoryArn]
instance Core.ToJSON CreateObject where
toJSON :: CreateObject -> Value
toJSON CreateObject' {[SchemaFacet]
Maybe [AttributeKeyAndValue]
Maybe Text
Maybe ObjectReference
Text
schemaFacets :: [SchemaFacet]
directoryArn :: Text
linkName :: Maybe Text
objectAttributeList :: Maybe [AttributeKeyAndValue]
parentReference :: Maybe ObjectReference
$sel:schemaFacets:CreateObject' :: CreateObject -> [SchemaFacet]
$sel:directoryArn:CreateObject' :: CreateObject -> Text
$sel:linkName:CreateObject' :: CreateObject -> Maybe Text
$sel:objectAttributeList:CreateObject' :: CreateObject -> Maybe [AttributeKeyAndValue]
$sel:parentReference:CreateObject' :: CreateObject -> Maybe ObjectReference
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ParentReference" Text -> ObjectReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(ObjectReference -> Pair) -> Maybe ObjectReference -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ObjectReference
parentReference,
(Text
"ObjectAttributeList" Text -> [AttributeKeyAndValue] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
([AttributeKeyAndValue] -> Pair)
-> Maybe [AttributeKeyAndValue] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AttributeKeyAndValue]
objectAttributeList,
(Text
"LinkName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
linkName,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SchemaFacets" Text -> [SchemaFacet] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [SchemaFacet]
schemaFacets)
]
)
instance Core.ToPath CreateObject where
toPath :: CreateObject -> ByteString
toPath =
ByteString -> CreateObject -> ByteString
forall a b. a -> b -> a
Prelude.const
ByteString
"/amazonclouddirectory/2017-01-11/object"
instance Core.ToQuery CreateObject where
toQuery :: CreateObject -> QueryString
toQuery = QueryString -> CreateObject -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateObjectResponse = CreateObjectResponse'
{
CreateObjectResponse -> Maybe Text
objectIdentifier :: Prelude.Maybe Prelude.Text,
CreateObjectResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateObjectResponse -> CreateObjectResponse -> Bool
(CreateObjectResponse -> CreateObjectResponse -> Bool)
-> (CreateObjectResponse -> CreateObjectResponse -> Bool)
-> Eq CreateObjectResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateObjectResponse -> CreateObjectResponse -> Bool
$c/= :: CreateObjectResponse -> CreateObjectResponse -> Bool
== :: CreateObjectResponse -> CreateObjectResponse -> Bool
$c== :: CreateObjectResponse -> CreateObjectResponse -> Bool
Prelude.Eq, ReadPrec [CreateObjectResponse]
ReadPrec CreateObjectResponse
Int -> ReadS CreateObjectResponse
ReadS [CreateObjectResponse]
(Int -> ReadS CreateObjectResponse)
-> ReadS [CreateObjectResponse]
-> ReadPrec CreateObjectResponse
-> ReadPrec [CreateObjectResponse]
-> Read CreateObjectResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateObjectResponse]
$creadListPrec :: ReadPrec [CreateObjectResponse]
readPrec :: ReadPrec CreateObjectResponse
$creadPrec :: ReadPrec CreateObjectResponse
readList :: ReadS [CreateObjectResponse]
$creadList :: ReadS [CreateObjectResponse]
readsPrec :: Int -> ReadS CreateObjectResponse
$creadsPrec :: Int -> ReadS CreateObjectResponse
Prelude.Read, Int -> CreateObjectResponse -> ShowS
[CreateObjectResponse] -> ShowS
CreateObjectResponse -> String
(Int -> CreateObjectResponse -> ShowS)
-> (CreateObjectResponse -> String)
-> ([CreateObjectResponse] -> ShowS)
-> Show CreateObjectResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateObjectResponse] -> ShowS
$cshowList :: [CreateObjectResponse] -> ShowS
show :: CreateObjectResponse -> String
$cshow :: CreateObjectResponse -> String
showsPrec :: Int -> CreateObjectResponse -> ShowS
$cshowsPrec :: Int -> CreateObjectResponse -> ShowS
Prelude.Show, (forall x. CreateObjectResponse -> Rep CreateObjectResponse x)
-> (forall x. Rep CreateObjectResponse x -> CreateObjectResponse)
-> Generic CreateObjectResponse
forall x. Rep CreateObjectResponse x -> CreateObjectResponse
forall x. CreateObjectResponse -> Rep CreateObjectResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateObjectResponse x -> CreateObjectResponse
$cfrom :: forall x. CreateObjectResponse -> Rep CreateObjectResponse x
Prelude.Generic)
newCreateObjectResponse ::
Prelude.Int ->
CreateObjectResponse
newCreateObjectResponse :: Int -> CreateObjectResponse
newCreateObjectResponse Int
pHttpStatus_ =
CreateObjectResponse' :: Maybe Text -> Int -> CreateObjectResponse
CreateObjectResponse'
{ $sel:objectIdentifier:CreateObjectResponse' :: Maybe Text
objectIdentifier =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateObjectResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createObjectResponse_objectIdentifier :: Lens.Lens' CreateObjectResponse (Prelude.Maybe Prelude.Text)
createObjectResponse_objectIdentifier :: (Maybe Text -> f (Maybe Text))
-> CreateObjectResponse -> f CreateObjectResponse
createObjectResponse_objectIdentifier = (CreateObjectResponse -> Maybe Text)
-> (CreateObjectResponse -> Maybe Text -> CreateObjectResponse)
-> Lens
CreateObjectResponse CreateObjectResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateObjectResponse' {Maybe Text
objectIdentifier :: Maybe Text
$sel:objectIdentifier:CreateObjectResponse' :: CreateObjectResponse -> Maybe Text
objectIdentifier} -> Maybe Text
objectIdentifier) (\s :: CreateObjectResponse
s@CreateObjectResponse' {} Maybe Text
a -> CreateObjectResponse
s {$sel:objectIdentifier:CreateObjectResponse' :: Maybe Text
objectIdentifier = Maybe Text
a} :: CreateObjectResponse)
createObjectResponse_httpStatus :: Lens.Lens' CreateObjectResponse Prelude.Int
createObjectResponse_httpStatus :: (Int -> f Int) -> CreateObjectResponse -> f CreateObjectResponse
createObjectResponse_httpStatus = (CreateObjectResponse -> Int)
-> (CreateObjectResponse -> Int -> CreateObjectResponse)
-> Lens CreateObjectResponse CreateObjectResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateObjectResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateObjectResponse' :: CreateObjectResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateObjectResponse
s@CreateObjectResponse' {} Int
a -> CreateObjectResponse
s {$sel:httpStatus:CreateObjectResponse' :: Int
httpStatus = Int
a} :: CreateObjectResponse)
instance Prelude.NFData CreateObjectResponse