{-# 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.AppStream.Types.DirectoryConfig
-- 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.AppStream.Types.DirectoryConfig where

import Amazonka.AppStream.Types.ServiceAccountCredentials
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the configuration information required to join fleets and
-- image builders to Microsoft Active Directory domains.
--
-- /See:/ 'newDirectoryConfig' smart constructor.
data DirectoryConfig = DirectoryConfig'
  { -- | The time the directory configuration was created.
    DirectoryConfig -> Maybe POSIX
createdTime :: Prelude.Maybe Core.POSIX,
    -- | The credentials for the service account used by the fleet or image
    -- builder to connect to the directory.
    DirectoryConfig -> Maybe ServiceAccountCredentials
serviceAccountCredentials :: Prelude.Maybe ServiceAccountCredentials,
    -- | The distinguished names of the organizational units for computer
    -- accounts.
    DirectoryConfig -> Maybe [Text]
organizationalUnitDistinguishedNames :: Prelude.Maybe [Prelude.Text],
    -- | The fully qualified name of the directory (for example,
    -- corp.example.com).
    DirectoryConfig -> Text
directoryName :: Prelude.Text
  }
  deriving (DirectoryConfig -> DirectoryConfig -> Bool
(DirectoryConfig -> DirectoryConfig -> Bool)
-> (DirectoryConfig -> DirectoryConfig -> Bool)
-> Eq DirectoryConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DirectoryConfig -> DirectoryConfig -> Bool
$c/= :: DirectoryConfig -> DirectoryConfig -> Bool
== :: DirectoryConfig -> DirectoryConfig -> Bool
$c== :: DirectoryConfig -> DirectoryConfig -> Bool
Prelude.Eq, Int -> DirectoryConfig -> ShowS
[DirectoryConfig] -> ShowS
DirectoryConfig -> String
(Int -> DirectoryConfig -> ShowS)
-> (DirectoryConfig -> String)
-> ([DirectoryConfig] -> ShowS)
-> Show DirectoryConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DirectoryConfig] -> ShowS
$cshowList :: [DirectoryConfig] -> ShowS
show :: DirectoryConfig -> String
$cshow :: DirectoryConfig -> String
showsPrec :: Int -> DirectoryConfig -> ShowS
$cshowsPrec :: Int -> DirectoryConfig -> ShowS
Prelude.Show, (forall x. DirectoryConfig -> Rep DirectoryConfig x)
-> (forall x. Rep DirectoryConfig x -> DirectoryConfig)
-> Generic DirectoryConfig
forall x. Rep DirectoryConfig x -> DirectoryConfig
forall x. DirectoryConfig -> Rep DirectoryConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DirectoryConfig x -> DirectoryConfig
$cfrom :: forall x. DirectoryConfig -> Rep DirectoryConfig x
Prelude.Generic)

-- |
-- Create a value of 'DirectoryConfig' 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:
--
-- 'createdTime', 'directoryConfig_createdTime' - The time the directory configuration was created.
--
-- 'serviceAccountCredentials', 'directoryConfig_serviceAccountCredentials' - The credentials for the service account used by the fleet or image
-- builder to connect to the directory.
--
-- 'organizationalUnitDistinguishedNames', 'directoryConfig_organizationalUnitDistinguishedNames' - The distinguished names of the organizational units for computer
-- accounts.
--
-- 'directoryName', 'directoryConfig_directoryName' - The fully qualified name of the directory (for example,
-- corp.example.com).
newDirectoryConfig ::
  -- | 'directoryName'
  Prelude.Text ->
  DirectoryConfig
newDirectoryConfig :: Text -> DirectoryConfig
newDirectoryConfig Text
pDirectoryName_ =
  DirectoryConfig' :: Maybe POSIX
-> Maybe ServiceAccountCredentials
-> Maybe [Text]
-> Text
-> DirectoryConfig
DirectoryConfig'
    { $sel:createdTime:DirectoryConfig' :: Maybe POSIX
createdTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:serviceAccountCredentials:DirectoryConfig' :: Maybe ServiceAccountCredentials
serviceAccountCredentials = Maybe ServiceAccountCredentials
forall a. Maybe a
Prelude.Nothing,
      $sel:organizationalUnitDistinguishedNames:DirectoryConfig' :: Maybe [Text]
organizationalUnitDistinguishedNames =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:directoryName:DirectoryConfig' :: Text
directoryName = Text
pDirectoryName_
    }

