{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.DirectoryService.CreateDirectory
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a Simple AD directory. For more information, see
-- <https://docs.aws.amazon.com/directoryservice/latest/admin-guide/directory_simple_ad.html Simple Active Directory>
-- in the /Directory Service Admin Guide/.
--
-- Before you call @CreateDirectory@, ensure that all of the required
-- permissions have been explicitly granted through a policy. For details
-- about what permissions are required to run the @CreateDirectory@
-- operation, see
-- <http://docs.aws.amazon.com/directoryservice/latest/admin-guide/UsingWithDS_IAM_ResourcePermissions.html Directory Service API Permissions: Actions, Resources, and Conditions Reference>.
module Amazonka.DirectoryService.CreateDirectory
  ( -- * Creating a Request
    CreateDirectory (..),
    newCreateDirectory,

    -- * Request Lenses
    createDirectory_shortName,
    createDirectory_vpcSettings,
    createDirectory_description,
    createDirectory_tags,
    createDirectory_name,
    createDirectory_password,
    createDirectory_size,

    -- * Destructuring the Response
    CreateDirectoryResponse (..),
    newCreateDirectoryResponse,

    -- * Response Lenses
    createDirectoryResponse_directoryId,
    createDirectoryResponse_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

-- | Contains the inputs for the CreateDirectory operation.
--
-- /See:/ 'newCreateDirectory' smart constructor.
data CreateDirectory = CreateDirectory'
  { -- | The NetBIOS name of the directory, such as @CORP@.
    CreateDirectory -> Maybe Text
shortName :: Prelude.Maybe Prelude.Text,
    -- | A DirectoryVpcSettings object that contains additional information for
    -- the operation.
    CreateDirectory -> Maybe DirectoryVpcSettings
vpcSettings :: Prelude.Maybe DirectoryVpcSettings,
    -- | A description for the directory.
    CreateDirectory -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The tags to be assigned to the Simple AD directory.
    CreateDirectory -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The fully qualified name for the directory, such as @corp.example.com@.
    CreateDirectory -> Text
name :: Prelude.Text,
    -- | The password for the directory administrator. The directory creation
    -- process creates a directory administrator account with the user name
    -- @Administrator@ and this password.
    --
    -- If you need to change the password for the administrator account, you
    -- can use the ResetUserPassword API call.
    --
    -- The regex pattern for this string is made up of the following
    -- conditions:
    --
    -- -   Length (?=^.{8,64}$) – Must be between 8 and 64 characters
    --
    -- AND any 3 of the following password complexity rules required by Active
    -- Directory:
    --
    -- -   Numbers and upper case and lowercase (?=.*\\d)(?=.*[A-Z])(?=.*[a-z])
    --
    -- -   Numbers and special characters and lower case
    --     (?=.*\\d)(?=.*[^A-Za-z0-9\\s])(?=.*[a-z])
    --
    -- -   Special characters and upper case and lower case
    --     (?=.*[^A-Za-z0-9\\s])(?=.*[A-Z])(?=.*[a-z])
    --
    -- -   Numbers and upper case and special characters
    --     (?=.*\\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9\\s])
    --
    -- For additional information about how Active Directory passwords are
    -- enforced, see
    -- <https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/password-must-meet-complexity-requirements Password must meet complexity requirements>
    -- on the Microsoft website.
    CreateDirectory -> Sensitive Text
password :: Core.Sensitive Prelude.Text,
    -- | The size of the directory.
    CreateDirectory -> DirectorySize
size :: DirectorySize
  }
  deriving (CreateDirectory -> CreateDirectory -> Bool
(CreateDirectory -> CreateDirectory -> Bool)
-> (CreateDirectory -> CreateDirectory -> Bool)
-> Eq CreateDirectory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDirectory -> CreateDirectory -> Bool
$c/= :: CreateDirectory -> CreateDirectory -> Bool
== :: CreateDirectory -> CreateDirectory -> Bool
$c== :: CreateDirectory -> CreateDirectory -> Bool
Prelude.Eq, Int -> CreateDirectory -> ShowS
[CreateDirectory] -> ShowS
CreateDirectory -> String
(Int -> CreateDirectory -> ShowS)
-> (CreateDirectory -> String)
-> ([CreateDirectory] -> ShowS)
-> Show CreateDirectory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDirectory] -> ShowS
$cshowList :: [CreateDirectory] -> ShowS
show :: CreateDirectory -> String
$cshow :: CreateDirectory -> String
showsPrec :: Int -> CreateDirectory -> ShowS
$cshowsPrec :: Int -> CreateDirectory -> ShowS
Prelude.Show, (forall x. CreateDirectory -> Rep CreateDirectory x)
-> (forall x. Rep CreateDirectory x -> CreateDirectory)
-> Generic CreateDirectory
forall x. Rep CreateDirectory x -> CreateDirectory
forall x. CreateDirectory -> Rep CreateDirectory x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateDirectory x -> CreateDirectory
$cfrom :: forall x. CreateDirectory -> Rep CreateDirectory x
Prelude.Generic)

