{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Backup.Types.AdvancedBackupSetting
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Backup.Types.AdvancedBackupSetting where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A list of backup options for each resource type.
--
-- /See:/ 'newAdvancedBackupSetting' smart constructor.
data AdvancedBackupSetting = AdvancedBackupSetting'
  { -- | Specifies an object containing resource type and backup options. The
    -- only supported resource type is Amazon EC2 instances with Windows Volume
    -- Shadow Copy Service (VSS). For a CloudFormation example, see the
    -- <https://docs.aws.amazon.com/aws-backup/latest/devguide/integrate-cloudformation-with-aws-backup.html sample CloudFormation template to enable Windows VSS>
    -- in the /Backup User Guide/.
    --
    -- Valid values: @EC2@.
    AdvancedBackupSetting -> Maybe Text
resourceType :: Prelude.Maybe Prelude.Text,
    -- | Specifies the backup option for a selected resource. This option is only
    -- available for Windows VSS backup jobs.
    --
    -- Valid values:
    --
    -- Set to @\"WindowsVSS\":\"enabled\"@ to enable the @WindowsVSS@ backup
    -- option and create a Windows VSS backup.
    --
    -- Set to @\"WindowsVSS\":\"disabled\"@ to create a regular backup. The
    -- @WindowsVSS@ option is not enabled by default.
    --
    -- If you specify an invalid option, you get an
    -- @InvalidParameterValueException@ exception.
    --
    -- For more information about Windows VSS backups, see
    -- <https://docs.aws.amazon.com/aws-backup/latest/devguide/windows-backups.html Creating a VSS-Enabled Windows Backup>.
    AdvancedBackupSetting -> Maybe (HashMap Text Text)
backupOptions :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (AdvancedBackupSetting -> AdvancedBackupSetting -> Bool
(AdvancedBackupSetting -> AdvancedBackupSetting -> Bool)
-> (AdvancedBackupSetting -> AdvancedBackupSetting -> Bool)
-> Eq AdvancedBackupSetting
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AdvancedBackupSetting -> AdvancedBackupSetting -> Bool
$c/= :: AdvancedBackupSetting -> AdvancedBackupSetting -> Bool
== :: AdvancedBackupSetting -> AdvancedBackupSetting -> Bool
$c== :: AdvancedBackupSetting -> AdvancedBackupSetting -> Bool
Prelude.Eq, ReadPrec [AdvancedBackupSetting]
ReadPrec AdvancedBackupSetting
Int -> ReadS AdvancedBackupSetting
ReadS [AdvancedBackupSetting]
(Int -> ReadS AdvancedBackupSetting)
-> ReadS [AdvancedBackupSetting]
-> ReadPrec AdvancedBackupSetting
-> ReadPrec [AdvancedBackupSetting]
-> Read AdvancedBackupSetting
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AdvancedBackupSetting]
$creadListPrec :: ReadPrec [AdvancedBackupSetting]
readPrec :: ReadPrec AdvancedBackupSetting
$creadPrec :: ReadPrec AdvancedBackupSetting
readList :: ReadS [AdvancedBackupSetting]
$creadList :: ReadS [AdvancedBackupSetting]
readsPrec :: Int -> ReadS AdvancedBackupSetting
$creadsPrec :: Int -> ReadS AdvancedBackupSetting
Prelude.Read, Int -> AdvancedBackupSetting -> ShowS
[AdvancedBackupSetting] -> ShowS
AdvancedBackupSetting -> String
(Int -> AdvancedBackupSetting -> ShowS)
-> (AdvancedBackupSetting -> String)
-> ([AdvancedBackupSetting] -> ShowS)
-> Show AdvancedBackupSetting
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AdvancedBackupSetting] -> ShowS
$cshowList :: [AdvancedBackupSetting] -> ShowS
show :: AdvancedBackupSetting -> String
$cshow :: AdvancedBackupSetting -> String
showsPrec :: Int -> AdvancedBackupSetting -> ShowS
$cshowsPrec :: Int -> AdvancedBackupSetting -> ShowS
Prelude.Show, (forall x. AdvancedBackupSetting -> Rep AdvancedBackupSetting x)
-> (forall x. Rep AdvancedBackupSetting x -> AdvancedBackupSetting)
-> Generic AdvancedBackupSetting
forall x. Rep AdvancedBackupSetting x -> AdvancedBackupSetting
forall x. AdvancedBackupSetting -> Rep AdvancedBackupSetting x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AdvancedBackupSetting x -> AdvancedBackupSetting
$cfrom :: forall x. AdvancedBackupSetting -> Rep AdvancedBackupSetting x
Prelude.Generic)

