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

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

-- | Describes authorization configurations for the auth resources,
-- configured as a part of your Amplify project.
--
-- /See:/ 'newCreateBackendAuthIdentityPoolConfig' smart constructor.
data CreateBackendAuthIdentityPoolConfig = CreateBackendAuthIdentityPoolConfig'
  { -- | Set to true or false based on whether you want to enable guest
    -- authorization to your Amplify app.
    CreateBackendAuthIdentityPoolConfig -> Bool
unauthenticatedLogin :: Prelude.Bool,
    -- | Name of the Amazon Cognito identity pool used for authorization.
    CreateBackendAuthIdentityPoolConfig -> Text
identityPoolName :: Prelude.Text
  }
  deriving (CreateBackendAuthIdentityPoolConfig
-> CreateBackendAuthIdentityPoolConfig -> Bool
(CreateBackendAuthIdentityPoolConfig
 -> CreateBackendAuthIdentityPoolConfig -> Bool)
-> (CreateBackendAuthIdentityPoolConfig
    -> CreateBackendAuthIdentityPoolConfig -> Bool)
-> Eq CreateBackendAuthIdentityPoolConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateBackendAuthIdentityPoolConfig
-> CreateBackendAuthIdentityPoolConfig -> Bool
$c/= :: CreateBackendAuthIdentityPoolConfig
-> CreateBackendAuthIdentityPoolConfig -> Bool
== :: CreateBackendAuthIdentityPoolConfig
-> CreateBackendAuthIdentityPoolConfig -> Bool
$c== :: CreateBackendAuthIdentityPoolConfig
-> CreateBackendAuthIdentityPoolConfig -> Bool
Prelude.Eq, ReadPrec [CreateBackendAuthIdentityPoolConfig]
ReadPrec CreateBackendAuthIdentityPoolConfig
Int -> ReadS CreateBackendAuthIdentityPoolConfig
ReadS [CreateBackendAuthIdentityPoolConfig]
(Int -> ReadS CreateBackendAuthIdentityPoolConfig)
-> ReadS [CreateBackendAuthIdentityPoolConfig]
-> ReadPrec CreateBackendAuthIdentityPoolConfig
-> ReadPrec [CreateBackendAuthIdentityPoolConfig]
-> Read CreateBackendAuthIdentityPoolConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateBackendAuthIdentityPoolConfig]
$creadListPrec :: ReadPrec [CreateBackendAuthIdentityPoolConfig]
readPrec :: ReadPrec CreateBackendAuthIdentityPoolConfig
$creadPrec :: ReadPrec CreateBackendAuthIdentityPoolConfig
readList :: ReadS [CreateBackendAuthIdentityPoolConfig]
$creadList :: ReadS [CreateBackendAuthIdentityPoolConfig]
readsPrec :: Int -> ReadS CreateBackendAuthIdentityPoolConfig
$creadsPrec :: Int -> ReadS CreateBackendAuthIdentityPoolConfig
Prelude.Read, Int -> CreateBackendAuthIdentityPoolConfig -> ShowS
[CreateBackendAuthIdentityPoolConfig] -> ShowS
CreateBackendAuthIdentityPoolConfig -> String
(Int -> CreateBackendAuthIdentityPoolConfig -> ShowS)
-> (CreateBackendAuthIdentityPoolConfig -> String)
-> ([CreateBackendAuthIdentityPoolConfig] -> ShowS)
-> Show CreateBackendAuthIdentityPoolConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateBackendAuthIdentityPoolConfig] -> ShowS
$cshowList :: [CreateBackendAuthIdentityPoolConfig] -> ShowS
show :: CreateBackendAuthIdentityPoolConfig -> String
$cshow :: CreateBackendAuthIdentityPoolConfig -> String
showsPrec :: Int -> CreateBackendAuthIdentityPoolConfig -> ShowS
$cshowsPrec :: Int -> CreateBackendAuthIdentityPoolConfig -> ShowS
Prelude.Show, (forall x.
 CreateBackendAuthIdentityPoolConfig
 -> Rep CreateBackendAuthIdentityPoolConfig x)
-> (forall x.
    Rep CreateBackendAuthIdentityPoolConfig x
    -> CreateBackendAuthIdentityPoolConfig)
-> Generic CreateBackendAuthIdentityPoolConfig
forall x.
Rep CreateBackendAuthIdentityPoolConfig x
-> CreateBackendAuthIdentityPoolConfig
forall x.
CreateBackendAuthIdentityPoolConfig
-> Rep CreateBackendAuthIdentityPoolConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateBackendAuthIdentityPoolConfig x
-> CreateBackendAuthIdentityPoolConfig
$cfrom :: forall x.
CreateBackendAuthIdentityPoolConfig
-> Rep CreateBackendAuthIdentityPoolConfig x
Prelude.Generic)

-- |
-- Create a value of 'CreateBackendAuthIdentityPoolConfig' 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:
--
-- 'unauthenticatedLogin', 'createBackendAuthIdentityPoolConfig_unauthenticatedLogin' - Set to true or false based on whether you want to enable guest
-- authorization to your Amplify app.
--
-- 'identityPoolName', 'createBackendAuthIdentityPoolConfig_identityPoolName' - Name of the Amazon Cognito identity pool used for authorization.
newCreateBackendAuthIdentityPoolConfig ::
  -- | 'unauthenticatedLogin'
  Prelude.Bool ->
  -- | 'identityPoolName'
  Prelude.Text ->
  CreateBackendAuthIdentityPoolConfig
