{-# 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.SecurityHub.Types.AwsSecretsManagerSecretRotationRules
-- 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.SecurityHub.Types.AwsSecretsManagerSecretRotationRules where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Defines the rotation schedule for the secret.
--
-- /See:/ 'newAwsSecretsManagerSecretRotationRules' smart constructor.
data AwsSecretsManagerSecretRotationRules = AwsSecretsManagerSecretRotationRules'
  { -- | The number of days after the previous rotation to rotate the secret.
    AwsSecretsManagerSecretRotationRules -> Maybe Int
automaticallyAfterDays :: Prelude.Maybe Prelude.Int
  }
  deriving (AwsSecretsManagerSecretRotationRules
-> AwsSecretsManagerSecretRotationRules -> Bool
(AwsSecretsManagerSecretRotationRules
 -> AwsSecretsManagerSecretRotationRules -> Bool)
-> (AwsSecretsManagerSecretRotationRules
    -> AwsSecretsManagerSecretRotationRules -> Bool)
-> Eq AwsSecretsManagerSecretRotationRules
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsSecretsManagerSecretRotationRules
-> AwsSecretsManagerSecretRotationRules -> Bool
$c/= :: AwsSecretsManagerSecretRotationRules
-> AwsSecretsManagerSecretRotationRules -> Bool
== :: AwsSecretsManagerSecretRotationRules
-> AwsSecretsManagerSecretRotationRules -> Bool
$c== :: AwsSecretsManagerSecretRotationRules
-> AwsSecretsManagerSecretRotationRules -> Bool
Prelude.Eq, ReadPrec [AwsSecretsManagerSecretRotationRules]
ReadPrec AwsSecretsManagerSecretRotationRules
Int -> ReadS AwsSecretsManagerSecretRotationRules
ReadS [AwsSecretsManagerSecretRotationRules]
(Int -> ReadS AwsSecretsManagerSecretRotationRules)
-> ReadS [AwsSecretsManagerSecretRotationRules]
-> ReadPrec AwsSecretsManagerSecretRotationRules
-> ReadPrec [AwsSecretsManagerSecretRotationRules]
-> Read AwsSecretsManagerSecretRotationRules
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsSecretsManagerSecretRotationRules]
$creadListPrec :: ReadPrec [AwsSecretsManagerSecretRotationRules]
readPrec :: ReadPrec AwsSecretsManagerSecretRotationRules
$creadPrec :: ReadPrec AwsSecretsManagerSecretRotationRules
readList :: ReadS [AwsSecretsManagerSecretRotationRules]
$creadList :: ReadS [AwsSecretsManagerSecretRotationRules]
readsPrec :: Int -> ReadS AwsSecretsManagerSecretRotationRules
$creadsPrec :: Int -> ReadS AwsSecretsManagerSecretRotationRules
Prelude.Read, Int -> AwsSecretsManagerSecretRotationRules -> ShowS
[AwsSecretsManagerSecretRotationRules] -> ShowS
AwsSecretsManagerSecretRotationRules -> String
(Int -> AwsSecretsManagerSecretRotationRules -> ShowS)
-> (AwsSecretsManagerSecretRotationRules -> String)
-> ([AwsSecretsManagerSecretRotationRules] -> ShowS)
-> Show AwsSecretsManagerSecretRotationRules
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsSecretsManagerSecretRotationRules] -> ShowS
$cshowList :: [AwsSecretsManagerSecretRotationRules] -> ShowS
show :: AwsSecretsManagerSecretRotationRules -> String
$cshow :: AwsSecretsManagerSecretRotationRules -> String
showsPrec :: Int -> AwsSecretsManagerSecretRotationRules -> ShowS
$cshowsPrec :: Int -> AwsSecretsManagerSecretRotationRules -> ShowS
Prelude.Show, (forall x.
 AwsSecretsManagerSecretRotationRules
 -> Rep AwsSecretsManagerSecretRotationRules x)
-> (forall x.
    Rep AwsSecretsManagerSecretRotationRules x
    -> AwsSecretsManagerSecretRotationRules)
