{-# 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.ApiKeyCredentials
-- 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.ApiKeyCredentials 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 API key credentials required for API key authentication.
--
-- /See:/ 'newApiKeyCredentials' smart constructor.
data ApiKeyCredentials = ApiKeyCredentials'
  { -- | The API secret key required for API key authentication.
    ApiKeyCredentials -> Maybe (Sensitive Text)
apiSecretKey :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The API key required for API key authentication.
    ApiKeyCredentials -> Sensitive Text
apiKey :: Data.Sensitive Prelude.Text
  }
  deriving (ApiKeyCredentials -> ApiKeyCredentials -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApiKeyCredentials -> ApiKeyCredentials -> Bool
$c/= :: ApiKeyCredentials -> ApiKeyCredentials -> Bool
== :: ApiKeyCredentials -> ApiKeyCredentials -> Bool
$c== :: ApiKeyCredentials -> ApiKeyCredentials -> Bool
Prelude.Eq, Int -> ApiKeyCredentials -> ShowS
[ApiKeyCredentials] -> ShowS
ApiKeyCredentials -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApiKeyCredentials] -> ShowS
$cshowList :: [ApiKeyCredentials] -> ShowS
show :: ApiKeyCredentials -> String
$cshow :: ApiKeyCredentials -> String
showsPrec :: Int -> ApiKeyCredentials -> ShowS
$cshowsPrec :: Int -> ApiKeyCredentials -> ShowS
Prelude.Show, forall x. Rep ApiKeyCredentials x -> ApiKeyCredentials
forall x. ApiKeyCredentials -> Rep ApiKeyCredentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ApiKeyCredentials x -> ApiKeyCredentials
$cfrom :: forall x. ApiKeyCredentials -> Rep ApiKeyCredentials x
Prelude.Generic)

-- |
-- Create a value of 'ApiKeyCredentials' 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:
--
-- 'apiSecretKey', 'apiKeyCredentials_apiSecretKey' - The API secret key required for API key authentication.
--
-- 'apiKey', 'apiKeyCredentials_apiKey' - The API key required for API key authentication.
newApiKeyCredentials ::
  -- | 'apiKey'
  Prelude.Text ->
  ApiKeyCredentials
newApiKeyCredentials :: Text -> ApiKeyCredentials
newApiKeyCredentials Text
pApiKey_ =
  ApiKeyCredentials'
    { $sel:apiSecretKey:ApiKeyCredentials' :: Maybe (Sensitive Text)
apiSecretKey = forall a. Maybe a
Prelude.Nothing,
      $sel:apiKey:ApiKeyCredentials' :: Sensitive Text
apiKey = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pApiKey_
    }

-- | The API secret key required for API key authentication.
apiKeyCredentials_apiSecretKey :: Lens.Lens' ApiKeyCredentials (Prelude.Maybe Prelude.Text)
apiKeyCredentials_apiSecretKey :: Lens' ApiKeyCredentials (Maybe Text)
apiKeyCredentials_apiSecretKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiKeyCredentials' {Maybe (Sensitive Text)
apiSecretKey :: Maybe (Sensitive Text)
$sel:apiSecretKey:ApiKeyCredentials' :: ApiKeyCredentials -> Maybe (Sensitive Text)
apiSecretKey} -> Maybe (Sensitive Text)
apiSecretKey) (\s :: ApiKeyCredentials
s@ApiKeyCredentials' {} Maybe (Sensitive Text)
a -> ApiKeyCredentials
s {$sel:apiSecretKey:ApiKeyCredentials' :: Maybe (Sensitive Text)
apiSecretKey = Maybe (Sensitive Text)
a} :: ApiKeyCredentials) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The API key required for API key authentication.
apiKeyCredentials_apiKey :: Lens.Lens' ApiKeyCredentials Prelude.Text
apiKeyCredentials_apiKey :: Lens' ApiKeyCredentials Text
apiKeyCredentials_apiKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiKeyCredentials' {Sensitive Text
apiKey :: Sensitive Text
$sel:apiKey:ApiKeyCredentials' :: ApiKeyCredentials -> Sensitive Text
apiKey} -> Sensitive Text
apiKey) (\s :: ApiKeyCredentials
s@ApiKeyCredentials' {} Sensitive Text
a -> ApiKeyCredentials
s {$sel:apiKey:ApiKeyCredentials' :: Sensitive Text
apiKey = Sensitive Text
a} :: ApiKeyCredentials) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Prelude.Hashable ApiKeyCredentials where
  hashWithSalt :: Int -> ApiKeyCredentials -> Int
hashWithSalt Int
_salt ApiKeyCredentials' {Maybe (Sensitive Text)
Sensitive Text
apiKey :: Sensitive Text
apiSecretKey :: Maybe (Sensitive Text)
$sel:apiKey:ApiKeyCredentials' :: ApiKeyCredentials -> Sensitive Text
$sel:apiSecretKey:ApiKeyCredentials' :: ApiKeyCredentials -> Maybe (Sensitive Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
apiSecretKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
apiKey

instance Prelude.NFData ApiKeyCredentials where
  rnf :: ApiKeyCredentials -> ()
rnf ApiKeyCredentials' {Maybe (Sensitive Text)
Sensitive Text
apiKey :: Sensitive Text
apiSecretKey :: Maybe (Sensitive Text)
$sel:apiKey:ApiKeyCredentials' :: ApiKeyCredentials -> Sensitive Text
$sel:apiSecretKey:ApiKeyCredentials' :: ApiKeyCredentials -> Maybe (Sensitive Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
apiSecretKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
apiKey

instance Data.ToJSON ApiKeyCredentials where
  toJSON :: ApiKeyCredentials -> Value
toJSON ApiKeyCredentials' {Maybe (Sensitive Text)
Sensitive Text
apiKey :: Sensitive Text
apiSecretKey :: Maybe (Sensitive Text)
$sel:apiKey:ApiKeyCredentials' :: ApiKeyCredentials -> Sensitive Text
$sel:apiSecretKey:ApiKeyCredentials' :: ApiKeyCredentials -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"apiSecretKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
apiSecretKey,
            forall a. a -> Maybe a
Prelude.Just (Key
"apiKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
apiKey)
          ]
      )