{-# 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.Chime.Types.Credential
-- 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.Chime.Types.Credential where

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

-- | The SIP credentials used to authenticate requests to your Amazon Chime
-- Voice Connector.
--
-- /See:/ 'newCredential' smart constructor.
data Credential = Credential'
  { -- | The RFC2617 compliant user name associated with the SIP credentials, in
    -- US-ASCII format.
    Credential -> Maybe (Sensitive Text)
username :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The RFC2617 compliant password associated with the SIP credentials, in
    -- US-ASCII format.
    Credential -> Maybe (Sensitive Text)
password :: Prelude.Maybe (Core.Sensitive Prelude.Text)
  }
  deriving (Credential -> Credential -> Bool
(Credential -> Credential -> Bool)
-> (Credential -> Credential -> Bool) -> Eq Credential
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Credential -> Credential -> Bool
$c/= :: Credential -> Credential -> Bool
== :: Credential -> Credential -> Bool
$c== :: Credential -> Credential -> Bool
Prelude.Eq, Int -> Credential -> ShowS
[Credential] -> ShowS
Credential -> String
(Int -> Credential -> ShowS)
-> (Credential -> String)
-> ([Credential] -> ShowS)
-> Show Credential
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Credential] -> ShowS
$cshowList :: [Credential] -> ShowS
show :: Credential -> String
$cshow :: Credential -> String
showsPrec :: Int -> Credential -> ShowS
$cshowsPrec :: Int -> Credential -> ShowS
Prelude.Show, (forall x. Credential -> Rep Credential x)
-> (forall x. Rep Credential x -> Credential) -> Generic Credential
forall x. Rep Credential x -> Credential
forall x. Credential -> Rep Credential x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Credential x -> Credential
$cfrom :: forall x. Credential -> Rep Credential x
Prelude.Generic)

-- |
-- Create a value of 'Credential' 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:
--
-- 'username', 'credential_username' - The RFC2617 compliant user name associated with the SIP credentials, in
-- US-ASCII format.
--
-- 'password', 'credential_password' - The RFC2617 compliant password associated with the SIP credentials, in
-- US-ASCII format.
newCredential ::
  Credential
newCredential :: Credential
newCredential =
  Credential' :: Maybe (Sensitive Text) -> Maybe (Sensitive Text) -> Credential
Credential'
    { $sel:username:Credential' :: Maybe (Sensitive Text)
username = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:password:Credential' :: Maybe (Sensitive Text)
password = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | The RFC2617 compliant user name associated with the SIP credentials, in
-- US-ASCII format.
credential_username :: Lens.Lens' Credential (Prelude.Maybe Prelude.Text)
credential_username :: (Maybe Text -> f (Maybe Text)) -> Credential -> f Credential
credential_username = (Credential -> Maybe (Sensitive Text))
-> (Credential -> Maybe (Sensitive Text) -> Credential)
-> Lens
     Credential
     Credential
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Credential' {Maybe (Sensitive Text)
username :: Maybe (Sensitive Text)
$sel:username:Credential' :: Credential -> Maybe (Sensitive Text)
username} -> Maybe (Sensitive Text)
username) (\s :: Credential
s@Credential' {} Maybe (Sensitive Text)
a -> Credential
s {$sel:username:Credential' :: Maybe (Sensitive Text)
username = Maybe (Sensitive Text)
a} :: Credential) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> Credential -> f Credential)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> Credential
-> f Credential
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 RFC2617 compliant password associated with the SIP credentials, in
-- US-ASCII format.
credential_password :: Lens.Lens' Credential (Prelude.Maybe Prelude.Text)
credential_password :: (Maybe Text -> f (Maybe Text)) -> Credential -> f Credential
credential_password = (Credential -> Maybe (Sensitive Text))
-> (Credential -> Maybe (Sensitive Text) -> Credential)
-> Lens
     Credential
     Credential
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Credential' {Maybe (Sensitive Text)
password :: Maybe (Sensitive Text)
$sel:password:Credential' :: Credential -> Maybe (Sensitive Text)
password} -> Maybe (Sensitive Text)
password) (\s :: Credential
s@Credential' {} Maybe (Sensitive Text)
a -> Credential
s {$sel:password:Credential' :: Maybe (Sensitive Text)
password = Maybe (Sensitive Text)
a} :: Credential) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> Credential -> f Credential)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> Credential
-> f Credential
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

instance Prelude.Hashable Credential

instance Prelude.NFData Credential

instance Core.ToJSON Credential where
  toJSON :: Credential -> Value
toJSON Credential' {Maybe (Sensitive Text)
password :: Maybe (Sensitive Text)
username :: Maybe (Sensitive Text)
$sel:password:Credential' :: Credential -> Maybe (Sensitive Text)
$sel:username:Credential' :: Credential -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Username" 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)
username,
            (Text
"Password" 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)
password
          ]
      )