{-# 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.ServiceAccountCredentials
-- 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.ServiceAccountCredentials where

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

-- | Describes the credentials for the service account used by the fleet or
-- image builder to connect to the directory.
--
-- /See:/ 'newServiceAccountCredentials' smart constructor.
data ServiceAccountCredentials = ServiceAccountCredentials'
  { -- | The user name of the account. This account must have the following
    -- privileges: create computer objects, join computers to the domain, and
    -- change\/reset the password on descendant computer objects for the
    -- organizational units specified.
    ServiceAccountCredentials -> Sensitive Text
accountName :: Core.Sensitive Prelude.Text,
    -- | The password for the account.
    ServiceAccountCredentials -> Sensitive Text
accountPassword :: Core.Sensitive Prelude.Text
  }
  deriving (ServiceAccountCredentials -> ServiceAccountCredentials -> Bool
(ServiceAccountCredentials -> ServiceAccountCredentials -> Bool)
-> (ServiceAccountCredentials -> ServiceAccountCredentials -> Bool)
-> Eq ServiceAccountCredentials
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServiceAccountCredentials -> ServiceAccountCredentials -> Bool
$c/= :: ServiceAccountCredentials -> ServiceAccountCredentials -> Bool
== :: ServiceAccountCredentials -> ServiceAccountCredentials -> Bool
$c== :: ServiceAccountCredentials -> ServiceAccountCredentials -> Bool
Prelude.Eq, Int -> ServiceAccountCredentials -> ShowS
[ServiceAccountCredentials] -> ShowS
ServiceAccountCredentials -> String
(Int -> ServiceAccountCredentials -> ShowS)
-> (ServiceAccountCredentials -> String)
-> ([ServiceAccountCredentials] -> ShowS)
-> Show ServiceAccountCredentials
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServiceAccountCredentials] -> ShowS
$cshowList :: [ServiceAccountCredentials] -> ShowS
show :: ServiceAccountCredentials -> String
$cshow :: ServiceAccountCredentials -> String
showsPrec :: Int -> ServiceAccountCredentials -> ShowS
$cshowsPrec :: Int -> ServiceAccountCredentials -> ShowS
Prelude.Show, (forall x.
 ServiceAccountCredentials -> Rep ServiceAccountCredentials x)
-> (forall x.
    Rep ServiceAccountCredentials x -> ServiceAccountCredentials)
-> Generic ServiceAccountCredentials
forall x.
Rep ServiceAccountCredentials x -> ServiceAccountCredentials
forall x.
ServiceAccountCredentials -> Rep ServiceAccountCredentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ServiceAccountCredentials x -> ServiceAccountCredentials
$cfrom :: forall x.
ServiceAccountCredentials -> Rep ServiceAccountCredentials x
Prelude.Generic)

-- |
-- Create a value of 'ServiceAccountCredentials' 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:
--
-- 'accountName', 'serviceAccountCredentials_accountName' - The user name of the account. This account must have the following
-- privileges: create computer objects, join computers to the domain, and
-- change\/reset the password on descendant computer objects for the
-- organizational units specified.
--
-- 'accountPassword', 'serviceAccountCredentials_accountPassword' - The password for the account.
newServiceAccountCredentials ::
  -- | 'accountName'
  Prelude.Text ->
  -- | 'accountPassword'
  Prelude.Text ->
  ServiceAccountCredentials
newServiceAccountCredentials :: Text -> Text -> ServiceAccountCredentials
newServiceAccountCredentials
  Text
pAccountName_
  Text
pAccountPassword_ =
    ServiceAccountCredentials' :: Sensitive Text -> Sensitive Text -> ServiceAccountCredentials
ServiceAccountCredentials'
      { $sel:accountName:ServiceAccountCredentials' :: Sensitive Text
accountName =
          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
pAccountName_,
        $sel:accountPassword:ServiceAccountCredentials' :: Sensitive Text
accountPassword =
          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
pAccountPassword_
      }

