{-# 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.DLM.Types.CreateRule where
import qualified Amazonka.Core as Core
import Amazonka.DLM.Types.IntervalUnitValues
import Amazonka.DLM.Types.LocationValues
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data CreateRule = CreateRule'
{
CreateRule -> Maybe LocationValues
location :: Prelude.Maybe LocationValues,
CreateRule -> Maybe Natural
interval :: Prelude.Maybe Prelude.Natural,
CreateRule -> Maybe Text
cronExpression :: Prelude.Maybe Prelude.Text,
CreateRule -> Maybe [Text]
times :: Prelude.Maybe [Prelude.Text],
CreateRule -> Maybe IntervalUnitValues
intervalUnit :: Prelude.Maybe IntervalUnitValues
}
deriving (CreateRule -> CreateRule -> Bool
(CreateRule -> CreateRule -> Bool)
-> (CreateRule -> CreateRule -> Bool) -> Eq CreateRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRule -> CreateRule -> Bool
$c/= :: CreateRule -> CreateRule -> Bool
== :: CreateRule -> CreateRule -> Bool
$c== :: CreateRule -> CreateRule -> Bool
Prelude.Eq, ReadPrec [CreateRule]
ReadPrec CreateRule
Int -> ReadS CreateRule
ReadS [CreateRule]
(Int -> ReadS CreateRule)
-> ReadS [CreateRule]
-> ReadPrec CreateRule
-> ReadPrec [CreateRule]
-> Read CreateRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRule]
$creadListPrec :: ReadPrec [CreateRule]
readPrec :: ReadPrec CreateRule
$creadPrec :: ReadPrec CreateRule
readList :: ReadS [CreateRule]
$creadList :: ReadS [CreateRule]
readsPrec :: Int -> ReadS CreateRule
$creadsPrec :: Int -> ReadS CreateRule
Prelude.Read, Int -> CreateRule -> ShowS
[CreateRule] -> ShowS
CreateRule -> String
(Int -> CreateRule -> ShowS)
-> (CreateRule -> String)
-> ([CreateRule] -> ShowS)
-> Show CreateRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRule] -> ShowS
$cshowList :: [CreateRule] -> ShowS
show :: CreateRule -> String
$cshow :: CreateRule -> String
showsPrec :: Int -> CreateRule -> ShowS
$cshowsPrec :: Int -> CreateRule -> ShowS
Prelude.Show, (forall x. CreateRule -> Rep CreateRule x)
-> (forall x. Rep CreateRule x -> CreateRule) -> Generic CreateRule
forall x. Rep CreateRule x -> CreateRule
forall x. CreateRule -> Rep CreateRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRule x -> CreateRule
$cfrom :: forall x. CreateRule -> Rep CreateRule x
Prelude.Generic)
newCreateRule ::
CreateRule
newCreateRule :: CreateRule
newCreateRule =
CreateRule' :: Maybe LocationValues
-> Maybe Natural
-> Maybe Text
-> Maybe [Text]
-> Maybe IntervalUnitValues
-> CreateRule
CreateRule'
{ $sel:location:CreateRule' :: Maybe LocationValues
location = Maybe LocationValues
forall a. Maybe a
Prelude.Nothing,
$sel:interval:CreateRule' :: Maybe Natural
interval = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:cronExpression:CreateRule' :: Maybe Text
cronExpression = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:times:CreateRule' :: Maybe [Text]
times = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:intervalUnit:CreateRule' :: Maybe IntervalUnitValues
intervalUnit = Maybe IntervalUnitValues
forall a. Maybe a
Prelude.Nothing
}
createRule_location :: Lens.Lens' CreateRule (Prelude.Maybe LocationValues)
createRule_location :: (Maybe LocationValues -> f (Maybe LocationValues))
-> CreateRule -> f CreateRule
createRule_location = (CreateRule -> Maybe LocationValues)
-> (CreateRule -> Maybe LocationValues -> CreateRule)
-> Lens
CreateRule CreateRule (Maybe LocationValues) (Maybe LocationValues)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {Maybe LocationValues
location :: Maybe LocationValues
$sel:location:CreateRule' :: CreateRule -> Maybe LocationValues
location} -> Maybe LocationValues
location) (\s :: CreateRule
s@CreateRule' {} Maybe LocationValues
a -> CreateRule
s {$sel:location:CreateRule' :: Maybe LocationValues
location = Maybe LocationValues
a} :: CreateRule)
createRule_interval :: Lens.Lens' CreateRule (Prelude.Maybe Prelude.Natural)
createRule_interval :: (Maybe Natural -> f (Maybe Natural)) -> CreateRule -> f CreateRule
createRule_interval = (CreateRule -> Maybe Natural)
-> (CreateRule -> Maybe Natural -> CreateRule)
-> Lens CreateRule CreateRule (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {Maybe Natural
interval :: Maybe Natural
$sel:interval:CreateRule' :: CreateRule -> Maybe Natural
interval} -> Maybe Natural
interval) (\s :: CreateRule
s@CreateRule' {} Maybe Natural
a -> CreateRule
s {$sel:interval:CreateRule' :: Maybe Natural
interval = Maybe Natural
a} :: CreateRule)
createRule_cronExpression :: Lens.Lens' CreateRule (Prelude.Maybe Prelude.Text)
createRule_cronExpression :: (Maybe Text -> f (Maybe Text)) -> CreateRule -> f CreateRule
createRule_cronExpression = (CreateRule -> Maybe Text)
-> (CreateRule -> Maybe Text -> CreateRule)
-> Lens CreateRule CreateRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {Maybe Text
cronExpression :: Maybe Text
$sel:cronExpression:CreateRule' :: CreateRule -> Maybe Text
cronExpression} -> Maybe Text
cronExpression) (\s :: CreateRule
s@CreateRule' {} Maybe Text
a -> CreateRule
s {$sel:cronExpression:CreateRule' :: Maybe Text
cronExpression = Maybe Text
a} :: CreateRule)
createRule_times :: Lens.Lens' CreateRule (Prelude.Maybe [Prelude.Text])
createRule_times :: (Maybe [Text] -> f (Maybe [Text])) -> CreateRule -> f CreateRule
createRule_times = (CreateRule -> Maybe [Text])
-> (CreateRule -> Maybe [Text] -> CreateRule)
-> Lens CreateRule CreateRule (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {Maybe [Text]
times :: Maybe [Text]
$sel:times:CreateRule' :: CreateRule -> Maybe [Text]
times} -> Maybe [Text]
times) (\s :: CreateRule
s@CreateRule' {} Maybe [Text]
a -> CreateRule
s {$sel:times:CreateRule' :: Maybe [Text]
times = Maybe [Text]
a} :: CreateRule) ((Maybe [Text] -> f (Maybe [Text])) -> CreateRule -> f CreateRule)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateRule
-> f CreateRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createRule_intervalUnit :: Lens.Lens' CreateRule (Prelude.Maybe IntervalUnitValues)
createRule_intervalUnit :: (Maybe IntervalUnitValues -> f (Maybe IntervalUnitValues))
-> CreateRule -> f CreateRule
createRule_intervalUnit = (CreateRule -> Maybe IntervalUnitValues)
-> (CreateRule -> Maybe IntervalUnitValues -> CreateRule)
-> Lens
CreateRule
CreateRule
(Maybe IntervalUnitValues)
(Maybe IntervalUnitValues)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {Maybe IntervalUnitValues
intervalUnit :: Maybe IntervalUnitValues
$sel:intervalUnit:CreateRule' :: CreateRule -> Maybe IntervalUnitValues
intervalUnit} -> Maybe IntervalUnitValues
intervalUnit) (\s :: CreateRule
s@CreateRule' {} Maybe IntervalUnitValues
a -> CreateRule
s {$sel:intervalUnit:CreateRule' :: Maybe IntervalUnitValues
intervalUnit = Maybe IntervalUnitValues
a} :: CreateRule)
instance Core.FromJSON CreateRule where
parseJSON :: Value -> Parser CreateRule
parseJSON =
String
-> (Object -> Parser CreateRule) -> Value -> Parser CreateRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"CreateRule"
( \Object
x ->
Maybe LocationValues
-> Maybe Natural
-> Maybe Text
-> Maybe [Text]
-> Maybe IntervalUnitValues
-> CreateRule
CreateRule'
(Maybe LocationValues
-> Maybe Natural
-> Maybe Text
-> Maybe [Text]
-> Maybe IntervalUnitValues
-> CreateRule)
-> Parser (Maybe LocationValues)
-> Parser
(Maybe Natural
-> Maybe Text
-> Maybe [Text]
-> Maybe IntervalUnitValues
-> CreateRule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe LocationValues)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Location")
Parser
(Maybe Natural
-> Maybe Text
-> Maybe [Text]
-> Maybe IntervalUnitValues
-> CreateRule)
-> Parser (Maybe Natural)
-> Parser
(Maybe Text
-> Maybe [Text] -> Maybe IntervalUnitValues -> CreateRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Interval")
Parser
(Maybe Text
-> Maybe [Text] -> Maybe IntervalUnitValues -> CreateRule)
-> Parser (Maybe Text)
-> Parser (Maybe [Text] -> Maybe IntervalUnitValues -> CreateRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CronExpression")
Parser (Maybe [Text] -> Maybe IntervalUnitValues -> CreateRule)
-> Parser (Maybe [Text])
-> Parser (Maybe IntervalUnitValues -> CreateRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Times" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
Parser (Maybe IntervalUnitValues -> CreateRule)
-> Parser (Maybe IntervalUnitValues) -> Parser CreateRule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe IntervalUnitValues)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IntervalUnit")
)
instance Prelude.Hashable CreateRule
instance Prelude.NFData CreateRule
instance Core.ToJSON CreateRule where
toJSON :: CreateRule -> Value
toJSON CreateRule' {Maybe Natural
Maybe [Text]
Maybe Text
Maybe IntervalUnitValues
Maybe LocationValues
intervalUnit :: Maybe IntervalUnitValues
times :: Maybe [Text]
cronExpression :: Maybe Text
interval :: Maybe Natural
location :: Maybe LocationValues
$sel:intervalUnit:CreateRule' :: CreateRule -> Maybe IntervalUnitValues
$sel:times:CreateRule' :: CreateRule -> Maybe [Text]
$sel:cronExpression:CreateRule' :: CreateRule -> Maybe Text
$sel:interval:CreateRule' :: CreateRule -> Maybe Natural
$sel:location:CreateRule' :: CreateRule -> Maybe LocationValues
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Location" Text -> LocationValues -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LocationValues -> Pair) -> Maybe LocationValues -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LocationValues
location,
(Text
"Interval" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
interval,
(Text
"CronExpression" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
cronExpression,
(Text
"Times" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
times,
(Text
"IntervalUnit" Text -> IntervalUnitValues -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (IntervalUnitValues -> Pair)
-> Maybe IntervalUnitValues -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe IntervalUnitValues
intervalUnit
]
)