{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Backup.Types.AdvancedBackupSetting where

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

-- | A list of backup options for each resource type.
--
-- /See:/ 'newAdvancedBackupSetting' smart constructor.
data AdvancedBackupSetting = 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 -> Maybe (HashMap Text Text)
backupOptions :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | 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
  }
  deriving (AdvancedBackupSetting -> AdvancedBackupSetting -> Bool
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]
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
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. 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:
--
-- '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>.
--
-- '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@.
newAdvancedBackupSetting ::
  AdvancedBackupSetting
newAdvancedBackupSetting :: AdvancedBackupSetting
newAdvancedBackupSetting =
  AdvancedBackupSetting'
    { $sel:backupOptions:AdvancedBackupSetting' :: Maybe (HashMap Text Text)
backupOptions =
        forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:AdvancedBackupSetting' :: Maybe Text
resourceType = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' AdvancedBackupSetting (Maybe (HashMap Text Text))
advancedBackupSetting_backupOptions = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: Lens' AdvancedBackupSetting (Maybe Text)
advancedBackupSetting_resourceType = 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)

instance Data.FromJSON AdvancedBackupSetting where
  parseJSON :: Value -> Parser AdvancedBackupSetting
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AdvancedBackupSetting"
      ( \Object
x ->
          Maybe (HashMap Text Text) -> Maybe Text -> AdvancedBackupSetting
AdvancedBackupSetting'
            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
"BackupOptions" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"ResourceType")
      )

instance Prelude.Hashable AdvancedBackupSetting where
  hashWithSalt :: Int -> AdvancedBackupSetting -> Int
hashWithSalt Int
_salt AdvancedBackupSetting' {Maybe Text
Maybe (HashMap Text Text)
resourceType :: Maybe Text
backupOptions :: Maybe (HashMap Text Text)
$sel:resourceType:AdvancedBackupSetting' :: AdvancedBackupSetting -> Maybe Text
$sel:backupOptions:AdvancedBackupSetting' :: AdvancedBackupSetting -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
backupOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceType

instance Prelude.NFData AdvancedBackupSetting where
  rnf :: AdvancedBackupSetting -> ()
rnf AdvancedBackupSetting' {Maybe Text
Maybe (HashMap Text Text)
resourceType :: Maybe Text
backupOptions :: Maybe (HashMap Text Text)
$sel:resourceType:AdvancedBackupSetting' :: AdvancedBackupSetting -> Maybe Text
$sel:backupOptions:AdvancedBackupSetting' :: AdvancedBackupSetting -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
backupOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceType

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