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

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 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
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]
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
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.
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'
      { $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 :: Lens' CreateBackendAuthIdentityPoolConfig Bool
createBackendAuthIdentityPoolConfig_unauthenticatedLogin = 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 :: Lens' CreateBackendAuthIdentityPoolConfig Text
createBackendAuthIdentityPoolConfig_identityPoolName = 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
  Data.FromJSON
    CreateBackendAuthIdentityPoolConfig
  where
  parseJSON :: Value -> Parser CreateBackendAuthIdentityPoolConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CreateBackendAuthIdentityPoolConfig"
      ( \Object
x ->
          Bool -> Text -> CreateBackendAuthIdentityPoolConfig
CreateBackendAuthIdentityPoolConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"unauthenticatedLogin")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"identityPoolName")
      )

instance
  Prelude.Hashable
    CreateBackendAuthIdentityPoolConfig
  where
  hashWithSalt :: Int -> CreateBackendAuthIdentityPoolConfig -> Int
hashWithSalt
    Int
_salt
    CreateBackendAuthIdentityPoolConfig' {Bool
Text
identityPoolName :: Text
unauthenticatedLogin :: Bool
$sel:identityPoolName:CreateBackendAuthIdentityPoolConfig' :: CreateBackendAuthIdentityPoolConfig -> Text
$sel:unauthenticatedLogin:CreateBackendAuthIdentityPoolConfig' :: CreateBackendAuthIdentityPoolConfig -> Bool
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
unauthenticatedLogin
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
identityPoolName

instance
  Prelude.NFData
    CreateBackendAuthIdentityPoolConfig
  where
  rnf :: CreateBackendAuthIdentityPoolConfig -> ()
rnf CreateBackendAuthIdentityPoolConfig' {Bool
Text
identityPoolName :: Text
unauthenticatedLogin :: Bool
$sel:identityPoolName:CreateBackendAuthIdentityPoolConfig' :: CreateBackendAuthIdentityPoolConfig -> Text
$sel:unauthenticatedLogin:CreateBackendAuthIdentityPoolConfig' :: CreateBackendAuthIdentityPoolConfig -> Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Bool
unauthenticatedLogin
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
identityPoolName

instance
  Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"unauthenticatedLogin"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
unauthenticatedLogin
              ),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"identityPoolName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
identityPoolName)
          ]
      )