-- |
-- Create a value of 'AdvancedBackupSetting' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'resourceType', 'advancedBackupSetting_resourceType' - Specifies an object containing resource type and backup options. The
-- only supported resource type is Amazon EC2 instances with Windows Volume
-- Shadow Copy Service (VSS). For a CloudFormation example, see the
-- <https://docs.aws.amazon.com/aws-backup/latest/devguide/integrate-cloudformation-with-aws-backup.html sample CloudFormation template to enable Windows VSS>
-- in the /Backup User Guide/.
--
-- Valid values: @EC2@.
--
-- 'backupOptions', 'advancedBackupSetting_backupOptions' - Specifies the backup option for a selected resource. This option is only
-- available for Windows VSS backup jobs.
--
-- Valid values:
--
-- Set to @\"WindowsVSS\":\"enabled\"@ to enable the @WindowsVSS@ backup
-- option and create a Windows VSS backup.
--
-- Set to @\"WindowsVSS\":\"disabled\"@ to create a regular backup. The
-- @WindowsVSS@ option is not enabled by default.
--
-- If you specify an invalid option, you get an
-- @InvalidParameterValueException@ exception.
--
-- For more information about Windows VSS backups, see
-- <https://docs.aws.amazon.com/aws-backup/latest/devguide/windows-backups.html Creating a VSS-Enabled Windows Backup>.
newAdvancedBackupSetting ::
  AdvancedBackupSetting
newAdvancedBackupSetting :: AdvancedBackupSetting
newAdvancedBackupSetting =
  AdvancedBackupSetting' :: Maybe Text -> Maybe (HashMap Text Text) -> AdvancedBackupSetting
AdvancedBackupSetting'
    { $sel:resourceType:AdvancedBackupSetting' :: Maybe Text
resourceType =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:backupOptions:AdvancedBackupSetting' :: Maybe (HashMap Text Text)
backupOptions = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies an object containing resource type and backup options. The
-- only supported resource type is Amazon EC2 instances with Windows Volume
-- Shadow Copy Service (VSS). For a CloudFormation example, see the
-- <https://docs.aws.amazon.com/aws-backup/latest/devguide/integrate-cloudformation-with-aws-backup.html sample CloudFormation template to enable Windows VSS>
-- in the /Backup User Guide/.
--
-- Valid values: @EC2@.
advancedBackupSetting_resourceType :: Lens.Lens' AdvancedBackupSetting (Prelude.Maybe Prelude.Text)
advancedBackupSetting_resourceType :: (Maybe Text -> f (Maybe Text))
-> AdvancedBackupSetting -> f AdvancedBackupSetting
advancedBackupSetting_resourceType = (AdvancedBackupSetting -> Maybe Text)
-> (AdvancedBackupSetting -> Maybe Text -> AdvancedBackupSetting)
-> Lens
     AdvancedBackupSetting
     AdvancedBackupSetting
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdvancedBackupSetting' {Maybe Text
resourceType :: Maybe Text
$sel:resourceType:AdvancedBackupSetting' :: AdvancedBackupSetting -> Maybe Text
resourceType} -> Maybe Text
resourceType) (\s :: AdvancedBackupSetting
s@AdvancedBackupSetting' {} Maybe Text
a -> AdvancedBackupSetting
s {$sel:resourceType:AdvancedBackupSetting' :: Maybe Text
resourceType = Maybe Text
a} :: AdvancedBackupSetting)

