{-# 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.EMR.Types.KerberosAttributes
-- 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.EMR.Types.KerberosAttributes where

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

-- | Attributes for Kerberos configuration when Kerberos authentication is
-- enabled using a security configuration. For more information see
-- <https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-kerberos.html Use Kerberos Authentication>
-- in the /Amazon EMR Management Guide/.
--
-- /See:/ 'newKerberosAttributes' smart constructor.
data KerberosAttributes = KerberosAttributes'
  { -- | The password used within the cluster for the kadmin service on the
    -- cluster-dedicated KDC, which maintains Kerberos principals, password
    -- policies, and keytabs for the cluster.
    KerberosAttributes -> Maybe Text
kdcAdminPassword :: Prelude.Maybe Prelude.Text,
    -- | The name of the Kerberos realm to which all nodes in a cluster belong.
    -- For example, @EC2.INTERNAL@.
    KerberosAttributes -> Maybe Text
realm :: Prelude.Maybe Prelude.Text,
    -- | The Active Directory password for @ADDomainJoinUser@.
    KerberosAttributes -> Maybe Text
aDDomainJoinPassword :: Prelude.Maybe Prelude.Text,
    -- | Required only when establishing a cross-realm trust with a KDC in a
    -- different realm. The cross-realm principal password, which must be
    -- identical across realms.
    KerberosAttributes -> Maybe Text
crossRealmTrustPrincipalPassword :: Prelude.Maybe Prelude.Text,
    -- | Required only when establishing a cross-realm trust with an Active
    -- Directory domain. A user with sufficient privileges to join resources to
    -- the domain.
    KerberosAttributes -> Maybe Text
aDDomainJoinUser :: Prelude.Maybe Prelude.Text
  }
  deriving (KerberosAttributes -> KerberosAttributes -> Bool
(KerberosAttributes -> KerberosAttributes -> Bool)
-> (KerberosAttributes -> KerberosAttributes -> Bool)
-> Eq KerberosAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KerberosAttributes -> KerberosAttributes -> Bool
$c/= :: KerberosAttributes -> KerberosAttributes -> Bool
== :: KerberosAttributes -> KerberosAttributes -> Bool
$c== :: KerberosAttributes -> KerberosAttributes -> Bool
Prelude.Eq, ReadPrec [KerberosAttributes]
ReadPrec KerberosAttributes
Int -> ReadS KerberosAttributes
ReadS [KerberosAttributes]
(Int -> ReadS KerberosAttributes)
-> ReadS [KerberosAttributes]
-> ReadPrec KerberosAttributes
-> ReadPrec [KerberosAttributes]
-> Read KerberosAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KerberosAttributes]
$creadListPrec :: ReadPrec [KerberosAttributes]
readPrec :: ReadPrec KerberosAttributes
$creadPrec :: ReadPrec KerberosAttributes
readList :: ReadS [KerberosAttributes]
$creadList :: ReadS [KerberosAttributes]
readsPrec :: Int -> ReadS KerberosAttributes
$creadsPrec :: Int -> ReadS KerberosAttributes
Prelude.Read, Int -> KerberosAttributes -> ShowS
[KerberosAttributes] -> ShowS
KerberosAttributes -> String
(Int -> KerberosAttributes -> ShowS)
-> (KerberosAttributes -> String)
-> ([KerberosAttributes] -> ShowS)
-> Show KerberosAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KerberosAttributes] -> ShowS
$cshowList :: [KerberosAttributes] -> ShowS
show :: KerberosAttributes -> String
$cshow :: KerberosAttributes -> String
showsPrec :: Int -> KerberosAttributes -> ShowS
$cshowsPrec :: Int -> KerberosAttributes -> ShowS
Prelude.Show, (forall x. KerberosAttributes -> Rep KerberosAttributes x)
-> (forall x. Rep KerberosAttributes x -> KerberosAttributes)
-> Generic KerberosAttributes
forall x. Rep KerberosAttributes x -> KerberosAttributes
forall x. KerberosAttributes -> Rep KerberosAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KerberosAttributes x -> KerberosAttributes
$cfrom :: forall x. KerberosAttributes -> Rep KerberosAttributes x
Prelude.Generic)

