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

import Amazonka.AppFlow.Types.OAuth2GrantType
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 OAuth 2.0 properties required for OAuth 2.0 authentication.
--
-- /See:/ 'newOAuth2Properties' smart constructor.
data OAuth2Properties = OAuth2Properties'
  { -- | Associates your token URL with a map of properties that you define. Use
    -- this parameter to provide any additional details that the connector
    -- requires to authenticate your request.
    OAuth2Properties -> Maybe (HashMap Text Text)
tokenUrlCustomProperties :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The token URL required for OAuth 2.0 authentication.
    OAuth2Properties -> Text
tokenUrl :: Prelude.Text,
    -- | The OAuth 2.0 grant type used by connector for OAuth 2.0 authentication.
    OAuth2Properties -> OAuth2GrantType
oAuth2GrantType :: OAuth2GrantType
  }
  deriving (OAuth2Properties -> OAuth2Properties -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OAuth2Properties -> OAuth2Properties -> Bool
$c/= :: OAuth2Properties -> OAuth2Properties -> Bool
== :: OAuth2Properties -> OAuth2Properties -> Bool
$c== :: OAuth2Properties -> OAuth2Properties -> Bool
Prelude.Eq, ReadPrec [OAuth2Properties]
ReadPrec OAuth2Properties
Int -> ReadS OAuth2Properties
ReadS [OAuth2Properties]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OAuth2Properties]
$creadListPrec :: ReadPrec [OAuth2Properties]
readPrec :: ReadPrec OAuth2Properties
$creadPrec :: ReadPrec OAuth2Properties
readList :: ReadS [OAuth2Properties]
$creadList :: ReadS [OAuth2Properties]
readsPrec :: Int -> ReadS OAuth2Properties
$creadsPrec :: Int -> ReadS OAuth2Properties
Prelude.Read, Int -> OAuth2Properties -> ShowS
[OAuth2Properties] -> ShowS
OAuth2Properties -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OAuth2Properties] -> ShowS
$cshowList :: [OAuth2Properties] -> ShowS
show :: OAuth2Properties -> String
$cshow :: OAuth2Properties -> String
showsPrec :: Int -> OAuth2Properties -> ShowS
$cshowsPrec :: Int -> OAuth2Properties -> ShowS
Prelude.Show, forall x. Rep OAuth2Properties x -> OAuth2Properties
forall x. OAuth2Properties -> Rep OAuth2Properties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OAuth2Properties x -> OAuth2Properties
$cfrom :: forall x. OAuth2Properties -> Rep OAuth2Properties x
Prelude.Generic)

-- |
-- Create a value of 'OAuth2Properties' 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:
--
-- 'tokenUrlCustomProperties', 'oAuth2Properties_tokenUrlCustomProperties' - Associates your token URL with a map of properties that you define. Use
-- this parameter to provide any additional details that the connector
-- requires to authenticate your request.
--
-- 'tokenUrl', 'oAuth2Properties_tokenUrl' - The token URL required for OAuth 2.0 authentication.
--
-- 'oAuth2GrantType', 'oAuth2Properties_oAuth2GrantType' - The OAuth 2.0 grant type used by connector for OAuth 2.0 authentication.
newOAuth2Properties ::
  -- | 'tokenUrl'
  Prelude.Text ->
  -- | 'oAuth2GrantType'
  OAuth2GrantType ->
  OAuth2Properties
newOAuth2Properties :: Text -> OAuth2GrantType -> OAuth2Properties
newOAuth2Properties Text
pTokenUrl_ OAuth2GrantType
pOAuth2GrantType_ =
  OAuth2Properties'
    { $sel:tokenUrlCustomProperties:OAuth2Properties' :: Maybe (HashMap Text Text)
tokenUrlCustomProperties =
        forall a. Maybe a
Prelude.Nothing,
      $sel:tokenUrl:OAuth2Properties' :: Text
tokenUrl = Text
pTokenUrl_,
      $sel:oAuth2GrantType:OAuth2Properties' :: OAuth2GrantType
oAuth2GrantType = OAuth2GrantType
pOAuth2GrantType_
    }

