{-# 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.EFS.Types.BackupPolicy
-- 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.EFS.Types.BackupPolicy where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EFS.Types.BackupStatus
import qualified Amazonka.Prelude as Prelude

-- | The backup policy for the file system used to create automatic daily
-- backups. If status has a value of @ENABLED@, the file system is being
-- automatically backed up. For more information, see
-- <https://docs.aws.amazon.com/efs/latest/ug/awsbackup.html#automatic-backups Automatic backups>.
--
-- /See:/ 'newBackupPolicy' smart constructor.
data BackupPolicy = BackupPolicy'
  { -- | Describes the status of the file system\'s backup policy.
    --
    -- -   __@ENABLED@__ - EFS is automatically backing up the file system.
    --
    -- -   __@ENABLING@__ - EFS is turning on automatic backups for the file
    --     system.
    --
    -- -   __@DISABLED@__ - Automatic back ups are turned off for the file
    --     system.
    --
    -- -   __@DISABLING@__ - EFS is turning off automatic backups for the file
    --     system.
    BackupPolicy -> BackupStatus
status :: BackupStatus
  }
  deriving (BackupPolicy -> BackupPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BackupPolicy -> BackupPolicy -> Bool
$c/= :: BackupPolicy -> BackupPolicy -> Bool
== :: BackupPolicy -> BackupPolicy -> Bool
$c== :: BackupPolicy -> BackupPolicy -> Bool
Prelude.Eq, ReadPrec [BackupPolicy]
ReadPrec BackupPolicy
Int -> ReadS BackupPolicy
ReadS [BackupPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BackupPolicy]
$creadListPrec :: ReadPrec [BackupPolicy]
readPrec :: ReadPrec BackupPolicy
$creadPrec :: ReadPrec BackupPolicy
readList :: ReadS [BackupPolicy]
$creadList :: ReadS [BackupPolicy]
readsPrec :: Int -> ReadS BackupPolicy
$creadsPrec :: Int -> ReadS BackupPolicy
Prelude.Read, Int -> BackupPolicy -> ShowS
[BackupPolicy] -> ShowS
BackupPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BackupPolicy] -> ShowS
$cshowList :: [BackupPolicy] -> ShowS
show :: BackupPolicy -> String
$cshow :: BackupPolicy -> String
showsPrec :: Int -> BackupPolicy -> ShowS
$cshowsPrec :: Int -> BackupPolicy -> ShowS
Prelude.Show, forall x. Rep BackupPolicy x -> BackupPolicy
forall x. BackupPolicy -> Rep BackupPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BackupPolicy x -> BackupPolicy
$cfrom :: forall x. BackupPolicy -> Rep BackupPolicy x
Prelude.Generic)

-- |
-- Create a value of 'BackupPolicy' 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:
--
-- 'status', 'backupPolicy_status' - Describes the status of the file system\'s backup policy.
--
-- -   __@ENABLED@__ - EFS is automatically backing up the file system.
--
-- -   __@ENABLING@__ - EFS is turning on automatic backups for the file
--     system.
--
-- -   __@DISABLED@__ - Automatic back ups are turned off for the file
--     system.
--
-- -   __@DISABLING@__ - EFS is turning off automatic backups for the file
--     system.
newBackupPolicy ::
  -- | 'status'
  BackupStatus ->
  BackupPolicy
newBackupPolicy :: BackupStatus -> BackupPolicy
newBackupPolicy BackupStatus
pStatus_ =
  BackupPolicy' {$sel:status:BackupPolicy' :: BackupStatus
status = BackupStatus
pStatus_}

-- | Describes the status of the file system\'s backup policy.
--
-- -   __@ENABLED@__ - EFS is automatically backing up the file system.
--
-- -   __@ENABLING@__ - EFS is turning on automatic backups for the file
--     system.
--
-- -   __@DISABLED@__ - Automatic back ups are turned off for the file
--     system.
--
-- -   __@DISABLING@__ - EFS is turning off automatic backups for the file
--     system.
backupPolicy_status :: Lens.Lens' BackupPolicy BackupStatus
backupPolicy_status :: Lens' BackupPolicy BackupStatus
backupPolicy_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupPolicy' {BackupStatus
status :: BackupStatus
$sel:status:BackupPolicy' :: BackupPolicy -> BackupStatus
status} -> BackupStatus
status) (\s :: BackupPolicy
s@BackupPolicy' {} BackupStatus
a -> BackupPolicy
s {$sel:status:BackupPolicy' :: BackupStatus
status = BackupStatus
a} :: BackupPolicy)

instance Data.FromJSON BackupPolicy where
  parseJSON :: Value -> Parser BackupPolicy
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BackupPolicy"
      ( \Object
x ->
          BackupStatus -> BackupPolicy
BackupPolicy' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Status")
      )

instance Prelude.Hashable BackupPolicy where
  hashWithSalt :: Int -> BackupPolicy -> Int
hashWithSalt Int
_salt BackupPolicy' {BackupStatus
status :: BackupStatus
$sel:status:BackupPolicy' :: BackupPolicy -> BackupStatus
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` BackupStatus
status

instance Prelude.NFData BackupPolicy where
  rnf :: BackupPolicy -> ()
rnf BackupPolicy' {BackupStatus
status :: BackupStatus
$sel:status:BackupPolicy' :: BackupPolicy -> BackupStatus
..} = forall a. NFData a => a -> ()
Prelude.rnf BackupStatus
status

instance Data.ToJSON BackupPolicy where
  toJSON :: BackupPolicy -> Value
toJSON BackupPolicy' {BackupStatus
status :: BackupStatus
$sel:status:BackupPolicy' :: BackupPolicy -> BackupStatus
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"Status" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= BackupStatus
status)]
      )