{-# 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.SalesforceConnectorProfileCredentials
-- 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.SalesforceConnectorProfileCredentials where

import Amazonka.AppFlow.Types.ConnectorOAuthRequest
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The connector-specific profile credentials required when using
-- Salesforce.
--
-- /See:/ 'newSalesforceConnectorProfileCredentials' smart constructor.
data SalesforceConnectorProfileCredentials = SalesforceConnectorProfileCredentials'
  { -- | The credentials used to access protected Salesforce resources.
    SalesforceConnectorProfileCredentials -> Maybe (Sensitive Text)
accessToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The credentials used to acquire new access tokens.
    SalesforceConnectorProfileCredentials -> Maybe Text
refreshToken :: Prelude.Maybe Prelude.Text,
    -- | The OAuth requirement needed to request security tokens from the
    -- connector endpoint.
    SalesforceConnectorProfileCredentials
-> Maybe ConnectorOAuthRequest
oAuthRequest :: Prelude.Maybe ConnectorOAuthRequest,
    -- | The secret manager ARN, which contains the client ID and client secret
    -- of the connected app.
    SalesforceConnectorProfileCredentials -> Maybe (Sensitive Text)
clientCredentialsArn :: Prelude.Maybe (Core.Sensitive Prelude.Text)
  }
  deriving (SalesforceConnectorProfileCredentials
-> SalesforceConnectorProfileCredentials -> Bool
(SalesforceConnectorProfileCredentials
 -> SalesforceConnectorProfileCredentials -> Bool)
-> (SalesforceConnectorProfileCredentials
    -> SalesforceConnectorProfileCredentials -> Bool)
-> Eq SalesforceConnectorProfileCredentials
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SalesforceConnectorProfileCredentials
-> SalesforceConnectorProfileCredentials -> Bool
$c/= :: SalesforceConnectorProfileCredentials
-> SalesforceConnectorProfileCredentials -> Bool
== :: SalesforceConnectorProfileCredentials
-> SalesforceConnectorProfileCredentials -> Bool
$c== :: SalesforceConnectorProfileCredentials
-> SalesforceConnectorProfileCredentials -> Bool
Prelude.Eq, Int -> SalesforceConnectorProfileCredentials -> ShowS
[SalesforceConnectorProfileCredentials] -> ShowS
SalesforceConnectorProfileCredentials -> String
(Int -> SalesforceConnectorProfileCredentials -> ShowS)
-> (SalesforceConnectorProfileCredentials -> String)
-> ([SalesforceConnectorProfileCredentials] -> ShowS)
-> Show SalesforceConnectorProfileCredentials
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SalesforceConnectorProfileCredentials] -> ShowS
$cshowList :: [SalesforceConnectorProfileCredentials] -> ShowS
show :: SalesforceConnectorProfileCredentials -> String
$cshow :: SalesforceConnectorProfileCredentials -> String
showsPrec :: Int -> SalesforceConnectorProfileCredentials -> ShowS
$cshowsPrec :: Int -> SalesforceConnectorProfileCredentials -> ShowS
Prelude.Show, (forall x.
 SalesforceConnectorProfileCredentials
 -> Rep SalesforceConnectorProfileCredentials x)
-> (forall x.
    Rep SalesforceConnectorProfileCredentials x
    -> SalesforceConnectorProfileCredentials)
-> Generic SalesforceConnectorProfileCredentials
forall x.
Rep SalesforceConnectorProfileCredentials x
-> SalesforceConnectorProfileCredentials
forall x.
SalesforceConnectorProfileCredentials
-> Rep SalesforceConnectorProfileCredentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SalesforceConnectorProfileCredentials x
-> SalesforceConnectorProfileCredentials
$cfrom :: forall x.
SalesforceConnectorProfileCredentials
-> Rep SalesforceConnectorProfileCredentials x
Prelude.Generic)

-- |
-- Create a value of 'SalesforceConnectorProfileCredentials' 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:
--
-- 'accessToken', 'salesforceConnectorProfileCredentials_accessToken' - The credentials used to access protected Salesforce resources.
--
-- 'refreshToken', 'salesforceConnectorProfileCredentials_refreshToken' - The credentials used to acquire new access tokens.
--
-- 'oAuthRequest', 'salesforceConnectorProfileCredentials_oAuthRequest' - The OAuth requirement needed to request security tokens from the
-- connector endpoint.
--
-- 'clientCredentialsArn', 'salesforceConnectorProfileCredentials_clientCredentialsArn' - The secret manager ARN, which contains the client ID and client secret
-- of the connected app.
newSalesforceConnectorProfileCredentials ::
  SalesforceConnectorProfileCredentials
