{-# 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 qualified Amazonka.Core.Lens.Internal as Lens
import Amazonka.DLM.Types.RetentionIntervalUnitValues
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
{ $sel:count:RetainRule' :: Maybe Natural
count = forall a. Maybe a
Prelude.Nothing,
$sel:interval:RetainRule' :: Maybe Natural
interval = forall a. Maybe a
Prelude.Nothing,
$sel:intervalUnit:RetainRule' :: Maybe RetentionIntervalUnitValues
intervalUnit = forall a. Maybe a
Prelude.Nothing
}
retainRule_count :: Lens.Lens' RetainRule (Prelude.Maybe Prelude.Natural)
retainRule_count :: Lens' RetainRule (Maybe Natural)
retainRule_count = 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 :: Lens' RetainRule (Maybe Natural)
retainRule_interval = 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 :: Lens' RetainRule (Maybe RetentionIntervalUnitValues)
retainRule_intervalUnit = 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 Data.FromJSON RetainRule where
parseJSON :: Value -> Parser RetainRule
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"RetainRule"
( \Object
x ->
Maybe Natural
-> Maybe Natural -> Maybe RetentionIntervalUnitValues -> RetainRule
RetainRule'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Count")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Interval")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"IntervalUnit")
)
instance Prelude.Hashable RetainRule where
hashWithSalt :: Int -> RetainRule -> Int
hashWithSalt Int
_salt 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
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
count
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
interval
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RetentionIntervalUnitValues
intervalUnit
instance Prelude.NFData RetainRule where
rnf :: RetainRule -> ()
rnf 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
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
count
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
interval
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RetentionIntervalUnitValues
intervalUnit
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"Count" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
count,
(Key
"Interval" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
interval,
(Key
"IntervalUnit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RetentionIntervalUnitValues
intervalUnit
]
)