{-# 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.S3.Types.DefaultRetention where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.S3.Internal
import Amazonka.S3.Types.ObjectLockRetentionMode
data DefaultRetention = DefaultRetention'
{
DefaultRetention -> Maybe Int
days :: Prelude.Maybe Prelude.Int,
DefaultRetention -> Maybe ObjectLockRetentionMode
mode :: Prelude.Maybe ObjectLockRetentionMode,
DefaultRetention -> Maybe Int
years :: Prelude.Maybe Prelude.Int
}
deriving (DefaultRetention -> DefaultRetention -> Bool
(DefaultRetention -> DefaultRetention -> Bool)
-> (DefaultRetention -> DefaultRetention -> Bool)
-> Eq DefaultRetention
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DefaultRetention -> DefaultRetention -> Bool
$c/= :: DefaultRetention -> DefaultRetention -> Bool
== :: DefaultRetention -> DefaultRetention -> Bool
$c== :: DefaultRetention -> DefaultRetention -> Bool
Prelude.Eq, ReadPrec [DefaultRetention]
ReadPrec DefaultRetention
Int -> ReadS DefaultRetention
ReadS [DefaultRetention]
(Int -> ReadS DefaultRetention)
-> ReadS [DefaultRetention]
-> ReadPrec DefaultRetention
-> ReadPrec [DefaultRetention]
-> Read DefaultRetention
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DefaultRetention]
$creadListPrec :: ReadPrec [DefaultRetention]
readPrec :: ReadPrec DefaultRetention
$creadPrec :: ReadPrec DefaultRetention
readList :: ReadS [DefaultRetention]
$creadList :: ReadS [DefaultRetention]
readsPrec :: Int -> ReadS DefaultRetention
$creadsPrec :: Int -> ReadS DefaultRetention
Prelude.Read, Int -> DefaultRetention -> ShowS
[DefaultRetention] -> ShowS
DefaultRetention -> String
(Int -> DefaultRetention -> ShowS)
-> (DefaultRetention -> String)
-> ([DefaultRetention] -> ShowS)
-> Show DefaultRetention
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DefaultRetention] -> ShowS
$cshowList :: [DefaultRetention] -> ShowS
show :: DefaultRetention -> String
$cshow :: DefaultRetention -> String
showsPrec :: Int -> DefaultRetention -> ShowS
$cshowsPrec :: Int -> DefaultRetention -> ShowS
Prelude.Show, (forall x. DefaultRetention -> Rep DefaultRetention x)
-> (forall x. Rep DefaultRetention x -> DefaultRetention)
-> Generic DefaultRetention
forall x. Rep DefaultRetention x -> DefaultRetention
forall x. DefaultRetention -> Rep DefaultRetention x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DefaultRetention x -> DefaultRetention
$cfrom :: forall x. DefaultRetention -> Rep DefaultRetention x
Prelude.Generic)
newDefaultRetention ::
DefaultRetention
newDefaultRetention :: DefaultRetention
newDefaultRetention =
DefaultRetention' :: Maybe Int
-> Maybe ObjectLockRetentionMode -> Maybe Int -> DefaultRetention
DefaultRetention'
{ $sel:days:DefaultRetention' :: Maybe Int
days = Maybe Int
forall a. Maybe a
Prelude.Nothing,
$sel:mode:DefaultRetention' :: Maybe ObjectLockRetentionMode
mode = Maybe ObjectLockRetentionMode
forall a. Maybe a
Prelude.Nothing,
$sel:years:DefaultRetention' :: Maybe Int
years = Maybe Int
forall a. Maybe a
Prelude.Nothing
}
defaultRetention_days :: Lens.Lens' DefaultRetention (Prelude.Maybe Prelude.Int)
defaultRetention_days :: (Maybe Int -> f (Maybe Int))
-> DefaultRetention -> f DefaultRetention
defaultRetention_days = (DefaultRetention -> Maybe Int)
-> (DefaultRetention -> Maybe Int -> DefaultRetention)
-> Lens DefaultRetention DefaultRetention (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DefaultRetention' {Maybe Int
days :: Maybe Int
$sel:days:DefaultRetention' :: DefaultRetention -> Maybe Int
days} -> Maybe Int
days) (\s :: DefaultRetention
s@DefaultRetention' {} Maybe Int
a -> DefaultRetention
s {$sel:days:DefaultRetention' :: Maybe Int
days = Maybe Int
a} :: DefaultRetention)
defaultRetention_mode :: Lens.Lens' DefaultRetention (Prelude.Maybe ObjectLockRetentionMode)
defaultRetention_mode :: (Maybe ObjectLockRetentionMode
-> f (Maybe ObjectLockRetentionMode))
-> DefaultRetention -> f DefaultRetention
defaultRetention_mode = (DefaultRetention -> Maybe ObjectLockRetentionMode)
-> (DefaultRetention
-> Maybe ObjectLockRetentionMode -> DefaultRetention)
-> Lens
DefaultRetention
DefaultRetention
(Maybe ObjectLockRetentionMode)
(Maybe ObjectLockRetentionMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DefaultRetention' {Maybe ObjectLockRetentionMode
mode :: Maybe ObjectLockRetentionMode
$sel:mode:DefaultRetention' :: DefaultRetention -> Maybe ObjectLockRetentionMode
mode} -> Maybe ObjectLockRetentionMode
mode) (\s :: DefaultRetention
s@DefaultRetention' {} Maybe ObjectLockRetentionMode
a -> DefaultRetention
s {$sel:mode:DefaultRetention' :: Maybe ObjectLockRetentionMode
mode = Maybe ObjectLockRetentionMode
a} :: DefaultRetention)
defaultRetention_years :: Lens.Lens' DefaultRetention (Prelude.Maybe Prelude.Int)
defaultRetention_years :: (Maybe Int -> f (Maybe Int))
-> DefaultRetention -> f DefaultRetention
defaultRetention_years = (DefaultRetention -> Maybe Int)
-> (DefaultRetention -> Maybe Int -> DefaultRetention)
-> Lens DefaultRetention DefaultRetention (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DefaultRetention' {Maybe Int
years :: Maybe Int
$sel:years:DefaultRetention' :: DefaultRetention -> Maybe Int
years} -> Maybe Int
years) (\s :: DefaultRetention
s@DefaultRetention' {} Maybe Int
a -> DefaultRetention
s {$sel:years:DefaultRetention' :: Maybe Int
years = Maybe Int
a} :: DefaultRetention)
instance Core.FromXML DefaultRetention where
parseXML :: [Node] -> Either String DefaultRetention
parseXML [Node]
x =
Maybe Int
-> Maybe ObjectLockRetentionMode -> Maybe Int -> DefaultRetention
DefaultRetention'
(Maybe Int
-> Maybe ObjectLockRetentionMode -> Maybe Int -> DefaultRetention)
-> Either String (Maybe Int)
-> Either
String
(Maybe ObjectLockRetentionMode -> Maybe Int -> DefaultRetention)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Days")
Either
String
(Maybe ObjectLockRetentionMode -> Maybe Int -> DefaultRetention)
-> Either String (Maybe ObjectLockRetentionMode)
-> Either String (Maybe Int -> DefaultRetention)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ObjectLockRetentionMode)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Mode")
Either String (Maybe Int -> DefaultRetention)
-> Either String (Maybe Int) -> Either String DefaultRetention
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Years")
instance Prelude.Hashable DefaultRetention
instance Prelude.NFData DefaultRetention
instance Core.ToXML DefaultRetention where
toXML :: DefaultRetention -> XML
toXML DefaultRetention' {Maybe Int
Maybe ObjectLockRetentionMode
years :: Maybe Int
mode :: Maybe ObjectLockRetentionMode
days :: Maybe Int
$sel:years:DefaultRetention' :: DefaultRetention -> Maybe Int
$sel:mode:DefaultRetention' :: DefaultRetention -> Maybe ObjectLockRetentionMode
$sel:days:DefaultRetention' :: DefaultRetention -> Maybe Int
..} =
[XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ Name
"Days" Name -> Maybe Int -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Int
days,
Name
"Mode" Name -> Maybe ObjectLockRetentionMode -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe ObjectLockRetentionMode
mode,
Name
"Years" Name -> Maybe Int -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Int
years
]