{-# 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.ShareRule 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 ShareRule = ShareRule'
{
ShareRule -> Maybe Natural
unshareInterval :: Prelude.Maybe Prelude.Natural,
ShareRule -> Maybe RetentionIntervalUnitValues
unshareIntervalUnit :: Prelude.Maybe RetentionIntervalUnitValues,
ShareRule -> NonEmpty Text
targetAccounts :: Prelude.NonEmpty Prelude.Text
}
deriving (ShareRule -> ShareRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ShareRule -> ShareRule -> Bool
$c/= :: ShareRule -> ShareRule -> Bool
== :: ShareRule -> ShareRule -> Bool
$c== :: ShareRule -> ShareRule -> Bool
Prelude.Eq, ReadPrec [ShareRule]
ReadPrec ShareRule
Int -> ReadS ShareRule
ReadS [ShareRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ShareRule]
$creadListPrec :: ReadPrec [ShareRule]
readPrec :: ReadPrec ShareRule
$creadPrec :: ReadPrec ShareRule
readList :: ReadS [ShareRule]
$creadList :: ReadS [ShareRule]
readsPrec :: Int -> ReadS ShareRule
$creadsPrec :: Int -> ReadS ShareRule
Prelude.Read, Int -> ShareRule -> ShowS
[ShareRule] -> ShowS
ShareRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ShareRule] -> ShowS
$cshowList :: [ShareRule] -> ShowS
show :: ShareRule -> String
$cshow :: ShareRule -> String
showsPrec :: Int -> ShareRule -> ShowS
$cshowsPrec :: Int -> ShareRule -> ShowS
Prelude.Show, forall x. Rep ShareRule x -> ShareRule
forall x. ShareRule -> Rep ShareRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ShareRule x -> ShareRule
$cfrom :: forall x. ShareRule -> Rep ShareRule x
Prelude.Generic)
newShareRule ::
Prelude.NonEmpty Prelude.Text ->
ShareRule
newShareRule :: NonEmpty Text -> ShareRule
newShareRule NonEmpty Text
pTargetAccounts_ =
ShareRule'
{ $sel:unshareInterval:ShareRule' :: Maybe Natural
unshareInterval = forall a. Maybe a
Prelude.Nothing,
$sel:unshareIntervalUnit:ShareRule' :: Maybe RetentionIntervalUnitValues
unshareIntervalUnit = forall a. Maybe a
Prelude.Nothing,
$sel:targetAccounts:ShareRule' :: NonEmpty Text
targetAccounts =
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pTargetAccounts_
}
shareRule_unshareInterval :: Lens.Lens' ShareRule (Prelude.Maybe Prelude.Natural)
shareRule_unshareInterval :: Lens' ShareRule (Maybe Natural)
shareRule_unshareInterval = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ShareRule' {Maybe Natural
unshareInterval :: Maybe Natural
$sel:unshareInterval:ShareRule' :: ShareRule -> Maybe Natural
unshareInterval} -> Maybe Natural
unshareInterval) (\s :: ShareRule
s@ShareRule' {} Maybe Natural
a -> ShareRule
s {$sel:unshareInterval:ShareRule' :: Maybe Natural
unshareInterval = Maybe Natural
a} :: ShareRule)
shareRule_unshareIntervalUnit :: Lens.Lens' ShareRule (Prelude.Maybe RetentionIntervalUnitValues)
shareRule_unshareIntervalUnit :: Lens' ShareRule (Maybe RetentionIntervalUnitValues)
shareRule_unshareIntervalUnit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ShareRule' {Maybe RetentionIntervalUnitValues
unshareIntervalUnit :: Maybe RetentionIntervalUnitValues
$sel:unshareIntervalUnit:ShareRule' :: ShareRule -> Maybe RetentionIntervalUnitValues
unshareIntervalUnit} -> Maybe RetentionIntervalUnitValues
unshareIntervalUnit) (\s :: ShareRule
s@ShareRule' {} Maybe RetentionIntervalUnitValues
a -> ShareRule
s {$sel:unshareIntervalUnit:ShareRule' :: Maybe RetentionIntervalUnitValues
unshareIntervalUnit = Maybe RetentionIntervalUnitValues
a} :: ShareRule)
shareRule_targetAccounts :: Lens.Lens' ShareRule (Prelude.NonEmpty Prelude.Text)
shareRule_targetAccounts :: Lens' ShareRule (NonEmpty Text)
shareRule_targetAccounts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ShareRule' {NonEmpty Text
targetAccounts :: NonEmpty Text
$sel:targetAccounts:ShareRule' :: ShareRule -> NonEmpty Text
targetAccounts} -> NonEmpty Text
targetAccounts) (\s :: ShareRule
s@ShareRule' {} NonEmpty Text
a -> ShareRule
s {$sel:targetAccounts:ShareRule' :: NonEmpty Text
targetAccounts = NonEmpty Text
a} :: ShareRule) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Data.FromJSON ShareRule where
parseJSON :: Value -> Parser ShareRule
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"ShareRule"
( \Object
x ->
Maybe Natural
-> Maybe RetentionIntervalUnitValues -> NonEmpty Text -> ShareRule
ShareRule'
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
"UnshareInterval")
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
"UnshareIntervalUnit")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"TargetAccounts")
)
instance Prelude.Hashable ShareRule where
hashWithSalt :: Int -> ShareRule -> Int
hashWithSalt Int
_salt ShareRule' {Maybe Natural
Maybe RetentionIntervalUnitValues
NonEmpty Text
targetAccounts :: NonEmpty Text
unshareIntervalUnit :: Maybe RetentionIntervalUnitValues
unshareInterval :: Maybe Natural
$sel:targetAccounts:ShareRule' :: ShareRule -> NonEmpty Text
$sel:unshareIntervalUnit:ShareRule' :: ShareRule -> Maybe RetentionIntervalUnitValues
$sel:unshareInterval:ShareRule' :: ShareRule -> Maybe Natural
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
unshareInterval
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RetentionIntervalUnitValues
unshareIntervalUnit
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
targetAccounts
instance Prelude.NFData ShareRule where
rnf :: ShareRule -> ()
rnf ShareRule' {Maybe Natural
Maybe RetentionIntervalUnitValues
NonEmpty Text
targetAccounts :: NonEmpty Text
unshareIntervalUnit :: Maybe RetentionIntervalUnitValues
unshareInterval :: Maybe Natural
$sel:targetAccounts:ShareRule' :: ShareRule -> NonEmpty Text
$sel:unshareIntervalUnit:ShareRule' :: ShareRule -> Maybe RetentionIntervalUnitValues
$sel:unshareInterval:ShareRule' :: ShareRule -> Maybe Natural
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
unshareInterval
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RetentionIntervalUnitValues
unshareIntervalUnit
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
targetAccounts
instance Data.ToJSON ShareRule where
toJSON :: ShareRule -> Value
toJSON ShareRule' {Maybe Natural
Maybe RetentionIntervalUnitValues
NonEmpty Text
targetAccounts :: NonEmpty Text
unshareIntervalUnit :: Maybe RetentionIntervalUnitValues
unshareInterval :: Maybe Natural
$sel:targetAccounts:ShareRule' :: ShareRule -> NonEmpty Text
$sel:unshareIntervalUnit:ShareRule' :: ShareRule -> Maybe RetentionIntervalUnitValues
$sel:unshareInterval:ShareRule' :: ShareRule -> Maybe Natural
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"UnshareInterval" 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
unshareInterval,
(Key
"UnshareIntervalUnit" 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
unshareIntervalUnit,
forall a. a -> Maybe a
Prelude.Just
(Key
"TargetAccounts" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
targetAccounts)
]
)