{-# 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 #-}
module Amazonka.AppSync.Types.AuthorizationConfig where
import Amazonka.AppSync.Types.AuthorizationType
import Amazonka.AppSync.Types.AwsIamConfig
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data AuthorizationConfig = AuthorizationConfig'
{
AuthorizationConfig -> Maybe AwsIamConfig
awsIamConfig :: Prelude.Maybe AwsIamConfig,
AuthorizationConfig -> AuthorizationType
authorizationType :: AuthorizationType
}
deriving (AuthorizationConfig -> AuthorizationConfig -> Bool
(AuthorizationConfig -> AuthorizationConfig -> Bool)
-> (AuthorizationConfig -> AuthorizationConfig -> Bool)
-> Eq AuthorizationConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AuthorizationConfig -> AuthorizationConfig -> Bool
$c/= :: AuthorizationConfig -> AuthorizationConfig -> Bool
== :: AuthorizationConfig -> AuthorizationConfig -> Bool
$c== :: AuthorizationConfig -> AuthorizationConfig -> Bool
Prelude.Eq, ReadPrec [AuthorizationConfig]
ReadPrec AuthorizationConfig
Int -> ReadS AuthorizationConfig
ReadS [AuthorizationConfig]
(Int -> ReadS AuthorizationConfig)
-> ReadS [AuthorizationConfig]
-> ReadPrec AuthorizationConfig
-> ReadPrec [AuthorizationConfig]
-> Read AuthorizationConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AuthorizationConfig]
$creadListPrec :: ReadPrec [AuthorizationConfig]
readPrec :: ReadPrec AuthorizationConfig
$creadPrec :: ReadPrec AuthorizationConfig
readList :: ReadS [AuthorizationConfig]
$creadList :: ReadS [AuthorizationConfig]
readsPrec :: Int -> ReadS AuthorizationConfig
$creadsPrec :: Int -> ReadS AuthorizationConfig
Prelude.Read, Int -> AuthorizationConfig -> ShowS
[AuthorizationConfig] -> ShowS
AuthorizationConfig -> String
(Int -> AuthorizationConfig -> ShowS)
-> (AuthorizationConfig -> String)
-> ([AuthorizationConfig] -> ShowS)
-> Show AuthorizationConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AuthorizationConfig] -> ShowS
$cshowList :: [AuthorizationConfig] -> ShowS
show :: AuthorizationConfig -> String
$cshow :: AuthorizationConfig -> String
showsPrec :: Int -> AuthorizationConfig -> ShowS
$cshowsPrec :: Int -> AuthorizationConfig -> ShowS
Prelude.Show, (forall x. AuthorizationConfig -> Rep AuthorizationConfig x)
-> (forall x. Rep AuthorizationConfig x -> AuthorizationConfig)
-> Generic AuthorizationConfig
forall x. Rep AuthorizationConfig x -> AuthorizationConfig
forall x. AuthorizationConfig -> Rep AuthorizationConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AuthorizationConfig x -> AuthorizationConfig
$cfrom :: forall x. AuthorizationConfig -> Rep AuthorizationConfig x
Prelude.Generic)
newAuthorizationConfig ::
AuthorizationType ->
AuthorizationConfig
newAuthorizationConfig :: AuthorizationType -> AuthorizationConfig
newAuthorizationConfig AuthorizationType
pAuthorizationType_ =
AuthorizationConfig' :: Maybe AwsIamConfig -> AuthorizationType -> AuthorizationConfig
AuthorizationConfig'
{ $sel:awsIamConfig:AuthorizationConfig' :: Maybe AwsIamConfig
awsIamConfig =
Maybe AwsIamConfig
forall a. Maybe a
Prelude.Nothing,
$sel:authorizationType:AuthorizationConfig' :: AuthorizationType
authorizationType = AuthorizationType
pAuthorizationType_
}
authorizationConfig_awsIamConfig :: Lens.Lens' AuthorizationConfig (Prelude.Maybe AwsIamConfig)
authorizationConfig_awsIamConfig :: (Maybe AwsIamConfig -> f (Maybe AwsIamConfig))
-> AuthorizationConfig -> f AuthorizationConfig
authorizationConfig_awsIamConfig = (AuthorizationConfig -> Maybe AwsIamConfig)
-> (AuthorizationConfig
-> Maybe AwsIamConfig -> AuthorizationConfig)
-> Lens
AuthorizationConfig
AuthorizationConfig
(Maybe AwsIamConfig)
(Maybe AwsIamConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthorizationConfig' {Maybe AwsIamConfig
awsIamConfig :: Maybe AwsIamConfig
$sel:awsIamConfig:AuthorizationConfig' :: AuthorizationConfig -> Maybe AwsIamConfig
awsIamConfig} -> Maybe AwsIamConfig
awsIamConfig) (\s :: AuthorizationConfig
s@AuthorizationConfig' {} Maybe AwsIamConfig
a -> AuthorizationConfig
s {$sel:awsIamConfig:AuthorizationConfig' :: Maybe AwsIamConfig
awsIamConfig = Maybe AwsIamConfig
a} :: AuthorizationConfig)
authorizationConfig_authorizationType :: Lens.Lens' AuthorizationConfig AuthorizationType
authorizationConfig_authorizationType :: (AuthorizationType -> f AuthorizationType)
-> AuthorizationConfig -> f AuthorizationConfig
authorizationConfig_authorizationType = (AuthorizationConfig -> AuthorizationType)
-> (AuthorizationConfig
-> AuthorizationType -> AuthorizationConfig)
-> Lens
AuthorizationConfig
AuthorizationConfig
AuthorizationType
AuthorizationType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthorizationConfig' {AuthorizationType
authorizationType :: AuthorizationType
$sel:authorizationType:AuthorizationConfig' :: AuthorizationConfig -> AuthorizationType
authorizationType} -> AuthorizationType
authorizationType) (\s :: AuthorizationConfig
s@AuthorizationConfig' {} AuthorizationType
a -> AuthorizationConfig
s {$sel:authorizationType:AuthorizationConfig' :: AuthorizationType
authorizationType = AuthorizationType
a} :: AuthorizationConfig)
instance Core.FromJSON AuthorizationConfig where
parseJSON :: Value -> Parser AuthorizationConfig
parseJSON =
String
-> (Object -> Parser AuthorizationConfig)
-> Value
-> Parser AuthorizationConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"AuthorizationConfig"
( \Object
x ->
Maybe AwsIamConfig -> AuthorizationType -> AuthorizationConfig
AuthorizationConfig'
(Maybe AwsIamConfig -> AuthorizationType -> AuthorizationConfig)
-> Parser (Maybe AwsIamConfig)
-> Parser (AuthorizationType -> AuthorizationConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AwsIamConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"awsIamConfig")
Parser (AuthorizationType -> AuthorizationConfig)
-> Parser AuthorizationType -> Parser AuthorizationConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser AuthorizationType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"authorizationType")
)
instance Prelude.Hashable AuthorizationConfig
instance Prelude.NFData AuthorizationConfig
instance Core.ToJSON AuthorizationConfig where
toJSON :: AuthorizationConfig -> Value
toJSON AuthorizationConfig' {Maybe AwsIamConfig
AuthorizationType
authorizationType :: AuthorizationType
awsIamConfig :: Maybe AwsIamConfig
$sel:authorizationType:AuthorizationConfig' :: AuthorizationConfig -> AuthorizationType
$sel:awsIamConfig:AuthorizationConfig' :: AuthorizationConfig -> Maybe AwsIamConfig
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"awsIamConfig" Text -> AwsIamConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AwsIamConfig -> Pair) -> Maybe AwsIamConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AwsIamConfig
awsIamConfig,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"authorizationType" Text -> AuthorizationType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AuthorizationType
authorizationType)
]
)