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

-- | 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 :: Data.Sensitive Prelude.Text
  }
  deriving (BasicAuthCredentials -> BasicAuthCredentials -> Bool
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
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. 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'
    { $sel:username:BasicAuthCredentials' :: Text
username = Text
pUsername_,
      $sel:password:BasicAuthCredentials' :: Sensitive Text
password = forall a. Iso' (Sensitive a) a
Data._Sensitive 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 :: Lens' BasicAuthCredentials Text
basicAuthCredentials_username = 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 :: Lens' BasicAuthCredentials Text
basicAuthCredentials_password = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Prelude.Hashable BasicAuthCredentials where
  hashWithSalt :: Int -> BasicAuthCredentials -> Int
hashWithSalt Int
_salt BasicAuthCredentials' {Text
Sensitive Text
password :: Sensitive Text
username :: Text
$sel:password:BasicAuthCredentials' :: BasicAuthCredentials -> Sensitive Text
$sel:username:BasicAuthCredentials' :: BasicAuthCredentials -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
username
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
password

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

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