{-# 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.OpenSearch.Types.MasterUserOptions
-- 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.OpenSearch.Types.MasterUserOptions where

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

-- | Credentials for the master user: username and password, ARN, or both.
--
-- /See:/ 'newMasterUserOptions' smart constructor.
data MasterUserOptions = MasterUserOptions'
  { -- | The master user\'s password, which is stored in the Amazon OpenSearch
    -- Service domain\'s internal database.
    MasterUserOptions -> Maybe (Sensitive Text)
masterUserPassword :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The master user\'s username, which is stored in the Amazon OpenSearch
    -- Service domain\'s internal database.
    MasterUserOptions -> Maybe (Sensitive Text)
masterUserName :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | ARN for the master user (if IAM is enabled).
    MasterUserOptions -> Maybe Text
masterUserARN :: Prelude.Maybe Prelude.Text
  }
  deriving (MasterUserOptions -> MasterUserOptions -> Bool
(MasterUserOptions -> MasterUserOptions -> Bool)
-> (MasterUserOptions -> MasterUserOptions -> Bool)
-> Eq MasterUserOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MasterUserOptions -> MasterUserOptions -> Bool
$c/= :: MasterUserOptions -> MasterUserOptions -> Bool
== :: MasterUserOptions -> MasterUserOptions -> Bool
$c== :: MasterUserOptions -> MasterUserOptions -> Bool
Prelude.Eq, Int -> MasterUserOptions -> ShowS
[MasterUserOptions] -> ShowS
MasterUserOptions -> String
(Int -> MasterUserOptions -> ShowS)
-> (MasterUserOptions -> String)
-> ([MasterUserOptions] -> ShowS)
-> Show MasterUserOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MasterUserOptions] -> ShowS
$cshowList :: [MasterUserOptions] -> ShowS
show :: MasterUserOptions -> String
$cshow :: MasterUserOptions -> String
showsPrec :: Int -> MasterUserOptions -> ShowS
$cshowsPrec :: Int -> MasterUserOptions -> ShowS
Prelude.Show, (forall x. MasterUserOptions -> Rep MasterUserOptions x)
-> (forall x. Rep MasterUserOptions x -> MasterUserOptions)
-> Generic MasterUserOptions
forall x. Rep MasterUserOptions x -> MasterUserOptions
forall x. MasterUserOptions -> Rep MasterUserOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MasterUserOptions x -> MasterUserOptions
$cfrom :: forall x. MasterUserOptions -> Rep MasterUserOptions x
Prelude.Generic)

-- |
-- Create a value of 'MasterUserOptions' 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:
--
-- 'masterUserPassword', 'masterUserOptions_masterUserPassword' - The master user\'s password, which is stored in the Amazon OpenSearch
-- Service domain\'s internal database.
--
-- 'masterUserName', 'masterUserOptions_masterUserName' - The master user\'s username, which is stored in the Amazon OpenSearch
-- Service domain\'s internal database.
--
-- 'masterUserARN', 'masterUserOptions_masterUserARN' - ARN for the master user (if IAM is enabled).
newMasterUserOptions ::
  MasterUserOptions
newMasterUserOptions :: MasterUserOptions
newMasterUserOptions =
  MasterUserOptions' :: Maybe (Sensitive Text)
