{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.DirectoryVpcSettings
-- 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)
module Amazonka.DirectoryService.Types.DirectoryVpcSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains VPC information for the CreateDirectory or CreateMicrosoftAD
-- operation.
--
-- /See:/ 'newDirectoryVpcSettings' smart constructor.
data DirectoryVpcSettings = DirectoryVpcSettings'
  { -- | The identifier of the VPC in which to create the directory.
    DirectoryVpcSettings -> Text
vpcId :: Prelude.Text,
    -- | The identifiers of the subnets for the directory servers. The two
    -- subnets must be in different Availability Zones. Directory Service
    -- creates a directory server and a DNS server in each of these subnets.
    DirectoryVpcSettings -> [Text]
subnetIds :: [Prelude.Text]
  }
  deriving (DirectoryVpcSettings -> DirectoryVpcSettings -> Bool
(DirectoryVpcSettings -> DirectoryVpcSettings -> Bool)
-> (DirectoryVpcSettings -> DirectoryVpcSettings -> Bool)
-> Eq DirectoryVpcSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DirectoryVpcSettings -> DirectoryVpcSettings -> Bool
$c/= :: DirectoryVpcSettings -> DirectoryVpcSettings -> Bool
== :: DirectoryVpcSettings -> DirectoryVpcSettings -> Bool
$c== :: DirectoryVpcSettings -> DirectoryVpcSettings -> Bool
Prelude.Eq, ReadPrec [DirectoryVpcSettings]
ReadPrec DirectoryVpcSettings
Int -> ReadS DirectoryVpcSettings
ReadS [DirectoryVpcSettings]
(Int -> ReadS DirectoryVpcSettings)
-> ReadS [DirectoryVpcSettings]
-> ReadPrec DirectoryVpcSettings
-> ReadPrec [DirectoryVpcSettings]
-> Read DirectoryVpcSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DirectoryVpcSettings]
$creadListPrec :: ReadPrec [DirectoryVpcSettings]
readPrec :: ReadPrec DirectoryVpcSettings
$creadPrec :: ReadPrec DirectoryVpcSettings
readList :: ReadS [DirectoryVpcSettings]
$creadList :: ReadS [DirectoryVpcSettings]
readsPrec :: Int -> ReadS DirectoryVpcSettings
$creadsPrec :: Int -> ReadS DirectoryVpcSettings
Prelude.Read, Int -> DirectoryVpcSettings -> ShowS
[DirectoryVpcSettings] -> ShowS
DirectoryVpcSettings -> String
(Int -> DirectoryVpcSettings -> ShowS)
-> (DirectoryVpcSettings -> String)
-> ([DirectoryVpcSettings] -> ShowS)
-> Show DirectoryVpcSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DirectoryVpcSettings] -> ShowS
$cshowList :: [DirectoryVpcSettings] -> ShowS
show :: DirectoryVpcSettings -> String
$cshow :: DirectoryVpcSettings -> String
showsPrec :: Int -> DirectoryVpcSettings -> ShowS
$cshowsPrec :: Int -> DirectoryVpcSettings -> ShowS
Prelude.Show, (forall x. DirectoryVpcSettings -> Rep DirectoryVpcSettings x)
-> (forall x. Rep DirectoryVpcSettings x -> DirectoryVpcSettings)
-> Generic DirectoryVpcSettings
forall x. Rep DirectoryVpcSettings x -> DirectoryVpcSettings
forall x. DirectoryVpcSettings -> Rep DirectoryVpcSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DirectoryVpcSettings x -> DirectoryVpcSettings
$cfrom :: forall x. DirectoryVpcSettings -> Rep DirectoryVpcSettings x
Prelude.Generic)

-- |
-- Create a value of 'DirectoryVpcSettings' 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:
--
-- 'vpcId', 'directoryVpcSettings_vpcId' - The identifier of the VPC in which to create the directory.
--
-- 'subnetIds', 'directoryVpcSettings_subnetIds' - The identifiers of the subnets for the directory servers. The two
-- subnets must be in different Availability Zones. Directory Service
-- creates a directory server and a DNS server in each of these subnets.
newDirectoryVpcSettings ::
  -- | 'vpcId'
  Prelude.Text ->
  DirectoryVpcSettings