-- |
-- Create a value of 'CreateDirectory' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'shortName', 'createDirectory_shortName' - The NetBIOS name of the directory, such as @CORP@.
--
-- 'vpcSettings', 'createDirectory_vpcSettings' - A DirectoryVpcSettings object that contains additional information for
-- the operation.
--
-- 'description', 'createDirectory_description' - A description for the directory.
--
-- 'tags', 'createDirectory_tags' - The tags to be assigned to the Simple AD directory.
--
-- 'name', 'createDirectory_name' - The fully qualified name for the directory, such as @corp.example.com@.
--
-- 'password', 'createDirectory_password' - The password for the directory administrator. The directory creation
-- process creates a directory administrator account with the user name
-- @Administrator@ and this password.
--
-- If you need to change the password for the administrator account, you
-- can use the ResetUserPassword API call.
--
-- The regex pattern for this string is made up of the following
-- conditions:
--
-- -   Length (?=^.{8,64}$) – Must be between 8 and 64 characters
--
-- AND any 3 of the following password complexity rules required by Active
-- Directory:
--
-- -   Numbers and upper case and lowercase (?=.*\\d)(?=.*[A-Z])(?=.*[a-z])
--
-- -   Numbers and special characters and lower case
--     (?=.*\\d)(?=.*[^A-Za-z0-9\\s])(?=.*[a-z])
--
-- -   Special characters and upper case and lower case
--     (?=.*[^A-Za-z0-9\\s])(?=.*[A-Z])(?=.*[a-z])
--
-- -   Numbers and upper case and special characters
--     (?=.*\\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9\\s])
--
-- For additional information about how Active Directory passwords are
-- enforced, see
-- <https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/password-must-meet-complexity-requirements Password must meet complexity requirements>
-- on the Microsoft website.
--
-- 'size', 'createDirectory_size' - The size of the directory.
newCreateDirectory ::
  -- | 'name'
  Prelude.Text ->
  -- | 'password'
  Prelude.Text ->
  -- | 'size'
  DirectorySize ->
  CreateDirectory
newCreateDirectory :: Text -> Text -> DirectorySize -> CreateDirectory
newCreateDirectory Text
pName_ Text
pPassword_ DirectorySize
pSize_ =
  CreateDirectory' :: Maybe Text
-> Maybe DirectoryVpcSettings
-> Maybe Text
-> Maybe [Tag]
-> Text
-> Sensitive Text
-> DirectorySize
-> CreateDirectory
CreateDirectory'
    { $sel:shortName:CreateDirectory' :: Maybe Text
shortName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:vpcSettings:CreateDirectory' :: Maybe DirectoryVpcSettings
vpcSettings = Maybe DirectoryVpcSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:description:CreateDirectory' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateDirectory' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateDirectory' :: Text
name = Text
pName_,
      $sel:password:CreateDirectory' :: 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_,
      $sel:size:CreateDirectory' :: DirectorySize
size = DirectorySize
pSize_
    }