newCreateBackendAuthIdentityPoolConfig :: Bool -> Text -> CreateBackendAuthIdentityPoolConfig
newCreateBackendAuthIdentityPoolConfig
  Bool
pUnauthenticatedLogin_
  Text
pIdentityPoolName_ =
    CreateBackendAuthIdentityPoolConfig' :: Bool -> Text -> CreateBackendAuthIdentityPoolConfig
CreateBackendAuthIdentityPoolConfig'
      { $sel:unauthenticatedLogin:CreateBackendAuthIdentityPoolConfig' :: Bool
unauthenticatedLogin =
          Bool
pUnauthenticatedLogin_,
        $sel:identityPoolName:CreateBackendAuthIdentityPoolConfig' :: Text
identityPoolName = Text
pIdentityPoolName_
      }

-- | Set to true or false based on whether you want to enable guest
-- authorization to your Amplify app.
createBackendAuthIdentityPoolConfig_unauthenticatedLogin :: Lens.Lens' CreateBackendAuthIdentityPoolConfig Prelude.Bool
createBackendAuthIdentityPoolConfig_unauthenticatedLogin :: (Bool -> f Bool)
-> CreateBackendAuthIdentityPoolConfig
-> f CreateBackendAuthIdentityPoolConfig
createBackendAuthIdentityPoolConfig_unauthenticatedLogin = (CreateBackendAuthIdentityPoolConfig -> Bool)
-> (CreateBackendAuthIdentityPoolConfig
    -> Bool -> CreateBackendAuthIdentityPoolConfig)
-> Lens
     CreateBackendAuthIdentityPoolConfig
     CreateBackendAuthIdentityPoolConfig
     Bool
     Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBackendAuthIdentityPoolConfig' {Bool
unauthenticatedLogin :: Bool
$sel:unauthenticatedLogin:CreateBackendAuthIdentityPoolConfig' :: CreateBackendAuthIdentityPoolConfig -> Bool
unauthenticatedLogin} -> Bool
unauthenticatedLogin) (\s :: CreateBackendAuthIdentityPoolConfig
s@CreateBackendAuthIdentityPoolConfig' {} Bool
a -> CreateBackendAuthIdentityPoolConfig
s {$sel:unauthenticatedLogin:CreateBackendAuthIdentityPoolConfig' :: Bool
unauthenticatedLogin = Bool
a} :: CreateBackendAuthIdentityPoolConfig)

-- | Name of the Amazon Cognito identity pool used for authorization.
createBackendAuthIdentityPoolConfig_identityPoolName :: Lens.Lens' CreateBackendAuthIdentityPoolConfig Prelude.Text
createBackendAuthIdentityPoolConfig_identityPoolName :: (Text -> f Text)
-> CreateBackendAuthIdentityPoolConfig
-> f CreateBackendAuthIdentityPoolConfig
createBackendAuthIdentityPoolConfig_identityPoolName = (CreateBackendAuthIdentityPoolConfig -> Text)
-> (CreateBackendAuthIdentityPoolConfig
    -> Text -> CreateBackendAuthIdentityPoolConfig)
-> Lens
     CreateBackendAuthIdentityPoolConfig
     CreateBackendAuthIdentityPoolConfig
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBackendAuthIdentityPoolConfig' {Text
identityPoolName :: Text
$sel:identityPoolName:CreateBackendAuthIdentityPoolConfig' :: CreateBackendAuthIdentityPoolConfig -> Text
identityPoolName} -> Text
identityPoolName) (\s :: CreateBackendAuthIdentityPoolConfig
s@CreateBackendAuthIdentityPoolConfig' {} Text
a -> CreateBackendAuthIdentityPoolConfig
s {$sel:identityPoolName:CreateBackendAuthIdentityPoolConfig' :: Text
identityPoolName = Text
a} :: CreateBackendAuthIdentityPoolConfig)

instance
  Core.FromJSON
    CreateBackendAuthIdentityPoolConfig
  where
  parseJSON :: Value -> Parser CreateBackendAuthIdentityPoolConfig
parseJSON =
    String
-> (Object -> Parser CreateBackendAuthIdentityPoolConfig)
-> Value
-> Parser CreateBackendAuthIdentityPoolConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CreateBackendAuthIdentityPoolConfig"
      ( \Object
x ->
          Bool -> Text -> CreateBackendAuthIdentityPoolConfig
CreateBackendAuthIdentityPoolConfig'
            (Bool -> Text -> CreateBackendAuthIdentityPoolConfig)
-> Parser Bool
-> Parser (Text -> CreateBackendAuthIdentityPoolConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"unauthenticatedLogin")
            Parser (Text -> CreateBackendAuthIdentityPoolConfig)
-> Parser Text -> Parser CreateBackendAuthIdentityPoolConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"identityPoolName")
      )

instance
  Prelude.Hashable
    CreateBackendAuthIdentityPoolConfig

instance
  Prelude.NFData
    CreateBackendAuthIdentityPoolConfig

instance
  Core.ToJSON
    CreateBackendAuthIdentityPoolConfig
  where
  toJSON :: CreateBackendAuthIdentityPoolConfig -> Value
toJSON CreateBackendAuthIdentityPoolConfig' {Bool
Text
identityPoolName :: Text
unauthenticatedLogin :: Bool
$sel:identityPoolName:CreateBackendAuthIdentityPoolConfig' :: CreateBackendAuthIdentityPoolConfig -> Text
$sel:unauthenticatedLogin:CreateBackendAuthIdentityPoolConfig' :: CreateBackendAuthIdentityPoolConfig -> Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"unauthenticatedLogin"
                  Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
unauthenticatedLogin
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"identityPoolName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
identityPoolName)
          ]
      )