{-# 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.RetainRule where
import qualified Amazonka.Core as Core
import Amazonka.DLM.Types.RetentionIntervalUnitValues
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data RetainRule = RetainRule'
{
RetainRule -> Maybe Natural
count :: Prelude.Maybe Prelude.Natural,
RetainRule -> Maybe Natural
interval :: Prelude.Maybe Prelude.Natural,
RetainRule -> Maybe RetentionIntervalUnitValues
intervalUnit :: Prelude.Maybe RetentionIntervalUnitValues
}
deriving (RetainRule -> RetainRule -> Bool
(RetainRule -> RetainRule -> Bool)
-> (RetainRule -> RetainRule -> Bool) -> Eq RetainRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RetainRule -> RetainRule -> Bool
$c/= :: RetainRule -> RetainRule -> Bool
== :: RetainRule -> RetainRule -> Bool
$c== :: RetainRule -> RetainRule -> Bool
Prelude.Eq, ReadPrec [RetainRule]
ReadPrec RetainRule
Int -> ReadS RetainRule
ReadS [RetainRule]
(Int -> ReadS RetainRule)
-> ReadS [RetainRule]
-> ReadPrec RetainRule
-> ReadPrec [RetainRule]
-> Read RetainRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RetainRule]
$creadListPrec :: ReadPrec [RetainRule]
readPrec :: ReadPrec RetainRule
$creadPrec :: ReadPrec RetainRule
readList :: ReadS [RetainRule]
$creadList :: ReadS [RetainRule]
readsPrec :: Int -> ReadS RetainRule
$creadsPrec :: Int -> ReadS RetainRule
Prelude.Read, Int -> RetainRule -> ShowS
[RetainRule] -> ShowS
RetainRule -> String
(Int -> RetainRule -> ShowS)
-> (RetainRule -> String)
-> ([RetainRule] -> ShowS)
-> Show RetainRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RetainRule] -> ShowS
$cshowList :: [RetainRule] -> ShowS
show :: RetainRule -> String
$cshow :: RetainRule -> String
showsPrec :: Int -> RetainRule -> ShowS
$cshowsPrec :: Int -> RetainRule -> ShowS
Prelude.Show, (forall x. RetainRule -> Rep RetainRule x)
-> (forall x. Rep RetainRule x -> RetainRule) -> Generic RetainRule
forall x. Rep RetainRule x -> RetainRule
forall x. RetainRule -> Rep RetainRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RetainRule x -> RetainRule
$cfrom :: forall x. RetainRule -> Rep RetainRule x
Prelude.Generic)
newRetainRule ::
RetainRule
newRetainRule :: RetainRule
newRetainRule =
RetainRule' :: Maybe Natural
-> Maybe Natural -> Maybe RetentionIntervalUnitValues -> RetainRule
RetainRule'
{ $sel:count:RetainRule' :: Maybe Natural
count = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:interval:RetainRule' :: Maybe Natural
interval = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:intervalUnit:RetainRule' :: Maybe RetentionIntervalUnitValues
intervalUnit = Maybe RetentionIntervalUnitValues
forall a. Maybe a
Prelude.Nothing
}
retainRule_count :: Lens.Lens' RetainRule (Prelude.Maybe Prelude.Natural)
retainRule_count :: (Maybe Natural -> f (Maybe Natural)) -> RetainRule -> f RetainRule
retainRule_count = (RetainRule -> Maybe Natural)
-> (RetainRule -> Maybe Natural -> RetainRule)
-> Lens RetainRule RetainRule (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetainRule' {Maybe Natural
count :: Maybe Natural
$sel:count:RetainRule' :: RetainRule -> Maybe Natural
count} -> Maybe Natural
count) (\s :: RetainRule
s@RetainRule' {} Maybe Natural
a -> RetainRule
s {$sel:count:RetainRule' :: Maybe Natural
count = Maybe Natural
a} :: RetainRule)
retainRule_interval :: Lens.Lens' RetainRule (Prelude.Maybe Prelude.Natural)
retainRule_interval :: (Maybe Natural -> f (Maybe Natural)) -> RetainRule -> f RetainRule
retainRule_interval = (RetainRule -> Maybe Natural)
-> (RetainRule -> Maybe Natural -> RetainRule)
-> Lens RetainRule RetainRule (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetainRule' {Maybe Natural
interval :: Maybe Natural
$sel:interval:RetainRule' :: RetainRule -> Maybe Natural
interval} -> Maybe Natural
interval) (\s :: RetainRule
s@RetainRule' {} Maybe Natural
a -> RetainRule
s {$sel:interval:RetainRule' :: Maybe Natural
interval = Maybe Natural
a} :: RetainRule)
retainRule_intervalUnit :: Lens.Lens' RetainRule (Prelude.Maybe RetentionIntervalUnitValues)
retainRule_intervalUnit :: (Maybe RetentionIntervalUnitValues
-> f (Maybe RetentionIntervalUnitValues))
-> RetainRule -> f RetainRule
retainRule_intervalUnit = (RetainRule -> Maybe RetentionIntervalUnitValues)
-> (RetainRule -> Maybe RetentionIntervalUnitValues -> RetainRule)
-> Lens
RetainRule
RetainRule
(Maybe RetentionIntervalUnitValues)
(Maybe RetentionIntervalUnitValues)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetainRule' {Maybe RetentionIntervalUnitValues
intervalUnit :: Maybe RetentionIntervalUnitValues
$sel:intervalUnit:RetainRule' :: RetainRule -> Maybe RetentionIntervalUnitValues
intervalUnit} -> Maybe RetentionIntervalUnitValues
intervalUnit) (\s :: RetainRule
s@RetainRule' {} Maybe RetentionIntervalUnitValues
a -> RetainRule
s {$sel:intervalUnit:RetainRule' :: Maybe RetentionIntervalUnitValues
intervalUnit = Maybe RetentionIntervalUnitValues
a} :: RetainRule)
instance Core.FromJSON RetainRule where
parseJSON :: Value -> Parser RetainRule
parseJSON =
String
-> (Object -> Parser RetainRule) -> Value -> Parser RetainRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"RetainRule"
( \Object
x ->
Maybe Natural
-> Maybe Natural -> Maybe RetentionIntervalUnitValues -> RetainRule
RetainRule'
(Maybe Natural
-> Maybe Natural
-> Maybe RetentionIntervalUnitValues
-> RetainRule)
-> Parser (Maybe Natural)
-> Parser
(Maybe Natural -> Maybe RetentionIntervalUnitValues -> RetainRule)
forall (f :: * -> *) a b. Functor 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
"Count")
Parser
(Maybe Natural -> Maybe RetentionIntervalUnitValues -> RetainRule)
-> Parser (Maybe Natural)
-> Parser (Maybe RetentionIntervalUnitValues -> RetainRule)
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 RetentionIntervalUnitValues -> RetainRule)
-> Parser (Maybe RetentionIntervalUnitValues) -> Parser RetainRule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RetentionIntervalUnitValues)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IntervalUnit")
)
instance Prelude.Hashable RetainRule
instance Prelude.NFData RetainRule
instance Core.ToJSON RetainRule where
toJSON :: RetainRule -> Value
toJSON RetainRule' {Maybe Natural
Maybe RetentionIntervalUnitValues
intervalUnit :: Maybe RetentionIntervalUnitValues
interval :: Maybe Natural
count :: Maybe Natural
$sel:intervalUnit:RetainRule' :: RetainRule -> Maybe RetentionIntervalUnitValues
$sel:interval:RetainRule' :: RetainRule -> Maybe Natural
$sel:count:RetainRule' :: RetainRule -> Maybe Natural
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Count" 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
count,
(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
"IntervalUnit" Text -> RetentionIntervalUnitValues -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (RetentionIntervalUnitValues -> Pair)
-> Maybe RetentionIntervalUnitValues -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RetentionIntervalUnitValues
intervalUnit
]
)