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

import Amazonka.AppFlow.Types.CustomAuthConfig
import Amazonka.AppFlow.Types.OAuth2Defaults
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

-- | Contains information about the authentication config that the connector
-- supports.
--
-- /See:/ 'newAuthenticationConfig' smart constructor.
data AuthenticationConfig = AuthenticationConfig'
  { -- | Contains information required for custom authentication.
    AuthenticationConfig -> Maybe [CustomAuthConfig]
customAuthConfigs :: Prelude.Maybe [CustomAuthConfig],
    -- | Indicates whether API key authentication is supported by the connector
    AuthenticationConfig -> Maybe Bool
isApiKeyAuthSupported :: Prelude.Maybe Prelude.Bool,
    -- | Indicates whether basic authentication is supported by the connector.
    AuthenticationConfig -> Maybe Bool
isBasicAuthSupported :: Prelude.Maybe Prelude.Bool,
    -- | Indicates whether custom authentication is supported by the connector
    AuthenticationConfig -> Maybe Bool
isCustomAuthSupported :: Prelude.Maybe Prelude.Bool,
    -- | Indicates whether OAuth 2.0 authentication is supported by the
    -- connector.
    AuthenticationConfig -> Maybe Bool
isOAuth2Supported :: Prelude.Maybe Prelude.Bool,
    -- | Contains the default values required for OAuth 2.0 authentication.
    AuthenticationConfig -> Maybe OAuth2Defaults
oAuth2Defaults :: Prelude.Maybe OAuth2Defaults
  }
  deriving (AuthenticationConfig -> AuthenticationConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AuthenticationConfig -> AuthenticationConfig -> Bool
$c/= :: AuthenticationConfig -> AuthenticationConfig -> Bool
== :: AuthenticationConfig -> AuthenticationConfig -> Bool
$c== :: AuthenticationConfig -> AuthenticationConfig -> Bool
Prelude.Eq, ReadPrec [AuthenticationConfig]
ReadPrec AuthenticationConfig
Int -> ReadS AuthenticationConfig
ReadS [AuthenticationConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AuthenticationConfig]
$creadListPrec :: ReadPrec [AuthenticationConfig]
readPrec :: ReadPrec AuthenticationConfig
$creadPrec :: ReadPrec AuthenticationConfig
readList :: ReadS [AuthenticationConfig]
$creadList :: ReadS [AuthenticationConfig]
readsPrec :: Int -> ReadS AuthenticationConfig
$creadsPrec :: Int -> ReadS AuthenticationConfig
Prelude.Read, Int -> AuthenticationConfig -> ShowS
[AuthenticationConfig] -> ShowS
AuthenticationConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AuthenticationConfig] -> ShowS
$cshowList :: [AuthenticationConfig] -> ShowS
show :: AuthenticationConfig -> String
$cshow :: AuthenticationConfig -> String
showsPrec :: Int -> AuthenticationConfig -> ShowS
$cshowsPrec :: Int -> AuthenticationConfig -> ShowS
Prelude.Show, forall x. Rep AuthenticationConfig x -> AuthenticationConfig
forall x. AuthenticationConfig -> Rep AuthenticationConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AuthenticationConfig x -> AuthenticationConfig
$cfrom :: forall x. AuthenticationConfig -> Rep AuthenticationConfig x
Prelude.Generic)

-- |
-- Create a value of 'AuthenticationConfig' 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:
--
-- 'customAuthConfigs', 'authenticationConfig_customAuthConfigs' - Contains information required for custom authentication.
--
-- 'isApiKeyAuthSupported', 'authenticationConfig_isApiKeyAuthSupported' - Indicates whether API key authentication is supported by the connector
--
-- 'isBasicAuthSupported', 'authenticationConfig_isBasicAuthSupported' - Indicates whether basic authentication is supported by the connector.
--
-- 'isCustomAuthSupported', 'authenticationConfig_isCustomAuthSupported' - Indicates whether custom authentication is supported by the connector
--
-- 'isOAuth2Supported', 'authenticationConfig_isOAuth2Supported' - Indicates whether OAuth 2.0 authentication is supported by the
-- connector.
--
-- 'oAuth2Defaults', 'authenticationConfig_oAuth2Defaults' - Contains the default values required for OAuth 2.0 authentication.
newAuthenticationConfig ::
  AuthenticationConfig
newAuthenticationConfig :: AuthenticationConfig
newAuthenticationConfig =
  AuthenticationConfig'
    { $sel:customAuthConfigs:AuthenticationConfig' :: Maybe [CustomAuthConfig]
customAuthConfigs =
        forall a. Maybe a
Prelude.Nothing,
      $sel:isApiKeyAuthSupported:AuthenticationConfig' :: Maybe Bool
isApiKeyAuthSupported = forall a. Maybe a
Prelude.Nothing,
      $sel:isBasicAuthSupported:AuthenticationConfig' :: Maybe Bool
isBasicAuthSupported = forall a. Maybe a
Prelude.Nothing,
      $sel:isCustomAuthSupported:AuthenticationConfig' :: Maybe Bool
isCustomAuthSupported = forall a. Maybe a
Prelude.Nothing,
      $sel:isOAuth2Supported:AuthenticationConfig' :: Maybe Bool
isOAuth2Supported = forall a. Maybe a
Prelude.Nothing,
      $sel:oAuth2Defaults:AuthenticationConfig' :: Maybe OAuth2Defaults
oAuth2Defaults = forall a. Maybe a
Prelude.Nothing
    }

