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

import Amazonka.AmplifyBackend.Types.AuthResources
import Amazonka.AmplifyBackend.Types.Service
import Amazonka.AmplifyBackend.Types.UpdateBackendAuthIdentityPoolConfig
import Amazonka.AmplifyBackend.Types.UpdateBackendAuthUserPoolConfig
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Defines the resource configuration when updating an authentication
-- resource in your Amplify project.
--
-- /See:/ 'newUpdateBackendAuthResourceConfig' smart constructor.
data UpdateBackendAuthResourceConfig = UpdateBackendAuthResourceConfig'
  { -- | Describes the authorization configuration for the Amazon Cognito
    -- identity pool, provisioned as a part of your auth resource in the
    -- Amplify project.
    UpdateBackendAuthResourceConfig
-> Maybe UpdateBackendAuthIdentityPoolConfig
identityPoolConfigs :: Prelude.Maybe UpdateBackendAuthIdentityPoolConfig,
    -- | Defines the service name to use when configuring an authentication
    -- resource in your Amplify project.
    UpdateBackendAuthResourceConfig -> AuthResources
authResources :: AuthResources,
    -- | Describes the authentication configuration for the Amazon Cognito user
    -- pool, provisioned as a part of your auth resource in the Amplify
    -- project.
    UpdateBackendAuthResourceConfig -> UpdateBackendAuthUserPoolConfig
userPoolConfigs :: UpdateBackendAuthUserPoolConfig,
    -- | Defines the service name to use when configuring an authentication
    -- resource in your Amplify project.
    UpdateBackendAuthResourceConfig -> Service
service :: Service
  }
  deriving (UpdateBackendAuthResourceConfig
-> UpdateBackendAuthResourceConfig -> Bool
(UpdateBackendAuthResourceConfig
 -> UpdateBackendAuthResourceConfig -> Bool)
-> (UpdateBackendAuthResourceConfig
    -> UpdateBackendAuthResourceConfig -> Bool)
-> Eq UpdateBackendAuthResourceConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateBackendAuthResourceConfig
-> UpdateBackendAuthResourceConfig -> Bool
$c/= :: UpdateBackendAuthResourceConfig
-> UpdateBackendAuthResourceConfig -> Bool
== :: UpdateBackendAuthResourceConfig
-> UpdateBackendAuthResourceConfig -> Bool
$c== :: UpdateBackendAuthResourceConfig
-> UpdateBackendAuthResourceConfig -> Bool
Prelude.Eq, ReadPrec [UpdateBackendAuthResourceConfig]
ReadPrec UpdateBackendAuthResourceConfig
Int -> ReadS UpdateBackendAuthResourceConfig
ReadS [UpdateBackendAuthResourceConfig]
(Int -> ReadS UpdateBackendAuthResourceConfig)
-> ReadS [UpdateBackendAuthResourceConfig]
-> ReadPrec UpdateBackendAuthResourceConfig
-> ReadPrec [UpdateBackendAuthResourceConfig]
-> Read UpdateBackendAuthResourceConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateBackendAuthResourceConfig]
$creadListPrec :: ReadPrec [UpdateBackendAuthResourceConfig]
readPrec :: ReadPrec UpdateBackendAuthResourceConfig
$creadPrec :: ReadPrec UpdateBackendAuthResourceConfig
readList :: ReadS [UpdateBackendAuthResourceConfig]
$creadList :: ReadS [UpdateBackendAuthResourceConfig]
readsPrec :: Int -> ReadS UpdateBackendAuthResourceConfig
$creadsPrec :: Int -> ReadS UpdateBackendAuthResourceConfig
Prelude.Read, Int -> UpdateBackendAuthResourceConfig -> ShowS
[UpdateBackendAuthResourceConfig] -> ShowS
UpdateBackendAuthResourceConfig -> String
(Int -> UpdateBackendAuthResourceConfig -> ShowS)
-> (UpdateBackendAuthResourceConfig -> String)
-> ([UpdateBackendAuthResourceConfig] -> ShowS)
-> Show UpdateBackendAuthResourceConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateBackendAuthResourceConfig] -> ShowS
$cshowList :: [UpdateBackendAuthResourceConfig] -> ShowS
show :: UpdateBackendAuthResourceConfig -> String
$cshow :: UpdateBackendAuthResourceConfig -> String
showsPrec :: Int -> UpdateBackendAuthResourceConfig -> ShowS
$cshowsPrec :: Int -> UpdateBackendAuthResourceConfig -> ShowS
Prelude.Show, (forall x.
 UpdateBackendAuthResourceConfig
 -> Rep UpdateBackendAuthResourceConfig x)
