{-# 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.AmplifyBackend.Types.BackendAuthSocialProviderConfig
-- 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.AmplifyBackend.Types.BackendAuthSocialProviderConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes third-party social federation configurations for allowing your
-- app users to sign in using OAuth.
--
-- /See:/ 'newBackendAuthSocialProviderConfig' smart constructor.
data BackendAuthSocialProviderConfig = BackendAuthSocialProviderConfig'
  { -- | Describes the client_id, which can be obtained from the third-party
    -- social federation provider.
    BackendAuthSocialProviderConfig -> Maybe Text
clientId :: Prelude.Maybe Prelude.Text,
    -- | Describes the client_secret, which can be obtained from third-party
    -- social federation providers.
    BackendAuthSocialProviderConfig -> Maybe Text
clientSecret :: Prelude.Maybe Prelude.Text
  }
  deriving (BackendAuthSocialProviderConfig
-> BackendAuthSocialProviderConfig -> Bool
(BackendAuthSocialProviderConfig
 -> BackendAuthSocialProviderConfig -> Bool)
-> (BackendAuthSocialProviderConfig
    -> BackendAuthSocialProviderConfig -> Bool)
-> Eq BackendAuthSocialProviderConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BackendAuthSocialProviderConfig
-> BackendAuthSocialProviderConfig -> Bool
$c/= :: BackendAuthSocialProviderConfig
-> BackendAuthSocialProviderConfig -> Bool
== :: BackendAuthSocialProviderConfig
-> BackendAuthSocialProviderConfig -> Bool
$c== :: BackendAuthSocialProviderConfig
-> BackendAuthSocialProviderConfig -> Bool
Prelude.Eq, ReadPrec [BackendAuthSocialProviderConfig]
ReadPrec BackendAuthSocialProviderConfig
Int -> ReadS BackendAuthSocialProviderConfig
ReadS [BackendAuthSocialProviderConfig]
(Int -> ReadS BackendAuthSocialProviderConfig)
-> ReadS [BackendAuthSocialProviderConfig]
-> ReadPrec BackendAuthSocialProviderConfig
-> ReadPrec [BackendAuthSocialProviderConfig]
-> Read BackendAuthSocialProviderConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BackendAuthSocialProviderConfig]
$creadListPrec :: ReadPrec [BackendAuthSocialProviderConfig]
readPrec :: ReadPrec BackendAuthSocialProviderConfig
$creadPrec :: ReadPrec BackendAuthSocialProviderConfig
readList :: ReadS [BackendAuthSocialProviderConfig]
$creadList :: ReadS [BackendAuthSocialProviderConfig]
readsPrec :: Int -> ReadS BackendAuthSocialProviderConfig
$creadsPrec :: Int -> ReadS BackendAuthSocialProviderConfig
Prelude.Read, Int -> BackendAuthSocialProviderConfig -> ShowS
[BackendAuthSocialProviderConfig] -> ShowS
BackendAuthSocialProviderConfig -> String
(Int -> BackendAuthSocialProviderConfig -> ShowS)
-> (BackendAuthSocialProviderConfig -> String)
-> ([BackendAuthSocialProviderConfig] -> ShowS)
-> Show BackendAuthSocialProviderConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BackendAuthSocialProviderConfig] -> ShowS
$cshowList :: [BackendAuthSocialProviderConfig] -> ShowS
show :: BackendAuthSocialProviderConfig -> String
$cshow :: BackendAuthSocialProviderConfig -> String
showsPrec :: Int -> BackendAuthSocialProviderConfig -> ShowS
$cshowsPrec :: Int -> BackendAuthSocialProviderConfig -> ShowS
Prelude.Show, (forall x.
 BackendAuthSocialProviderConfig
 -> Rep BackendAuthSocialProviderConfig x)
-> (forall x.
    Rep BackendAuthSocialProviderConfig x
    -> BackendAuthSocialProviderConfig)
-> Generic BackendAuthSocialProviderConfig
forall x.
Rep BackendAuthSocialProviderConfig x
-> BackendAuthSocialProviderConfig
forall x.
BackendAuthSocialProviderConfig
-> Rep BackendAuthSocialProviderConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BackendAuthSocialProviderConfig x
-> BackendAuthSocialProviderConfig
$cfrom :: forall x.
BackendAuthSocialProviderConfig
-> Rep BackendAuthSocialProviderConfig x
Prelude.Generic)

-- |
-- Create a value of 'BackendAuthSocialProviderConfig' 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:
--
-- 'clientId', 'backendAuthSocialProviderConfig_clientId' - Describes the client_id, which can be obtained from the third-party
-- social federation provider.
--
-- 'clientSecret', 'backendAuthSocialProviderConfig_clientSecret' - Describes the client_secret, which can be obtained from third-party
-- social federation providers.
newBackendAuthSocialProviderConfig ::
  BackendAuthSocialProviderConfig