-- | Contains information required for custom authentication.
authenticationConfig_customAuthConfigs :: Lens.Lens' AuthenticationConfig (Prelude.Maybe [CustomAuthConfig])
authenticationConfig_customAuthConfigs :: Lens' AuthenticationConfig (Maybe [CustomAuthConfig])
authenticationConfig_customAuthConfigs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationConfig' {Maybe [CustomAuthConfig]
customAuthConfigs :: Maybe [CustomAuthConfig]
$sel:customAuthConfigs:AuthenticationConfig' :: AuthenticationConfig -> Maybe [CustomAuthConfig]
customAuthConfigs} -> Maybe [CustomAuthConfig]
customAuthConfigs) (\s :: AuthenticationConfig
s@AuthenticationConfig' {} Maybe [CustomAuthConfig]
a -> AuthenticationConfig
s {$sel:customAuthConfigs:AuthenticationConfig' :: Maybe [CustomAuthConfig]
customAuthConfigs = Maybe [CustomAuthConfig]
a} :: AuthenticationConfig) 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

-- | Indicates whether API key authentication is supported by the connector
authenticationConfig_isApiKeyAuthSupported :: Lens.Lens' AuthenticationConfig (Prelude.Maybe Prelude.Bool)
authenticationConfig_isApiKeyAuthSupported :: Lens' AuthenticationConfig (Maybe Bool)
authenticationConfig_isApiKeyAuthSupported = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationConfig' {Maybe Bool
isApiKeyAuthSupported :: Maybe Bool
$sel:isApiKeyAuthSupported:AuthenticationConfig' :: AuthenticationConfig -> Maybe Bool
isApiKeyAuthSupported} -> Maybe Bool
isApiKeyAuthSupported) (\s :: AuthenticationConfig
s@AuthenticationConfig' {} Maybe Bool
a -> AuthenticationConfig
s {$sel:isApiKeyAuthSupported:AuthenticationConfig' :: Maybe Bool
isApiKeyAuthSupported = Maybe Bool
a} :: AuthenticationConfig)

-- | Indicates whether basic authentication is supported by the connector.
authenticationConfig_isBasicAuthSupported :: Lens.Lens' AuthenticationConfig (Prelude.Maybe Prelude.Bool)
authenticationConfig_isBasicAuthSupported :: Lens' AuthenticationConfig (Maybe Bool)
authenticationConfig_isBasicAuthSupported = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationConfig' {Maybe Bool
isBasicAuthSupported :: Maybe Bool
$sel:isBasicAuthSupported:AuthenticationConfig' :: AuthenticationConfig -> Maybe Bool
isBasicAuthSupported} -> Maybe Bool
isBasicAuthSupported) (\s :: AuthenticationConfig
s@AuthenticationConfig' {} Maybe Bool
a -> AuthenticationConfig
s {$sel:isBasicAuthSupported:AuthenticationConfig' :: Maybe Bool
isBasicAuthSupported = Maybe Bool
a} :: AuthenticationConfig)

-- | Indicates whether custom authentication is supported by the connector
authenticationConfig_isCustomAuthSupported :: Lens.Lens' AuthenticationConfig (Prelude.Maybe Prelude.Bool)
authenticationConfig_isCustomAuthSupported :: Lens' AuthenticationConfig (Maybe Bool)
authenticationConfig_isCustomAuthSupported = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationConfig' {Maybe Bool
isCustomAuthSupported :: Maybe Bool
$sel:isCustomAuthSupported:AuthenticationConfig' :: AuthenticationConfig -> Maybe Bool
isCustomAuthSupported} -> Maybe Bool
isCustomAuthSupported) (\s :: AuthenticationConfig
s@AuthenticationConfig' {} Maybe Bool
a -> AuthenticationConfig
s {$sel:isCustomAuthSupported:AuthenticationConfig' :: Maybe Bool
isCustomAuthSupported = Maybe Bool
a} :: AuthenticationConfig)

-- | Indicates whether OAuth 2.0 authentication is supported by the
-- connector.
authenticationConfig_isOAuth2Supported :: Lens.Lens' AuthenticationConfig (Prelude.Maybe Prelude.Bool)
authenticationConfig_isOAuth2Supported :: Lens' AuthenticationConfig (Maybe Bool)
authenticationConfig_isOAuth2Supported = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationConfig' {Maybe Bool
isOAuth2Supported :: Maybe Bool
$sel:isOAuth2Supported:AuthenticationConfig' :: AuthenticationConfig -> Maybe Bool
isOAuth2Supported} -> Maybe Bool
isOAuth2Supported) (\s :: AuthenticationConfig
s@AuthenticationConfig' {} Maybe Bool
a -> AuthenticationConfig
s {$sel:isOAuth2Supported:AuthenticationConfig' :: Maybe Bool
isOAuth2Supported = Maybe Bool
a} :: AuthenticationConfig)

