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

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

-- | Describes Apple social federation configurations for allowing your app
-- users to sign in using OAuth.
--
-- /See:/ 'newBackendAuthAppleProviderConfig' smart constructor.
data BackendAuthAppleProviderConfig = BackendAuthAppleProviderConfig'
  { -- | Describes the client_id (also called Services ID) that comes from Apple.
    BackendAuthAppleProviderConfig -> Maybe Text
clientId :: Prelude.Maybe Prelude.Text,
    -- | Describes the private_key that comes from Apple.
    BackendAuthAppleProviderConfig -> Maybe Text
privateKey :: Prelude.Maybe Prelude.Text,
    -- | Describes the key_id that comes from Apple.
    BackendAuthAppleProviderConfig -> Maybe Text
keyId :: Prelude.Maybe Prelude.Text,
    -- | Describes the team_id that comes from Apple.
    BackendAuthAppleProviderConfig -> Maybe Text
teamId :: Prelude.Maybe Prelude.Text
  }
  deriving (BackendAuthAppleProviderConfig
-> BackendAuthAppleProviderConfig -> Bool
(BackendAuthAppleProviderConfig
 -> BackendAuthAppleProviderConfig -> Bool)
-> (BackendAuthAppleProviderConfig
    -> BackendAuthAppleProviderConfig -> Bool)
-> Eq BackendAuthAppleProviderConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BackendAuthAppleProviderConfig
-> BackendAuthAppleProviderConfig -> Bool
$c/= :: BackendAuthAppleProviderConfig
-> BackendAuthAppleProviderConfig -> Bool
== :: BackendAuthAppleProviderConfig
-> BackendAuthAppleProviderConfig -> Bool
$c== :: BackendAuthAppleProviderConfig
-> BackendAuthAppleProviderConfig -> Bool
Prelude.Eq, ReadPrec [BackendAuthAppleProviderConfig]
ReadPrec BackendAuthAppleProviderConfig
Int -> ReadS BackendAuthAppleProviderConfig
ReadS [BackendAuthAppleProviderConfig]
(Int -> ReadS BackendAuthAppleProviderConfig)
-> ReadS [BackendAuthAppleProviderConfig]
-> ReadPrec BackendAuthAppleProviderConfig
-> ReadPrec [BackendAuthAppleProviderConfig]
-> Read BackendAuthAppleProviderConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BackendAuthAppleProviderConfig]
$creadListPrec :: ReadPrec [BackendAuthAppleProviderConfig]
readPrec :: ReadPrec BackendAuthAppleProviderConfig
$creadPrec :: ReadPrec BackendAuthAppleProviderConfig
readList :: ReadS [BackendAuthAppleProviderConfig]
$creadList :: ReadS [BackendAuthAppleProviderConfig]
readsPrec :: Int -> ReadS BackendAuthAppleProviderConfig
$creadsPrec :: Int -> ReadS BackendAuthAppleProviderConfig
Prelude.Read, Int -> BackendAuthAppleProviderConfig -> ShowS
[BackendAuthAppleProviderConfig] -> ShowS
BackendAuthAppleProviderConfig -> String
(Int -> BackendAuthAppleProviderConfig -> ShowS)
-> (BackendAuthAppleProviderConfig -> String)
-> ([BackendAuthAppleProviderConfig] -> ShowS)
-> Show BackendAuthAppleProviderConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BackendAuthAppleProviderConfig] -> ShowS
$cshowList :: [BackendAuthAppleProviderConfig] -> ShowS
show :: BackendAuthAppleProviderConfig -> String
$cshow :: BackendAuthAppleProviderConfig -> String
showsPrec :: Int -> BackendAuthAppleProviderConfig -> ShowS
$cshowsPrec :: Int -> BackendAuthAppleProviderConfig -> ShowS
Prelude.Show, (forall x.
 BackendAuthAppleProviderConfig
 -> Rep BackendAuthAppleProviderConfig x)
-> (forall x.
    Rep BackendAuthAppleProviderConfig x
    -> BackendAuthAppleProviderConfig)