-- | The user name of the account. This account must have the following
-- privileges: create computer objects, join computers to the domain, and
-- change\/reset the password on descendant computer objects for the
-- organizational units specified.
serviceAccountCredentials_accountName :: Lens.Lens' ServiceAccountCredentials Prelude.Text
serviceAccountCredentials_accountName :: (Text -> f Text)
-> ServiceAccountCredentials -> f ServiceAccountCredentials
serviceAccountCredentials_accountName = (ServiceAccountCredentials -> Sensitive Text)
-> (ServiceAccountCredentials
    -> Sensitive Text -> ServiceAccountCredentials)
-> Lens
     ServiceAccountCredentials
     ServiceAccountCredentials
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceAccountCredentials' {Sensitive Text
accountName :: Sensitive Text
$sel:accountName:ServiceAccountCredentials' :: ServiceAccountCredentials -> Sensitive Text
accountName} -> Sensitive Text
accountName) (\s :: ServiceAccountCredentials
s@ServiceAccountCredentials' {} Sensitive Text
a -> ServiceAccountCredentials
s {$sel:accountName:ServiceAccountCredentials' :: Sensitive Text
accountName = Sensitive Text
a} :: ServiceAccountCredentials) ((Sensitive Text -> f (Sensitive Text))
 -> ServiceAccountCredentials -> f ServiceAccountCredentials)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> ServiceAccountCredentials
-> f ServiceAccountCredentials
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 password for the account.
serviceAccountCredentials_accountPassword :: Lens.Lens' ServiceAccountCredentials Prelude.Text
serviceAccountCredentials_accountPassword :: (Text -> f Text)
-> ServiceAccountCredentials -> f ServiceAccountCredentials
serviceAccountCredentials_accountPassword = (ServiceAccountCredentials -> Sensitive Text)
-> (ServiceAccountCredentials
    -> Sensitive Text -> ServiceAccountCredentials)
-> Lens
     ServiceAccountCredentials
     ServiceAccountCredentials
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceAccountCredentials' {Sensitive Text
accountPassword :: Sensitive Text
$sel:accountPassword:ServiceAccountCredentials' :: ServiceAccountCredentials -> Sensitive Text
accountPassword} -> Sensitive Text
accountPassword) (\s :: ServiceAccountCredentials
s@ServiceAccountCredentials' {} Sensitive Text
a -> ServiceAccountCredentials
s {$sel:accountPassword:ServiceAccountCredentials' :: Sensitive Text
accountPassword = Sensitive Text
a} :: ServiceAccountCredentials) ((Sensitive Text -> f (Sensitive Text))
 -> ServiceAccountCredentials -> f ServiceAccountCredentials)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> ServiceAccountCredentials
-> f ServiceAccountCredentials
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.FromJSON ServiceAccountCredentials where
  parseJSON :: Value -> Parser ServiceAccountCredentials
parseJSON =
    String
-> (Object -> Parser ServiceAccountCredentials)
-> Value
-> Parser ServiceAccountCredentials
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ServiceAccountCredentials"
      ( \Object
x ->
          Sensitive Text -> Sensitive Text -> ServiceAccountCredentials
ServiceAccountCredentials'
            (Sensitive Text -> Sensitive Text -> ServiceAccountCredentials)
-> Parser (Sensitive Text)
-> Parser (Sensitive Text -> ServiceAccountCredentials)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Sensitive Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AccountName")
            Parser (Sensitive Text -> ServiceAccountCredentials)
-> Parser (Sensitive Text) -> Parser ServiceAccountCredentials
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Sensitive Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AccountPassword")
      )

instance Prelude.Hashable ServiceAccountCredentials

instance Prelude.NFData ServiceAccountCredentials

instance Core.ToJSON ServiceAccountCredentials where
  toJSON :: ServiceAccountCredentials -> Value
toJSON ServiceAccountCredentials' {Sensitive Text
accountPassword :: Sensitive Text
accountName :: Sensitive Text
$sel:accountPassword:ServiceAccountCredentials' :: ServiceAccountCredentials -> Sensitive Text
$sel:accountName:ServiceAccountCredentials' :: ServiceAccountCredentials -> Sensitive 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
"AccountName" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
accountName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AccountPassword" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
accountPassword)
          ]
      )