newDirectoryVpcSettings :: Text -> DirectoryVpcSettings
newDirectoryVpcSettings Text
pVpcId_ =
  DirectoryVpcSettings' :: Text -> [Text] -> DirectoryVpcSettings
DirectoryVpcSettings'
    { $sel:vpcId:DirectoryVpcSettings' :: Text
vpcId = Text
pVpcId_,
      $sel:subnetIds:DirectoryVpcSettings' :: [Text]
subnetIds = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The identifier of the VPC in which to create the directory.
directoryVpcSettings_vpcId :: Lens.Lens' DirectoryVpcSettings Prelude.Text
directoryVpcSettings_vpcId :: (Text -> f Text) -> DirectoryVpcSettings -> f DirectoryVpcSettings
directoryVpcSettings_vpcId = (DirectoryVpcSettings -> Text)
-> (DirectoryVpcSettings -> Text -> DirectoryVpcSettings)
-> Lens DirectoryVpcSettings DirectoryVpcSettings Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DirectoryVpcSettings' {Text
vpcId :: Text
$sel:vpcId:DirectoryVpcSettings' :: DirectoryVpcSettings -> Text
vpcId} -> Text
vpcId) (\s :: DirectoryVpcSettings
s@DirectoryVpcSettings' {} Text
a -> DirectoryVpcSettings
s {$sel:vpcId:DirectoryVpcSettings' :: Text
vpcId = Text
a} :: DirectoryVpcSettings)

-- | The identifiers of the subnets for the directory servers. The two
-- subnets must be in different Availability Zones. Directory Service
-- creates a directory server and a DNS server in each of these subnets.
directoryVpcSettings_subnetIds :: Lens.Lens' DirectoryVpcSettings [Prelude.Text]
directoryVpcSettings_subnetIds :: ([Text] -> f [Text])
-> DirectoryVpcSettings -> f DirectoryVpcSettings
directoryVpcSettings_subnetIds = (DirectoryVpcSettings -> [Text])
-> (DirectoryVpcSettings -> [Text] -> DirectoryVpcSettings)
-> Lens DirectoryVpcSettings DirectoryVpcSettings [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DirectoryVpcSettings' {[Text]
subnetIds :: [Text]
$sel:subnetIds:DirectoryVpcSettings' :: DirectoryVpcSettings -> [Text]
subnetIds} -> [Text]
subnetIds) (\s :: DirectoryVpcSettings
s@DirectoryVpcSettings' {} [Text]
a -> DirectoryVpcSettings
s {$sel:subnetIds:DirectoryVpcSettings' :: [Text]
subnetIds = [Text]
a} :: DirectoryVpcSettings) (([Text] -> f [Text])
 -> DirectoryVpcSettings -> f DirectoryVpcSettings)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DirectoryVpcSettings
-> f DirectoryVpcSettings
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON DirectoryVpcSettings where
  parseJSON :: Value -> Parser DirectoryVpcSettings
parseJSON =
    String
-> (Object -> Parser DirectoryVpcSettings)
-> Value
-> Parser DirectoryVpcSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DirectoryVpcSettings"
      ( \Object
x ->
          Text -> [Text] -> DirectoryVpcSettings
DirectoryVpcSettings'
            (Text -> [Text] -> DirectoryVpcSettings)
-> Parser Text -> Parser ([Text] -> DirectoryVpcSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"VpcId")
            Parser ([Text] -> DirectoryVpcSettings)
-> Parser [Text] -> Parser DirectoryVpcSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SubnetIds" Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Text]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable DirectoryVpcSettings

instance Prelude.NFData DirectoryVpcSettings

instance Core.ToJSON DirectoryVpcSettings where
  toJSON :: DirectoryVpcSettings -> Value
toJSON DirectoryVpcSettings' {[Text]
Text
subnetIds :: [Text]
vpcId :: Text
$sel:subnetIds:DirectoryVpcSettings' :: DirectoryVpcSettings -> [Text]
$sel:vpcId:DirectoryVpcSettings' :: DirectoryVpcSettings -> 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
"VpcId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
vpcId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SubnetIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
subnetIds)
          ]
      )