-> (forall x.
    Rep UpdateBackendAuthResourceConfig x
    -> UpdateBackendAuthResourceConfig)
-> Generic UpdateBackendAuthResourceConfig
forall x.
Rep UpdateBackendAuthResourceConfig x
-> UpdateBackendAuthResourceConfig
forall x.
UpdateBackendAuthResourceConfig
-> Rep UpdateBackendAuthResourceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateBackendAuthResourceConfig x
-> UpdateBackendAuthResourceConfig
$cfrom :: forall x.
UpdateBackendAuthResourceConfig
-> Rep UpdateBackendAuthResourceConfig x
Prelude.Generic)

-- |
-- Create a value of 'UpdateBackendAuthResourceConfig' 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:
--
-- 'identityPoolConfigs', 'updateBackendAuthResourceConfig_identityPoolConfigs' - Describes the authorization configuration for the Amazon Cognito
-- identity pool, provisioned as a part of your auth resource in the
-- Amplify project.
--
-- 'authResources', 'updateBackendAuthResourceConfig_authResources' - Defines the service name to use when configuring an authentication
-- resource in your Amplify project.
--
-- 'userPoolConfigs', 'updateBackendAuthResourceConfig_userPoolConfigs' - Describes the authentication configuration for the Amazon Cognito user
-- pool, provisioned as a part of your auth resource in the Amplify
-- project.
--
-- 'service', 'updateBackendAuthResourceConfig_service' - Defines the service name to use when configuring an authentication
-- resource in your Amplify project.
newUpdateBackendAuthResourceConfig ::
  -- | 'authResources'
  AuthResources ->
  -- | 'userPoolConfigs'
  UpdateBackendAuthUserPoolConfig ->
  -- | 'service'
  Service ->
  UpdateBackendAuthResourceConfig
newUpdateBackendAuthResourceConfig :: AuthResources
-> UpdateBackendAuthUserPoolConfig
-> Service
-> UpdateBackendAuthResourceConfig
newUpdateBackendAuthResourceConfig
  AuthResources
pAuthResources_
  UpdateBackendAuthUserPoolConfig
pUserPoolConfigs_
  Service
pService_ =
    UpdateBackendAuthResourceConfig' :: Maybe UpdateBackendAuthIdentityPoolConfig
-> AuthResources
-> UpdateBackendAuthUserPoolConfig
-> Service
-> UpdateBackendAuthResourceConfig
UpdateBackendAuthResourceConfig'
      { $sel:identityPoolConfigs:UpdateBackendAuthResourceConfig' :: Maybe UpdateBackendAuthIdentityPoolConfig
identityPoolConfigs =
          Maybe UpdateBackendAuthIdentityPoolConfig
forall a. Maybe a
Prelude.Nothing,
        $sel:authResources:UpdateBackendAuthResourceConfig' :: AuthResources
authResources = AuthResources
pAuthResources_,
        $sel:userPoolConfigs:UpdateBackendAuthResourceConfig' :: UpdateBackendAuthUserPoolConfig
userPoolConfigs = UpdateBackendAuthUserPoolConfig
pUserPoolConfigs_,
        $sel:service:UpdateBackendAuthResourceConfig' :: Service
service = Service
pService_
      }

-- | Describes the authorization configuration for the Amazon Cognito
-- identity pool, provisioned as a part of your auth resource in the
-- Amplify project.
updateBackendAuthResourceConfig_identityPoolConfigs :: Lens.Lens' UpdateBackendAuthResourceConfig (Prelude.Maybe UpdateBackendAuthIdentityPoolConfig)
updateBackendAuthResourceConfig_identityPoolConfigs :: (Maybe UpdateBackendAuthIdentityPoolConfig
 -> f (Maybe UpdateBackendAuthIdentityPoolConfig))
