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

import Amazonka.AppFlow.Types.ConnectorOAuthRequest
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 connector-specific profile credentials required by Google Analytics.
--
-- /See:/ 'newGoogleAnalyticsConnectorProfileCredentials' smart constructor.
data GoogleAnalyticsConnectorProfileCredentials = GoogleAnalyticsConnectorProfileCredentials'
  { -- | The credentials used to access protected Google Analytics resources.
    GoogleAnalyticsConnectorProfileCredentials
-> Maybe (Sensitive Text)
accessToken :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The OAuth requirement needed to request security tokens from the
    -- connector endpoint.
    GoogleAnalyticsConnectorProfileCredentials
-> Maybe ConnectorOAuthRequest
oAuthRequest :: Prelude.Maybe ConnectorOAuthRequest,
    -- | The credentials used to acquire new access tokens. This is required only
    -- for OAuth2 access tokens, and is not required for OAuth1 access tokens.
    GoogleAnalyticsConnectorProfileCredentials -> Maybe Text
refreshToken :: Prelude.Maybe Prelude.Text,
    -- | The identifier for the desired client.
    GoogleAnalyticsConnectorProfileCredentials -> Text
clientId :: Prelude.Text,
    -- | The client secret used by the OAuth client to authenticate to the
    -- authorization server.
    GoogleAnalyticsConnectorProfileCredentials -> Sensitive Text
clientSecret :: Data.Sensitive Prelude.Text
  }
  deriving (GoogleAnalyticsConnectorProfileCredentials
-> GoogleAnalyticsConnectorProfileCredentials -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GoogleAnalyticsConnectorProfileCredentials
-> GoogleAnalyticsConnectorProfileCredentials -> Bool
$c/= :: GoogleAnalyticsConnectorProfileCredentials
-> GoogleAnalyticsConnectorProfileCredentials -> Bool
== :: GoogleAnalyticsConnectorProfileCredentials
-> GoogleAnalyticsConnectorProfileCredentials -> Bool
$c== :: GoogleAnalyticsConnectorProfileCredentials
-> GoogleAnalyticsConnectorProfileCredentials -> Bool
Prelude.Eq, Int -> GoogleAnalyticsConnectorProfileCredentials -> ShowS
[GoogleAnalyticsConnectorProfileCredentials] -> ShowS
GoogleAnalyticsConnectorProfileCredentials -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GoogleAnalyticsConnectorProfileCredentials] -> ShowS
$cshowList :: [GoogleAnalyticsConnectorProfileCredentials] -> ShowS
show :: GoogleAnalyticsConnectorProfileCredentials -> String
$cshow :: GoogleAnalyticsConnectorProfileCredentials -> String
showsPrec :: Int -> GoogleAnalyticsConnectorProfileCredentials -> ShowS
$cshowsPrec :: Int -> GoogleAnalyticsConnectorProfileCredentials -> ShowS
Prelude.Show, forall x.
Rep GoogleAnalyticsConnectorProfileCredentials x
-> GoogleAnalyticsConnectorProfileCredentials
forall x.
GoogleAnalyticsConnectorProfileCredentials
-> Rep GoogleAnalyticsConnectorProfileCredentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GoogleAnalyticsConnectorProfileCredentials x
-> GoogleAnalyticsConnectorProfileCredentials
$cfrom :: forall x.
GoogleAnalyticsConnectorProfileCredentials
-> Rep GoogleAnalyticsConnectorProfileCredentials x
Prelude.Generic)

-- |
-- Create a value of 'GoogleAnalyticsConnectorProfileCredentials' 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', 'googleAnalyticsConnectorProfileCredentials_accessToken' - The credentials used to access protected Google Analytics resources.
--
-- 'oAuthRequest', 'googleAnalyticsConnectorProfileCredentials_oAuthRequest' - The OAuth requirement needed to request security tokens from the
-- connector endpoint.
--
-- 'refreshToken', 'googleAnalyticsConnectorProfileCredentials_refreshToken' - The credentials used to acquire new access tokens. This is required only
-- for OAuth2 access tokens, and is not required for OAuth1 access tokens.
--
-- 'clientId', 'googleAnalyticsConnectorProfileCredentials_clientId' - The identifier for the desired client.
--
-- 'clientSecret', 'googleAnalyticsConnectorProfileCredentials_clientSecret' - The client secret used by the OAuth client to authenticate to the
-- authorization server.
newGoogleAnalyticsConnectorProfileCredentials ::
  -- | 'clientId'
  Prelude.Text ->
  -- | 'clientSecret'
  Prelude.Text ->
  GoogleAnalyticsConnectorProfileCredentials
newGoogleAnalyticsConnectorProfileCredentials :: Text -> Text -> GoogleAnalyticsConnectorProfileCredentials
newGoogleAnalyticsConnectorProfileCredentials
  Text
pClientId_
  Text
pClientSecret_ =
    GoogleAnalyticsConnectorProfileCredentials'
      { $sel:accessToken:GoogleAnalyticsConnectorProfileCredentials' :: Maybe (Sensitive Text)
accessToken =
          forall a. Maybe a
Prelude.Nothing,
        $sel:oAuthRequest:GoogleAnalyticsConnectorProfileCredentials' :: Maybe ConnectorOAuthRequest
oAuthRequest = forall a. Maybe a
Prelude.Nothing,
        $sel:refreshToken:GoogleAnalyticsConnectorProfileCredentials' :: Maybe Text
refreshToken = forall a. Maybe a
Prelude.Nothing,
        $sel:clientId:GoogleAnalyticsConnectorProfileCredentials' :: Text
clientId = Text
pClientId_,
        $sel:clientSecret:GoogleAnalyticsConnectorProfileCredentials' :: Sensitive Text
clientSecret =
          forall a. Iso' (Sensitive a) a
Data._Sensitive
            forall t b. AReview t b -> b -> t
Lens.# Text
pClientSecret_
      }

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

