{-# 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.RBin.Types.RuleSummary
-- 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.RBin.Types.RuleSummary 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
import Amazonka.RBin.Types.LockState
import Amazonka.RBin.Types.RetentionPeriod

-- | Information about a Recycle Bin retention rule.
--
-- /See:/ 'newRuleSummary' smart constructor.
data RuleSummary = RuleSummary'
  { -- | The retention rule description.
    RuleSummary -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The unique ID of the retention rule.
    RuleSummary -> Maybe Text
identifier :: Prelude.Maybe Prelude.Text,
    -- | The lock state for the retention rule.
    --
    -- -   @locked@ - The retention rule is locked and can\'t be modified or
    --     deleted.
    --
    -- -   @pending_unlock@ - The retention rule has been unlocked but it is
    --     still within the unlock delay period. The retention rule can be
    --     modified or deleted only after the unlock delay period has expired.
    --
    -- -   @unlocked@ - The retention rule is unlocked and it can be modified
    --     or deleted by any user with the required permissions.
    --
    -- -   @null@ - The retention rule has never been locked. Once a retention
    --     rule has been locked, it can transition between the @locked@ and
    --     @unlocked@ states only; it can never transition back to @null@.
    RuleSummary -> Maybe LockState
lockState :: Prelude.Maybe LockState,
    -- | Information about the retention period for which the retention rule is
    -- to retain resources.
    RuleSummary -> Maybe RetentionPeriod
retentionPeriod :: Prelude.Maybe RetentionPeriod
  }
  deriving (RuleSummary -> RuleSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RuleSummary -> RuleSummary -> Bool
$c/= :: RuleSummary -> RuleSummary -> Bool
== :: RuleSummary -> RuleSummary -> Bool
$c== :: RuleSummary -> RuleSummary -> Bool
Prelude.Eq, ReadPrec [RuleSummary]
ReadPrec RuleSummary
Int -> ReadS RuleSummary
ReadS [RuleSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RuleSummary]
$creadListPrec :: ReadPrec [RuleSummary]
readPrec :: ReadPrec RuleSummary
$creadPrec :: ReadPrec RuleSummary
readList :: ReadS [RuleSummary]
$creadList :: ReadS [RuleSummary]
readsPrec :: Int -> ReadS RuleSummary
$creadsPrec :: Int -> ReadS RuleSummary
Prelude.Read, Int -> RuleSummary -> ShowS
[RuleSummary] -> ShowS
RuleSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RuleSummary] -> ShowS
$cshowList :: [RuleSummary] -> ShowS
show :: RuleSummary -> String
$cshow :: RuleSummary -> String
showsPrec :: Int -> RuleSummary -> ShowS
$cshowsPrec :: Int -> RuleSummary -> ShowS
Prelude.Show, forall x. Rep RuleSummary x -> RuleSummary
forall x. RuleSummary -> Rep RuleSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RuleSummary x -> RuleSummary
$cfrom :: forall x. RuleSummary -> Rep RuleSummary x
Prelude.Generic)

-- |
-- Create a value of 'RuleSummary' 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:
--
-- 'description', 'ruleSummary_description' - The retention rule description.
--
-- 'identifier', 'ruleSummary_identifier' - The unique ID of the retention rule.
--
-- 'lockState', 'ruleSummary_lockState' - The lock state for the retention rule.
--
-- -   @locked@ - The retention rule is locked and can\'t be modified or
--     deleted.
--
-- -   @pending_unlock@ - The retention rule has been unlocked but it is
--     still within the unlock delay period. The retention rule can be
--     modified or deleted only after the unlock delay period has expired.
--
-- -   @unlocked@ - The retention rule is unlocked and it can be modified
--     or deleted by any user with the required permissions.
--
-- -   @null@ - The retention rule has never been locked. Once a retention
--     rule has been locked, it can transition between the @locked@ and
--     @unlocked@ states only; it can never transition back to @null@.
--
-- 'retentionPeriod', 'ruleSummary_retentionPeriod' - Information about the retention period for which the retention rule is
-- to retain resources.
newRuleSummary ::
  RuleSummary
newRuleSummary :: RuleSummary
newRuleSummary =
  RuleSummary'
    { $sel:description:RuleSummary' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:identifier:RuleSummary' :: Maybe Text
identifier = forall a. Maybe a
Prelude.Nothing,
      $sel:lockState:RuleSummary' :: Maybe LockState
lockState = forall a. Maybe a
Prelude.Nothing,
      $sel:retentionPeriod:RuleSummary' :: Maybe RetentionPeriod
retentionPeriod = forall a. Maybe a
Prelude.Nothing
    }

-- | The retention rule description.
ruleSummary_description :: Lens.Lens' RuleSummary (Prelude.Maybe Prelude.Text)
ruleSummary_description :: Lens' RuleSummary (Maybe Text)
ruleSummary_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleSummary' {Maybe Text
description :: Maybe Text
$sel:description:RuleSummary' :: RuleSummary -> Maybe Text
description} -> Maybe Text
description) (\s :: RuleSummary
s@RuleSummary' {} Maybe Text
a -> RuleSummary
s {$sel:description:RuleSummary' :: Maybe Text
description = Maybe Text
a} :: RuleSummary)

