{-# 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.DirectoryService.CreateAlias
(
CreateAlias (..),
newCreateAlias,
createAlias_directoryId,
createAlias_alias,
CreateAliasResponse (..),
newCreateAliasResponse,
createAliasResponse_directoryId,
createAliasResponse_alias,
createAliasResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.DirectoryService.Types
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 CreateAlias = CreateAlias'
{
CreateAlias -> Text
directoryId :: Prelude.Text,
CreateAlias -> Text
alias :: Prelude.Text
}
deriving (CreateAlias -> CreateAlias -> Bool
(CreateAlias -> CreateAlias -> Bool)
-> (CreateAlias -> CreateAlias -> Bool) -> Eq CreateAlias
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAlias -> CreateAlias -> Bool
$c/= :: CreateAlias -> CreateAlias -> Bool
== :: CreateAlias -> CreateAlias -> Bool
$c== :: CreateAlias -> CreateAlias -> Bool
Prelude.Eq, ReadPrec [CreateAlias]
ReadPrec CreateAlias
Int -> ReadS CreateAlias
ReadS [CreateAlias]
(Int -> ReadS CreateAlias)
-> ReadS [CreateAlias]
-> ReadPrec CreateAlias
-> ReadPrec [CreateAlias]
-> Read CreateAlias
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAlias]
$creadListPrec :: ReadPrec [CreateAlias]
readPrec :: ReadPrec CreateAlias
$creadPrec :: ReadPrec CreateAlias
readList :: ReadS [CreateAlias]
$creadList :: ReadS [CreateAlias]
readsPrec :: Int -> ReadS CreateAlias
$creadsPrec :: Int -> ReadS CreateAlias
Prelude.Read, Int -> CreateAlias -> ShowS
[CreateAlias] -> ShowS
CreateAlias -> String
(Int -> CreateAlias -> ShowS)
-> (CreateAlias -> String)
-> ([CreateAlias] -> ShowS)
-> Show CreateAlias
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAlias] -> ShowS
$cshowList :: [CreateAlias] -> ShowS
show :: CreateAlias -> String
$cshow :: CreateAlias -> String
showsPrec :: Int -> CreateAlias -> ShowS
$cshowsPrec :: Int -> CreateAlias -> ShowS
Prelude.Show, (forall x. CreateAlias -> Rep CreateAlias x)
-> (forall x. Rep CreateAlias x -> CreateAlias)
-> Generic CreateAlias
forall x. Rep CreateAlias x -> CreateAlias
forall x. CreateAlias -> Rep CreateAlias x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAlias x -> CreateAlias
$cfrom :: forall x. CreateAlias -> Rep CreateAlias x
Prelude.Generic)
newCreateAlias ::
Prelude.Text ->
Prelude.Text ->
CreateAlias
newCreateAlias :: Text -> Text -> CreateAlias
newCreateAlias Text
pDirectoryId_ Text
pAlias_ =
CreateAlias' :: Text -> Text -> CreateAlias
CreateAlias'
{ $sel:directoryId:CreateAlias' :: Text
directoryId = Text
pDirectoryId_,
$sel:alias:CreateAlias' :: Text
alias = Text
pAlias_
}
createAlias_directoryId :: Lens.Lens' CreateAlias Prelude.Text
createAlias_directoryId :: (Text -> f Text) -> CreateAlias -> f CreateAlias
createAlias_directoryId = (CreateAlias -> Text)
-> (CreateAlias -> Text -> CreateAlias)
-> Lens CreateAlias CreateAlias Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAlias' {Text
directoryId :: Text
$sel:directoryId:CreateAlias' :: CreateAlias -> Text
directoryId} -> Text
directoryId) (\s :: CreateAlias
s@CreateAlias' {} Text
a -> CreateAlias
s {$sel:directoryId:CreateAlias' :: Text
directoryId = Text
a} :: CreateAlias)
createAlias_alias :: Lens.Lens' CreateAlias Prelude.Text
createAlias_alias :: (Text -> f Text) -> CreateAlias -> f CreateAlias
createAlias_alias = (CreateAlias -> Text)
-> (CreateAlias -> Text -> CreateAlias)
-> Lens CreateAlias CreateAlias Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAlias' {Text
alias :: Text
$sel:alias:CreateAlias' :: CreateAlias -> Text
alias} -> Text
alias) (\s :: CreateAlias
s@CreateAlias' {} Text
a -> CreateAlias
s {$sel:alias:CreateAlias' :: Text
alias = Text
a} :: CreateAlias)
instance Core.AWSRequest CreateAlias where
type AWSResponse CreateAlias = CreateAliasResponse
request :: CreateAlias -> Request CreateAlias
request = Service -> CreateAlias -> Request CreateAlias
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateAlias
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateAlias)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateAlias))
-> Logger
-> Service
-> Proxy CreateAlias
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateAlias)))
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 -> Maybe Text -> Int -> CreateAliasResponse
CreateAliasResponse'
(Maybe Text -> Maybe Text -> Int -> CreateAliasResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> CreateAliasResponse)
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
"DirectoryId")
Either String (Maybe Text -> Int -> CreateAliasResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateAliasResponse)
forall (f :: * -> *) a b. Applicative f => 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
"Alias")
Either String (Int -> CreateAliasResponse)
-> Either String Int -> Either String CreateAliasResponse
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 CreateAlias
instance Prelude.NFData CreateAlias
instance Core.ToHeaders CreateAlias where
toHeaders :: CreateAlias -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateAlias -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"DirectoryService_20150416.CreateAlias" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON CreateAlias where
toJSON :: CreateAlias -> Value
toJSON CreateAlias' {Text
alias :: Text
directoryId :: Text
$sel:alias:CreateAlias' :: CreateAlias -> Text
$sel:directoryId:CreateAlias' :: CreateAlias -> 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
"DirectoryId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
directoryId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Alias" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
alias)
]
)
instance Core.ToPath CreateAlias where
toPath :: CreateAlias -> ByteString
toPath = ByteString -> CreateAlias -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateAlias where
toQuery :: CreateAlias -> QueryString
toQuery = QueryString -> CreateAlias -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateAliasResponse = CreateAliasResponse'
{
CreateAliasResponse -> Maybe Text
directoryId :: Prelude.Maybe Prelude.Text,
CreateAliasResponse -> Maybe Text
alias :: Prelude.Maybe Prelude.Text,
CreateAliasResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateAliasResponse -> CreateAliasResponse -> Bool
(CreateAliasResponse -> CreateAliasResponse -> Bool)
-> (CreateAliasResponse -> CreateAliasResponse -> Bool)
-> Eq CreateAliasResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAliasResponse -> CreateAliasResponse -> Bool
$c/= :: CreateAliasResponse -> CreateAliasResponse -> Bool
== :: CreateAliasResponse -> CreateAliasResponse -> Bool
$c== :: CreateAliasResponse -> CreateAliasResponse -> Bool
Prelude.Eq, ReadPrec [CreateAliasResponse]
ReadPrec CreateAliasResponse
Int -> ReadS CreateAliasResponse
ReadS [CreateAliasResponse]
(Int -> ReadS CreateAliasResponse)
-> ReadS [CreateAliasResponse]
-> ReadPrec CreateAliasResponse
-> ReadPrec [CreateAliasResponse]
-> Read CreateAliasResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAliasResponse]
$creadListPrec :: ReadPrec [CreateAliasResponse]
readPrec :: ReadPrec CreateAliasResponse
$creadPrec :: ReadPrec CreateAliasResponse
readList :: ReadS [CreateAliasResponse]
$creadList :: ReadS [CreateAliasResponse]
readsPrec :: Int -> ReadS CreateAliasResponse
$creadsPrec :: Int -> ReadS CreateAliasResponse
Prelude.Read, Int -> CreateAliasResponse -> ShowS
[CreateAliasResponse] -> ShowS
CreateAliasResponse -> String
(Int -> CreateAliasResponse -> ShowS)
-> (CreateAliasResponse -> String)
-> ([CreateAliasResponse] -> ShowS)
-> Show CreateAliasResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAliasResponse] -> ShowS
$cshowList :: [CreateAliasResponse] -> ShowS
show :: CreateAliasResponse -> String
$cshow :: CreateAliasResponse -> String
showsPrec :: Int -> CreateAliasResponse -> ShowS
$cshowsPrec :: Int -> CreateAliasResponse -> ShowS
Prelude.Show, (forall x. CreateAliasResponse -> Rep CreateAliasResponse x)
-> (forall x. Rep CreateAliasResponse x -> CreateAliasResponse)
-> Generic CreateAliasResponse
forall x. Rep CreateAliasResponse x -> CreateAliasResponse
forall x. CreateAliasResponse -> Rep CreateAliasResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAliasResponse x -> CreateAliasResponse
$cfrom :: forall x. CreateAliasResponse -> Rep CreateAliasResponse x
Prelude.Generic)
newCreateAliasResponse ::
Prelude.Int ->
CreateAliasResponse
newCreateAliasResponse :: Int -> CreateAliasResponse
newCreateAliasResponse Int
pHttpStatus_ =
CreateAliasResponse' :: Maybe Text -> Maybe Text -> Int -> CreateAliasResponse
CreateAliasResponse'
{ $sel:directoryId:CreateAliasResponse' :: Maybe Text
directoryId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:alias:CreateAliasResponse' :: Maybe Text
alias = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateAliasResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createAliasResponse_directoryId :: Lens.Lens' CreateAliasResponse (Prelude.Maybe Prelude.Text)
createAliasResponse_directoryId :: (Maybe Text -> f (Maybe Text))
-> CreateAliasResponse -> f CreateAliasResponse
createAliasResponse_directoryId = (CreateAliasResponse -> Maybe Text)
-> (CreateAliasResponse -> Maybe Text -> CreateAliasResponse)
-> Lens
CreateAliasResponse CreateAliasResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAliasResponse' {Maybe Text
directoryId :: Maybe Text
$sel:directoryId:CreateAliasResponse' :: CreateAliasResponse -> Maybe Text
directoryId} -> Maybe Text
directoryId) (\s :: CreateAliasResponse
s@CreateAliasResponse' {} Maybe Text
a -> CreateAliasResponse
s {$sel:directoryId:CreateAliasResponse' :: Maybe Text
directoryId = Maybe Text
a} :: CreateAliasResponse)
createAliasResponse_alias :: Lens.Lens' CreateAliasResponse (Prelude.Maybe Prelude.Text)
createAliasResponse_alias :: (Maybe Text -> f (Maybe Text))
-> CreateAliasResponse -> f CreateAliasResponse
createAliasResponse_alias = (CreateAliasResponse -> Maybe Text)
-> (CreateAliasResponse -> Maybe Text -> CreateAliasResponse)
-> Lens
CreateAliasResponse CreateAliasResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAliasResponse' {Maybe Text
alias :: Maybe Text
$sel:alias:CreateAliasResponse' :: CreateAliasResponse -> Maybe Text
alias} -> Maybe Text
alias) (\s :: CreateAliasResponse
s@CreateAliasResponse' {} Maybe Text
a -> CreateAliasResponse
s {$sel:alias:CreateAliasResponse' :: Maybe Text
alias = Maybe Text
a} :: CreateAliasResponse)
createAliasResponse_httpStatus :: Lens.Lens' CreateAliasResponse Prelude.Int
createAliasResponse_httpStatus :: (Int -> f Int) -> CreateAliasResponse -> f CreateAliasResponse
createAliasResponse_httpStatus = (CreateAliasResponse -> Int)
-> (CreateAliasResponse -> Int -> CreateAliasResponse)
-> Lens CreateAliasResponse CreateAliasResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAliasResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateAliasResponse' :: CreateAliasResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateAliasResponse
s@CreateAliasResponse' {} Int
a -> CreateAliasResponse
s {$sel:httpStatus:CreateAliasResponse' :: Int
httpStatus = Int
a} :: CreateAliasResponse)
instance Prelude.NFData CreateAliasResponse