{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE NamedFieldPuns #-}
module AWS.Lambda.Events.EventBridge.Detail.SSM.ParameterStoreChange
( ParameterStoreChange (..),
Operation (.., Create, Update, Delete, LabelParameterVersion),
Type (..),
)
where
import Data.Aeson
( FromJSON (..),
ToJSON (..),
object,
pairs,
withObject,
withText,
(.:),
(.:?),
(.=),
)
import qualified Data.Aeson as Aeson
import Data.Aeson.Encoding (text)
import Data.Text (Text)
import GHC.Generics (Generic)
data ParameterStoreChange = ParameterStoreChange
{ ParameterStoreChange -> Operation
operation :: Operation,
ParameterStoreChange -> Text
name :: Text,
ParameterStoreChange -> Type
type_ :: Type,
ParameterStoreChange -> Maybe Text
description :: Maybe Text
}
deriving (ParameterStoreChange -> ParameterStoreChange -> Bool
(ParameterStoreChange -> ParameterStoreChange -> Bool)
-> (ParameterStoreChange -> ParameterStoreChange -> Bool)
-> Eq ParameterStoreChange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParameterStoreChange -> ParameterStoreChange -> Bool
$c/= :: ParameterStoreChange -> ParameterStoreChange -> Bool
== :: ParameterStoreChange -> ParameterStoreChange -> Bool
$c== :: ParameterStoreChange -> ParameterStoreChange -> Bool
Eq, Int -> ParameterStoreChange -> ShowS
[ParameterStoreChange] -> ShowS
ParameterStoreChange -> String
(Int -> ParameterStoreChange -> ShowS)
-> (ParameterStoreChange -> String)
-> ([ParameterStoreChange] -> ShowS)
-> Show ParameterStoreChange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ParameterStoreChange] -> ShowS
$cshowList :: [ParameterStoreChange] -> ShowS
show :: ParameterStoreChange -> String
$cshow :: ParameterStoreChange -> String
showsPrec :: Int -> ParameterStoreChange -> ShowS
$cshowsPrec :: Int -> ParameterStoreChange -> ShowS
Show, (forall x. ParameterStoreChange -> Rep ParameterStoreChange x)
-> (forall x. Rep ParameterStoreChange x -> ParameterStoreChange)
-> Generic ParameterStoreChange
forall x. Rep ParameterStoreChange x -> ParameterStoreChange
forall x. ParameterStoreChange -> Rep ParameterStoreChange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ParameterStoreChange x -> ParameterStoreChange
$cfrom :: forall x. ParameterStoreChange -> Rep ParameterStoreChange x
Generic)
instance FromJSON ParameterStoreChange where
parseJSON :: Value -> Parser ParameterStoreChange
parseJSON = String
-> (Object -> Parser ParameterStoreChange)
-> Value
-> Parser ParameterStoreChange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ParameterStoreChange" ((Object -> Parser ParameterStoreChange)
-> Value -> Parser ParameterStoreChange)
-> (Object -> Parser ParameterStoreChange)
-> Value
-> Parser ParameterStoreChange
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Operation
operation <- Object
o Object -> Key -> Parser Operation
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"operation"
Text
name <- Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"name"
Type
type_ <- Object
o Object -> Key -> Parser Type
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"type"
Maybe Text
description <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"description"
pure
ParameterStoreChange :: Operation -> Text -> Type -> Maybe Text -> ParameterStoreChange
ParameterStoreChange
{ Operation
operation :: Operation
$sel:operation:ParameterStoreChange :: Operation
operation,
Text
name :: Text
$sel:name:ParameterStoreChange :: Text
name,
Type
type_ :: Type
$sel:type_:ParameterStoreChange :: Type
type_,
Maybe Text
description :: Maybe Text
$sel:description:ParameterStoreChange :: Maybe Text
description
}
instance ToJSON ParameterStoreChange where
toJSON :: ParameterStoreChange -> Value
toJSON ParameterStoreChange
change =
[Pair] -> Value
object
[ Key
"operation" Key -> Operation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ParameterStoreChange -> Operation
operation ParameterStoreChange
change,
Key
"name" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ParameterStoreChange -> Text
name ParameterStoreChange
change,
Key
"type" Key -> Type -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ParameterStoreChange -> Type
type_ ParameterStoreChange
change,
Key
"description" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ParameterStoreChange -> Maybe Text
description ParameterStoreChange
change
]
toEncoding :: ParameterStoreChange -> Encoding
toEncoding ParameterStoreChange
change =
Series -> Encoding
pairs (Series -> Encoding) -> Series -> Encoding
forall a b. (a -> b) -> a -> b
$
[Series] -> Series
forall a. Monoid a => [a] -> a
mconcat
[ Key
"operation" Key -> Operation -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ParameterStoreChange -> Operation
operation ParameterStoreChange
change,
Key
"name" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ParameterStoreChange -> Text
name ParameterStoreChange
change,
Key
"type" Key -> Type -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ParameterStoreChange -> Type
type_ ParameterStoreChange
change,
Key
"description" Key -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ParameterStoreChange -> Maybe Text
description ParameterStoreChange
change
]
newtype Operation = Operation Text deriving (Operation -> Operation -> Bool
(Operation -> Operation -> Bool)
-> (Operation -> Operation -> Bool) -> Eq Operation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Operation -> Operation -> Bool
$c/= :: Operation -> Operation -> Bool
== :: Operation -> Operation -> Bool
$c== :: Operation -> Operation -> Bool
Eq, Int -> Operation -> ShowS
[Operation] -> ShowS
Operation -> String
(Int -> Operation -> ShowS)
-> (Operation -> String)
-> ([Operation] -> ShowS)
-> Show Operation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Operation] -> ShowS
$cshowList :: [Operation] -> ShowS
show :: Operation -> String
$cshow :: Operation -> String
showsPrec :: Int -> Operation -> ShowS
$cshowsPrec :: Int -> Operation -> ShowS
Show, (forall x. Operation -> Rep Operation x)
-> (forall x. Rep Operation x -> Operation) -> Generic Operation
forall x. Rep Operation x -> Operation
forall x. Operation -> Rep Operation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Operation x -> Operation
$cfrom :: forall x. Operation -> Rep Operation x
Generic)
pattern Create :: Operation
pattern $bCreate :: Operation
$mCreate :: forall r. Operation -> (Void# -> r) -> (Void# -> r) -> r
Create = Operation "Create"
pattern Update :: Operation
pattern $bUpdate :: Operation
$mUpdate :: forall r. Operation -> (Void# -> r) -> (Void# -> r) -> r
Update = Operation "Update"
pattern Delete :: Operation
pattern $bDelete :: Operation
$mDelete :: forall r. Operation -> (Void# -> r) -> (Void# -> r) -> r
Delete = Operation "Delete"
pattern LabelParameterVersion :: Operation
pattern $bLabelParameterVersion :: Operation
$mLabelParameterVersion :: forall r. Operation -> (Void# -> r) -> (Void# -> r) -> r
LabelParameterVersion = Operation "LabelParameterVersion"
{-# COMPLETE Create, Update, Delete, LabelParameterVersion #-}
instance FromJSON Operation where
parseJSON :: Value -> Parser Operation
parseJSON = String -> (Text -> Parser Operation) -> Value -> Parser Operation
forall a. String -> (Text -> Parser a) -> Value -> Parser a
withText String
"Operation" ((Text -> Parser Operation) -> Value -> Parser Operation)
-> (Text -> Parser Operation) -> Value -> Parser Operation
forall a b. (a -> b) -> a -> b
$ Operation -> Parser Operation
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Operation -> Parser Operation)
-> (Text -> Operation) -> Text -> Parser Operation
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Operation
Operation
instance ToJSON Operation where
toJSON :: Operation -> Value
toJSON (Operation Text
op) = Text -> Value
Aeson.String Text
op
toEncoding :: Operation -> Encoding
toEncoding (Operation Text
op) = Text -> Encoding
forall a. Text -> Encoding' a
text Text
op
data Type = String | StringList | SecureString
deriving (Type -> Type -> Bool
(Type -> Type -> Bool) -> (Type -> Type -> Bool) -> Eq Type
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Type -> Type -> Bool
$c/= :: Type -> Type -> Bool
== :: Type -> Type -> Bool
$c== :: Type -> Type -> Bool
Eq, Eq Type
Eq Type
-> (Type -> Type -> Ordering)
-> (Type -> Type -> Bool)
-> (Type -> Type -> Bool)
-> (Type -> Type -> Bool)
-> (Type -> Type -> Bool)
-> (Type -> Type -> Type)
-> (Type -> Type -> Type)
-> Ord Type
Type -> Type -> Bool
Type -> Type -> Ordering
Type -> Type -> Type
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Type -> Type -> Type
$cmin :: Type -> Type -> Type
max :: Type -> Type -> Type
$cmax :: Type -> Type -> Type
>= :: Type -> Type -> Bool
$c>= :: Type -> Type -> Bool
> :: Type -> Type -> Bool
$c> :: Type -> Type -> Bool
<= :: Type -> Type -> Bool
$c<= :: Type -> Type -> Bool
< :: Type -> Type -> Bool
$c< :: Type -> Type -> Bool
compare :: Type -> Type -> Ordering
$ccompare :: Type -> Type -> Ordering
$cp1Ord :: Eq Type
Ord, Int -> Type -> ShowS
[Type] -> ShowS
Type -> String
(Int -> Type -> ShowS)
-> (Type -> String) -> ([Type] -> ShowS) -> Show Type
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Type] -> ShowS
$cshowList :: [Type] -> ShowS
show :: Type -> String
$cshow :: Type -> String
showsPrec :: Int -> Type -> ShowS
$cshowsPrec :: Int -> Type -> ShowS
Show, Int -> Type
Type -> Int
Type -> [Type]
Type -> Type
Type -> Type -> [Type]
Type -> Type -> Type -> [Type]
(Type -> Type)
-> (Type -> Type)
-> (Int -> Type)
-> (Type -> Int)
-> (Type -> [Type])
-> (Type -> Type -> [Type])
-> (Type -> Type -> [Type])
-> (Type -> Type -> Type -> [Type])
-> Enum Type
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Type -> Type -> Type -> [Type]
$cenumFromThenTo :: Type -> Type -> Type -> [Type]
enumFromTo :: Type -> Type -> [Type]
$cenumFromTo :: Type -> Type -> [Type]
enumFromThen :: Type -> Type -> [Type]
$cenumFromThen :: Type -> Type -> [Type]
enumFrom :: Type -> [Type]
$cenumFrom :: Type -> [Type]
fromEnum :: Type -> Int
$cfromEnum :: Type -> Int
toEnum :: Int -> Type
$ctoEnum :: Int -> Type
pred :: Type -> Type
$cpred :: Type -> Type
succ :: Type -> Type
$csucc :: Type -> Type
Enum, Type
Type -> Type -> Bounded Type
forall a. a -> a -> Bounded a
maxBound :: Type
$cmaxBound :: Type
minBound :: Type
$cminBound :: Type
Bounded, (forall x. Type -> Rep Type x)
-> (forall x. Rep Type x -> Type) -> Generic Type
forall x. Rep Type x -> Type
forall x. Type -> Rep Type x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Type x -> Type
$cfrom :: forall x. Type -> Rep Type x
Generic)
instance FromJSON Type where
parseJSON :: Value -> Parser Type
parseJSON = String -> (Text -> Parser Type) -> Value -> Parser Type
forall a. String -> (Text -> Parser a) -> Value -> Parser a
withText String
"Type" ((Text -> Parser Type) -> Value -> Parser Type)
-> (Text -> Parser Type) -> Value -> Parser Type
forall a b. (a -> b) -> a -> b
$ \case
Text
"String" -> Type -> Parser Type
forall (f :: * -> *) a. Applicative f => a -> f a
pure Type
String
Text
"StringList" -> Type -> Parser Type
forall (f :: * -> *) a. Applicative f => a -> f a
pure Type
StringList
Text
"SecureString" -> Type -> Parser Type
forall (f :: * -> *) a. Applicative f => a -> f a
pure Type
SecureString
Text
t -> String -> Parser Type
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser Type) -> String -> Parser Type
forall a b. (a -> b) -> a -> b
$ String
"Unrecognised type: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
t
instance ToJSON Type where
toJSON :: Type -> Value
toJSON =
Text -> Value
Aeson.String (Text -> Value) -> (Type -> Text) -> Type -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \case
Type
String -> Text
"String"
Type
StringList -> Text
"StringList"
Type
SecureString -> Text
"SecureString"
toEncoding :: Type -> Encoding
toEncoding =
Text -> Encoding
forall a. Text -> Encoding' a
text (Text -> Encoding) -> (Type -> Text) -> Type -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \case
Type
String -> Text
"String"
Type
StringList -> Text
"StringList"
Type
SecureString -> Text
"SecureString"