-- | Associates your token URL with a map of properties that you define. Use
-- this parameter to provide any additional details that the connector
-- requires to authenticate your request.
oAuth2Properties_tokenUrlCustomProperties :: Lens.Lens' OAuth2Properties (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
oAuth2Properties_tokenUrlCustomProperties :: Lens' OAuth2Properties (Maybe (HashMap Text Text))
oAuth2Properties_tokenUrlCustomProperties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OAuth2Properties' {Maybe (HashMap Text Text)
tokenUrlCustomProperties :: Maybe (HashMap Text Text)
$sel:tokenUrlCustomProperties:OAuth2Properties' :: OAuth2Properties -> Maybe (HashMap Text Text)
tokenUrlCustomProperties} -> Maybe (HashMap Text Text)
tokenUrlCustomProperties) (\s :: OAuth2Properties
s@OAuth2Properties' {} Maybe (HashMap Text Text)
a -> OAuth2Properties
s {$sel:tokenUrlCustomProperties:OAuth2Properties' :: Maybe (HashMap Text Text)
tokenUrlCustomProperties = Maybe (HashMap Text Text)
a} :: OAuth2Properties) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token URL required for OAuth 2.0 authentication.
oAuth2Properties_tokenUrl :: Lens.Lens' OAuth2Properties Prelude.Text
oAuth2Properties_tokenUrl :: Lens' OAuth2Properties Text
oAuth2Properties_tokenUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OAuth2Properties' {Text
tokenUrl :: Text
$sel:tokenUrl:OAuth2Properties' :: OAuth2Properties -> Text
tokenUrl} -> Text
tokenUrl) (\s :: OAuth2Properties
s@OAuth2Properties' {} Text
a -> OAuth2Properties
s {$sel:tokenUrl:OAuth2Properties' :: Text
tokenUrl = Text
a} :: OAuth2Properties)

-- | The OAuth 2.0 grant type used by connector for OAuth 2.0 authentication.
oAuth2Properties_oAuth2GrantType :: Lens.Lens' OAuth2Properties OAuth2GrantType
oAuth2Properties_oAuth2GrantType :: Lens' OAuth2Properties OAuth2GrantType
oAuth2Properties_oAuth2GrantType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OAuth2Properties' {OAuth2GrantType
oAuth2GrantType :: OAuth2GrantType
$sel:oAuth2GrantType:OAuth2Properties' :: OAuth2Properties -> OAuth2GrantType
oAuth2GrantType} -> OAuth2GrantType
oAuth2GrantType) (\s :: OAuth2Properties
s@OAuth2Properties' {} OAuth2GrantType
a -> OAuth2Properties
s {$sel:oAuth2GrantType:OAuth2Properties' :: OAuth2GrantType
oAuth2GrantType = OAuth2GrantType
a} :: OAuth2Properties)

instance Data.FromJSON OAuth2Properties where
  parseJSON :: Value -> Parser OAuth2Properties
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"OAuth2Properties"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> Text -> OAuth2GrantType -> OAuth2Properties
OAuth2Properties'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"tokenUrlCustomProperties"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"tokenUrl")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"oAuth2GrantType")
      )

instance Prelude.Hashable OAuth2Properties where
  hashWithSalt :: Int -> OAuth2Properties -> Int
hashWithSalt Int
_salt OAuth2Properties' {Maybe (HashMap Text Text)
Text
OAuth2GrantType
oAuth2GrantType :: OAuth2GrantType
tokenUrl :: Text
tokenUrlCustomProperties :: Maybe (HashMap Text Text)
$sel:oAuth2GrantType:OAuth2Properties' :: OAuth2Properties -> OAuth2GrantType
$sel:tokenUrl:OAuth2Properties' :: OAuth2Properties -> Text
$sel:tokenUrlCustomProperties:OAuth2Properties' :: OAuth2Properties -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tokenUrlCustomProperties
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tokenUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` OAuth2GrantType
oAuth2GrantType

instance Prelude.NFData OAuth2Properties where
  rnf :: OAuth2Properties -> ()
rnf OAuth2Properties' {Maybe (HashMap Text Text)
Text
OAuth2GrantType
oAuth2GrantType :: OAuth2GrantType
tokenUrl :: Text
tokenUrlCustomProperties :: Maybe (HashMap Text Text)
$sel:oAuth2GrantType:OAuth2Properties' :: OAuth2Properties -> OAuth2GrantType
$sel:tokenUrl:OAuth2Properties' :: OAuth2Properties -> Text
$sel:tokenUrlCustomProperties:OAuth2Properties' :: OAuth2Properties -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tokenUrlCustomProperties
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
tokenUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf OAuth2GrantType
oAuth2GrantType

instance Data.ToJSON OAuth2Properties where
  toJSON :: OAuth2Properties -> Value
toJSON OAuth2Properties' {Maybe (HashMap Text Text)
Text
OAuth2GrantType
oAuth2GrantType :: OAuth2GrantType
tokenUrl :: Text
tokenUrlCustomProperties :: Maybe (HashMap Text Text)
$sel:oAuth2GrantType:OAuth2Properties' :: OAuth2Properties -> OAuth2GrantType
$sel:tokenUrl:OAuth2Properties' :: OAuth2Properties -> Text
$sel:tokenUrlCustomProperties:OAuth2Properties' :: OAuth2Properties -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"tokenUrlCustomProperties" 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 (HashMap Text Text)
tokenUrlCustomProperties,
            forall a. a -> Maybe a
Prelude.Just (Key
"tokenUrl" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tokenUrl),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"oAuth2GrantType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= OAuth2GrantType
oAuth2GrantType)
          ]
      )