-- | The NetBIOS name of the directory, such as @CORP@.
createDirectory_shortName :: Lens.Lens' CreateDirectory (Prelude.Maybe Prelude.Text)
createDirectory_shortName :: (Maybe Text -> f (Maybe Text))
-> CreateDirectory -> f CreateDirectory
createDirectory_shortName = (CreateDirectory -> Maybe Text)
-> (CreateDirectory -> Maybe Text -> CreateDirectory)
-> Lens CreateDirectory CreateDirectory (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDirectory' {Maybe Text
shortName :: Maybe Text
$sel:shortName:CreateDirectory' :: CreateDirectory -> Maybe Text
shortName} -> Maybe Text
shortName) (\s :: CreateDirectory
s@CreateDirectory' {} Maybe Text
a -> CreateDirectory
s {$sel:shortName:CreateDirectory' :: Maybe Text
shortName = Maybe Text
a} :: CreateDirectory)

-- | A DirectoryVpcSettings object that contains additional information for
-- the operation.
createDirectory_vpcSettings :: Lens.Lens' CreateDirectory (Prelude.Maybe DirectoryVpcSettings)
createDirectory_vpcSettings :: (Maybe DirectoryVpcSettings -> f (Maybe DirectoryVpcSettings))
-> CreateDirectory -> f CreateDirectory
createDirectory_vpcSettings = (CreateDirectory -> Maybe DirectoryVpcSettings)
-> (CreateDirectory
    -> Maybe DirectoryVpcSettings -> CreateDirectory)
-> Lens
     CreateDirectory
     CreateDirectory
     (Maybe DirectoryVpcSettings)
     (Maybe DirectoryVpcSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDirectory' {Maybe DirectoryVpcSettings
vpcSettings :: Maybe DirectoryVpcSettings
$sel:vpcSettings:CreateDirectory' :: CreateDirectory -> Maybe DirectoryVpcSettings
vpcSettings} -> Maybe DirectoryVpcSettings
vpcSettings) (\s :: CreateDirectory
s@CreateDirectory' {} Maybe DirectoryVpcSettings
a -> CreateDirectory
s {$sel:vpcSettings:CreateDirectory' :: Maybe DirectoryVpcSettings
vpcSettings = Maybe DirectoryVpcSettings
a} :: CreateDirectory)

-- | A description for the directory.
createDirectory_description :: Lens.Lens' CreateDirectory (Prelude.Maybe Prelude.Text)
createDirectory_description :: (Maybe Text -> f (Maybe Text))
-> CreateDirectory -> f CreateDirectory
createDirectory_description = (CreateDirectory -> Maybe Text)
-> (CreateDirectory -> Maybe Text -> CreateDirectory)
-> Lens CreateDirectory CreateDirectory (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDirectory' {Maybe Text
description :: Maybe Text
$sel:description:CreateDirectory' :: CreateDirectory -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateDirectory
s@CreateDirectory' {} Maybe Text
a -> CreateDirectory
s {$sel:description:CreateDirectory' :: Maybe Text
description = Maybe Text
a} :: CreateDirectory)

-- | The tags to be assigned to the Simple AD directory.
createDirectory_tags :: Lens.Lens' CreateDirectory (Prelude.Maybe [Tag])
createDirectory_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateDirectory -> f CreateDirectory
createDirectory_tags = (CreateDirectory -> Maybe [Tag])
-> (CreateDirectory -> Maybe [Tag] -> CreateDirectory)
-> Lens CreateDirectory CreateDirectory (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDirectory' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateDirectory' :: CreateDirectory -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateDirectory
s@CreateDirectory' {} Maybe [Tag]
a -> CreateDirectory
s {$sel:tags:CreateDirectory' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateDirectory) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateDirectory -> f CreateDirectory)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateDirectory
-> f CreateDirectory
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The fully qualified name for the directory, such as @corp.example.com@.
createDirectory_name :: Lens.Lens' CreateDirectory Prelude.Text
createDirectory_name :: (Text -> f Text) -> CreateDirectory -> f CreateDirectory
createDirectory_name = (CreateDirectory -> Text)
-> (CreateDirectory -> Text -> CreateDirectory)
-> Lens CreateDirectory CreateDirectory Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDirectory' {Text
name :: Text
$sel:name:CreateDirectory' :: CreateDirectory -> Text
name} -> Text
name) (\s :: CreateDirectory
s@CreateDirectory' {} Text
a -> CreateDirectory
s {$sel:name:CreateDirectory' :: Text
name = Text
a} :: CreateDirectory)