-> Generic BackendAuthAppleProviderConfig
forall x.
Rep BackendAuthAppleProviderConfig x
-> BackendAuthAppleProviderConfig
forall x.
BackendAuthAppleProviderConfig
-> Rep BackendAuthAppleProviderConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BackendAuthAppleProviderConfig x
-> BackendAuthAppleProviderConfig
$cfrom :: forall x.
BackendAuthAppleProviderConfig
-> Rep BackendAuthAppleProviderConfig x
Prelude.Generic)

-- |
-- Create a value of 'BackendAuthAppleProviderConfig' 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', 'backendAuthAppleProviderConfig_clientId' - Describes the client_id (also called Services ID) that comes from Apple.
--
-- 'privateKey', 'backendAuthAppleProviderConfig_privateKey' - Describes the private_key that comes from Apple.
--
-- 'keyId', 'backendAuthAppleProviderConfig_keyId' - Describes the key_id that comes from Apple.
--
-- 'teamId', 'backendAuthAppleProviderConfig_teamId' - Describes the team_id that comes from Apple.
newBackendAuthAppleProviderConfig ::
  BackendAuthAppleProviderConfig
newBackendAuthAppleProviderConfig :: BackendAuthAppleProviderConfig
newBackendAuthAppleProviderConfig =
  BackendAuthAppleProviderConfig' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> BackendAuthAppleProviderConfig
BackendAuthAppleProviderConfig'
    { $sel:clientId:BackendAuthAppleProviderConfig' :: Maybe Text
clientId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:privateKey:BackendAuthAppleProviderConfig' :: Maybe Text
privateKey = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:keyId:BackendAuthAppleProviderConfig' :: Maybe Text
keyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:teamId:BackendAuthAppleProviderConfig' :: Maybe Text
teamId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Describes the client_id (also called Services ID) that comes from Apple.
backendAuthAppleProviderConfig_clientId :: Lens.Lens' BackendAuthAppleProviderConfig (Prelude.Maybe Prelude.Text)
backendAuthAppleProviderConfig_clientId :: (Maybe Text -> f (Maybe Text))
-> BackendAuthAppleProviderConfig
-> f BackendAuthAppleProviderConfig
backendAuthAppleProviderConfig_clientId = (BackendAuthAppleProviderConfig -> Maybe Text)
-> (BackendAuthAppleProviderConfig
    -> Maybe Text -> BackendAuthAppleProviderConfig)
-> Lens
     BackendAuthAppleProviderConfig
     BackendAuthAppleProviderConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackendAuthAppleProviderConfig' {Maybe Text
clientId :: Maybe Text
$sel:clientId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
clientId} -> Maybe Text
clientId) (\s :: BackendAuthAppleProviderConfig
s@BackendAuthAppleProviderConfig' {} Maybe Text
a -> BackendAuthAppleProviderConfig
s {$sel:clientId:BackendAuthAppleProviderConfig' :: Maybe Text
clientId = Maybe Text
a} :: BackendAuthAppleProviderConfig)

-- | Describes the private_key that comes from Apple.
backendAuthAppleProviderConfig_privateKey :: Lens.Lens' BackendAuthAppleProviderConfig (Prelude.Maybe Prelude.Text)
backendAuthAppleProviderConfig_privateKey :: (Maybe Text -> f (Maybe Text))
-> BackendAuthAppleProviderConfig
-> f BackendAuthAppleProviderConfig
backendAuthAppleProviderConfig_privateKey = (BackendAuthAppleProviderConfig -> Maybe Text)
-> (BackendAuthAppleProviderConfig
    -> Maybe Text -> BackendAuthAppleProviderConfig)
-> Lens
     BackendAuthAppleProviderConfig
     BackendAuthAppleProviderConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackendAuthAppleProviderConfig' {Maybe Text
privateKey :: Maybe Text
$sel:privateKey:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
privateKey} -> Maybe Text
privateKey) (\s :: BackendAuthAppleProviderConfig
s@BackendAuthAppleProviderConfig' {} Maybe Text
a -> BackendAuthAppleProviderConfig
s {$sel:privateKey:BackendAuthAppleProviderConfig' :: Maybe Text
privateKey = Maybe Text
a} :: BackendAuthAppleProviderConfig)