-> UpdateBackendAuthResourceConfig
-> f UpdateBackendAuthResourceConfig
updateBackendAuthResourceConfig_identityPoolConfigs = (UpdateBackendAuthResourceConfig
 -> Maybe UpdateBackendAuthIdentityPoolConfig)
-> (UpdateBackendAuthResourceConfig
    -> Maybe UpdateBackendAuthIdentityPoolConfig
    -> UpdateBackendAuthResourceConfig)
-> Lens
     UpdateBackendAuthResourceConfig
     UpdateBackendAuthResourceConfig
     (Maybe UpdateBackendAuthIdentityPoolConfig)
     (Maybe UpdateBackendAuthIdentityPoolConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBackendAuthResourceConfig' {Maybe UpdateBackendAuthIdentityPoolConfig
identityPoolConfigs :: Maybe UpdateBackendAuthIdentityPoolConfig
$sel:identityPoolConfigs:UpdateBackendAuthResourceConfig' :: UpdateBackendAuthResourceConfig
-> Maybe UpdateBackendAuthIdentityPoolConfig
identityPoolConfigs} -> Maybe UpdateBackendAuthIdentityPoolConfig
identityPoolConfigs) (\s :: UpdateBackendAuthResourceConfig
s@UpdateBackendAuthResourceConfig' {} Maybe UpdateBackendAuthIdentityPoolConfig
a -> UpdateBackendAuthResourceConfig
s {$sel:identityPoolConfigs:UpdateBackendAuthResourceConfig' :: Maybe UpdateBackendAuthIdentityPoolConfig
identityPoolConfigs = Maybe UpdateBackendAuthIdentityPoolConfig
a} :: UpdateBackendAuthResourceConfig)

-- | Defines the service name to use when configuring an authentication
-- resource in your Amplify project.
updateBackendAuthResourceConfig_authResources :: Lens.Lens' UpdateBackendAuthResourceConfig AuthResources
updateBackendAuthResourceConfig_authResources :: (AuthResources -> f AuthResources)
-> UpdateBackendAuthResourceConfig
-> f UpdateBackendAuthResourceConfig
updateBackendAuthResourceConfig_authResources = (UpdateBackendAuthResourceConfig -> AuthResources)
-> (UpdateBackendAuthResourceConfig
    -> AuthResources -> UpdateBackendAuthResourceConfig)
-> Lens
     UpdateBackendAuthResourceConfig
     UpdateBackendAuthResourceConfig
     AuthResources
     AuthResources
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBackendAuthResourceConfig' {AuthResources
authResources :: AuthResources
$sel:authResources:UpdateBackendAuthResourceConfig' :: UpdateBackendAuthResourceConfig -> AuthResources
authResources} -> AuthResources
authResources) (\s :: UpdateBackendAuthResourceConfig
s@UpdateBackendAuthResourceConfig' {} AuthResources
a -> UpdateBackendAuthResourceConfig
s {$sel:authResources:UpdateBackendAuthResourceConfig' :: AuthResources
authResources = AuthResources
a} :: UpdateBackendAuthResourceConfig)

-- | Describes the authentication configuration for the Amazon Cognito user
-- pool, provisioned as a part of your auth resource in the Amplify
-- project.
updateBackendAuthResourceConfig_userPoolConfigs :: Lens.Lens' UpdateBackendAuthResourceConfig UpdateBackendAuthUserPoolConfig
updateBackendAuthResourceConfig_userPoolConfigs :: (UpdateBackendAuthUserPoolConfig
 -> f UpdateBackendAuthUserPoolConfig)
-> UpdateBackendAuthResourceConfig
-> f UpdateBackendAuthResourceConfig
updateBackendAuthResourceConfig_userPoolConfigs = (UpdateBackendAuthResourceConfig
 -> UpdateBackendAuthUserPoolConfig)
-> (UpdateBackendAuthResourceConfig
    -> UpdateBackendAuthUserPoolConfig
    -> UpdateBackendAuthResourceConfig)
