{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AppStream.Types.ServiceAccountCredentials where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 :: Data.Sensitive Prelude.Text,
    -- | The password for the account.
    ServiceAccountCredentials -> Sensitive Text
accountPassword :: Data.Sensitive Prelude.Text
  }
  deriving (ServiceAccountCredentials -> ServiceAccountCredentials -> Bool
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
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.
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'
      { $sel:accountName:ServiceAccountCredentials' :: Sensitive Text
accountName =
          forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pAccountName_,
        $sel:accountPassword:ServiceAccountCredentials' :: Sensitive Text
accountPassword =
          forall a. Iso' (Sensitive a) a
Data._Sensitive 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 :: Lens' ServiceAccountCredentials Text
serviceAccountCredentials_accountName = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The password for the account.
serviceAccountCredentials_accountPassword :: Lens.Lens' ServiceAccountCredentials Prelude.Text
serviceAccountCredentials_accountPassword :: Lens' ServiceAccountCredentials Text
serviceAccountCredentials_accountPassword = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Data.FromJSON ServiceAccountCredentials where
  parseJSON :: Value -> Parser ServiceAccountCredentials
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ServiceAccountCredentials"
      ( \Object
x ->
          Sensitive Text -> Sensitive Text -> ServiceAccountCredentials
ServiceAccountCredentials'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"AccountName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"AccountPassword")
      )

instance Prelude.Hashable ServiceAccountCredentials where
  hashWithSalt :: Int -> ServiceAccountCredentials -> Int
hashWithSalt Int
_salt ServiceAccountCredentials' {Sensitive Text
accountPassword :: Sensitive Text
accountName :: Sensitive Text
$sel:accountPassword:ServiceAccountCredentials' :: ServiceAccountCredentials -> Sensitive Text
$sel:accountName:ServiceAccountCredentials' :: ServiceAccountCredentials -> Sensitive Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
accountName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
accountPassword

instance Prelude.NFData ServiceAccountCredentials where
  rnf :: ServiceAccountCredentials -> ()
rnf ServiceAccountCredentials' {Sensitive Text
accountPassword :: Sensitive Text
accountName :: Sensitive Text
$sel:accountPassword:ServiceAccountCredentials' :: ServiceAccountCredentials -> Sensitive Text
$sel:accountName:ServiceAccountCredentials' :: ServiceAccountCredentials -> Sensitive Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
accountName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
accountPassword

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"AccountName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
accountName),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"AccountPassword" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
accountPassword)
          ]
      )