-- | The password for the directory administrator. The directory creation
-- process creates a directory administrator account with the user name
-- @Administrator@ and this password.
--
-- If you need to change the password for the administrator account, you
-- can use the ResetUserPassword API call.
--
-- The regex pattern for this string is made up of the following
-- conditions:
--
-- -   Length (?=^.{8,64}$) – Must be between 8 and 64 characters
--
-- AND any 3 of the following password complexity rules required by Active
-- Directory:
--
-- -   Numbers and upper case and lowercase (?=.*\\d)(?=.*[A-Z])(?=.*[a-z])
--
-- -   Numbers and special characters and lower case
--     (?=.*\\d)(?=.*[^A-Za-z0-9\\s])(?=.*[a-z])
--
-- -   Special characters and upper case and lower case
--     (?=.*[^A-Za-z0-9\\s])(?=.*[A-Z])(?=.*[a-z])
--
-- -   Numbers and upper case and special characters
--     (?=.*\\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9\\s])
--
-- For additional information about how Active Directory passwords are
-- enforced, see
-- <https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/password-must-meet-complexity-requirements Password must meet complexity requirements>
-- on the Microsoft website.
createDirectory_password :: Lens.Lens' CreateDirectory Prelude.Text
createDirectory_password :: (Text -> f Text) -> CreateDirectory -> f CreateDirectory
createDirectory_password = (CreateDirectory -> Sensitive Text)
-> (CreateDirectory -> Sensitive Text -> CreateDirectory)
-> Lens
     CreateDirectory CreateDirectory (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDirectory' {Sensitive Text
password :: Sensitive Text
$sel:password:CreateDirectory' :: CreateDirectory -> Sensitive Text
password} -> Sensitive Text
password) (\s :: CreateDirectory
s@CreateDirectory' {} Sensitive Text
a -> CreateDirectory
s {$sel:password:CreateDirectory' :: Sensitive Text
password = Sensitive Text
a} :: CreateDirectory) ((Sensitive Text -> f (Sensitive Text))
 -> CreateDirectory -> f CreateDirectory)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> CreateDirectory
-> f CreateDirectory
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

-- | The size of the directory.
createDirectory_size :: Lens.Lens' CreateDirectory DirectorySize
createDirectory_size :: (DirectorySize -> f DirectorySize)
-> CreateDirectory -> f CreateDirectory
createDirectory_size = (CreateDirectory -> DirectorySize)
-> (CreateDirectory -> DirectorySize -> CreateDirectory)
-> Lens CreateDirectory CreateDirectory DirectorySize DirectorySize
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDirectory' {DirectorySize
size :: DirectorySize
$sel:size:CreateDirectory' :: CreateDirectory -> DirectorySize
size} -> DirectorySize
size) (\s :: CreateDirectory
s@CreateDirectory' {} DirectorySize
a -> CreateDirectory
s {$sel:size:CreateDirectory' :: DirectorySize
size = DirectorySize
a} :: CreateDirectory)

instance Core.AWSRequest CreateDirectory where
  type
    AWSResponse CreateDirectory =
      CreateDirectoryResponse
  request :: CreateDirectory -> Request CreateDirectory