-> Lens
     UpdateBackendAuthResourceConfig
     UpdateBackendAuthResourceConfig
     UpdateBackendAuthUserPoolConfig
     UpdateBackendAuthUserPoolConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBackendAuthResourceConfig' {UpdateBackendAuthUserPoolConfig
userPoolConfigs :: UpdateBackendAuthUserPoolConfig
$sel:userPoolConfigs:UpdateBackendAuthResourceConfig' :: UpdateBackendAuthResourceConfig -> UpdateBackendAuthUserPoolConfig
userPoolConfigs} -> UpdateBackendAuthUserPoolConfig
userPoolConfigs) (\s :: UpdateBackendAuthResourceConfig
s@UpdateBackendAuthResourceConfig' {} UpdateBackendAuthUserPoolConfig
a -> UpdateBackendAuthResourceConfig
s {$sel:userPoolConfigs:UpdateBackendAuthResourceConfig' :: UpdateBackendAuthUserPoolConfig
userPoolConfigs = UpdateBackendAuthUserPoolConfig
a} :: UpdateBackendAuthResourceConfig)

-- | Defines the service name to use when configuring an authentication
-- resource in your Amplify project.
updateBackendAuthResourceConfig_service :: Lens.Lens' UpdateBackendAuthResourceConfig Service
updateBackendAuthResourceConfig_service :: (Service -> f Service)
-> UpdateBackendAuthResourceConfig
-> f UpdateBackendAuthResourceConfig
updateBackendAuthResourceConfig_service = (UpdateBackendAuthResourceConfig -> Service)
-> (UpdateBackendAuthResourceConfig
    -> Service -> UpdateBackendAuthResourceConfig)
-> Lens
     UpdateBackendAuthResourceConfig
     UpdateBackendAuthResourceConfig
     Service
     Service
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBackendAuthResourceConfig' {Service
service :: Service
$sel:service:UpdateBackendAuthResourceConfig' :: UpdateBackendAuthResourceConfig -> Service
service} -> Service
service) (\s :: UpdateBackendAuthResourceConfig
s@UpdateBackendAuthResourceConfig' {} Service
a -> UpdateBackendAuthResourceConfig
s {$sel:service:UpdateBackendAuthResourceConfig' :: Service
service = Service
a} :: UpdateBackendAuthResourceConfig)

instance
  Prelude.Hashable
    UpdateBackendAuthResourceConfig

instance
  Prelude.NFData
    UpdateBackendAuthResourceConfig

instance Core.ToJSON UpdateBackendAuthResourceConfig where
  toJSON :: UpdateBackendAuthResourceConfig -> Value
toJSON UpdateBackendAuthResourceConfig' {Maybe UpdateBackendAuthIdentityPoolConfig
AuthResources
Service
UpdateBackendAuthUserPoolConfig
service :: Service
userPoolConfigs :: UpdateBackendAuthUserPoolConfig
authResources :: AuthResources
identityPoolConfigs :: Maybe UpdateBackendAuthIdentityPoolConfig
$sel:service:UpdateBackendAuthResourceConfig' :: UpdateBackendAuthResourceConfig -> Service
$sel:userPoolConfigs:UpdateBackendAuthResourceConfig' :: UpdateBackendAuthResourceConfig -> UpdateBackendAuthUserPoolConfig
$sel:authResources:UpdateBackendAuthResourceConfig' :: UpdateBackendAuthResourceConfig -> AuthResources
$sel:identityPoolConfigs:UpdateBackendAuthResourceConfig' :: UpdateBackendAuthResourceConfig
-> Maybe UpdateBackendAuthIdentityPoolConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"identityPoolConfigs" Text -> UpdateBackendAuthIdentityPoolConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (UpdateBackendAuthIdentityPoolConfig -> Pair)
-> Maybe UpdateBackendAuthIdentityPoolConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UpdateBackendAuthIdentityPoolConfig
identityPoolConfigs,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"authResources" Text -> AuthResources -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AuthResources
authResources),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"userPoolConfigs" Text -> UpdateBackendAuthUserPoolConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= UpdateBackendAuthUserPoolConfig
userPoolConfigs),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"service" Text -> Service -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Service
service)
          ]
      )