-> Maybe (Sensitive Text) -> Maybe Text -> MasterUserOptions
MasterUserOptions'
    { $sel:masterUserPassword:MasterUserOptions' :: Maybe (Sensitive Text)
masterUserPassword =
        Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:masterUserName:MasterUserOptions' :: Maybe (Sensitive Text)
masterUserName = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:masterUserARN:MasterUserOptions' :: Maybe Text
masterUserARN = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The master user\'s password, which is stored in the Amazon OpenSearch
-- Service domain\'s internal database.
masterUserOptions_masterUserPassword :: Lens.Lens' MasterUserOptions (Prelude.Maybe Prelude.Text)
masterUserOptions_masterUserPassword :: (Maybe Text -> f (Maybe Text))
-> MasterUserOptions -> f MasterUserOptions
masterUserOptions_masterUserPassword = (MasterUserOptions -> Maybe (Sensitive Text))
-> (MasterUserOptions
    -> Maybe (Sensitive Text) -> MasterUserOptions)
-> Lens
     MasterUserOptions
     MasterUserOptions
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MasterUserOptions' {Maybe (Sensitive Text)
masterUserPassword :: Maybe (Sensitive Text)
$sel:masterUserPassword:MasterUserOptions' :: MasterUserOptions -> Maybe (Sensitive Text)
masterUserPassword} -> Maybe (Sensitive Text)
masterUserPassword) (\s :: MasterUserOptions
s@MasterUserOptions' {} Maybe (Sensitive Text)
a -> MasterUserOptions
s {$sel:masterUserPassword:MasterUserOptions' :: Maybe (Sensitive Text)
masterUserPassword = Maybe (Sensitive Text)
a} :: MasterUserOptions) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> MasterUserOptions -> f MasterUserOptions)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> MasterUserOptions
-> f MasterUserOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The master user\'s username, which is stored in the Amazon OpenSearch
-- Service domain\'s internal database.
masterUserOptions_masterUserName :: Lens.Lens' MasterUserOptions (Prelude.Maybe Prelude.Text)
masterUserOptions_masterUserName :: (Maybe Text -> f (Maybe Text))
-> MasterUserOptions -> f MasterUserOptions
masterUserOptions_masterUserName = (MasterUserOptions -> Maybe (Sensitive Text))
-> (MasterUserOptions
    -> Maybe (Sensitive Text) -> MasterUserOptions)
-> Lens
     MasterUserOptions
     MasterUserOptions
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MasterUserOptions' {Maybe (Sensitive Text)
masterUserName :: Maybe (Sensitive Text)
$sel:masterUserName:MasterUserOptions' :: MasterUserOptions -> Maybe (Sensitive Text)
masterUserName} -> Maybe (Sensitive Text)
masterUserName) (\s :: MasterUserOptions
s@MasterUserOptions' {} Maybe (Sensitive Text)
a -> MasterUserOptions
s {$sel:masterUserName:MasterUserOptions' :: Maybe (Sensitive Text)
masterUserName = Maybe (Sensitive Text)
a} :: MasterUserOptions) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> MasterUserOptions -> f MasterUserOptions)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> MasterUserOptions
-> f MasterUserOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | ARN for the master user (if IAM is enabled).
masterUserOptions_masterUserARN :: Lens.Lens' MasterUserOptions (Prelude.Maybe Prelude.Text)
masterUserOptions_masterUserARN :: (Maybe Text -> f (Maybe Text))
-> MasterUserOptions -> f MasterUserOptions
masterUserOptions_masterUserARN = (MasterUserOptions -> Maybe Text)
-> (MasterUserOptions -> Maybe Text -> MasterUserOptions)
-> Lens
     MasterUserOptions MasterUserOptions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MasterUserOptions' {Maybe Text
masterUserARN :: Maybe Text
$sel:masterUserARN:MasterUserOptions' :: MasterUserOptions -> Maybe Text
masterUserARN} -> Maybe Text
masterUserARN) (\s :: MasterUserOptions
s@MasterUserOptions' {} Maybe Text
a -> MasterUserOptions
s {$sel:masterUserARN:MasterUserOptions' :: Maybe Text
masterUserARN = Maybe Text
a} :: MasterUserOptions)

instance Prelude.Hashable MasterUserOptions

instance Prelude.NFData MasterUserOptions

instance Core.ToJSON MasterUserOptions where
  toJSON :: MasterUserOptions -> Value
toJSON MasterUserOptions' {Maybe Text
Maybe (Sensitive Text)
masterUserARN :: Maybe Text
masterUserName :: Maybe (Sensitive Text)
masterUserPassword :: Maybe (Sensitive Text)
$sel:masterUserARN:MasterUserOptions' :: MasterUserOptions -> Maybe Text
$sel:masterUserName:MasterUserOptions' :: MasterUserOptions -> Maybe (Sensitive Text)
$sel:masterUserPassword:MasterUserOptions' :: MasterUserOptions -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MasterUserPassword" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
masterUserPassword,
            (Text
"MasterUserName" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
masterUserName,
            (Text
"MasterUserARN" 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
masterUserARN
          ]
      )