{-# 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.UnlockDelay
-- 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.UnlockDelay 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.UnlockDelayUnit

-- | Information about the retention rule unlock delay. The unlock delay is
-- the period after which a retention rule can be modified or edited after
-- it has been unlocked by a user with the required permissions. The
-- retention rule can\'t be modified or deleted during the unlock delay.
--
-- /See:/ 'newUnlockDelay' smart constructor.
data UnlockDelay = UnlockDelay'
  { -- | The unlock delay period, measured in the unit specified for
    -- __UnlockDelayUnit__.
    UnlockDelay -> Natural
unlockDelayValue :: Prelude.Natural,
    -- | The unit of time in which to measure the unlock delay. Currently, the
    -- unlock delay can be measure only in days.
    UnlockDelay -> UnlockDelayUnit
unlockDelayUnit :: UnlockDelayUnit
  }
  deriving (UnlockDelay -> UnlockDelay -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnlockDelay -> UnlockDelay -> Bool
$c/= :: UnlockDelay -> UnlockDelay -> Bool
== :: UnlockDelay -> UnlockDelay -> Bool
$c== :: UnlockDelay -> UnlockDelay -> Bool
Prelude.Eq, ReadPrec [UnlockDelay]
ReadPrec UnlockDelay
Int -> ReadS UnlockDelay
ReadS [UnlockDelay]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UnlockDelay]
$creadListPrec :: ReadPrec [UnlockDelay]
readPrec :: ReadPrec UnlockDelay
$creadPrec :: ReadPrec UnlockDelay
readList :: ReadS [UnlockDelay]
$creadList :: ReadS [UnlockDelay]
readsPrec :: Int -> ReadS UnlockDelay
$creadsPrec :: Int -> ReadS UnlockDelay
Prelude.Read, Int -> UnlockDelay -> ShowS
[UnlockDelay] -> ShowS
UnlockDelay -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnlockDelay] -> ShowS
$cshowList :: [UnlockDelay] -> ShowS
show :: UnlockDelay -> String
$cshow :: UnlockDelay -> String
showsPrec :: Int -> UnlockDelay -> ShowS
$cshowsPrec :: Int -> UnlockDelay -> ShowS
Prelude.Show, forall x. Rep UnlockDelay x -> UnlockDelay
forall x. UnlockDelay -> Rep UnlockDelay x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UnlockDelay x -> UnlockDelay
$cfrom :: forall x. UnlockDelay -> Rep UnlockDelay x
Prelude.Generic)

-- |
-- Create a value of 'UnlockDelay' 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:
--
-- 'unlockDelayValue', 'unlockDelay_unlockDelayValue' - The unlock delay period, measured in the unit specified for
-- __UnlockDelayUnit__.
--
-- 'unlockDelayUnit', 'unlockDelay_unlockDelayUnit' - The unit of time in which to measure the unlock delay. Currently, the
-- unlock delay can be measure only in days.
newUnlockDelay ::
  -- | 'unlockDelayValue'
  Prelude.Natural ->
  -- | 'unlockDelayUnit'
  UnlockDelayUnit ->
  UnlockDelay
newUnlockDelay :: Natural -> UnlockDelayUnit -> UnlockDelay
newUnlockDelay Natural
pUnlockDelayValue_ UnlockDelayUnit
pUnlockDelayUnit_ =
  UnlockDelay'
    { $sel:unlockDelayValue:UnlockDelay' :: Natural
unlockDelayValue = Natural
pUnlockDelayValue_,
      $sel:unlockDelayUnit:UnlockDelay' :: UnlockDelayUnit
unlockDelayUnit = UnlockDelayUnit
pUnlockDelayUnit_
    }

-- | The unlock delay period, measured in the unit specified for
-- __UnlockDelayUnit__.
unlockDelay_unlockDelayValue :: Lens.Lens' UnlockDelay Prelude.Natural
unlockDelay_unlockDelayValue :: Lens' UnlockDelay Natural
unlockDelay_unlockDelayValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnlockDelay' {Natural
unlockDelayValue :: Natural
$sel:unlockDelayValue:UnlockDelay' :: UnlockDelay -> Natural
unlockDelayValue} -> Natural
unlockDelayValue) (\s :: UnlockDelay
s@UnlockDelay' {} Natural
a -> UnlockDelay
s {$sel:unlockDelayValue:UnlockDelay' :: Natural
unlockDelayValue = Natural
a} :: UnlockDelay)

-- | The unit of time in which to measure the unlock delay. Currently, the
-- unlock delay can be measure only in days.
unlockDelay_unlockDelayUnit :: Lens.Lens' UnlockDelay UnlockDelayUnit
unlockDelay_unlockDelayUnit :: Lens' UnlockDelay UnlockDelayUnit
unlockDelay_unlockDelayUnit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnlockDelay' {UnlockDelayUnit
unlockDelayUnit :: UnlockDelayUnit
$sel:unlockDelayUnit:UnlockDelay' :: UnlockDelay -> UnlockDelayUnit
unlockDelayUnit} -> UnlockDelayUnit
unlockDelayUnit) (\s :: UnlockDelay
s@UnlockDelay' {} UnlockDelayUnit
a -> UnlockDelay
s {$sel:unlockDelayUnit:UnlockDelay' :: UnlockDelayUnit
unlockDelayUnit = UnlockDelayUnit
a} :: UnlockDelay)

instance Data.FromJSON UnlockDelay where
  parseJSON :: Value -> Parser UnlockDelay
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UnlockDelay"
      ( \Object
x ->
          Natural -> UnlockDelayUnit -> UnlockDelay
UnlockDelay'
            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
"UnlockDelayValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"UnlockDelayUnit")
      )

instance Prelude.Hashable UnlockDelay where
  hashWithSalt :: Int -> UnlockDelay -> Int
hashWithSalt Int
_salt UnlockDelay' {Natural
UnlockDelayUnit
unlockDelayUnit :: UnlockDelayUnit
unlockDelayValue :: Natural
$sel:unlockDelayUnit:UnlockDelay' :: UnlockDelay -> UnlockDelayUnit
$sel:unlockDelayValue:UnlockDelay' :: UnlockDelay -> Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
unlockDelayValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` UnlockDelayUnit
unlockDelayUnit

instance Prelude.NFData UnlockDelay where
  rnf :: UnlockDelay -> ()
rnf UnlockDelay' {Natural
UnlockDelayUnit
unlockDelayUnit :: UnlockDelayUnit
unlockDelayValue :: Natural
$sel:unlockDelayUnit:UnlockDelay' :: UnlockDelay -> UnlockDelayUnit
$sel:unlockDelayValue:UnlockDelay' :: UnlockDelay -> Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Natural
unlockDelayValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf UnlockDelayUnit
unlockDelayUnit

instance Data.ToJSON UnlockDelay where
  toJSON :: UnlockDelay -> Value
toJSON UnlockDelay' {Natural
UnlockDelayUnit
unlockDelayUnit :: UnlockDelayUnit
unlockDelayValue :: Natural
$sel:unlockDelayUnit:UnlockDelay' :: UnlockDelay -> UnlockDelayUnit
$sel:unlockDelayValue:UnlockDelay' :: UnlockDelay -> Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"UnlockDelayValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
unlockDelayValue),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"UnlockDelayUnit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= UnlockDelayUnit
unlockDelayUnit)
          ]
      )