-> Generic AwsSecretsManagerSecretRotationRules
forall x.
Rep AwsSecretsManagerSecretRotationRules x
-> AwsSecretsManagerSecretRotationRules
forall x.
AwsSecretsManagerSecretRotationRules
-> Rep AwsSecretsManagerSecretRotationRules x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsSecretsManagerSecretRotationRules x
-> AwsSecretsManagerSecretRotationRules
$cfrom :: forall x.
AwsSecretsManagerSecretRotationRules
-> Rep AwsSecretsManagerSecretRotationRules x
Prelude.Generic)

-- |
-- Create a value of 'AwsSecretsManagerSecretRotationRules' 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:
--
-- 'automaticallyAfterDays', 'awsSecretsManagerSecretRotationRules_automaticallyAfterDays' - The number of days after the previous rotation to rotate the secret.
newAwsSecretsManagerSecretRotationRules ::
  AwsSecretsManagerSecretRotationRules
newAwsSecretsManagerSecretRotationRules :: AwsSecretsManagerSecretRotationRules
newAwsSecretsManagerSecretRotationRules =
  AwsSecretsManagerSecretRotationRules' :: Maybe Int -> AwsSecretsManagerSecretRotationRules
AwsSecretsManagerSecretRotationRules'
    { $sel:automaticallyAfterDays:AwsSecretsManagerSecretRotationRules' :: Maybe Int
automaticallyAfterDays =
        Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of days after the previous rotation to rotate the secret.
awsSecretsManagerSecretRotationRules_automaticallyAfterDays :: Lens.Lens' AwsSecretsManagerSecretRotationRules (Prelude.Maybe Prelude.Int)
awsSecretsManagerSecretRotationRules_automaticallyAfterDays :: (Maybe Int -> f (Maybe Int))
-> AwsSecretsManagerSecretRotationRules
-> f AwsSecretsManagerSecretRotationRules
awsSecretsManagerSecretRotationRules_automaticallyAfterDays = (AwsSecretsManagerSecretRotationRules -> Maybe Int)
-> (AwsSecretsManagerSecretRotationRules
    -> Maybe Int -> AwsSecretsManagerSecretRotationRules)
-> Lens
     AwsSecretsManagerSecretRotationRules
     AwsSecretsManagerSecretRotationRules
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsSecretsManagerSecretRotationRules' {Maybe Int
automaticallyAfterDays :: Maybe Int
$sel:automaticallyAfterDays:AwsSecretsManagerSecretRotationRules' :: AwsSecretsManagerSecretRotationRules -> Maybe Int
automaticallyAfterDays} -> Maybe Int
automaticallyAfterDays) (\s :: AwsSecretsManagerSecretRotationRules
s@AwsSecretsManagerSecretRotationRules' {} Maybe Int
a -> AwsSecretsManagerSecretRotationRules
s {$sel:automaticallyAfterDays:AwsSecretsManagerSecretRotationRules' :: Maybe Int
automaticallyAfterDays = Maybe Int
a} :: AwsSecretsManagerSecretRotationRules)

instance
  Core.FromJSON
    AwsSecretsManagerSecretRotationRules
  where
  parseJSON :: Value -> Parser AwsSecretsManagerSecretRotationRules
parseJSON =
    String
-> (Object -> Parser AwsSecretsManagerSecretRotationRules)
-> Value
-> Parser AwsSecretsManagerSecretRotationRules
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsSecretsManagerSecretRotationRules"
      ( \Object
x ->
          Maybe Int -> AwsSecretsManagerSecretRotationRules
AwsSecretsManagerSecretRotationRules'
            (Maybe Int -> AwsSecretsManagerSecretRotationRules)
-> Parser (Maybe Int)
-> Parser AwsSecretsManagerSecretRotationRules
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AutomaticallyAfterDays")
      )

instance
  Prelude.Hashable
    AwsSecretsManagerSecretRotationRules

instance
  Prelude.NFData
    AwsSecretsManagerSecretRotationRules

instance
  Core.ToJSON
    AwsSecretsManagerSecretRotationRules
  where
  toJSON :: AwsSecretsManagerSecretRotationRules -> Value
toJSON AwsSecretsManagerSecretRotationRules' {Maybe Int
automaticallyAfterDays :: Maybe Int
$sel:automaticallyAfterDays:AwsSecretsManagerSecretRotationRules' :: AwsSecretsManagerSecretRotationRules -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AutomaticallyAfterDays" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
automaticallyAfterDays
          ]
      )