{-# 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.CreateComputer
(
CreateComputer (..),
newCreateComputer,
createComputer_computerAttributes,
createComputer_organizationalUnitDistinguishedName,
createComputer_directoryId,
createComputer_computerName,
createComputer_password,
CreateComputerResponse (..),
newCreateComputerResponse,
createComputerResponse_computer,
createComputerResponse_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 CreateComputer = CreateComputer'
{
CreateComputer -> Maybe [Attribute]
computerAttributes :: Prelude.Maybe [Attribute],
CreateComputer -> Maybe Text
organizationalUnitDistinguishedName :: Prelude.Maybe Prelude.Text,
CreateComputer -> Text
directoryId :: Prelude.Text,
CreateComputer -> Text
computerName :: Prelude.Text,
CreateComputer -> Sensitive Text
password :: Core.Sensitive Prelude.Text
}
deriving (CreateComputer -> CreateComputer -> Bool
(CreateComputer -> CreateComputer -> Bool)
-> (CreateComputer -> CreateComputer -> Bool) -> Eq CreateComputer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateComputer -> CreateComputer -> Bool
$c/= :: CreateComputer -> CreateComputer -> Bool
== :: CreateComputer -> CreateComputer -> Bool
$c== :: CreateComputer -> CreateComputer -> Bool
Prelude.Eq, Int -> CreateComputer -> ShowS
[CreateComputer] -> ShowS
CreateComputer -> String
(Int -> CreateComputer -> ShowS)
-> (CreateComputer -> String)
-> ([CreateComputer] -> ShowS)
-> Show CreateComputer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateComputer] -> ShowS
$cshowList :: [CreateComputer] -> ShowS
show :: CreateComputer -> String
$cshow :: CreateComputer -> String
showsPrec :: Int -> CreateComputer -> ShowS
$cshowsPrec :: Int -> CreateComputer -> ShowS
Prelude.Show, (forall x. CreateComputer -> Rep CreateComputer x)
-> (forall x. Rep CreateComputer x -> CreateComputer)
-> Generic CreateComputer
forall x. Rep CreateComputer x -> CreateComputer
forall x. CreateComputer -> Rep CreateComputer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateComputer x -> CreateComputer
$cfrom :: forall x. CreateComputer -> Rep CreateComputer x
Prelude.Generic)
newCreateComputer ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
CreateComputer
newCreateComputer :: Text -> Text -> Text -> CreateComputer
newCreateComputer
Text
pDirectoryId_
Text
pComputerName_
Text
pPassword_ =
CreateComputer' :: Maybe [Attribute]
-> Maybe Text -> Text -> Text -> Sensitive Text -> CreateComputer
CreateComputer'
{ $sel:computerAttributes:CreateComputer' :: Maybe [Attribute]
computerAttributes =
Maybe [Attribute]
forall a. Maybe a
Prelude.Nothing,
$sel:organizationalUnitDistinguishedName:CreateComputer' :: Maybe Text
organizationalUnitDistinguishedName =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:directoryId:CreateComputer' :: Text
directoryId = Text
pDirectoryId_,
$sel:computerName:CreateComputer' :: Text
computerName = Text
pComputerName_,
$sel:password:CreateComputer' :: Sensitive Text
password = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pPassword_
}
createComputer_computerAttributes :: Lens.Lens' CreateComputer (Prelude.Maybe [Attribute])
createComputer_computerAttributes :: (Maybe [Attribute] -> f (Maybe [Attribute]))
-> CreateComputer -> f CreateComputer
createComputer_computerAttributes = (CreateComputer -> Maybe [Attribute])
-> (CreateComputer -> Maybe [Attribute] -> CreateComputer)
-> Lens
CreateComputer
CreateComputer
(Maybe [Attribute])
(Maybe [Attribute])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComputer' {Maybe [Attribute]
computerAttributes :: Maybe [Attribute]
$sel:computerAttributes:CreateComputer' :: CreateComputer -> Maybe [Attribute]
computerAttributes} -> Maybe [Attribute]
computerAttributes) (\s :: CreateComputer
s@CreateComputer' {} Maybe [Attribute]
a -> CreateComputer
s {$sel:computerAttributes:CreateComputer' :: Maybe [Attribute]
computerAttributes = Maybe [Attribute]
a} :: CreateComputer) ((Maybe [Attribute] -> f (Maybe [Attribute]))
-> CreateComputer -> f CreateComputer)
-> ((Maybe [Attribute] -> f (Maybe [Attribute]))
-> Maybe [Attribute] -> f (Maybe [Attribute]))
-> (Maybe [Attribute] -> f (Maybe [Attribute]))
-> CreateComputer
-> f CreateComputer
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Attribute] [Attribute] [Attribute] [Attribute]
-> Iso
(Maybe [Attribute])
(Maybe [Attribute])
(Maybe [Attribute])
(Maybe [Attribute])
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 [Attribute] [Attribute] [Attribute] [Attribute]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createComputer_organizationalUnitDistinguishedName :: Lens.Lens' CreateComputer (Prelude.Maybe Prelude.Text)
createComputer_organizationalUnitDistinguishedName :: (Maybe Text -> f (Maybe Text))
-> CreateComputer -> f CreateComputer
createComputer_organizationalUnitDistinguishedName = (CreateComputer -> Maybe Text)
-> (CreateComputer -> Maybe Text -> CreateComputer)
-> Lens CreateComputer CreateComputer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComputer' {Maybe Text
organizationalUnitDistinguishedName :: Maybe Text
$sel:organizationalUnitDistinguishedName:CreateComputer' :: CreateComputer -> Maybe Text
organizationalUnitDistinguishedName} -> Maybe Text
organizationalUnitDistinguishedName) (\s :: CreateComputer
s@CreateComputer' {} Maybe Text
a -> CreateComputer
s {$sel:organizationalUnitDistinguishedName:CreateComputer' :: Maybe Text
organizationalUnitDistinguishedName = Maybe Text
a} :: CreateComputer)
createComputer_directoryId :: Lens.Lens' CreateComputer Prelude.Text
createComputer_directoryId :: (Text -> f Text) -> CreateComputer -> f CreateComputer
createComputer_directoryId = (CreateComputer -> Text)
-> (CreateComputer -> Text -> CreateComputer)
-> Lens CreateComputer CreateComputer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComputer' {Text
directoryId :: Text
$sel:directoryId:CreateComputer' :: CreateComputer -> Text
directoryId} -> Text
directoryId) (\s :: CreateComputer
s@CreateComputer' {} Text
a -> CreateComputer
s {$sel:directoryId:CreateComputer' :: Text
directoryId = Text
a} :: CreateComputer)
createComputer_computerName :: Lens.Lens' CreateComputer Prelude.Text
createComputer_computerName :: (Text -> f Text) -> CreateComputer -> f CreateComputer
createComputer_computerName = (CreateComputer -> Text)
-> (CreateComputer -> Text -> CreateComputer)
-> Lens CreateComputer CreateComputer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComputer' {Text
computerName :: Text
$sel:computerName:CreateComputer' :: CreateComputer -> Text
computerName} -> Text
computerName) (\s :: CreateComputer
s@CreateComputer' {} Text
a -> CreateComputer
s {$sel:computerName:CreateComputer' :: Text
computerName = Text
a} :: CreateComputer)
createComputer_password :: Lens.Lens' CreateComputer Prelude.Text
createComputer_password :: (Text -> f Text) -> CreateComputer -> f CreateComputer
createComputer_password = (CreateComputer -> Sensitive Text)
-> (CreateComputer -> Sensitive Text -> CreateComputer)
-> Lens
CreateComputer CreateComputer (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComputer' {Sensitive Text
password :: Sensitive Text
$sel:password:CreateComputer' :: CreateComputer -> Sensitive Text
password} -> Sensitive Text
password) (\s :: CreateComputer
s@CreateComputer' {} Sensitive Text
a -> CreateComputer
s {$sel:password:CreateComputer' :: Sensitive Text
password = Sensitive Text
a} :: CreateComputer) ((Sensitive Text -> f (Sensitive Text))
-> CreateComputer -> f CreateComputer)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> CreateComputer
-> f CreateComputer
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive
instance Core.AWSRequest CreateComputer where
type
AWSResponse CreateComputer =
CreateComputerResponse
request :: CreateComputer -> Request CreateComputer
request = Service -> CreateComputer -> Request CreateComputer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateComputer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateComputer)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateComputer))
-> Logger
-> Service
-> Proxy CreateComputer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateComputer)))
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 Computer -> Int -> CreateComputerResponse
CreateComputerResponse'
(Maybe Computer -> Int -> CreateComputerResponse)
-> Either String (Maybe Computer)
-> Either String (Int -> CreateComputerResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Computer)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Computer")
Either String (Int -> CreateComputerResponse)
-> Either String Int -> Either String CreateComputerResponse
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 CreateComputer
instance Prelude.NFData CreateComputer
instance Core.ToHeaders CreateComputer where
toHeaders :: CreateComputer -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateComputer -> 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.CreateComputer" ::
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 CreateComputer where
toJSON :: CreateComputer -> Value
toJSON CreateComputer' {Maybe [Attribute]
Maybe Text
Text
Sensitive Text
password :: Sensitive Text
computerName :: Text
directoryId :: Text
organizationalUnitDistinguishedName :: Maybe Text
computerAttributes :: Maybe [Attribute]
$sel:password:CreateComputer' :: CreateComputer -> Sensitive Text
$sel:computerName:CreateComputer' :: CreateComputer -> Text
$sel:directoryId:CreateComputer' :: CreateComputer -> Text
$sel:organizationalUnitDistinguishedName:CreateComputer' :: CreateComputer -> Maybe Text
$sel:computerAttributes:CreateComputer' :: CreateComputer -> Maybe [Attribute]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ComputerAttributes" Text -> [Attribute] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
([Attribute] -> Pair) -> Maybe [Attribute] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Attribute]
computerAttributes,
(Text
"OrganizationalUnitDistinguishedName" 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
organizationalUnitDistinguishedName,
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
"ComputerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
computerName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Password" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
password)
]
)
instance Core.ToPath CreateComputer where
toPath :: CreateComputer -> ByteString
toPath = ByteString -> CreateComputer -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateComputer where
toQuery :: CreateComputer -> QueryString
toQuery = QueryString -> CreateComputer -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateComputerResponse = CreateComputerResponse'
{
CreateComputerResponse -> Maybe Computer
computer :: Prelude.Maybe Computer,
CreateComputerResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateComputerResponse -> CreateComputerResponse -> Bool
(CreateComputerResponse -> CreateComputerResponse -> Bool)
-> (CreateComputerResponse -> CreateComputerResponse -> Bool)
-> Eq CreateComputerResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateComputerResponse -> CreateComputerResponse -> Bool
$c/= :: CreateComputerResponse -> CreateComputerResponse -> Bool
== :: CreateComputerResponse -> CreateComputerResponse -> Bool
$c== :: CreateComputerResponse -> CreateComputerResponse -> Bool
Prelude.Eq, ReadPrec [CreateComputerResponse]
ReadPrec CreateComputerResponse
Int -> ReadS CreateComputerResponse
ReadS [CreateComputerResponse]
(Int -> ReadS CreateComputerResponse)
-> ReadS [CreateComputerResponse]
-> ReadPrec CreateComputerResponse
-> ReadPrec [CreateComputerResponse]
-> Read CreateComputerResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateComputerResponse]
$creadListPrec :: ReadPrec [CreateComputerResponse]
readPrec :: ReadPrec CreateComputerResponse
$creadPrec :: ReadPrec CreateComputerResponse
readList :: ReadS [CreateComputerResponse]
$creadList :: ReadS [CreateComputerResponse]
readsPrec :: Int -> ReadS CreateComputerResponse
$creadsPrec :: Int -> ReadS CreateComputerResponse
Prelude.Read, Int -> CreateComputerResponse -> ShowS
[CreateComputerResponse] -> ShowS
CreateComputerResponse -> String
(Int -> CreateComputerResponse -> ShowS)
-> (CreateComputerResponse -> String)
-> ([CreateComputerResponse] -> ShowS)
-> Show CreateComputerResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateComputerResponse] -> ShowS
$cshowList :: [CreateComputerResponse] -> ShowS
show :: CreateComputerResponse -> String
$cshow :: CreateComputerResponse -> String
showsPrec :: Int -> CreateComputerResponse -> ShowS
$cshowsPrec :: Int -> CreateComputerResponse -> ShowS
Prelude.Show, (forall x. CreateComputerResponse -> Rep CreateComputerResponse x)
-> (forall x.
Rep CreateComputerResponse x -> CreateComputerResponse)
-> Generic CreateComputerResponse
forall x. Rep CreateComputerResponse x -> CreateComputerResponse
forall x. CreateComputerResponse -> Rep CreateComputerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateComputerResponse x -> CreateComputerResponse
$cfrom :: forall x. CreateComputerResponse -> Rep CreateComputerResponse x
Prelude.Generic)
newCreateComputerResponse ::
Prelude.Int ->
CreateComputerResponse
newCreateComputerResponse :: Int -> CreateComputerResponse
newCreateComputerResponse Int
pHttpStatus_ =
CreateComputerResponse' :: Maybe Computer -> Int -> CreateComputerResponse
CreateComputerResponse'
{ $sel:computer:CreateComputerResponse' :: Maybe Computer
computer = Maybe Computer
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateComputerResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createComputerResponse_computer :: Lens.Lens' CreateComputerResponse (Prelude.Maybe Computer)
createComputerResponse_computer :: (Maybe Computer -> f (Maybe Computer))
-> CreateComputerResponse -> f CreateComputerResponse
createComputerResponse_computer = (CreateComputerResponse -> Maybe Computer)
-> (CreateComputerResponse
-> Maybe Computer -> CreateComputerResponse)
-> Lens
CreateComputerResponse
CreateComputerResponse
(Maybe Computer)
(Maybe Computer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComputerResponse' {Maybe Computer
computer :: Maybe Computer
$sel:computer:CreateComputerResponse' :: CreateComputerResponse -> Maybe Computer
computer} -> Maybe Computer
computer) (\s :: CreateComputerResponse
s@CreateComputerResponse' {} Maybe Computer
a -> CreateComputerResponse
s {$sel:computer:CreateComputerResponse' :: Maybe Computer
computer = Maybe Computer
a} :: CreateComputerResponse)
createComputerResponse_httpStatus :: Lens.Lens' CreateComputerResponse Prelude.Int
createComputerResponse_httpStatus :: (Int -> f Int)
-> CreateComputerResponse -> f CreateComputerResponse
createComputerResponse_httpStatus = (CreateComputerResponse -> Int)
-> (CreateComputerResponse -> Int -> CreateComputerResponse)
-> Lens CreateComputerResponse CreateComputerResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComputerResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateComputerResponse' :: CreateComputerResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateComputerResponse
s@CreateComputerResponse' {} Int
a -> CreateComputerResponse
s {$sel:httpStatus:CreateComputerResponse' :: Int
httpStatus = Int
a} :: CreateComputerResponse)
instance Prelude.NFData CreateComputerResponse