request = Service -> CreateDirectory -> Request CreateDirectory
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateDirectory
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateDirectory)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateDirectory))
-> Logger
-> Service
-> Proxy CreateDirectory
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateDirectory)))
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 -> CreateDirectoryResponse
CreateDirectoryResponse'
            (Maybe Text -> Int -> CreateDirectoryResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateDirectoryResponse)
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 (Int -> CreateDirectoryResponse)
-> Either String Int -> Either String CreateDirectoryResponse
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 CreateDirectory

instance Prelude.NFData CreateDirectory

instance Core.ToHeaders CreateDirectory where
  toHeaders :: CreateDirectory -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateDirectory -> 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.CreateDirectory" ::
                          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 CreateDirectory where
  toJSON :: CreateDirectory -> Value
toJSON CreateDirectory' {Maybe [Tag]
Maybe Text
Maybe DirectoryVpcSettings
Text
Sensitive Text
DirectorySize
size :: DirectorySize
password :: Sensitive Text
name :: Text
tags :: Maybe [Tag]
description :: Maybe Text
vpcSettings :: Maybe DirectoryVpcSettings
shortName :: Maybe Text
$sel:size:CreateDirectory' :: CreateDirectory -> DirectorySize
$sel:password:CreateDirectory' :: CreateDirectory -> Sensitive Text
$sel:name:CreateDirectory' :: CreateDirectory -> Text
$sel:tags:CreateDirectory' :: CreateDirectory -> Maybe [Tag]
$sel:description:CreateDirectory' :: CreateDirectory -> Maybe Text
$sel:vpcSettings:CreateDirectory' :: CreateDirectory -> Maybe DirectoryVpcSettings
$sel:shortName:CreateDirectory' :: CreateDirectory -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ShortName" 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
shortName,
            (Text
"VpcSettings" Text -> DirectoryVpcSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DirectoryVpcSettings -> Pair)
-> Maybe DirectoryVpcSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DirectoryVpcSettings
vpcSettings,
            (Text
"Description" 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
description,
            (Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Size" Text -> DirectorySize -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DirectorySize
size)
          ]
      )

instance Core.ToPath CreateDirectory where
  toPath :: CreateDirectory -> ByteString
toPath = ByteString -> CreateDirectory -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery CreateDirectory where
  toQuery :: CreateDirectory -> QueryString
toQuery = QueryString -> CreateDirectory -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | Contains the results of the CreateDirectory operation.
--
-- /See:/ 'newCreateDirectoryResponse' smart constructor.
data CreateDirectoryResponse = CreateDirectoryResponse'
  { -- | The identifier of the directory that was created.
    CreateDirectoryResponse -> Maybe Text
directoryId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateDirectoryResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateDirectoryResponse -> CreateDirectoryResponse -> Bool
(CreateDirectoryResponse -> CreateDirectoryResponse -> Bool)
-> (CreateDirectoryResponse -> CreateDirectoryResponse -> Bool)
-> Eq CreateDirectoryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDirectoryResponse -> CreateDirectoryResponse -> Bool
$c/= :: CreateDirectoryResponse -> CreateDirectoryResponse -> Bool
== :: CreateDirectoryResponse -> CreateDirectoryResponse -> Bool
$c== :: CreateDirectoryResponse -> CreateDirectoryResponse -> Bool
Prelude.Eq, ReadPrec [CreateDirectoryResponse]
ReadPrec CreateDirectoryResponse
Int -> ReadS CreateDirectoryResponse
ReadS [CreateDirectoryResponse]
(Int -> ReadS CreateDirectoryResponse)
-> ReadS [CreateDirectoryResponse]
-> ReadPrec CreateDirectoryResponse
-> ReadPrec [CreateDirectoryResponse]
-> Read CreateDirectoryResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDirectoryResponse]
$creadListPrec :: ReadPrec [CreateDirectoryResponse]
readPrec :: ReadPrec CreateDirectoryResponse
$creadPrec :: ReadPrec CreateDirectoryResponse
readList :: ReadS [CreateDirectoryResponse]
$creadList :: ReadS [CreateDirectoryResponse]
readsPrec :: Int -> ReadS CreateDirectoryResponse
$creadsPrec :: Int -> ReadS CreateDirectoryResponse
Prelude.Read, Int -> CreateDirectoryResponse -> ShowS
[CreateDirectoryResponse] -> ShowS
CreateDirectoryResponse -> String
(Int -> CreateDirectoryResponse -> ShowS)
-> (CreateDirectoryResponse -> String)
-> ([CreateDirectoryResponse] -> ShowS)
-> Show CreateDirectoryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDirectoryResponse] -> ShowS
$cshowList :: [CreateDirectoryResponse] -> ShowS
show :: CreateDirectoryResponse -> String
$cshow :: CreateDirectoryResponse -> String
showsPrec :: Int -> CreateDirectoryResponse -> ShowS
$cshowsPrec :: Int -> CreateDirectoryResponse -> ShowS
Prelude.Show, (forall x.
 CreateDirectoryResponse -> Rep CreateDirectoryResponse x)