-- |
-- Create a value of 'KerberosAttributes' 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:
--
-- 'kdcAdminPassword', 'kerberosAttributes_kdcAdminPassword' - The password used within the cluster for the kadmin service on the
-- cluster-dedicated KDC, which maintains Kerberos principals, password
-- policies, and keytabs for the cluster.
--
-- 'realm', 'kerberosAttributes_realm' - The name of the Kerberos realm to which all nodes in a cluster belong.
-- For example, @EC2.INTERNAL@.
--
-- 'aDDomainJoinPassword', 'kerberosAttributes_aDDomainJoinPassword' - The Active Directory password for @ADDomainJoinUser@.
--
-- 'crossRealmTrustPrincipalPassword', 'kerberosAttributes_crossRealmTrustPrincipalPassword' - Required only when establishing a cross-realm trust with a KDC in a
-- different realm. The cross-realm principal password, which must be
-- identical across realms.
--
-- 'aDDomainJoinUser', 'kerberosAttributes_aDDomainJoinUser' - Required only when establishing a cross-realm trust with an Active
-- Directory domain. A user with sufficient privileges to join resources to
-- the domain.
newKerberosAttributes ::
  KerberosAttributes
newKerberosAttributes :: KerberosAttributes
newKerberosAttributes =
  KerberosAttributes' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> KerberosAttributes
KerberosAttributes'
    { $sel:kdcAdminPassword:KerberosAttributes' :: Maybe Text
kdcAdminPassword =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:realm:KerberosAttributes' :: Maybe Text
realm = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:aDDomainJoinPassword:KerberosAttributes' :: Maybe Text
aDDomainJoinPassword = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:crossRealmTrustPrincipalPassword:KerberosAttributes' :: Maybe Text
crossRealmTrustPrincipalPassword = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:aDDomainJoinUser:KerberosAttributes' :: Maybe Text
aDDomainJoinUser = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The password used within the cluster for the kadmin service on the
-- cluster-dedicated KDC, which maintains Kerberos principals, password
-- policies, and keytabs for the cluster.
kerberosAttributes_kdcAdminPassword :: Lens.Lens' KerberosAttributes (Prelude.Maybe Prelude.Text)
kerberosAttributes_kdcAdminPassword :: (Maybe Text -> f (Maybe Text))
-> KerberosAttributes -> f KerberosAttributes
kerberosAttributes_kdcAdminPassword = (KerberosAttributes -> Maybe Text)
-> (KerberosAttributes -> Maybe Text -> KerberosAttributes)
-> Lens
     KerberosAttributes KerberosAttributes (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KerberosAttributes' {Maybe Text
kdcAdminPassword :: Maybe Text
$sel:kdcAdminPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
kdcAdminPassword} -> Maybe Text
kdcAdminPassword) (\s :: KerberosAttributes
s@KerberosAttributes' {} Maybe Text
a -> KerberosAttributes
s {$sel:kdcAdminPassword:KerberosAttributes' :: Maybe Text
kdcAdminPassword = Maybe Text
a} :: KerberosAttributes)

-- | The name of the Kerberos realm to which all nodes in a cluster belong.
-- For example, @EC2.INTERNAL@.
kerberosAttributes_realm :: Lens.Lens' KerberosAttributes (Prelude.Maybe Prelude.Text)
kerberosAttributes_realm :: (Maybe Text -> f (Maybe Text))
-> KerberosAttributes -> f KerberosAttributes
kerberosAttributes_realm = (KerberosAttributes -> Maybe Text)
-> (KerberosAttributes -> Maybe Text -> KerberosAttributes)
-> Lens
     KerberosAttributes KerberosAttributes (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KerberosAttributes' {Maybe Text
realm :: Maybe Text
$sel:realm:KerberosAttributes' :: KerberosAttributes -> Maybe Text
realm} -> Maybe Text
realm) (\s :: KerberosAttributes
s@KerberosAttributes' {} Maybe Text
a -> KerberosAttributes
s {$sel:realm:KerberosAttributes' :: Maybe Text
realm = Maybe Text
a} :: KerberosAttributes)

-- | The Active Directory password for @ADDomainJoinUser@.
kerberosAttributes_aDDomainJoinPassword :: Lens.Lens' KerberosAttributes (Prelude.Maybe Prelude.Text)
kerberosAttributes_aDDomainJoinPassword :: (Maybe Text -> f (Maybe Text))
-> KerberosAttributes -> f KerberosAttributes
kerberosAttributes_aDDomainJoinPassword = (KerberosAttributes -> Maybe Text)
-> (KerberosAttributes -> Maybe Text -> KerberosAttributes)
-> Lens
     KerberosAttributes KerberosAttributes (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KerberosAttributes' {Maybe Text
aDDomainJoinPassword :: Maybe Text
$sel:aDDomainJoinPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
aDDomainJoinPassword} -> Maybe Text
aDDomainJoinPassword) (\s :: KerberosAttributes
s@KerberosAttributes' {} Maybe Text
a -> KerberosAttributes
s {$sel:aDDomainJoinPassword:KerberosAttributes' :: Maybe Text
aDDomainJoinPassword = Maybe Text
a} :: KerberosAttributes)