-- | The unique ID of the retention rule.
ruleSummary_identifier :: Lens.Lens' RuleSummary (Prelude.Maybe Prelude.Text)
ruleSummary_identifier :: Lens' RuleSummary (Maybe Text)
ruleSummary_identifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleSummary' {Maybe Text
identifier :: Maybe Text
$sel:identifier:RuleSummary' :: RuleSummary -> Maybe Text
identifier} -> Maybe Text
identifier) (\s :: RuleSummary
s@RuleSummary' {} Maybe Text
a -> RuleSummary
s {$sel:identifier:RuleSummary' :: Maybe Text
identifier = Maybe Text
a} :: RuleSummary)

-- | The lock state for the retention rule.
--
-- -   @locked@ - The retention rule is locked and can\'t be modified or
--     deleted.
--
-- -   @pending_unlock@ - The retention rule has been unlocked but it is
--     still within the unlock delay period. The retention rule can be
--     modified or deleted only after the unlock delay period has expired.
--
-- -   @unlocked@ - The retention rule is unlocked and it can be modified
--     or deleted by any user with the required permissions.
--
-- -   @null@ - The retention rule has never been locked. Once a retention
--     rule has been locked, it can transition between the @locked@ and
--     @unlocked@ states only; it can never transition back to @null@.
ruleSummary_lockState :: Lens.Lens' RuleSummary (Prelude.Maybe LockState)
ruleSummary_lockState :: Lens' RuleSummary (Maybe LockState)
ruleSummary_lockState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleSummary' {Maybe LockState
lockState :: Maybe LockState
$sel:lockState:RuleSummary' :: RuleSummary -> Maybe LockState
lockState} -> Maybe LockState
lockState) (\s :: RuleSummary
s@RuleSummary' {} Maybe LockState
a -> RuleSummary
s {$sel:lockState:RuleSummary' :: Maybe LockState
lockState = Maybe LockState
a} :: RuleSummary)

-- | Information about the retention period for which the retention rule is
-- to retain resources.
ruleSummary_retentionPeriod :: Lens.Lens' RuleSummary (Prelude.Maybe RetentionPeriod)
ruleSummary_retentionPeriod :: Lens' RuleSummary (Maybe RetentionPeriod)
ruleSummary_retentionPeriod = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleSummary' {Maybe RetentionPeriod
retentionPeriod :: Maybe RetentionPeriod
$sel:retentionPeriod:RuleSummary' :: RuleSummary -> Maybe RetentionPeriod
retentionPeriod} -> Maybe RetentionPeriod
retentionPeriod) (\s :: RuleSummary
s@RuleSummary' {} Maybe RetentionPeriod
a -> RuleSummary
s {$sel:retentionPeriod:RuleSummary' :: Maybe RetentionPeriod
retentionPeriod = Maybe RetentionPeriod
a} :: RuleSummary)

instance Data.FromJSON RuleSummary where
  parseJSON :: Value -> Parser RuleSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RuleSummary"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe LockState
-> Maybe RetentionPeriod
-> RuleSummary
RuleSummary'
            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
"Description")
            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
"Identifier")
            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
"LockState")
            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
"RetentionPeriod")
      )

instance Prelude.Hashable RuleSummary where
  hashWithSalt :: Int -> RuleSummary -> Int
hashWithSalt Int
_salt RuleSummary' {Maybe Text
Maybe LockState
Maybe RetentionPeriod
retentionPeriod :: Maybe RetentionPeriod
lockState :: Maybe LockState
identifier :: Maybe Text
description :: Maybe Text
$sel:retentionPeriod:RuleSummary' :: RuleSummary -> Maybe RetentionPeriod
$sel:lockState:RuleSummary' :: RuleSummary -> Maybe LockState
$sel:identifier:RuleSummary' :: RuleSummary -> Maybe Text
$sel:description:RuleSummary' :: RuleSummary -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
identifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LockState
lockState
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RetentionPeriod
retentionPeriod

instance Prelude.NFData RuleSummary where
  rnf :: RuleSummary -> ()
rnf RuleSummary' {Maybe Text
Maybe LockState
Maybe RetentionPeriod
retentionPeriod :: Maybe RetentionPeriod
lockState :: Maybe LockState
identifier :: Maybe Text
description :: Maybe Text
$sel:retentionPeriod:RuleSummary' :: RuleSummary -> Maybe RetentionPeriod
$sel:lockState:RuleSummary' :: RuleSummary -> Maybe LockState
$sel:identifier:RuleSummary' :: RuleSummary -> Maybe Text
$sel:description:RuleSummary' :: RuleSummary -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
identifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe LockState
lockState
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RetentionPeriod
retentionPeriod