newBackendAuthSocialProviderConfig :: BackendAuthSocialProviderConfig
newBackendAuthSocialProviderConfig =
  BackendAuthSocialProviderConfig' :: Maybe Text -> Maybe Text -> BackendAuthSocialProviderConfig
BackendAuthSocialProviderConfig'
    { $sel:clientId:BackendAuthSocialProviderConfig' :: Maybe Text
clientId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:clientSecret:BackendAuthSocialProviderConfig' :: Maybe Text
clientSecret = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Describes the client_id, which can be obtained from the third-party
-- social federation provider.
backendAuthSocialProviderConfig_clientId :: Lens.Lens' BackendAuthSocialProviderConfig (Prelude.Maybe Prelude.Text)
backendAuthSocialProviderConfig_clientId :: (Maybe Text -> f (Maybe Text))
-> BackendAuthSocialProviderConfig
-> f BackendAuthSocialProviderConfig
backendAuthSocialProviderConfig_clientId = (BackendAuthSocialProviderConfig -> Maybe Text)
-> (BackendAuthSocialProviderConfig
    -> Maybe Text -> BackendAuthSocialProviderConfig)
-> Lens
     BackendAuthSocialProviderConfig
     BackendAuthSocialProviderConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackendAuthSocialProviderConfig' {Maybe Text
clientId :: Maybe Text
$sel:clientId:BackendAuthSocialProviderConfig' :: BackendAuthSocialProviderConfig -> Maybe Text
clientId} -> Maybe Text
clientId) (\s :: BackendAuthSocialProviderConfig
s@BackendAuthSocialProviderConfig' {} Maybe Text
a -> BackendAuthSocialProviderConfig
s {$sel:clientId:BackendAuthSocialProviderConfig' :: Maybe Text
clientId = Maybe Text
a} :: BackendAuthSocialProviderConfig)

-- | Describes the client_secret, which can be obtained from third-party
-- social federation providers.
backendAuthSocialProviderConfig_clientSecret :: Lens.Lens' BackendAuthSocialProviderConfig (Prelude.Maybe Prelude.Text)
backendAuthSocialProviderConfig_clientSecret :: (Maybe Text -> f (Maybe Text))
-> BackendAuthSocialProviderConfig
-> f BackendAuthSocialProviderConfig
backendAuthSocialProviderConfig_clientSecret = (BackendAuthSocialProviderConfig -> Maybe Text)
-> (BackendAuthSocialProviderConfig
    -> Maybe Text -> BackendAuthSocialProviderConfig)
-> Lens
     BackendAuthSocialProviderConfig
     BackendAuthSocialProviderConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackendAuthSocialProviderConfig' {Maybe Text
clientSecret :: Maybe Text
$sel:clientSecret:BackendAuthSocialProviderConfig' :: BackendAuthSocialProviderConfig -> Maybe Text
clientSecret} -> Maybe Text
clientSecret) (\s :: BackendAuthSocialProviderConfig
s@BackendAuthSocialProviderConfig' {} Maybe Text
a -> BackendAuthSocialProviderConfig
s {$sel:clientSecret:BackendAuthSocialProviderConfig' :: Maybe Text
clientSecret = Maybe Text
a} :: BackendAuthSocialProviderConfig)

instance
  Core.FromJSON
    BackendAuthSocialProviderConfig
  where
  parseJSON :: Value -> Parser BackendAuthSocialProviderConfig
parseJSON =
    String
-> (Object -> Parser BackendAuthSocialProviderConfig)
-> Value
-> Parser BackendAuthSocialProviderConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BackendAuthSocialProviderConfig"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> BackendAuthSocialProviderConfig
BackendAuthSocialProviderConfig'
            (Maybe Text -> Maybe Text -> BackendAuthSocialProviderConfig)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> BackendAuthSocialProviderConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"client_id")
            Parser (Maybe Text -> BackendAuthSocialProviderConfig)
-> Parser (Maybe Text) -> Parser BackendAuthSocialProviderConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"client_secret")
      )

instance
  Prelude.Hashable
    BackendAuthSocialProviderConfig

instance
  Prelude.NFData
    BackendAuthSocialProviderConfig

instance Core.ToJSON BackendAuthSocialProviderConfig where
  toJSON :: BackendAuthSocialProviderConfig -> Value
toJSON BackendAuthSocialProviderConfig' {Maybe Text
clientSecret :: Maybe Text
clientId :: Maybe Text
$sel:clientSecret:BackendAuthSocialProviderConfig' :: BackendAuthSocialProviderConfig -> Maybe Text
$sel:clientId:BackendAuthSocialProviderConfig' :: BackendAuthSocialProviderConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"client_id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientId,
            (Text
"client_secret" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientSecret
          ]
      )