-- | The credentials used to acquire new access tokens. This is required only
-- for OAuth2 access tokens, and is not required for OAuth1 access tokens.
googleAnalyticsConnectorProfileCredentials_refreshToken :: Lens.Lens' GoogleAnalyticsConnectorProfileCredentials (Prelude.Maybe Prelude.Text)
googleAnalyticsConnectorProfileCredentials_refreshToken :: Lens' GoogleAnalyticsConnectorProfileCredentials (Maybe Text)
googleAnalyticsConnectorProfileCredentials_refreshToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GoogleAnalyticsConnectorProfileCredentials' {Maybe Text
refreshToken :: Maybe Text
$sel:refreshToken:GoogleAnalyticsConnectorProfileCredentials' :: GoogleAnalyticsConnectorProfileCredentials -> Maybe Text
refreshToken} -> Maybe Text
refreshToken) (\s :: GoogleAnalyticsConnectorProfileCredentials
s@GoogleAnalyticsConnectorProfileCredentials' {} Maybe Text
a -> GoogleAnalyticsConnectorProfileCredentials
s {$sel:refreshToken:GoogleAnalyticsConnectorProfileCredentials' :: Maybe Text
refreshToken = Maybe Text
a} :: GoogleAnalyticsConnectorProfileCredentials)

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

-- | The client secret used by the OAuth client to authenticate to the
-- authorization server.
googleAnalyticsConnectorProfileCredentials_clientSecret :: Lens.Lens' GoogleAnalyticsConnectorProfileCredentials Prelude.Text
googleAnalyticsConnectorProfileCredentials_clientSecret :: Lens' GoogleAnalyticsConnectorProfileCredentials Text
googleAnalyticsConnectorProfileCredentials_clientSecret = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GoogleAnalyticsConnectorProfileCredentials' {Sensitive Text
clientSecret :: Sensitive Text
$sel:clientSecret:GoogleAnalyticsConnectorProfileCredentials' :: GoogleAnalyticsConnectorProfileCredentials -> Sensitive Text
clientSecret} -> Sensitive Text
clientSecret) (\s :: GoogleAnalyticsConnectorProfileCredentials
s@GoogleAnalyticsConnectorProfileCredentials' {} Sensitive Text
a -> GoogleAnalyticsConnectorProfileCredentials
s {$sel:clientSecret:GoogleAnalyticsConnectorProfileCredentials' :: Sensitive Text
clientSecret = Sensitive Text
a} :: GoogleAnalyticsConnectorProfileCredentials) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance
  Prelude.Hashable
    GoogleAnalyticsConnectorProfileCredentials
  where
  hashWithSalt :: Int -> GoogleAnalyticsConnectorProfileCredentials -> Int
hashWithSalt
    Int
_salt
    GoogleAnalyticsConnectorProfileCredentials' {Maybe Text
Maybe (Sensitive Text)
Maybe ConnectorOAuthRequest
Text
Sensitive Text
clientSecret :: Sensitive Text
clientId :: Text
refreshToken :: Maybe Text
oAuthRequest :: Maybe ConnectorOAuthRequest
accessToken :: Maybe (Sensitive Text)
$sel:clientSecret:GoogleAnalyticsConnectorProfileCredentials' :: GoogleAnalyticsConnectorProfileCredentials -> Sensitive Text
$sel:clientId:GoogleAnalyticsConnectorProfileCredentials' :: GoogleAnalyticsConnectorProfileCredentials -> Text
$sel:refreshToken:GoogleAnalyticsConnectorProfileCredentials' :: GoogleAnalyticsConnectorProfileCredentials -> Maybe Text
$sel:oAuthRequest:GoogleAnalyticsConnectorProfileCredentials' :: GoogleAnalyticsConnectorProfileCredentials
-> Maybe ConnectorOAuthRequest
$sel:accessToken:GoogleAnalyticsConnectorProfileCredentials' :: GoogleAnalyticsConnectorProfileCredentials
-> Maybe (Sensitive Text)
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
accessToken
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ConnectorOAuthRequest
oAuthRequest
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
refreshToken
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clientId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
clientSecret

instance
  Prelude.NFData
    GoogleAnalyticsConnectorProfileCredentials
  where
  rnf :: GoogleAnalyticsConnectorProfileCredentials -> ()
rnf GoogleAnalyticsConnectorProfileCredentials' {Maybe Text
Maybe (Sensitive Text)
Maybe ConnectorOAuthRequest
Text
Sensitive Text
clientSecret :: Sensitive Text
clientId :: Text
refreshToken :: Maybe Text
oAuthRequest :: Maybe ConnectorOAuthRequest
accessToken :: Maybe (Sensitive Text)
$sel:clientSecret:GoogleAnalyticsConnectorProfileCredentials' :: GoogleAnalyticsConnectorProfileCredentials -> Sensitive Text
$sel:clientId:GoogleAnalyticsConnectorProfileCredentials' :: GoogleAnalyticsConnectorProfileCredentials -> Text
$sel:refreshToken:GoogleAnalyticsConnectorProfileCredentials' :: GoogleAnalyticsConnectorProfileCredentials -> Maybe Text
$sel:oAuthRequest:GoogleAnalyticsConnectorProfileCredentials' :: GoogleAnalyticsConnectorProfileCredentials
-> Maybe ConnectorOAuthRequest
$sel:accessToken:GoogleAnalyticsConnectorProfileCredentials' :: GoogleAnalyticsConnectorProfileCredentials
-> Maybe (Sensitive Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
accessToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ConnectorOAuthRequest
oAuthRequest
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
refreshToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
clientId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
clientSecret

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