{-# 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.Glacier.Types.DataRetrievalPolicy where
import qualified Amazonka.Core as Core
import Amazonka.Glacier.Types.DataRetrievalRule
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data DataRetrievalPolicy = DataRetrievalPolicy'
{
DataRetrievalPolicy -> Maybe [DataRetrievalRule]
rules :: Prelude.Maybe [DataRetrievalRule]
}
deriving (DataRetrievalPolicy -> DataRetrievalPolicy -> Bool
(DataRetrievalPolicy -> DataRetrievalPolicy -> Bool)
-> (DataRetrievalPolicy -> DataRetrievalPolicy -> Bool)
-> Eq DataRetrievalPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataRetrievalPolicy -> DataRetrievalPolicy -> Bool
$c/= :: DataRetrievalPolicy -> DataRetrievalPolicy -> Bool
== :: DataRetrievalPolicy -> DataRetrievalPolicy -> Bool
$c== :: DataRetrievalPolicy -> DataRetrievalPolicy -> Bool
Prelude.Eq, ReadPrec [DataRetrievalPolicy]
ReadPrec DataRetrievalPolicy
Int -> ReadS DataRetrievalPolicy
ReadS [DataRetrievalPolicy]
(Int -> ReadS DataRetrievalPolicy)
-> ReadS [DataRetrievalPolicy]
-> ReadPrec DataRetrievalPolicy
-> ReadPrec [DataRetrievalPolicy]
-> Read DataRetrievalPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataRetrievalPolicy]
$creadListPrec :: ReadPrec [DataRetrievalPolicy]
readPrec :: ReadPrec DataRetrievalPolicy
$creadPrec :: ReadPrec DataRetrievalPolicy
readList :: ReadS [DataRetrievalPolicy]
$creadList :: ReadS [DataRetrievalPolicy]
readsPrec :: Int -> ReadS DataRetrievalPolicy
$creadsPrec :: Int -> ReadS DataRetrievalPolicy
Prelude.Read, Int -> DataRetrievalPolicy -> ShowS
[DataRetrievalPolicy] -> ShowS
DataRetrievalPolicy -> String
(Int -> DataRetrievalPolicy -> ShowS)
-> (DataRetrievalPolicy -> String)
-> ([DataRetrievalPolicy] -> ShowS)
-> Show DataRetrievalPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataRetrievalPolicy] -> ShowS
$cshowList :: [DataRetrievalPolicy] -> ShowS
show :: DataRetrievalPolicy -> String
$cshow :: DataRetrievalPolicy -> String
showsPrec :: Int -> DataRetrievalPolicy -> ShowS
$cshowsPrec :: Int -> DataRetrievalPolicy -> ShowS
Prelude.Show, (forall x. DataRetrievalPolicy -> Rep DataRetrievalPolicy x)
-> (forall x. Rep DataRetrievalPolicy x -> DataRetrievalPolicy)
-> Generic DataRetrievalPolicy
forall x. Rep DataRetrievalPolicy x -> DataRetrievalPolicy
forall x. DataRetrievalPolicy -> Rep DataRetrievalPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataRetrievalPolicy x -> DataRetrievalPolicy
$cfrom :: forall x. DataRetrievalPolicy -> Rep DataRetrievalPolicy x
Prelude.Generic)
newDataRetrievalPolicy ::
DataRetrievalPolicy
newDataRetrievalPolicy :: DataRetrievalPolicy
newDataRetrievalPolicy =
DataRetrievalPolicy' :: Maybe [DataRetrievalRule] -> DataRetrievalPolicy
DataRetrievalPolicy' {$sel:rules:DataRetrievalPolicy' :: Maybe [DataRetrievalRule]
rules = Maybe [DataRetrievalRule]
forall a. Maybe a
Prelude.Nothing}
dataRetrievalPolicy_rules :: Lens.Lens' DataRetrievalPolicy (Prelude.Maybe [DataRetrievalRule])
dataRetrievalPolicy_rules :: (Maybe [DataRetrievalRule] -> f (Maybe [DataRetrievalRule]))
-> DataRetrievalPolicy -> f DataRetrievalPolicy
dataRetrievalPolicy_rules = (DataRetrievalPolicy -> Maybe [DataRetrievalRule])
-> (DataRetrievalPolicy
-> Maybe [DataRetrievalRule] -> DataRetrievalPolicy)
-> Lens
DataRetrievalPolicy
DataRetrievalPolicy
(Maybe [DataRetrievalRule])
(Maybe [DataRetrievalRule])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataRetrievalPolicy' {Maybe [DataRetrievalRule]
rules :: Maybe [DataRetrievalRule]
$sel:rules:DataRetrievalPolicy' :: DataRetrievalPolicy -> Maybe [DataRetrievalRule]
rules} -> Maybe [DataRetrievalRule]
rules) (\s :: DataRetrievalPolicy
s@DataRetrievalPolicy' {} Maybe [DataRetrievalRule]
a -> DataRetrievalPolicy
s {$sel:rules:DataRetrievalPolicy' :: Maybe [DataRetrievalRule]
rules = Maybe [DataRetrievalRule]
a} :: DataRetrievalPolicy) ((Maybe [DataRetrievalRule] -> f (Maybe [DataRetrievalRule]))
-> DataRetrievalPolicy -> f DataRetrievalPolicy)
-> ((Maybe [DataRetrievalRule] -> f (Maybe [DataRetrievalRule]))
-> Maybe [DataRetrievalRule] -> f (Maybe [DataRetrievalRule]))
-> (Maybe [DataRetrievalRule] -> f (Maybe [DataRetrievalRule]))
-> DataRetrievalPolicy
-> f DataRetrievalPolicy
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[DataRetrievalRule]
[DataRetrievalRule]
[DataRetrievalRule]
[DataRetrievalRule]
-> Iso
(Maybe [DataRetrievalRule])
(Maybe [DataRetrievalRule])
(Maybe [DataRetrievalRule])
(Maybe [DataRetrievalRule])
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
[DataRetrievalRule]
[DataRetrievalRule]
[DataRetrievalRule]
[DataRetrievalRule]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON DataRetrievalPolicy where
parseJSON :: Value -> Parser DataRetrievalPolicy
parseJSON =
String
-> (Object -> Parser DataRetrievalPolicy)
-> Value
-> Parser DataRetrievalPolicy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"DataRetrievalPolicy"
( \Object
x ->
Maybe [DataRetrievalRule] -> DataRetrievalPolicy
DataRetrievalPolicy'
(Maybe [DataRetrievalRule] -> DataRetrievalPolicy)
-> Parser (Maybe [DataRetrievalRule]) -> Parser DataRetrievalPolicy
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [DataRetrievalRule]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Rules" Parser (Maybe (Maybe [DataRetrievalRule]))
-> Maybe [DataRetrievalRule] -> Parser (Maybe [DataRetrievalRule])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [DataRetrievalRule]
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable DataRetrievalPolicy
instance Prelude.NFData DataRetrievalPolicy
instance Core.ToJSON DataRetrievalPolicy where
toJSON :: DataRetrievalPolicy -> Value
toJSON DataRetrievalPolicy' {Maybe [DataRetrievalRule]
rules :: Maybe [DataRetrievalRule]
$sel:rules:DataRetrievalPolicy' :: DataRetrievalPolicy -> Maybe [DataRetrievalRule]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[(Text
"Rules" Text -> [DataRetrievalRule] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([DataRetrievalRule] -> Pair)
-> Maybe [DataRetrievalRule] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [DataRetrievalRule]
rules]
)