-- | Contains the default values required for OAuth 2.0 authentication.
authenticationConfig_oAuth2Defaults :: Lens.Lens' AuthenticationConfig (Prelude.Maybe OAuth2Defaults)
authenticationConfig_oAuth2Defaults :: Lens' AuthenticationConfig (Maybe OAuth2Defaults)
authenticationConfig_oAuth2Defaults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationConfig' {Maybe OAuth2Defaults
oAuth2Defaults :: Maybe OAuth2Defaults
$sel:oAuth2Defaults:AuthenticationConfig' :: AuthenticationConfig -> Maybe OAuth2Defaults
oAuth2Defaults} -> Maybe OAuth2Defaults
oAuth2Defaults) (\s :: AuthenticationConfig
s@AuthenticationConfig' {} Maybe OAuth2Defaults
a -> AuthenticationConfig
s {$sel:oAuth2Defaults:AuthenticationConfig' :: Maybe OAuth2Defaults
oAuth2Defaults = Maybe OAuth2Defaults
a} :: AuthenticationConfig)

instance Data.FromJSON AuthenticationConfig where
  parseJSON :: Value -> Parser AuthenticationConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AuthenticationConfig"
      ( \Object
x ->
          Maybe [CustomAuthConfig]
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe OAuth2Defaults
-> AuthenticationConfig
AuthenticationConfig'
            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
"customAuthConfigs"
                            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 (Maybe a)
Data..:? Key
"isApiKeyAuthSupported")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"isBasicAuthSupported")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"isCustomAuthSupported")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"isOAuth2Supported")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"oAuth2Defaults")
      )

instance Prelude.Hashable AuthenticationConfig where
  hashWithSalt :: Int -> AuthenticationConfig -> Int
hashWithSalt Int
_salt AuthenticationConfig' {Maybe Bool
Maybe [CustomAuthConfig]
Maybe OAuth2Defaults
oAuth2Defaults :: Maybe OAuth2Defaults
isOAuth2Supported :: Maybe Bool
isCustomAuthSupported :: Maybe Bool
isBasicAuthSupported :: Maybe Bool
isApiKeyAuthSupported :: Maybe Bool
customAuthConfigs :: Maybe [CustomAuthConfig]
$sel:oAuth2Defaults:AuthenticationConfig' :: AuthenticationConfig -> Maybe OAuth2Defaults
$sel:isOAuth2Supported:AuthenticationConfig' :: AuthenticationConfig -> Maybe Bool
$sel:isCustomAuthSupported:AuthenticationConfig' :: AuthenticationConfig -> Maybe Bool
$sel:isBasicAuthSupported:AuthenticationConfig' :: AuthenticationConfig -> Maybe Bool
$sel:isApiKeyAuthSupported:AuthenticationConfig' :: AuthenticationConfig -> Maybe Bool
$sel:customAuthConfigs:AuthenticationConfig' :: AuthenticationConfig -> Maybe [CustomAuthConfig]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [CustomAuthConfig]
customAuthConfigs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isApiKeyAuthSupported
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isBasicAuthSupported
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isCustomAuthSupported
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isOAuth2Supported
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe OAuth2Defaults
oAuth2Defaults

instance Prelude.NFData AuthenticationConfig where
  rnf :: AuthenticationConfig -> ()
rnf AuthenticationConfig' {Maybe Bool
Maybe [CustomAuthConfig]
Maybe OAuth2Defaults
oAuth2Defaults :: Maybe OAuth2Defaults
isOAuth2Supported :: Maybe Bool
isCustomAuthSupported :: Maybe Bool
isBasicAuthSupported :: Maybe Bool
isApiKeyAuthSupported :: Maybe Bool
customAuthConfigs :: Maybe [CustomAuthConfig]
$sel:oAuth2Defaults:AuthenticationConfig' :: AuthenticationConfig -> Maybe OAuth2Defaults
$sel:isOAuth2Supported:AuthenticationConfig' :: AuthenticationConfig -> Maybe Bool
$sel:isCustomAuthSupported:AuthenticationConfig' :: AuthenticationConfig -> Maybe Bool
$sel:isBasicAuthSupported:AuthenticationConfig' :: AuthenticationConfig -> Maybe Bool
$sel:isApiKeyAuthSupported:AuthenticationConfig' :: AuthenticationConfig -> Maybe Bool
$sel:customAuthConfigs:AuthenticationConfig' :: AuthenticationConfig -> Maybe [CustomAuthConfig]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [CustomAuthConfig]
customAuthConfigs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isApiKeyAuthSupported
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isBasicAuthSupported
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isCustomAuthSupported
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isOAuth2Supported
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe OAuth2Defaults
oAuth2Defaults