{-# 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.MarketoConnectorProfileCredentials
-- 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.MarketoConnectorProfileCredentials 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 by Marketo.
--
-- /See:/ 'newMarketoConnectorProfileCredentials' smart constructor.
data MarketoConnectorProfileCredentials = MarketoConnectorProfileCredentials'
  { -- | The credentials used to access protected Marketo resources.
    MarketoConnectorProfileCredentials -> Maybe (Sensitive Text)
accessToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The OAuth requirement needed to request security tokens from the
    -- connector endpoint.
    MarketoConnectorProfileCredentials -> Maybe ConnectorOAuthRequest
oAuthRequest :: Prelude.Maybe ConnectorOAuthRequest,
    -- | The identifier for the desired client.
    MarketoConnectorProfileCredentials -> Text
clientId :: Prelude.Text,
    -- | The client secret used by the OAuth client to authenticate to the
    -- authorization server.
    MarketoConnectorProfileCredentials -> Sensitive Text
clientSecret :: Core.Sensitive Prelude.Text
  }
  deriving (MarketoConnectorProfileCredentials
-> MarketoConnectorProfileCredentials -> Bool
(MarketoConnectorProfileCredentials
 -> MarketoConnectorProfileCredentials -> Bool)
-> (MarketoConnectorProfileCredentials
    -> MarketoConnectorProfileCredentials -> Bool)
-> Eq MarketoConnectorProfileCredentials
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MarketoConnectorProfileCredentials
-> MarketoConnectorProfileCredentials -> Bool
$c/= :: MarketoConnectorProfileCredentials
-> MarketoConnectorProfileCredentials -> Bool
== :: MarketoConnectorProfileCredentials
-> MarketoConnectorProfileCredentials -> Bool
$c== :: MarketoConnectorProfileCredentials
-> MarketoConnectorProfileCredentials -> Bool
Prelude.Eq, Int -> MarketoConnectorProfileCredentials -> ShowS
[MarketoConnectorProfileCredentials] -> ShowS
MarketoConnectorProfileCredentials -> String
(Int -> MarketoConnectorProfileCredentials -> ShowS)
-> (MarketoConnectorProfileCredentials -> String)
-> ([MarketoConnectorProfileCredentials] -> ShowS)
-> Show MarketoConnectorProfileCredentials
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MarketoConnectorProfileCredentials] -> ShowS
$cshowList :: [MarketoConnectorProfileCredentials] -> ShowS
show :: MarketoConnectorProfileCredentials -> String
$cshow :: MarketoConnectorProfileCredentials -> String
showsPrec :: Int -> MarketoConnectorProfileCredentials -> ShowS
$cshowsPrec :: Int -> MarketoConnectorProfileCredentials -> ShowS
Prelude.Show, (forall x.
 MarketoConnectorProfileCredentials
 -> Rep MarketoConnectorProfileCredentials x)
-> (forall x.
    Rep MarketoConnectorProfileCredentials x
    -> MarketoConnectorProfileCredentials)
-> Generic MarketoConnectorProfileCredentials
forall x.
Rep MarketoConnectorProfileCredentials x
-> MarketoConnectorProfileCredentials
forall x.
MarketoConnectorProfileCredentials
-> Rep MarketoConnectorProfileCredentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep MarketoConnectorProfileCredentials x
-> MarketoConnectorProfileCredentials
$cfrom :: forall x.
MarketoConnectorProfileCredentials
-> Rep MarketoConnectorProfileCredentials x
Prelude.Generic)

-- |
-- Create a value of 'MarketoConnectorProfileCredentials' 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', 'marketoConnectorProfileCredentials_accessToken' - The credentials used to access protected Marketo resources.
--
-- 'oAuthRequest', 'marketoConnectorProfileCredentials_oAuthRequest' - The OAuth requirement needed to request security tokens from the
-- connector endpoint.
--
-- 'clientId', 'marketoConnectorProfileCredentials_clientId' - The identifier for the desired client.
--
-- 'clientSecret', 'marketoConnectorProfileCredentials_clientSecret' - The client secret used by the OAuth client to authenticate to the
-- authorization server.
newMarketoConnectorProfileCredentials ::
  -- | 'clientId'
  Prelude.Text ->
  -- | 'clientSecret'
  Prelude.Text ->
  MarketoConnectorProfileCredentials