-- | The time the directory configuration was created.
directoryConfig_createdTime :: Lens.Lens' DirectoryConfig (Prelude.Maybe Prelude.UTCTime)
directoryConfig_createdTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DirectoryConfig -> f DirectoryConfig
directoryConfig_createdTime = (DirectoryConfig -> Maybe POSIX)
-> (DirectoryConfig -> Maybe POSIX -> DirectoryConfig)
-> Lens DirectoryConfig DirectoryConfig (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DirectoryConfig' {Maybe POSIX
createdTime :: Maybe POSIX
$sel:createdTime:DirectoryConfig' :: DirectoryConfig -> Maybe POSIX
createdTime} -> Maybe POSIX
createdTime) (\s :: DirectoryConfig
s@DirectoryConfig' {} Maybe POSIX
a -> DirectoryConfig
s {$sel:createdTime:DirectoryConfig' :: Maybe POSIX
createdTime = Maybe POSIX
a} :: DirectoryConfig) ((Maybe POSIX -> f (Maybe POSIX))
 -> DirectoryConfig -> f DirectoryConfig)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DirectoryConfig
-> f DirectoryConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The credentials for the service account used by the fleet or image
-- builder to connect to the directory.
directoryConfig_serviceAccountCredentials :: Lens.Lens' DirectoryConfig (Prelude.Maybe ServiceAccountCredentials)
directoryConfig_serviceAccountCredentials :: (Maybe ServiceAccountCredentials
 -> f (Maybe ServiceAccountCredentials))
-> DirectoryConfig -> f DirectoryConfig
directoryConfig_serviceAccountCredentials = (DirectoryConfig -> Maybe ServiceAccountCredentials)
-> (DirectoryConfig
    -> Maybe ServiceAccountCredentials -> DirectoryConfig)
-> Lens
     DirectoryConfig
     DirectoryConfig
     (Maybe ServiceAccountCredentials)
     (Maybe ServiceAccountCredentials)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DirectoryConfig' {Maybe ServiceAccountCredentials
serviceAccountCredentials :: Maybe ServiceAccountCredentials
$sel:serviceAccountCredentials:DirectoryConfig' :: DirectoryConfig -> Maybe ServiceAccountCredentials
serviceAccountCredentials} -> Maybe ServiceAccountCredentials
serviceAccountCredentials) (\s :: DirectoryConfig
s@DirectoryConfig' {} Maybe ServiceAccountCredentials
a -> DirectoryConfig
s {$sel:serviceAccountCredentials:DirectoryConfig' :: Maybe ServiceAccountCredentials
serviceAccountCredentials = Maybe ServiceAccountCredentials
a} :: DirectoryConfig)

-- | The distinguished names of the organizational units for computer
-- accounts.
directoryConfig_organizationalUnitDistinguishedNames :: Lens.Lens' DirectoryConfig (Prelude.Maybe [Prelude.Text])
directoryConfig_organizationalUnitDistinguishedNames :: (Maybe [Text] -> f (Maybe [Text]))
-> DirectoryConfig -> f DirectoryConfig
directoryConfig_organizationalUnitDistinguishedNames = (DirectoryConfig -> Maybe [Text])
-> (DirectoryConfig -> Maybe [Text] -> DirectoryConfig)
-> Lens
     DirectoryConfig DirectoryConfig (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DirectoryConfig' {Maybe [Text]
organizationalUnitDistinguishedNames :: Maybe [Text]
$sel:organizationalUnitDistinguishedNames:DirectoryConfig' :: DirectoryConfig -> Maybe [Text]
organizationalUnitDistinguishedNames} -> Maybe [Text]
organizationalUnitDistinguishedNames) (\s :: DirectoryConfig
s@DirectoryConfig' {} Maybe [Text]
a -> DirectoryConfig
s {$sel:organizationalUnitDistinguishedNames:DirectoryConfig' :: Maybe [Text]
organizationalUnitDistinguishedNames = Maybe [Text]
a} :: DirectoryConfig) ((Maybe [Text] -> f (Maybe [Text]))
 -> DirectoryConfig -> f DirectoryConfig)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DirectoryConfig
-> f DirectoryConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

instance Prelude.Hashable DirectoryConfig

instance Prelude.NFData DirectoryConfig