newSalesforceConnectorProfileCredentials :: SalesforceConnectorProfileCredentials
newSalesforceConnectorProfileCredentials =
  SalesforceConnectorProfileCredentials' :: Maybe (Sensitive Text)
-> Maybe Text
-> Maybe ConnectorOAuthRequest
-> Maybe (Sensitive Text)
-> SalesforceConnectorProfileCredentials
SalesforceConnectorProfileCredentials'
    { $sel:accessToken:SalesforceConnectorProfileCredentials' :: Maybe (Sensitive Text)
accessToken =
        Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:refreshToken:SalesforceConnectorProfileCredentials' :: Maybe Text
refreshToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:oAuthRequest:SalesforceConnectorProfileCredentials' :: Maybe ConnectorOAuthRequest
oAuthRequest = Maybe ConnectorOAuthRequest
forall a. Maybe a
Prelude.Nothing,
      $sel:clientCredentialsArn:SalesforceConnectorProfileCredentials' :: Maybe (Sensitive Text)
clientCredentialsArn =
        Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | The credentials used to access protected Salesforce resources.
salesforceConnectorProfileCredentials_accessToken :: Lens.Lens' SalesforceConnectorProfileCredentials (Prelude.Maybe Prelude.Text)
salesforceConnectorProfileCredentials_accessToken :: (Maybe Text -> f (Maybe Text))
-> SalesforceConnectorProfileCredentials
-> f SalesforceConnectorProfileCredentials
salesforceConnectorProfileCredentials_accessToken = (SalesforceConnectorProfileCredentials -> Maybe (Sensitive Text))
-> (SalesforceConnectorProfileCredentials
    -> Maybe (Sensitive Text) -> SalesforceConnectorProfileCredentials)
-> Lens
     SalesforceConnectorProfileCredentials
     SalesforceConnectorProfileCredentials
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SalesforceConnectorProfileCredentials' {Maybe (Sensitive Text)
accessToken :: Maybe (Sensitive Text)
$sel:accessToken:SalesforceConnectorProfileCredentials' :: SalesforceConnectorProfileCredentials -> Maybe (Sensitive Text)
accessToken} -> Maybe (Sensitive Text)
accessToken) (\s :: SalesforceConnectorProfileCredentials
s@SalesforceConnectorProfileCredentials' {} Maybe (Sensitive Text)
a -> SalesforceConnectorProfileCredentials
s {$sel:accessToken:SalesforceConnectorProfileCredentials' :: Maybe (Sensitive Text)
accessToken = Maybe (Sensitive Text)
a} :: SalesforceConnectorProfileCredentials) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> SalesforceConnectorProfileCredentials
 -> f SalesforceConnectorProfileCredentials)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> SalesforceConnectorProfileCredentials
-> f SalesforceConnectorProfileCredentials
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 credentials used to acquire new access tokens.
salesforceConnectorProfileCredentials_refreshToken :: Lens.Lens' SalesforceConnectorProfileCredentials (Prelude.Maybe Prelude.Text)
salesforceConnectorProfileCredentials_refreshToken :: (Maybe Text -> f (Maybe Text))
-> SalesforceConnectorProfileCredentials
-> f SalesforceConnectorProfileCredentials
salesforceConnectorProfileCredentials_refreshToken = (SalesforceConnectorProfileCredentials -> Maybe Text)
-> (SalesforceConnectorProfileCredentials
    -> Maybe Text -> SalesforceConnectorProfileCredentials)
-> Lens
     SalesforceConnectorProfileCredentials
     SalesforceConnectorProfileCredentials
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SalesforceConnectorProfileCredentials' {Maybe Text
refreshToken :: Maybe Text
$sel:refreshToken:SalesforceConnectorProfileCredentials' :: SalesforceConnectorProfileCredentials -> Maybe Text
refreshToken} -> Maybe Text
refreshToken) (\s :: SalesforceConnectorProfileCredentials
s@SalesforceConnectorProfileCredentials' {} Maybe Text
a -> SalesforceConnectorProfileCredentials
s {$sel:refreshToken:SalesforceConnectorProfileCredentials' :: Maybe Text
refreshToken = Maybe Text
a} :: SalesforceConnectorProfileCredentials)

-- | The OAuth requirement needed to request security tokens from the
-- connector endpoint.
salesforceConnectorProfileCredentials_oAuthRequest :: Lens.Lens' SalesforceConnectorProfileCredentials (Prelude.Maybe ConnectorOAuthRequest)
salesforceConnectorProfileCredentials_oAuthRequest :: (Maybe ConnectorOAuthRequest -> f (Maybe ConnectorOAuthRequest))
-> SalesforceConnectorProfileCredentials
-> f SalesforceConnectorProfileCredentials
salesforceConnectorProfileCredentials_oAuthRequest = (SalesforceConnectorProfileCredentials
 -> Maybe ConnectorOAuthRequest)