newMarketoConnectorProfileCredentials :: Text -> Text -> MarketoConnectorProfileCredentials
newMarketoConnectorProfileCredentials
  Text
pClientId_
  Text
pClientSecret_ =
    MarketoConnectorProfileCredentials' :: Maybe (Sensitive Text)
-> Maybe ConnectorOAuthRequest
-> Text
-> Sensitive Text
-> MarketoConnectorProfileCredentials
MarketoConnectorProfileCredentials'
      { $sel:accessToken:MarketoConnectorProfileCredentials' :: Maybe (Sensitive Text)
accessToken =
          Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:oAuthRequest:MarketoConnectorProfileCredentials' :: Maybe ConnectorOAuthRequest
oAuthRequest = Maybe ConnectorOAuthRequest
forall a. Maybe a
Prelude.Nothing,
        $sel:clientId:MarketoConnectorProfileCredentials' :: Text
clientId = Text
pClientId_,
        $sel:clientSecret:MarketoConnectorProfileCredentials' :: Sensitive Text
clientSecret =
          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
pClientSecret_
      }

-- | The credentials used to access protected Marketo resources.
marketoConnectorProfileCredentials_accessToken :: Lens.Lens' MarketoConnectorProfileCredentials (Prelude.Maybe Prelude.Text)
marketoConnectorProfileCredentials_accessToken :: (Maybe Text -> f (Maybe Text))
-> MarketoConnectorProfileCredentials
-> f MarketoConnectorProfileCredentials
marketoConnectorProfileCredentials_accessToken = (MarketoConnectorProfileCredentials -> Maybe (Sensitive Text))
-> (MarketoConnectorProfileCredentials
    -> Maybe (Sensitive Text) -> MarketoConnectorProfileCredentials)
-> Lens
     MarketoConnectorProfileCredentials
     MarketoConnectorProfileCredentials
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MarketoConnectorProfileCredentials' {Maybe (Sensitive Text)
accessToken :: Maybe (Sensitive Text)
$sel:accessToken:MarketoConnectorProfileCredentials' :: MarketoConnectorProfileCredentials -> Maybe (Sensitive Text)
accessToken} -> Maybe (Sensitive Text)
accessToken) (\s :: MarketoConnectorProfileCredentials
s@MarketoConnectorProfileCredentials' {} Maybe (Sensitive Text)
a -> MarketoConnectorProfileCredentials
s {$sel:accessToken:MarketoConnectorProfileCredentials' :: Maybe (Sensitive Text)
accessToken = Maybe (Sensitive Text)
a} :: MarketoConnectorProfileCredentials) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> MarketoConnectorProfileCredentials
 -> f MarketoConnectorProfileCredentials)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> MarketoConnectorProfileCredentials
-> f MarketoConnectorProfileCredentials
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 OAuth requirement needed to request security tokens from the
-- connector endpoint.
marketoConnectorProfileCredentials_oAuthRequest :: Lens.Lens' MarketoConnectorProfileCredentials (Prelude.Maybe ConnectorOAuthRequest)
marketoConnectorProfileCredentials_oAuthRequest :: (Maybe ConnectorOAuthRequest -> f (Maybe ConnectorOAuthRequest))
-> MarketoConnectorProfileCredentials
-> f MarketoConnectorProfileCredentials
marketoConnectorProfileCredentials_oAuthRequest = (MarketoConnectorProfileCredentials -> Maybe ConnectorOAuthRequest)
-> (MarketoConnectorProfileCredentials
    -> Maybe ConnectorOAuthRequest
    -> MarketoConnectorProfileCredentials)
