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

-- |
-- Create a value of 'ZendeskConnectorProfileCredentials' 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', 'zendeskConnectorProfileCredentials_accessToken' - The credentials used to access protected Zendesk resources.
--
-- 'oAuthRequest', 'zendeskConnectorProfileCredentials_oAuthRequest' - The OAuth requirement needed to request security tokens from the
-- connector endpoint.
--
-- 'clientId', 'zendeskConnectorProfileCredentials_clientId' - The identifier for the desired client.
--
-- 'clientSecret', 'zendeskConnectorProfileCredentials_clientSecret' - The client secret used by the OAuth client to authenticate to the
-- authorization server.
newZendeskConnectorProfileCredentials ::
  -- | 'clientId'
  Prelude.Text ->
  -- | 'clientSecret'
  Prelude.Text ->
  ZendeskConnectorProfileCredentials
newZendeskConnectorProfileCredentials :: Text -> Text -> ZendeskConnectorProfileCredentials
newZendeskConnectorProfileCredentials
  Text
pClientId_
  Text
pClientSecret_ =
    ZendeskConnectorProfileCredentials' :: Maybe (Sensitive Text)
-> Maybe ConnectorOAuthRequest
-> Text
-> Sensitive Text
-> ZendeskConnectorProfileCredentials
ZendeskConnectorProfileCredentials'
      { $sel:accessToken:ZendeskConnectorProfileCredentials' :: Maybe (Sensitive Text)
accessToken =
          Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:oAuthRequest:ZendeskConnectorProfileCredentials' :: Maybe ConnectorOAuthRequest
oAuthRequest = Maybe ConnectorOAuthRequest
forall a. Maybe a
Prelude.Nothing,
        $sel:clientId:ZendeskConnectorProfileCredentials' :: Text
clientId = Text
pClientId_,
        $sel:clientSecret:ZendeskConnectorProfileCredentials' :: 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 Zendesk resources.
zendeskConnectorProfileCredentials_accessToken :: Lens.Lens' ZendeskConnectorProfileCredentials (Prelude.Maybe Prelude.Text)
zendeskConnectorProfileCredentials_accessToken :: (Maybe Text -> f (Maybe Text))
-> ZendeskConnectorProfileCredentials
-> f ZendeskConnectorProfileCredentials
zendeskConnectorProfileCredentials_accessToken = (ZendeskConnectorProfileCredentials -> Maybe (Sensitive Text))
-> (ZendeskConnectorProfileCredentials
    -> Maybe (Sensitive Text) -> ZendeskConnectorProfileCredentials)
-> Lens
     ZendeskConnectorProfileCredentials
     ZendeskConnectorProfileCredentials
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ZendeskConnectorProfileCredentials' {Maybe (Sensitive Text)
accessToken :: Maybe (Sensitive Text)
$sel:accessToken:ZendeskConnectorProfileCredentials' :: ZendeskConnectorProfileCredentials -> Maybe (Sensitive Text)
accessToken} -> Maybe (Sensitive Text)
accessToken) (\s :: ZendeskConnectorProfileCredentials
s@ZendeskConnectorProfileCredentials' {} Maybe (Sensitive Text)
a -> ZendeskConnectorProfileCredentials
s {$sel:accessToken:ZendeskConnectorProfileCredentials' :: Maybe (Sensitive Text)
accessToken = Maybe (Sensitive Text)
a} :: ZendeskConnectorProfileCredentials) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> ZendeskConnectorProfileCredentials
 -> f ZendeskConnectorProfileCredentials)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> ZendeskConnectorProfileCredentials
-> f ZendeskConnectorProfileCredentials
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.
zendeskConnectorProfileCredentials_oAuthRequest :: Lens.Lens' ZendeskConnectorProfileCredentials (Prelude.Maybe ConnectorOAuthRequest)
zendeskConnectorProfileCredentials_oAuthRequest :: (Maybe ConnectorOAuthRequest -> f (Maybe ConnectorOAuthRequest))
-> ZendeskConnectorProfileCredentials
-> f ZendeskConnectorProfileCredentials
zendeskConnectorProfileCredentials_oAuthRequest = (ZendeskConnectorProfileCredentials -> Maybe ConnectorOAuthRequest)
-> (ZendeskConnectorProfileCredentials
    -> Maybe ConnectorOAuthRequest
    -> ZendeskConnectorProfileCredentials)
-> Lens
     ZendeskConnectorProfileCredentials
     ZendeskConnectorProfileCredentials
     (Maybe ConnectorOAuthRequest)
     (Maybe ConnectorOAuthRequest)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ZendeskConnectorProfileCredentials' {Maybe ConnectorOAuthRequest
oAuthRequest :: Maybe ConnectorOAuthRequest
$sel:oAuthRequest:ZendeskConnectorProfileCredentials' :: ZendeskConnectorProfileCredentials -> Maybe ConnectorOAuthRequest
oAuthRequest} -> Maybe ConnectorOAuthRequest
oAuthRequest) (\s :: ZendeskConnectorProfileCredentials
s@ZendeskConnectorProfileCredentials' {} Maybe ConnectorOAuthRequest
a -> ZendeskConnectorProfileCredentials
s {$sel:oAuthRequest:ZendeskConnectorProfileCredentials' :: Maybe ConnectorOAuthRequest
oAuthRequest = Maybe ConnectorOAuthRequest
a} :: ZendeskConnectorProfileCredentials)

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

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

instance
  Prelude.NFData
    ZendeskConnectorProfileCredentials

instance
  Core.ToJSON
    ZendeskConnectorProfileCredentials
  where
  toJSON :: ZendeskConnectorProfileCredentials -> Value
toJSON ZendeskConnectorProfileCredentials' {Maybe (Sensitive Text)
Maybe ConnectorOAuthRequest
Text
Sensitive Text
clientSecret :: Sensitive Text
clientId :: Text
oAuthRequest :: Maybe ConnectorOAuthRequest
accessToken :: Maybe (Sensitive Text)
$sel:clientSecret:ZendeskConnectorProfileCredentials' :: ZendeskConnectorProfileCredentials -> Sensitive Text
$sel:clientId:ZendeskConnectorProfileCredentials' :: ZendeskConnectorProfileCredentials -> Text
$sel:oAuthRequest:ZendeskConnectorProfileCredentials' :: ZendeskConnectorProfileCredentials -> Maybe ConnectorOAuthRequest
$sel:accessToken:ZendeskConnectorProfileCredentials' :: ZendeskConnectorProfileCredentials -> 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)
          ]
      )