-> (forall x.
    Rep CreateDirectoryResponse x -> CreateDirectoryResponse)
-> Generic CreateDirectoryResponse
forall x. Rep CreateDirectoryResponse x -> CreateDirectoryResponse
forall x. CreateDirectoryResponse -> Rep CreateDirectoryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateDirectoryResponse x -> CreateDirectoryResponse
$cfrom :: forall x. CreateDirectoryResponse -> Rep CreateDirectoryResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateDirectoryResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'directoryId', 'createDirectoryResponse_directoryId' - The identifier of the directory that was created.
--
-- 'httpStatus', 'createDirectoryResponse_httpStatus' - The response's http status code.
newCreateDirectoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateDirectoryResponse
newCreateDirectoryResponse :: Int -> CreateDirectoryResponse
newCreateDirectoryResponse Int
pHttpStatus_ =
  CreateDirectoryResponse' :: Maybe Text -> Int -> CreateDirectoryResponse
CreateDirectoryResponse'
    { $sel:directoryId:CreateDirectoryResponse' :: Maybe Text
directoryId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateDirectoryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The identifier of the directory that was created.
createDirectoryResponse_directoryId :: Lens.Lens' CreateDirectoryResponse (Prelude.Maybe Prelude.Text)
createDirectoryResponse_directoryId :: (Maybe Text -> f (Maybe Text))
-> CreateDirectoryResponse -> f CreateDirectoryResponse
createDirectoryResponse_directoryId = (CreateDirectoryResponse -> Maybe Text)
-> (CreateDirectoryResponse
    -> Maybe Text -> CreateDirectoryResponse)
-> Lens
     CreateDirectoryResponse
     CreateDirectoryResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDirectoryResponse' {Maybe Text
directoryId :: Maybe Text
$sel:directoryId:CreateDirectoryResponse' :: CreateDirectoryResponse -> Maybe Text
directoryId} -> Maybe Text
directoryId) (\s :: CreateDirectoryResponse
s@CreateDirectoryResponse' {} Maybe Text
a -> CreateDirectoryResponse
s {$sel:directoryId:CreateDirectoryResponse' :: Maybe Text
directoryId = Maybe Text
a} :: CreateDirectoryResponse)

-- | The response's http status code.
createDirectoryResponse_httpStatus :: Lens.Lens' CreateDirectoryResponse Prelude.Int
createDirectoryResponse_httpStatus :: (Int -> f Int)
-> CreateDirectoryResponse -> f CreateDirectoryResponse
createDirectoryResponse_httpStatus = (CreateDirectoryResponse -> Int)
-> (CreateDirectoryResponse -> Int -> CreateDirectoryResponse)
-> Lens CreateDirectoryResponse CreateDirectoryResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDirectoryResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateDirectoryResponse' :: CreateDirectoryResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateDirectoryResponse
s@CreateDirectoryResponse' {} Int
a -> CreateDirectoryResponse
s {$sel:httpStatus:CreateDirectoryResponse' :: Int
httpStatus = Int
a} :: CreateDirectoryResponse)

instance Prelude.NFData CreateDirectoryResponse