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

import Amazonka.AmplifyBackend.Types.BackendAPIAppSyncAuthSettings
import Amazonka.AmplifyBackend.Types.Mode
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

-- | Describes the auth types for your configured data models.
--
-- /See:/ 'newBackendAPIAuthType' smart constructor.
data BackendAPIAuthType = BackendAPIAuthType'
  { -- | Describes the authentication mode.
    BackendAPIAuthType -> Maybe Mode
mode :: Prelude.Maybe Mode,
    -- | Describes settings for the authentication mode.
    BackendAPIAuthType -> Maybe BackendAPIAppSyncAuthSettings
settings :: Prelude.Maybe BackendAPIAppSyncAuthSettings
  }
  deriving (BackendAPIAuthType -> BackendAPIAuthType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BackendAPIAuthType -> BackendAPIAuthType -> Bool
$c/= :: BackendAPIAuthType -> BackendAPIAuthType -> Bool
== :: BackendAPIAuthType -> BackendAPIAuthType -> Bool
$c== :: BackendAPIAuthType -> BackendAPIAuthType -> Bool
Prelude.Eq, ReadPrec [BackendAPIAuthType]
ReadPrec BackendAPIAuthType
Int -> ReadS BackendAPIAuthType
ReadS [BackendAPIAuthType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BackendAPIAuthType]
$creadListPrec :: ReadPrec [BackendAPIAuthType]
readPrec :: ReadPrec BackendAPIAuthType
$creadPrec :: ReadPrec BackendAPIAuthType
readList :: ReadS [BackendAPIAuthType]
$creadList :: ReadS [BackendAPIAuthType]
readsPrec :: Int -> ReadS BackendAPIAuthType
$creadsPrec :: Int -> ReadS BackendAPIAuthType
Prelude.Read, Int -> BackendAPIAuthType -> ShowS
[BackendAPIAuthType] -> ShowS
BackendAPIAuthType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BackendAPIAuthType] -> ShowS
$cshowList :: [BackendAPIAuthType] -> ShowS
show :: BackendAPIAuthType -> String
$cshow :: BackendAPIAuthType -> String
showsPrec :: Int -> BackendAPIAuthType -> ShowS
$cshowsPrec :: Int -> BackendAPIAuthType -> ShowS
Prelude.Show, forall x. Rep BackendAPIAuthType x -> BackendAPIAuthType
forall x. BackendAPIAuthType -> Rep BackendAPIAuthType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BackendAPIAuthType x -> BackendAPIAuthType
$cfrom :: forall x. BackendAPIAuthType -> Rep BackendAPIAuthType x
Prelude.Generic)

-- |
-- Create a value of 'BackendAPIAuthType' 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:
--
-- 'mode', 'backendAPIAuthType_mode' - Describes the authentication mode.
--
-- 'settings', 'backendAPIAuthType_settings' - Describes settings for the authentication mode.
newBackendAPIAuthType ::
  BackendAPIAuthType
newBackendAPIAuthType :: BackendAPIAuthType
newBackendAPIAuthType =
  BackendAPIAuthType'
    { $sel:mode:BackendAPIAuthType' :: Maybe Mode
mode = forall a. Maybe a
Prelude.Nothing,
      $sel:settings:BackendAPIAuthType' :: Maybe BackendAPIAppSyncAuthSettings
settings = forall a. Maybe a
Prelude.Nothing
    }

-- | Describes the authentication mode.
backendAPIAuthType_mode :: Lens.Lens' BackendAPIAuthType (Prelude.Maybe Mode)
backendAPIAuthType_mode :: Lens' BackendAPIAuthType (Maybe Mode)
backendAPIAuthType_mode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackendAPIAuthType' {Maybe Mode
mode :: Maybe Mode
$sel:mode:BackendAPIAuthType' :: BackendAPIAuthType -> Maybe Mode
mode} -> Maybe Mode
mode) (\s :: BackendAPIAuthType
s@BackendAPIAuthType' {} Maybe Mode
a -> BackendAPIAuthType
s {$sel:mode:BackendAPIAuthType' :: Maybe Mode
mode = Maybe Mode
a} :: BackendAPIAuthType)

-- | Describes settings for the authentication mode.
backendAPIAuthType_settings :: Lens.Lens' BackendAPIAuthType (Prelude.Maybe BackendAPIAppSyncAuthSettings)
backendAPIAuthType_settings :: Lens' BackendAPIAuthType (Maybe BackendAPIAppSyncAuthSettings)
backendAPIAuthType_settings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackendAPIAuthType' {Maybe BackendAPIAppSyncAuthSettings
settings :: Maybe BackendAPIAppSyncAuthSettings
$sel:settings:BackendAPIAuthType' :: BackendAPIAuthType -> Maybe BackendAPIAppSyncAuthSettings
settings} -> Maybe BackendAPIAppSyncAuthSettings
settings) (\s :: BackendAPIAuthType
s@BackendAPIAuthType' {} Maybe BackendAPIAppSyncAuthSettings
a -> BackendAPIAuthType
s {$sel:settings:BackendAPIAuthType' :: Maybe BackendAPIAppSyncAuthSettings
settings = Maybe BackendAPIAppSyncAuthSettings
a} :: BackendAPIAuthType)

instance Data.FromJSON BackendAPIAuthType where
  parseJSON :: Value -> Parser BackendAPIAuthType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BackendAPIAuthType"
      ( \Object
x ->
          Maybe Mode
-> Maybe BackendAPIAppSyncAuthSettings -> BackendAPIAuthType
BackendAPIAuthType'
            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
"mode")
            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
"settings")
      )

instance Prelude.Hashable BackendAPIAuthType where
  hashWithSalt :: Int -> BackendAPIAuthType -> Int
hashWithSalt Int
_salt BackendAPIAuthType' {Maybe BackendAPIAppSyncAuthSettings
Maybe Mode
settings :: Maybe BackendAPIAppSyncAuthSettings
mode :: Maybe Mode
$sel:settings:BackendAPIAuthType' :: BackendAPIAuthType -> Maybe BackendAPIAppSyncAuthSettings
$sel:mode:BackendAPIAuthType' :: BackendAPIAuthType -> Maybe Mode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Mode
mode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BackendAPIAppSyncAuthSettings
settings

instance Prelude.NFData BackendAPIAuthType where
  rnf :: BackendAPIAuthType -> ()
rnf BackendAPIAuthType' {Maybe BackendAPIAppSyncAuthSettings
Maybe Mode
settings :: Maybe BackendAPIAppSyncAuthSettings
mode :: Maybe Mode
$sel:settings:BackendAPIAuthType' :: BackendAPIAuthType -> Maybe BackendAPIAppSyncAuthSettings
$sel:mode:BackendAPIAuthType' :: BackendAPIAuthType -> Maybe Mode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Mode
mode seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe BackendAPIAppSyncAuthSettings
settings

instance Data.ToJSON BackendAPIAuthType where
  toJSON :: BackendAPIAuthType -> Value
toJSON BackendAPIAuthType' {Maybe BackendAPIAppSyncAuthSettings
Maybe Mode
settings :: Maybe BackendAPIAppSyncAuthSettings
mode :: Maybe Mode
$sel:settings:BackendAPIAuthType' :: BackendAPIAuthType -> Maybe BackendAPIAppSyncAuthSettings
$sel:mode:BackendAPIAuthType' :: BackendAPIAuthType -> Maybe Mode
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"mode" 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 Mode
mode,
            (Key
"settings" 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 BackendAPIAppSyncAuthSettings
settings
          ]
      )