-- | Specifies the backup option for a selected resource. This option is only
-- available for Windows VSS backup jobs.
--
-- Valid values:
--
-- Set to @\"WindowsVSS\":\"enabled\"@ to enable the @WindowsVSS@ backup
-- option and create a Windows VSS backup.
--
-- Set to @\"WindowsVSS\":\"disabled\"@ to create a regular backup. The
-- @WindowsVSS@ option is not enabled by default.
--
-- If you specify an invalid option, you get an
-- @InvalidParameterValueException@ exception.
--
-- For more information about Windows VSS backups, see
-- <https://docs.aws.amazon.com/aws-backup/latest/devguide/windows-backups.html Creating a VSS-Enabled Windows Backup>.
advancedBackupSetting_backupOptions :: Lens.Lens' AdvancedBackupSetting (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
advancedBackupSetting_backupOptions :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> AdvancedBackupSetting -> f AdvancedBackupSetting
advancedBackupSetting_backupOptions = (AdvancedBackupSetting -> Maybe (HashMap Text Text))
-> (AdvancedBackupSetting
    -> Maybe (HashMap Text Text) -> AdvancedBackupSetting)
-> Lens
     AdvancedBackupSetting
     AdvancedBackupSetting
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdvancedBackupSetting' {Maybe (HashMap Text Text)
backupOptions :: Maybe (HashMap Text Text)
$sel:backupOptions:AdvancedBackupSetting' :: AdvancedBackupSetting -> Maybe (HashMap Text Text)
backupOptions} -> Maybe (HashMap Text Text)
backupOptions) (\s :: AdvancedBackupSetting
s@AdvancedBackupSetting' {} Maybe (HashMap Text Text)
a -> AdvancedBackupSetting
s {$sel:backupOptions:AdvancedBackupSetting' :: Maybe (HashMap Text Text)
backupOptions = Maybe (HashMap Text Text)
a} :: AdvancedBackupSetting) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> AdvancedBackupSetting -> f AdvancedBackupSetting)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> AdvancedBackupSetting
-> f AdvancedBackupSetting
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON AdvancedBackupSetting where
  parseJSON :: Value -> Parser AdvancedBackupSetting
parseJSON =
    String
-> (Object -> Parser AdvancedBackupSetting)
-> Value
-> Parser AdvancedBackupSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AdvancedBackupSetting"
      ( \Object
x ->
          Maybe Text -> Maybe (HashMap Text Text) -> AdvancedBackupSetting
AdvancedBackupSetting'
            (Maybe Text -> Maybe (HashMap Text Text) -> AdvancedBackupSetting)
-> Parser (Maybe Text)
-> Parser (Maybe (HashMap Text Text) -> AdvancedBackupSetting)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceType")
            Parser (Maybe (HashMap Text Text) -> AdvancedBackupSetting)
-> Parser (Maybe (HashMap Text Text))
-> Parser AdvancedBackupSetting
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BackupOptions" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable AdvancedBackupSetting

instance Prelude.NFData AdvancedBackupSetting

instance Core.ToJSON AdvancedBackupSetting where
  toJSON :: AdvancedBackupSetting -> Value
toJSON AdvancedBackupSetting' {Maybe Text
Maybe (HashMap Text Text)
backupOptions :: Maybe (HashMap Text Text)
resourceType :: Maybe Text
$sel:backupOptions:AdvancedBackupSetting' :: AdvancedBackupSetting -> Maybe (HashMap Text Text)
$sel:resourceType:AdvancedBackupSetting' :: AdvancedBackupSetting -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ResourceType" 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
resourceType,
            (Text
"BackupOptions" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
backupOptions
          ]
      )