{-# 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.AppFlow.Types.BasicAuthCredentials
-- 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.AppFlow.Types.BasicAuthCredentials where

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

-- | The basic auth credentials required for basic authentication.
--
-- /See:/ 'newBasicAuthCredentials' smart constructor.
data BasicAuthCredentials = BasicAuthCredentials'
  { -- | The username to use to connect to a resource.
    BasicAuthCredentials -> Text
username :: Prelude.Text,
    -- | The password to use to connect to a resource.
    BasicAuthCredentials -> Sensitive Text
password :: Core.Sensitive Prelude.Text
  }
  deriving (BasicAuthCredentials -> BasicAuthCredentials -> Bool
(BasicAuthCredentials -> BasicAuthCredentials -> Bool)
-> (BasicAuthCredentials -> BasicAuthCredentials -> Bool)
-> Eq BasicAuthCredentials
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BasicAuthCredentials -> BasicAuthCredentials -> Bool
$c/= :: BasicAuthCredentials -> BasicAuthCredentials -> Bool
== :: BasicAuthCredentials -> BasicAuthCredentials -> Bool
$c== :: BasicAuthCredentials -> BasicAuthCredentials -> Bool
Prelude.Eq, Int -> BasicAuthCredentials -> ShowS
[BasicAuthCredentials] -> ShowS
BasicAuthCredentials -> String
(Int -> BasicAuthCredentials -> ShowS)
-> (BasicAuthCredentials -> String)
-> ([BasicAuthCredentials] -> ShowS)
-> Show BasicAuthCredentials
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BasicAuthCredentials] -> ShowS
$cshowList :: [BasicAuthCredentials] -> ShowS
show :: BasicAuthCredentials -> String
$cshow :: BasicAuthCredentials -> String
showsPrec :: Int -> BasicAuthCredentials -> ShowS
$cshowsPrec :: Int -> BasicAuthCredentials -> ShowS
Prelude.Show, (forall x. BasicAuthCredentials -> Rep BasicAuthCredentials x)
-> (forall x. Rep BasicAuthCredentials x -> BasicAuthCredentials)
-> Generic BasicAuthCredentials
forall x. Rep BasicAuthCredentials x -> BasicAuthCredentials
forall x. BasicAuthCredentials -> Rep BasicAuthCredentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BasicAuthCredentials x -> BasicAuthCredentials
$cfrom :: forall x. BasicAuthCredentials -> Rep BasicAuthCredentials x
Prelude.Generic)

-- |
-- Create a value of 'BasicAuthCredentials' 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', 'basicAuthCredentials_username' - The username to use to connect to a resource.
--
-- 'password', 'basicAuthCredentials_password' - The password to use to connect to a resource.
newBasicAuthCredentials ::
  -- | 'username'
  Prelude.Text ->
  -- | 'password'
  Prelude.Text ->
  BasicAuthCredentials
newBasicAuthCredentials :: Text -> Text -> BasicAuthCredentials
newBasicAuthCredentials Text
pUsername_ Text
pPassword_ =
  BasicAuthCredentials' :: Text -> Sensitive Text -> BasicAuthCredentials
BasicAuthCredentials'
    { $sel:username:BasicAuthCredentials' :: Text
username = Text
pUsername_,
      $sel:password:BasicAuthCredentials' :: Sensitive Text
password = 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
pPassword_
    }

-- | The username to use to connect to a resource.
basicAuthCredentials_username :: Lens.Lens' BasicAuthCredentials Prelude.Text
basicAuthCredentials_username :: (Text -> f Text) -> BasicAuthCredentials -> f BasicAuthCredentials
basicAuthCredentials_username = (BasicAuthCredentials -> Text)
-> (BasicAuthCredentials -> Text -> BasicAuthCredentials)
-> Lens BasicAuthCredentials BasicAuthCredentials Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BasicAuthCredentials' {Text
username :: Text
$sel:username:BasicAuthCredentials' :: BasicAuthCredentials -> Text
username} -> Text
username) (\s :: BasicAuthCredentials
s@BasicAuthCredentials' {} Text
a -> BasicAuthCredentials
s {$sel:username:BasicAuthCredentials' :: Text
username = Text
a} :: BasicAuthCredentials)

-- | The password to use to connect to a resource.
basicAuthCredentials_password :: Lens.Lens' BasicAuthCredentials Prelude.Text
basicAuthCredentials_password :: (Text -> f Text) -> BasicAuthCredentials -> f BasicAuthCredentials
basicAuthCredentials_password = (BasicAuthCredentials -> Sensitive Text)
-> (BasicAuthCredentials -> Sensitive Text -> BasicAuthCredentials)
-> Lens
     BasicAuthCredentials
     BasicAuthCredentials
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BasicAuthCredentials' {Sensitive Text
password :: Sensitive Text
$sel:password:BasicAuthCredentials' :: BasicAuthCredentials -> Sensitive Text
password} -> Sensitive Text
password) (\s :: BasicAuthCredentials
s@BasicAuthCredentials' {} Sensitive Text
a -> BasicAuthCredentials
s {$sel:password:BasicAuthCredentials' :: Sensitive Text
password = Sensitive Text
a} :: BasicAuthCredentials) ((Sensitive Text -> f (Sensitive Text))
 -> BasicAuthCredentials -> f BasicAuthCredentials)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> BasicAuthCredentials
-> f BasicAuthCredentials
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 Prelude.Hashable BasicAuthCredentials

instance Prelude.NFData BasicAuthCredentials

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