-- | Required only when establishing a cross-realm trust with a KDC in a
-- different realm. The cross-realm principal password, which must be
-- identical across realms.
kerberosAttributes_crossRealmTrustPrincipalPassword :: Lens.Lens' KerberosAttributes (Prelude.Maybe Prelude.Text)
kerberosAttributes_crossRealmTrustPrincipalPassword :: (Maybe Text -> f (Maybe Text))
-> KerberosAttributes -> f KerberosAttributes
kerberosAttributes_crossRealmTrustPrincipalPassword = (KerberosAttributes -> Maybe Text)
-> (KerberosAttributes -> Maybe Text -> KerberosAttributes)
-> Lens
     KerberosAttributes KerberosAttributes (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KerberosAttributes' {Maybe Text
crossRealmTrustPrincipalPassword :: Maybe Text
$sel:crossRealmTrustPrincipalPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
crossRealmTrustPrincipalPassword} -> Maybe Text
crossRealmTrustPrincipalPassword) (\s :: KerberosAttributes
s@KerberosAttributes' {} Maybe Text
a -> KerberosAttributes
s {$sel:crossRealmTrustPrincipalPassword:KerberosAttributes' :: Maybe Text
crossRealmTrustPrincipalPassword = Maybe Text
a} :: KerberosAttributes)

-- | Required only when establishing a cross-realm trust with an Active
-- Directory domain. A user with sufficient privileges to join resources to
-- the domain.
kerberosAttributes_aDDomainJoinUser :: Lens.Lens' KerberosAttributes (Prelude.Maybe Prelude.Text)
kerberosAttributes_aDDomainJoinUser :: (Maybe Text -> f (Maybe Text))
-> KerberosAttributes -> f KerberosAttributes
kerberosAttributes_aDDomainJoinUser = (KerberosAttributes -> Maybe Text)
-> (KerberosAttributes -> Maybe Text -> KerberosAttributes)
-> Lens
     KerberosAttributes KerberosAttributes (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KerberosAttributes' {Maybe Text
aDDomainJoinUser :: Maybe Text
$sel:aDDomainJoinUser:KerberosAttributes' :: KerberosAttributes -> Maybe Text
aDDomainJoinUser} -> Maybe Text
aDDomainJoinUser) (\s :: KerberosAttributes
s@KerberosAttributes' {} Maybe Text
a -> KerberosAttributes
s {$sel:aDDomainJoinUser:KerberosAttributes' :: Maybe Text
aDDomainJoinUser = Maybe Text
a} :: KerberosAttributes)

instance Core.FromJSON KerberosAttributes where
  parseJSON :: Value -> Parser KerberosAttributes
parseJSON =
    String
-> (Object -> Parser KerberosAttributes)
-> Value
-> Parser KerberosAttributes
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"KerberosAttributes"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> KerberosAttributes
KerberosAttributes'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> KerberosAttributes)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Text -> KerberosAttributes)
forall (f :: * -> *) a b. Functor 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
"KdcAdminPassword")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Text -> KerberosAttributes)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> KerberosAttributes)
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
"Realm")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> KerberosAttributes)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> KerberosAttributes)
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
"ADDomainJoinPassword")
            Parser (Maybe Text -> Maybe Text -> KerberosAttributes)
-> Parser (Maybe Text) -> Parser (Maybe Text -> KerberosAttributes)
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
"CrossRealmTrustPrincipalPassword")
            Parser (Maybe Text -> KerberosAttributes)
-> Parser (Maybe Text) -> Parser KerberosAttributes
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
"ADDomainJoinUser")
      )

instance Prelude.Hashable KerberosAttributes

instance Prelude.NFData KerberosAttributes

instance Core.ToJSON KerberosAttributes where
  toJSON :: KerberosAttributes -> Value
toJSON KerberosAttributes' {Maybe Text
aDDomainJoinUser :: Maybe Text
crossRealmTrustPrincipalPassword :: Maybe Text
aDDomainJoinPassword :: Maybe Text
realm :: Maybe Text
kdcAdminPassword :: Maybe Text
$sel:aDDomainJoinUser:KerberosAttributes' :: KerberosAttributes -> Maybe Text
$sel:crossRealmTrustPrincipalPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
$sel:aDDomainJoinPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
$sel:realm:KerberosAttributes' :: KerberosAttributes -> Maybe Text
$sel:kdcAdminPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"KdcAdminPassword" 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
kdcAdminPassword,
            (Text
"Realm" 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
realm,
            (Text
"ADDomainJoinPassword" 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
aDDomainJoinPassword,
            (Text
"CrossRealmTrustPrincipalPassword" 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
crossRealmTrustPrincipalPassword,
            (Text
"ADDomainJoinUser" 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
aDDomainJoinUser
          ]
      )