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

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

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

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

instance
  Prelude.NFData
    SlackConnectorProfileCredentials

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