{-# 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.Backup.Types.BackupSelection where
import Amazonka.Backup.Types.Condition
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data BackupSelection = BackupSelection'
{
BackupSelection -> Maybe [Text]
resources :: Prelude.Maybe [Prelude.Text],
BackupSelection -> Maybe [Condition]
listOfTags :: Prelude.Maybe [Condition],
BackupSelection -> Text
selectionName :: Prelude.Text,
BackupSelection -> Text
iamRoleArn :: Prelude.Text
}
deriving (BackupSelection -> BackupSelection -> Bool
(BackupSelection -> BackupSelection -> Bool)
-> (BackupSelection -> BackupSelection -> Bool)
-> Eq BackupSelection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BackupSelection -> BackupSelection -> Bool
$c/= :: BackupSelection -> BackupSelection -> Bool
== :: BackupSelection -> BackupSelection -> Bool
$c== :: BackupSelection -> BackupSelection -> Bool
Prelude.Eq, ReadPrec [BackupSelection]
ReadPrec BackupSelection
Int -> ReadS BackupSelection
ReadS [BackupSelection]
(Int -> ReadS BackupSelection)
-> ReadS [BackupSelection]
-> ReadPrec BackupSelection
-> ReadPrec [BackupSelection]
-> Read BackupSelection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BackupSelection]
$creadListPrec :: ReadPrec [BackupSelection]
readPrec :: ReadPrec BackupSelection
$creadPrec :: ReadPrec BackupSelection
readList :: ReadS [BackupSelection]
$creadList :: ReadS [BackupSelection]
readsPrec :: Int -> ReadS BackupSelection
$creadsPrec :: Int -> ReadS BackupSelection
Prelude.Read, Int -> BackupSelection -> ShowS
[BackupSelection] -> ShowS
BackupSelection -> String
(Int -> BackupSelection -> ShowS)
-> (BackupSelection -> String)
-> ([BackupSelection] -> ShowS)
-> Show BackupSelection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BackupSelection] -> ShowS
$cshowList :: [BackupSelection] -> ShowS
show :: BackupSelection -> String
$cshow :: BackupSelection -> String
showsPrec :: Int -> BackupSelection -> ShowS
$cshowsPrec :: Int -> BackupSelection -> ShowS
Prelude.Show, (forall x. BackupSelection -> Rep BackupSelection x)
-> (forall x. Rep BackupSelection x -> BackupSelection)
-> Generic BackupSelection
forall x. Rep BackupSelection x -> BackupSelection
forall x. BackupSelection -> Rep BackupSelection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BackupSelection x -> BackupSelection
$cfrom :: forall x. BackupSelection -> Rep BackupSelection x
Prelude.Generic)
newBackupSelection ::
Prelude.Text ->
Prelude.Text ->
BackupSelection
newBackupSelection :: Text -> Text -> BackupSelection
newBackupSelection Text
pSelectionName_ Text
pIamRoleArn_ =
BackupSelection' :: Maybe [Text]
-> Maybe [Condition] -> Text -> Text -> BackupSelection
BackupSelection'
{ $sel:resources:BackupSelection' :: Maybe [Text]
resources = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:listOfTags:BackupSelection' :: Maybe [Condition]
listOfTags = Maybe [Condition]
forall a. Maybe a
Prelude.Nothing,
$sel:selectionName:BackupSelection' :: Text
selectionName = Text
pSelectionName_,
$sel:iamRoleArn:BackupSelection' :: Text
iamRoleArn = Text
pIamRoleArn_
}
backupSelection_resources :: Lens.Lens' BackupSelection (Prelude.Maybe [Prelude.Text])
backupSelection_resources :: (Maybe [Text] -> f (Maybe [Text]))
-> BackupSelection -> f BackupSelection
backupSelection_resources = (BackupSelection -> Maybe [Text])
-> (BackupSelection -> Maybe [Text] -> BackupSelection)
-> Lens
BackupSelection BackupSelection (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupSelection' {Maybe [Text]
resources :: Maybe [Text]
$sel:resources:BackupSelection' :: BackupSelection -> Maybe [Text]
resources} -> Maybe [Text]
resources) (\s :: BackupSelection
s@BackupSelection' {} Maybe [Text]
a -> BackupSelection
s {$sel:resources:BackupSelection' :: Maybe [Text]
resources = Maybe [Text]
a} :: BackupSelection) ((Maybe [Text] -> f (Maybe [Text]))
-> BackupSelection -> f BackupSelection)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> BackupSelection
-> f BackupSelection
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
backupSelection_listOfTags :: Lens.Lens' BackupSelection (Prelude.Maybe [Condition])
backupSelection_listOfTags :: (Maybe [Condition] -> f (Maybe [Condition]))
-> BackupSelection -> f BackupSelection
backupSelection_listOfTags = (BackupSelection -> Maybe [Condition])
-> (BackupSelection -> Maybe [Condition] -> BackupSelection)
-> Lens
BackupSelection
BackupSelection
(Maybe [Condition])
(Maybe [Condition])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupSelection' {Maybe [Condition]
listOfTags :: Maybe [Condition]
$sel:listOfTags:BackupSelection' :: BackupSelection -> Maybe [Condition]
listOfTags} -> Maybe [Condition]
listOfTags) (\s :: BackupSelection
s@BackupSelection' {} Maybe [Condition]
a -> BackupSelection
s {$sel:listOfTags:BackupSelection' :: Maybe [Condition]
listOfTags = Maybe [Condition]
a} :: BackupSelection) ((Maybe [Condition] -> f (Maybe [Condition]))
-> BackupSelection -> f BackupSelection)
-> ((Maybe [Condition] -> f (Maybe [Condition]))
-> Maybe [Condition] -> f (Maybe [Condition]))
-> (Maybe [Condition] -> f (Maybe [Condition]))
-> BackupSelection
-> f BackupSelection
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Condition] [Condition] [Condition] [Condition]
-> Iso
(Maybe [Condition])
(Maybe [Condition])
(Maybe [Condition])
(Maybe [Condition])
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 [Condition] [Condition] [Condition] [Condition]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
backupSelection_selectionName :: Lens.Lens' BackupSelection Prelude.Text
backupSelection_selectionName :: (Text -> f Text) -> BackupSelection -> f BackupSelection
backupSelection_selectionName = (BackupSelection -> Text)
-> (BackupSelection -> Text -> BackupSelection)
-> Lens BackupSelection BackupSelection Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupSelection' {Text
selectionName :: Text
$sel:selectionName:BackupSelection' :: BackupSelection -> Text
selectionName} -> Text
selectionName) (\s :: BackupSelection
s@BackupSelection' {} Text
a -> BackupSelection
s {$sel:selectionName:BackupSelection' :: Text
selectionName = Text
a} :: BackupSelection)
backupSelection_iamRoleArn :: Lens.Lens' BackupSelection Prelude.Text
backupSelection_iamRoleArn :: (Text -> f Text) -> BackupSelection -> f BackupSelection
backupSelection_iamRoleArn = (BackupSelection -> Text)
-> (BackupSelection -> Text -> BackupSelection)
-> Lens BackupSelection BackupSelection Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupSelection' {Text
iamRoleArn :: Text
$sel:iamRoleArn:BackupSelection' :: BackupSelection -> Text
iamRoleArn} -> Text
iamRoleArn) (\s :: BackupSelection
s@BackupSelection' {} Text
a -> BackupSelection
s {$sel:iamRoleArn:BackupSelection' :: Text
iamRoleArn = Text
a} :: BackupSelection)
instance Core.FromJSON BackupSelection where
parseJSON :: Value -> Parser BackupSelection
parseJSON =
String
-> (Object -> Parser BackupSelection)
-> Value
-> Parser BackupSelection
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"BackupSelection"
( \Object
x ->
Maybe [Text]
-> Maybe [Condition] -> Text -> Text -> BackupSelection
BackupSelection'
(Maybe [Text]
-> Maybe [Condition] -> Text -> Text -> BackupSelection)
-> Parser (Maybe [Text])
-> Parser (Maybe [Condition] -> Text -> Text -> BackupSelection)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Resources" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
Parser (Maybe [Condition] -> Text -> Text -> BackupSelection)
-> Parser (Maybe [Condition])
-> Parser (Text -> Text -> BackupSelection)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Condition]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ListOfTags" Parser (Maybe (Maybe [Condition]))
-> Maybe [Condition] -> Parser (Maybe [Condition])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Condition]
forall a. Monoid a => a
Prelude.mempty)
Parser (Text -> Text -> BackupSelection)
-> Parser Text -> Parser (Text -> BackupSelection)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"SelectionName")
Parser (Text -> BackupSelection)
-> Parser Text -> Parser BackupSelection
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"IamRoleArn")
)
instance Prelude.Hashable BackupSelection
instance Prelude.NFData BackupSelection
instance Core.ToJSON BackupSelection where
toJSON :: BackupSelection -> Value
toJSON BackupSelection' {Maybe [Text]
Maybe [Condition]
Text
iamRoleArn :: Text
selectionName :: Text
listOfTags :: Maybe [Condition]
resources :: Maybe [Text]
$sel:iamRoleArn:BackupSelection' :: BackupSelection -> Text
$sel:selectionName:BackupSelection' :: BackupSelection -> Text
$sel:listOfTags:BackupSelection' :: BackupSelection -> Maybe [Condition]
$sel:resources:BackupSelection' :: BackupSelection -> Maybe [Text]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Resources" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
resources,
(Text
"ListOfTags" Text -> [Condition] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Condition] -> Pair) -> Maybe [Condition] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Condition]
listOfTags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SelectionName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
selectionName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"IamRoleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
iamRoleArn)
]
)