{-# 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.DLM.Types.CrossRegionCopyDeprecateRule
-- 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.DLM.Types.CrossRegionCopyDeprecateRule where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import Amazonka.DLM.Types.RetentionIntervalUnitValues
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | __[AMI policies only]__ Specifies an AMI deprecation rule for
-- cross-Region AMI copies created by an AMI policy.
--
-- /See:/ 'newCrossRegionCopyDeprecateRule' smart constructor.
data CrossRegionCopyDeprecateRule = CrossRegionCopyDeprecateRule'
  { -- | The period after which to deprecate the cross-Region AMI copies. The
    -- period must be less than or equal to the cross-Region AMI copy retention
    -- period, and it can\'t be greater than 10 years. This is equivalent to
    -- 120 months, 520 weeks, or 3650 days.
    CrossRegionCopyDeprecateRule -> Maybe Natural
interval :: Prelude.Maybe Prelude.Natural,
    -- | The unit of time in which to measure the __Interval__. For example, to
    -- deprecate a cross-Region AMI copy after 3 months, specify @Interval=3@
    -- and @IntervalUnit=MONTHS@.
    CrossRegionCopyDeprecateRule -> Maybe RetentionIntervalUnitValues
intervalUnit :: Prelude.Maybe RetentionIntervalUnitValues
  }
  deriving (CrossRegionCopyDeprecateRule
-> CrossRegionCopyDeprecateRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CrossRegionCopyDeprecateRule
-> CrossRegionCopyDeprecateRule -> Bool
$c/= :: CrossRegionCopyDeprecateRule
-> CrossRegionCopyDeprecateRule -> Bool
== :: CrossRegionCopyDeprecateRule
-> CrossRegionCopyDeprecateRule -> Bool
$c== :: CrossRegionCopyDeprecateRule
-> CrossRegionCopyDeprecateRule -> Bool
Prelude.Eq, ReadPrec [CrossRegionCopyDeprecateRule]
ReadPrec CrossRegionCopyDeprecateRule
Int -> ReadS CrossRegionCopyDeprecateRule
ReadS [CrossRegionCopyDeprecateRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CrossRegionCopyDeprecateRule]
$creadListPrec :: ReadPrec [CrossRegionCopyDeprecateRule]
readPrec :: ReadPrec CrossRegionCopyDeprecateRule
$creadPrec :: ReadPrec CrossRegionCopyDeprecateRule
readList :: ReadS [CrossRegionCopyDeprecateRule]
$creadList :: ReadS [CrossRegionCopyDeprecateRule]
readsPrec :: Int -> ReadS CrossRegionCopyDeprecateRule
$creadsPrec :: Int -> ReadS CrossRegionCopyDeprecateRule
Prelude.Read, Int -> CrossRegionCopyDeprecateRule -> ShowS
[CrossRegionCopyDeprecateRule] -> ShowS
CrossRegionCopyDeprecateRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CrossRegionCopyDeprecateRule] -> ShowS
$cshowList :: [CrossRegionCopyDeprecateRule] -> ShowS
show :: CrossRegionCopyDeprecateRule -> String
$cshow :: CrossRegionCopyDeprecateRule -> String
showsPrec :: Int -> CrossRegionCopyDeprecateRule -> ShowS
$cshowsPrec :: Int -> CrossRegionCopyDeprecateRule -> ShowS
Prelude.Show, forall x.
Rep CrossRegionCopyDeprecateRule x -> CrossRegionCopyDeprecateRule
forall x.
CrossRegionCopyDeprecateRule -> Rep CrossRegionCopyDeprecateRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CrossRegionCopyDeprecateRule x -> CrossRegionCopyDeprecateRule
$cfrom :: forall x.
CrossRegionCopyDeprecateRule -> Rep CrossRegionCopyDeprecateRule x
Prelude.Generic)

-- |
-- Create a value of 'CrossRegionCopyDeprecateRule' 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:
--
-- 'interval', 'crossRegionCopyDeprecateRule_interval' - The period after which to deprecate the cross-Region AMI copies. The
-- period must be less than or equal to the cross-Region AMI copy retention
-- period, and it can\'t be greater than 10 years. This is equivalent to
-- 120 months, 520 weeks, or 3650 days.
--
-- 'intervalUnit', 'crossRegionCopyDeprecateRule_intervalUnit' - The unit of time in which to measure the __Interval__. For example, to
-- deprecate a cross-Region AMI copy after 3 months, specify @Interval=3@
-- and @IntervalUnit=MONTHS@.
newCrossRegionCopyDeprecateRule ::
  CrossRegionCopyDeprecateRule
newCrossRegionCopyDeprecateRule :: CrossRegionCopyDeprecateRule
newCrossRegionCopyDeprecateRule =
  CrossRegionCopyDeprecateRule'
    { $sel:interval:CrossRegionCopyDeprecateRule' :: Maybe Natural
interval =
        forall a. Maybe a
Prelude.Nothing,
      $sel:intervalUnit:CrossRegionCopyDeprecateRule' :: Maybe RetentionIntervalUnitValues
intervalUnit = forall a. Maybe a
Prelude.Nothing
    }

