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

import qualified Amazonka.Core as Core
import Amazonka.EFS.Types.BackupStatus
import qualified Amazonka.Lens as Lens
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
(BackupPolicy -> BackupPolicy -> Bool)
-> (BackupPolicy -> BackupPolicy -> Bool) -> Eq BackupPolicy
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]
(Int -> ReadS BackupPolicy)
-> ReadS [BackupPolicy]
-> ReadPrec BackupPolicy
-> ReadPrec [BackupPolicy]
-> Read 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
(Int -> BackupPolicy -> ShowS)
-> (BackupPolicy -> String)
-> ([BackupPolicy] -> ShowS)
-> Show BackupPolicy
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. BackupPolicy -> Rep BackupPolicy x)
-> (forall x. Rep BackupPolicy x -> BackupPolicy)
-> Generic BackupPolicy
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' :: BackupStatus -> BackupPolicy
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 :: (BackupStatus -> f BackupStatus) -> BackupPolicy -> f BackupPolicy
backupPolicy_status = (BackupPolicy -> BackupStatus)
-> (BackupPolicy -> BackupStatus -> BackupPolicy)
-> Lens BackupPolicy BackupPolicy BackupStatus BackupStatus
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 Core.FromJSON BackupPolicy where
  parseJSON :: Value -> Parser BackupPolicy
parseJSON =
    String
-> (Object -> Parser BackupPolicy) -> Value -> Parser BackupPolicy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BackupPolicy"
      ( \Object
x ->
          BackupStatus -> BackupPolicy
BackupPolicy' (BackupStatus -> BackupPolicy)
-> Parser BackupStatus -> Parser BackupPolicy
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser BackupStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Status")
      )

instance Prelude.Hashable BackupPolicy

instance Prelude.NFData BackupPolicy

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