-> (SalesforceConnectorProfileCredentials
    -> Maybe ConnectorOAuthRequest
    -> SalesforceConnectorProfileCredentials)
-> Lens
     SalesforceConnectorProfileCredentials
     SalesforceConnectorProfileCredentials
     (Maybe ConnectorOAuthRequest)
     (Maybe ConnectorOAuthRequest)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SalesforceConnectorProfileCredentials' {Maybe ConnectorOAuthRequest
oAuthRequest :: Maybe ConnectorOAuthRequest
$sel:oAuthRequest:SalesforceConnectorProfileCredentials' :: SalesforceConnectorProfileCredentials
-> Maybe ConnectorOAuthRequest
oAuthRequest} -> Maybe ConnectorOAuthRequest
oAuthRequest) (\s :: SalesforceConnectorProfileCredentials
s@SalesforceConnectorProfileCredentials' {} Maybe ConnectorOAuthRequest
a -> SalesforceConnectorProfileCredentials
s {$sel:oAuthRequest:SalesforceConnectorProfileCredentials' :: Maybe ConnectorOAuthRequest
oAuthRequest = Maybe ConnectorOAuthRequest
a} :: SalesforceConnectorProfileCredentials)

-- | The secret manager ARN, which contains the client ID and client secret
-- of the connected app.
salesforceConnectorProfileCredentials_clientCredentialsArn :: Lens.Lens' SalesforceConnectorProfileCredentials (Prelude.Maybe Prelude.Text)
salesforceConnectorProfileCredentials_clientCredentialsArn :: (Maybe Text -> f (Maybe Text))
-> SalesforceConnectorProfileCredentials
-> f SalesforceConnectorProfileCredentials
salesforceConnectorProfileCredentials_clientCredentialsArn = (SalesforceConnectorProfileCredentials -> Maybe (Sensitive Text))
-> (SalesforceConnectorProfileCredentials
    -> Maybe (Sensitive Text) -> SalesforceConnectorProfileCredentials)
-> Lens
     SalesforceConnectorProfileCredentials
     SalesforceConnectorProfileCredentials
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SalesforceConnectorProfileCredentials' {Maybe (Sensitive Text)
clientCredentialsArn :: Maybe (Sensitive Text)
$sel:clientCredentialsArn:SalesforceConnectorProfileCredentials' :: SalesforceConnectorProfileCredentials -> Maybe (Sensitive Text)
clientCredentialsArn} -> Maybe (Sensitive Text)
clientCredentialsArn) (\s :: SalesforceConnectorProfileCredentials
s@SalesforceConnectorProfileCredentials' {} Maybe (Sensitive Text)
a -> SalesforceConnectorProfileCredentials
s {$sel:clientCredentialsArn:SalesforceConnectorProfileCredentials' :: Maybe (Sensitive Text)
clientCredentialsArn = Maybe (Sensitive Text)
a} :: SalesforceConnectorProfileCredentials) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> SalesforceConnectorProfileCredentials
 -> f SalesforceConnectorProfileCredentials)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> SalesforceConnectorProfileCredentials
-> f SalesforceConnectorProfileCredentials
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
    SalesforceConnectorProfileCredentials

instance
  Prelude.NFData
    SalesforceConnectorProfileCredentials

instance
  Core.ToJSON
    SalesforceConnectorProfileCredentials
  where
  toJSON :: SalesforceConnectorProfileCredentials -> Value
toJSON SalesforceConnectorProfileCredentials' {Maybe Text
Maybe (Sensitive Text)
Maybe ConnectorOAuthRequest
clientCredentialsArn :: Maybe (Sensitive Text)
oAuthRequest :: Maybe ConnectorOAuthRequest
refreshToken :: Maybe Text
accessToken :: Maybe (Sensitive Text)
$sel:clientCredentialsArn:SalesforceConnectorProfileCredentials' :: SalesforceConnectorProfileCredentials -> Maybe (Sensitive Text)
$sel:oAuthRequest:SalesforceConnectorProfileCredentials' :: SalesforceConnectorProfileCredentials
-> Maybe ConnectorOAuthRequest
$sel:refreshToken:SalesforceConnectorProfileCredentials' :: SalesforceConnectorProfileCredentials -> Maybe Text
$sel:accessToken:SalesforceConnectorProfileCredentials' :: SalesforceConnectorProfileCredentials -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"accessToken" 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)
accessToken,
            (Text
"refreshToken" 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
refreshToken,
            (Text
"oAuthRequest" Text -> ConnectorOAuthRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ConnectorOAuthRequest -> Pair)
-> Maybe ConnectorOAuthRequest -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ConnectorOAuthRequest
oAuthRequest,
            (Text
"clientCredentialsArn" 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)
clientCredentialsArn
          ]
      )