-- | The period after which to deprecate the cross-Region AMI copies. The
-- period must be less than or equal to the cross-Region AMI copy retention
-- period, and it can\'t be greater than 10 years. This is equivalent to
-- 120 months, 520 weeks, or 3650 days.
crossRegionCopyDeprecateRule_interval :: Lens.Lens' CrossRegionCopyDeprecateRule (Prelude.Maybe Prelude.Natural)
crossRegionCopyDeprecateRule_interval :: Lens' CrossRegionCopyDeprecateRule (Maybe Natural)
crossRegionCopyDeprecateRule_interval = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CrossRegionCopyDeprecateRule' {Maybe Natural
interval :: Maybe Natural
$sel:interval:CrossRegionCopyDeprecateRule' :: CrossRegionCopyDeprecateRule -> Maybe Natural
interval} -> Maybe Natural
interval) (\s :: CrossRegionCopyDeprecateRule
s@CrossRegionCopyDeprecateRule' {} Maybe Natural
a -> CrossRegionCopyDeprecateRule
s {$sel:interval:CrossRegionCopyDeprecateRule' :: Maybe Natural
interval = Maybe Natural
a} :: CrossRegionCopyDeprecateRule)

-- | The unit of time in which to measure the __Interval__. For example, to
-- deprecate a cross-Region AMI copy after 3 months, specify @Interval=3@
-- and @IntervalUnit=MONTHS@.
crossRegionCopyDeprecateRule_intervalUnit :: Lens.Lens' CrossRegionCopyDeprecateRule (Prelude.Maybe RetentionIntervalUnitValues)
crossRegionCopyDeprecateRule_intervalUnit :: Lens'
  CrossRegionCopyDeprecateRule (Maybe RetentionIntervalUnitValues)
crossRegionCopyDeprecateRule_intervalUnit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CrossRegionCopyDeprecateRule' {Maybe RetentionIntervalUnitValues
intervalUnit :: Maybe RetentionIntervalUnitValues
$sel:intervalUnit:CrossRegionCopyDeprecateRule' :: CrossRegionCopyDeprecateRule -> Maybe RetentionIntervalUnitValues
intervalUnit} -> Maybe RetentionIntervalUnitValues
intervalUnit) (\s :: CrossRegionCopyDeprecateRule
s@CrossRegionCopyDeprecateRule' {} Maybe RetentionIntervalUnitValues
a -> CrossRegionCopyDeprecateRule
s {$sel:intervalUnit:CrossRegionCopyDeprecateRule' :: Maybe RetentionIntervalUnitValues
intervalUnit = Maybe RetentionIntervalUnitValues
a} :: CrossRegionCopyDeprecateRule)

instance Data.FromJSON CrossRegionCopyDeprecateRule where
  parseJSON :: Value -> Parser CrossRegionCopyDeprecateRule
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CrossRegionCopyDeprecateRule"
      ( \Object
x ->
          Maybe Natural
-> Maybe RetentionIntervalUnitValues
-> CrossRegionCopyDeprecateRule
CrossRegionCopyDeprecateRule'
            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
"Interval")
            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
"IntervalUnit")
      )

instance
  Prelude.Hashable
    CrossRegionCopyDeprecateRule
  where
  hashWithSalt :: Int -> CrossRegionCopyDeprecateRule -> Int
hashWithSalt Int
_salt CrossRegionCopyDeprecateRule' {Maybe Natural
Maybe RetentionIntervalUnitValues
intervalUnit :: Maybe RetentionIntervalUnitValues
interval :: Maybe Natural
$sel:intervalUnit:CrossRegionCopyDeprecateRule' :: CrossRegionCopyDeprecateRule -> Maybe RetentionIntervalUnitValues
$sel:interval:CrossRegionCopyDeprecateRule' :: CrossRegionCopyDeprecateRule -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
interval
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RetentionIntervalUnitValues
intervalUnit

instance Prelude.NFData CrossRegionCopyDeprecateRule where
  rnf :: CrossRegionCopyDeprecateRule -> ()
rnf CrossRegionCopyDeprecateRule' {Maybe Natural
Maybe RetentionIntervalUnitValues
intervalUnit :: Maybe RetentionIntervalUnitValues
interval :: Maybe Natural
$sel:intervalUnit:CrossRegionCopyDeprecateRule' :: CrossRegionCopyDeprecateRule -> Maybe RetentionIntervalUnitValues
$sel:interval:CrossRegionCopyDeprecateRule' :: CrossRegionCopyDeprecateRule -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
interval
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RetentionIntervalUnitValues
intervalUnit

instance Data.ToJSON CrossRegionCopyDeprecateRule where
  toJSON :: CrossRegionCopyDeprecateRule -> Value
toJSON CrossRegionCopyDeprecateRule' {Maybe Natural
Maybe RetentionIntervalUnitValues
intervalUnit :: Maybe RetentionIntervalUnitValues
interval :: Maybe Natural
$sel:intervalUnit:CrossRegionCopyDeprecateRule' :: CrossRegionCopyDeprecateRule -> Maybe RetentionIntervalUnitValues
$sel:interval:CrossRegionCopyDeprecateRule' :: CrossRegionCopyDeprecateRule -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Interval" 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 Natural
interval,
            (Key
"IntervalUnit" 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 RetentionIntervalUnitValues
intervalUnit
          ]
      )