-> Lens
     MarketoConnectorProfileCredentials
     MarketoConnectorProfileCredentials
     (Maybe ConnectorOAuthRequest)
     (Maybe ConnectorOAuthRequest)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MarketoConnectorProfileCredentials' {Maybe ConnectorOAuthRequest
oAuthRequest :: Maybe ConnectorOAuthRequest
$sel:oAuthRequest:MarketoConnectorProfileCredentials' :: MarketoConnectorProfileCredentials -> Maybe ConnectorOAuthRequest
oAuthRequest} -> Maybe ConnectorOAuthRequest
oAuthRequest) (\s :: MarketoConnectorProfileCredentials
s@MarketoConnectorProfileCredentials' {} Maybe ConnectorOAuthRequest
a -> MarketoConnectorProfileCredentials
s {$sel:oAuthRequest:MarketoConnectorProfileCredentials' :: Maybe ConnectorOAuthRequest
oAuthRequest = Maybe ConnectorOAuthRequest
a} :: MarketoConnectorProfileCredentials)

-- | The identifier for the desired client.
marketoConnectorProfileCredentials_clientId :: Lens.Lens' MarketoConnectorProfileCredentials Prelude.Text
marketoConnectorProfileCredentials_clientId :: (Text -> f Text)
-> MarketoConnectorProfileCredentials
-> f MarketoConnectorProfileCredentials
marketoConnectorProfileCredentials_clientId = (MarketoConnectorProfileCredentials -> Text)
-> (MarketoConnectorProfileCredentials
    -> Text -> MarketoConnectorProfileCredentials)
-> Lens
     MarketoConnectorProfileCredentials
     MarketoConnectorProfileCredentials
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MarketoConnectorProfileCredentials' {Text
clientId :: Text
$sel:clientId:MarketoConnectorProfileCredentials' :: MarketoConnectorProfileCredentials -> Text
clientId} -> Text
clientId) (\s :: MarketoConnectorProfileCredentials
s@MarketoConnectorProfileCredentials' {} Text
a -> MarketoConnectorProfileCredentials
s {$sel:clientId:MarketoConnectorProfileCredentials' :: Text
clientId = Text
a} :: MarketoConnectorProfileCredentials)

-- | The client secret used by the OAuth client to authenticate to the
-- authorization server.
marketoConnectorProfileCredentials_clientSecret :: Lens.Lens' MarketoConnectorProfileCredentials Prelude.Text
marketoConnectorProfileCredentials_clientSecret :: (Text -> f Text)
-> MarketoConnectorProfileCredentials
-> f MarketoConnectorProfileCredentials
marketoConnectorProfileCredentials_clientSecret = (MarketoConnectorProfileCredentials -> Sensitive Text)
-> (MarketoConnectorProfileCredentials
    -> Sensitive Text -> MarketoConnectorProfileCredentials)
-> Lens
     MarketoConnectorProfileCredentials
     MarketoConnectorProfileCredentials
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MarketoConnectorProfileCredentials' {Sensitive Text
clientSecret :: Sensitive Text
$sel:clientSecret:MarketoConnectorProfileCredentials' :: MarketoConnectorProfileCredentials -> Sensitive Text
clientSecret} -> Sensitive Text
clientSecret) (\s :: MarketoConnectorProfileCredentials
s@MarketoConnectorProfileCredentials' {} Sensitive Text
a -> MarketoConnectorProfileCredentials
s {$sel:clientSecret:MarketoConnectorProfileCredentials' :: Sensitive Text
clientSecret = Sensitive Text
a} :: MarketoConnectorProfileCredentials) ((Sensitive Text -> f (Sensitive Text))
 -> MarketoConnectorProfileCredentials
 -> f MarketoConnectorProfileCredentials)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> MarketoConnectorProfileCredentials
-> f MarketoConnectorProfileCredentials
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
    MarketoConnectorProfileCredentials

instance
  Prelude.NFData
    MarketoConnectorProfileCredentials

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