{-# 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.AttachObject
(
AttachObject (..),
newAttachObject,
attachObject_directoryArn,
attachObject_parentReference,
attachObject_childReference,
attachObject_linkName,
AttachObjectResponse (..),
newAttachObjectResponse,
attachObjectResponse_attachedObjectIdentifier,
attachObjectResponse_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 AttachObject = AttachObject'
{
AttachObject -> Text
directoryArn :: Prelude.Text,
AttachObject -> ObjectReference
parentReference :: ObjectReference,
AttachObject -> ObjectReference
childReference :: ObjectReference,
AttachObject -> Text
linkName :: Prelude.Text
}
deriving (AttachObject -> AttachObject -> Bool
(AttachObject -> AttachObject -> Bool)
-> (AttachObject -> AttachObject -> Bool) -> Eq AttachObject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachObject -> AttachObject -> Bool
$c/= :: AttachObject -> AttachObject -> Bool
== :: AttachObject -> AttachObject -> Bool
$c== :: AttachObject -> AttachObject -> Bool
Prelude.Eq, ReadPrec [AttachObject]
ReadPrec AttachObject
Int -> ReadS AttachObject
ReadS [AttachObject]
(Int -> ReadS AttachObject)
-> ReadS [AttachObject]
-> ReadPrec AttachObject
-> ReadPrec [AttachObject]
-> Read AttachObject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttachObject]
$creadListPrec :: ReadPrec [AttachObject]
readPrec :: ReadPrec AttachObject
$creadPrec :: ReadPrec AttachObject
readList :: ReadS [AttachObject]
$creadList :: ReadS [AttachObject]
readsPrec :: Int -> ReadS AttachObject
$creadsPrec :: Int -> ReadS AttachObject
Prelude.Read, Int -> AttachObject -> ShowS
[AttachObject] -> ShowS
AttachObject -> String
(Int -> AttachObject -> ShowS)
-> (AttachObject -> String)
-> ([AttachObject] -> ShowS)
-> Show AttachObject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachObject] -> ShowS
$cshowList :: [AttachObject] -> ShowS
show :: AttachObject -> String
$cshow :: AttachObject -> String
showsPrec :: Int -> AttachObject -> ShowS
$cshowsPrec :: Int -> AttachObject -> ShowS
Prelude.Show, (forall x. AttachObject -> Rep AttachObject x)
-> (forall x. Rep AttachObject x -> AttachObject)
-> Generic AttachObject
forall x. Rep AttachObject x -> AttachObject
forall x. AttachObject -> Rep AttachObject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttachObject x -> AttachObject
$cfrom :: forall x. AttachObject -> Rep AttachObject x
Prelude.Generic)
newAttachObject ::
Prelude.Text ->
ObjectReference ->
ObjectReference ->
Prelude.Text ->
AttachObject
newAttachObject :: Text -> ObjectReference -> ObjectReference -> Text -> AttachObject
newAttachObject
Text
pDirectoryArn_
ObjectReference
pParentReference_
ObjectReference
pChildReference_
Text
pLinkName_ =
AttachObject' :: Text -> ObjectReference -> ObjectReference -> Text -> AttachObject
AttachObject'
{ $sel:directoryArn:AttachObject' :: Text
directoryArn = Text
pDirectoryArn_,
$sel:parentReference:AttachObject' :: ObjectReference
parentReference = ObjectReference
pParentReference_,
$sel:childReference:AttachObject' :: ObjectReference
childReference = ObjectReference
pChildReference_,
$sel:linkName:AttachObject' :: Text
linkName = Text
pLinkName_
}
attachObject_directoryArn :: Lens.Lens' AttachObject Prelude.Text
attachObject_directoryArn :: (Text -> f Text) -> AttachObject -> f AttachObject
attachObject_directoryArn = (AttachObject -> Text)
-> (AttachObject -> Text -> AttachObject)
-> Lens AttachObject AttachObject Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachObject' {Text
directoryArn :: Text
$sel:directoryArn:AttachObject' :: AttachObject -> Text
directoryArn} -> Text
directoryArn) (\s :: AttachObject
s@AttachObject' {} Text
a -> AttachObject
s {$sel:directoryArn:AttachObject' :: Text
directoryArn = Text
a} :: AttachObject)
attachObject_parentReference :: Lens.Lens' AttachObject ObjectReference
attachObject_parentReference :: (ObjectReference -> f ObjectReference)
-> AttachObject -> f AttachObject
attachObject_parentReference = (AttachObject -> ObjectReference)
-> (AttachObject -> ObjectReference -> AttachObject)
-> Lens AttachObject AttachObject ObjectReference ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachObject' {ObjectReference
parentReference :: ObjectReference
$sel:parentReference:AttachObject' :: AttachObject -> ObjectReference
parentReference} -> ObjectReference
parentReference) (\s :: AttachObject
s@AttachObject' {} ObjectReference
a -> AttachObject
s {$sel:parentReference:AttachObject' :: ObjectReference
parentReference = ObjectReference
a} :: AttachObject)
attachObject_childReference :: Lens.Lens' AttachObject ObjectReference
attachObject_childReference :: (ObjectReference -> f ObjectReference)
-> AttachObject -> f AttachObject
attachObject_childReference = (AttachObject -> ObjectReference)
-> (AttachObject -> ObjectReference -> AttachObject)
-> Lens AttachObject AttachObject ObjectReference ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachObject' {ObjectReference
childReference :: ObjectReference
$sel:childReference:AttachObject' :: AttachObject -> ObjectReference
childReference} -> ObjectReference
childReference) (\s :: AttachObject
s@AttachObject' {} ObjectReference
a -> AttachObject
s {$sel:childReference:AttachObject' :: ObjectReference
childReference = ObjectReference
a} :: AttachObject)
attachObject_linkName :: Lens.Lens' AttachObject Prelude.Text
attachObject_linkName :: (Text -> f Text) -> AttachObject -> f AttachObject
attachObject_linkName = (AttachObject -> Text)
-> (AttachObject -> Text -> AttachObject)
-> Lens AttachObject AttachObject Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachObject' {Text
linkName :: Text
$sel:linkName:AttachObject' :: AttachObject -> Text
linkName} -> Text
linkName) (\s :: AttachObject
s@AttachObject' {} Text
a -> AttachObject
s {$sel:linkName:AttachObject' :: Text
linkName = Text
a} :: AttachObject)
instance Core.AWSRequest AttachObject where
type AWSResponse AttachObject = AttachObjectResponse
request :: AttachObject -> Request AttachObject
request = Service -> AttachObject -> Request AttachObject
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
response :: Logger
-> Service
-> Proxy AttachObject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AttachObject)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse AttachObject))
-> Logger
-> Service
-> Proxy AttachObject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AttachObject)))
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 -> AttachObjectResponse
AttachObjectResponse'
(Maybe Text -> Int -> AttachObjectResponse)
-> Either String (Maybe Text)
-> Either String (Int -> AttachObjectResponse)
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
"AttachedObjectIdentifier")
Either String (Int -> AttachObjectResponse)
-> Either String Int -> Either String AttachObjectResponse
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 AttachObject
instance Prelude.NFData AttachObject
instance Core.ToHeaders AttachObject where
toHeaders :: AttachObject -> ResponseHeaders
toHeaders AttachObject' {Text
ObjectReference
linkName :: Text
childReference :: ObjectReference
parentReference :: ObjectReference
directoryArn :: Text
$sel:linkName:AttachObject' :: AttachObject -> Text
$sel:childReference:AttachObject' :: AttachObject -> ObjectReference
$sel:parentReference:AttachObject' :: AttachObject -> ObjectReference
$sel:directoryArn:AttachObject' :: AttachObject -> Text
..} =
[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 AttachObject where
toJSON :: AttachObject -> Value
toJSON AttachObject' {Text
ObjectReference
linkName :: Text
childReference :: ObjectReference
parentReference :: ObjectReference
directoryArn :: Text
$sel:linkName:AttachObject' :: AttachObject -> Text
$sel:childReference:AttachObject' :: AttachObject -> ObjectReference
$sel:parentReference:AttachObject' :: AttachObject -> ObjectReference
$sel:directoryArn:AttachObject' :: AttachObject -> 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
"ParentReference" Text -> ObjectReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ObjectReference
parentReference),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"ChildReference" Text -> ObjectReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ObjectReference
childReference),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"LinkName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
linkName)
]
)
instance Core.ToPath AttachObject where
toPath :: AttachObject -> ByteString
toPath =
ByteString -> AttachObject -> ByteString
forall a b. a -> b -> a
Prelude.const
ByteString
"/amazonclouddirectory/2017-01-11/object/attach"
instance Core.ToQuery AttachObject where
toQuery :: AttachObject -> QueryString
toQuery = QueryString -> AttachObject -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data AttachObjectResponse = AttachObjectResponse'
{
AttachObjectResponse -> Maybe Text
attachedObjectIdentifier :: Prelude.Maybe Prelude.Text,
AttachObjectResponse -> Int
httpStatus :: Prelude.Int
}
deriving (AttachObjectResponse -> AttachObjectResponse -> Bool
(AttachObjectResponse -> AttachObjectResponse -> Bool)
-> (AttachObjectResponse -> AttachObjectResponse -> Bool)
-> Eq AttachObjectResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachObjectResponse -> AttachObjectResponse -> Bool
$c/= :: AttachObjectResponse -> AttachObjectResponse -> Bool
== :: AttachObjectResponse -> AttachObjectResponse -> Bool
$c== :: AttachObjectResponse -> AttachObjectResponse -> Bool
Prelude.Eq, ReadPrec [AttachObjectResponse]
ReadPrec AttachObjectResponse
Int -> ReadS AttachObjectResponse
ReadS [AttachObjectResponse]
(Int -> ReadS AttachObjectResponse)
-> ReadS [AttachObjectResponse]
-> ReadPrec AttachObjectResponse
-> ReadPrec [AttachObjectResponse]
-> Read AttachObjectResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttachObjectResponse]
$creadListPrec :: ReadPrec [AttachObjectResponse]
readPrec :: ReadPrec AttachObjectResponse
$creadPrec :: ReadPrec AttachObjectResponse
readList :: ReadS [AttachObjectResponse]
$creadList :: ReadS [AttachObjectResponse]
readsPrec :: Int -> ReadS AttachObjectResponse
$creadsPrec :: Int -> ReadS AttachObjectResponse
Prelude.Read, Int -> AttachObjectResponse -> ShowS
[AttachObjectResponse] -> ShowS
AttachObjectResponse -> String
(Int -> AttachObjectResponse -> ShowS)
-> (AttachObjectResponse -> String)
-> ([AttachObjectResponse] -> ShowS)
-> Show AttachObjectResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachObjectResponse] -> ShowS
$cshowList :: [AttachObjectResponse] -> ShowS
show :: AttachObjectResponse -> String
$cshow :: AttachObjectResponse -> String
showsPrec :: Int -> AttachObjectResponse -> ShowS
$cshowsPrec :: Int -> AttachObjectResponse -> ShowS
Prelude.Show, (forall x. AttachObjectResponse -> Rep AttachObjectResponse x)
-> (forall x. Rep AttachObjectResponse x -> AttachObjectResponse)
-> Generic AttachObjectResponse
forall x. Rep AttachObjectResponse x -> AttachObjectResponse
forall x. AttachObjectResponse -> Rep AttachObjectResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttachObjectResponse x -> AttachObjectResponse
$cfrom :: forall x. AttachObjectResponse -> Rep AttachObjectResponse x
Prelude.Generic)
newAttachObjectResponse ::
Prelude.Int ->
AttachObjectResponse
newAttachObjectResponse :: Int -> AttachObjectResponse
newAttachObjectResponse Int
pHttpStatus_ =
AttachObjectResponse' :: Maybe Text -> Int -> AttachObjectResponse
AttachObjectResponse'
{ $sel:attachedObjectIdentifier:AttachObjectResponse' :: Maybe Text
attachedObjectIdentifier =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:AttachObjectResponse' :: Int
httpStatus = Int
pHttpStatus_
}
attachObjectResponse_attachedObjectIdentifier :: Lens.Lens' AttachObjectResponse (Prelude.Maybe Prelude.Text)
attachObjectResponse_attachedObjectIdentifier :: (Maybe Text -> f (Maybe Text))
-> AttachObjectResponse -> f AttachObjectResponse
attachObjectResponse_attachedObjectIdentifier = (AttachObjectResponse -> Maybe Text)
-> (AttachObjectResponse -> Maybe Text -> AttachObjectResponse)
-> Lens
AttachObjectResponse AttachObjectResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachObjectResponse' {Maybe Text
attachedObjectIdentifier :: Maybe Text
$sel:attachedObjectIdentifier:AttachObjectResponse' :: AttachObjectResponse -> Maybe Text
attachedObjectIdentifier} -> Maybe Text
attachedObjectIdentifier) (\s :: AttachObjectResponse
s@AttachObjectResponse' {} Maybe Text
a -> AttachObjectResponse
s {$sel:attachedObjectIdentifier:AttachObjectResponse' :: Maybe Text
attachedObjectIdentifier = Maybe Text
a} :: AttachObjectResponse)
attachObjectResponse_httpStatus :: Lens.Lens' AttachObjectResponse Prelude.Int
attachObjectResponse_httpStatus :: (Int -> f Int) -> AttachObjectResponse -> f AttachObjectResponse
attachObjectResponse_httpStatus = (AttachObjectResponse -> Int)
-> (AttachObjectResponse -> Int -> AttachObjectResponse)
-> Lens AttachObjectResponse AttachObjectResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachObjectResponse' {Int
httpStatus :: Int
$sel:httpStatus:AttachObjectResponse' :: AttachObjectResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AttachObjectResponse
s@AttachObjectResponse' {} Int
a -> AttachObjectResponse
s {$sel:httpStatus:AttachObjectResponse' :: Int
httpStatus = Int
a} :: AttachObjectResponse)
instance Prelude.NFData AttachObjectResponse