-- | Describes the key_id that comes from Apple.
backendAuthAppleProviderConfig_keyId :: Lens.Lens' BackendAuthAppleProviderConfig (Prelude.Maybe Prelude.Text)
backendAuthAppleProviderConfig_keyId :: (Maybe Text -> f (Maybe Text))
-> BackendAuthAppleProviderConfig
-> f BackendAuthAppleProviderConfig
backendAuthAppleProviderConfig_keyId = (BackendAuthAppleProviderConfig -> Maybe Text)
-> (BackendAuthAppleProviderConfig
    -> Maybe Text -> BackendAuthAppleProviderConfig)
-> Lens
     BackendAuthAppleProviderConfig
     BackendAuthAppleProviderConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackendAuthAppleProviderConfig' {Maybe Text
keyId :: Maybe Text
$sel:keyId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
keyId} -> Maybe Text
keyId) (\s :: BackendAuthAppleProviderConfig
s@BackendAuthAppleProviderConfig' {} Maybe Text
a -> BackendAuthAppleProviderConfig
s {$sel:keyId:BackendAuthAppleProviderConfig' :: Maybe Text
keyId = Maybe Text
a} :: BackendAuthAppleProviderConfig)

-- | Describes the team_id that comes from Apple.
backendAuthAppleProviderConfig_teamId :: Lens.Lens' BackendAuthAppleProviderConfig (Prelude.Maybe Prelude.Text)
backendAuthAppleProviderConfig_teamId :: (Maybe Text -> f (Maybe Text))
-> BackendAuthAppleProviderConfig
-> f BackendAuthAppleProviderConfig
backendAuthAppleProviderConfig_teamId = (BackendAuthAppleProviderConfig -> Maybe Text)
-> (BackendAuthAppleProviderConfig
    -> Maybe Text -> BackendAuthAppleProviderConfig)
-> Lens
     BackendAuthAppleProviderConfig
     BackendAuthAppleProviderConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackendAuthAppleProviderConfig' {Maybe Text
teamId :: Maybe Text
$sel:teamId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
teamId} -> Maybe Text
teamId) (\s :: BackendAuthAppleProviderConfig
s@BackendAuthAppleProviderConfig' {} Maybe Text
a -> BackendAuthAppleProviderConfig
s {$sel:teamId:BackendAuthAppleProviderConfig' :: Maybe Text
teamId = Maybe Text
a} :: BackendAuthAppleProviderConfig)

instance Core.FromJSON BackendAuthAppleProviderConfig where
  parseJSON :: Value -> Parser BackendAuthAppleProviderConfig
parseJSON =
    String
-> (Object -> Parser BackendAuthAppleProviderConfig)
-> Value
-> Parser BackendAuthAppleProviderConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BackendAuthAppleProviderConfig"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> BackendAuthAppleProviderConfig
BackendAuthAppleProviderConfig'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> BackendAuthAppleProviderConfig)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> BackendAuthAppleProviderConfig)
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
   -> Maybe Text -> Maybe Text -> BackendAuthAppleProviderConfig)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> BackendAuthAppleProviderConfig)
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
"private_key")
            Parser (Maybe Text -> Maybe Text -> BackendAuthAppleProviderConfig)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> BackendAuthAppleProviderConfig)
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
"key_id")
            Parser (Maybe Text -> BackendAuthAppleProviderConfig)
-> Parser (Maybe Text) -> Parser BackendAuthAppleProviderConfig
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
"team_id")
      )

instance
  Prelude.Hashable
    BackendAuthAppleProviderConfig

instance
  Prelude.NFData
    BackendAuthAppleProviderConfig

instance Core.ToJSON BackendAuthAppleProviderConfig where
  toJSON :: BackendAuthAppleProviderConfig -> Value
toJSON BackendAuthAppleProviderConfig' {Maybe Text
teamId :: Maybe Text
keyId :: Maybe Text
privateKey :: Maybe Text
clientId :: Maybe Text
$sel:teamId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
$sel:keyId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
$sel:privateKey:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
$sel:clientId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> 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
"private_key" 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
privateKey,
            (Text
"key_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
keyId,
            (Text
"team_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
teamId
          ]
      )