{-# 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.WAFV2.Types.ManagedRuleSetVersion
-- 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.WAFV2.Types.ManagedRuleSetVersion 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

-- | Information for a single version of a managed rule set.
--
-- This is intended for use only by vendors of managed rule sets. Vendors
-- are Amazon Web Services and Amazon Web Services Marketplace sellers.
--
-- Vendors, you can use the managed rule set APIs to provide controlled
-- rollout of your versioned managed rule group offerings for your
-- customers. The APIs are @ListManagedRuleSets@, @GetManagedRuleSet@,
-- @PutManagedRuleSetVersions@, and
-- @UpdateManagedRuleSetVersionExpiryDate@.
--
-- /See:/ 'newManagedRuleSetVersion' smart constructor.
data ManagedRuleSetVersion = ManagedRuleSetVersion'
  { -- | The Amazon Resource Name (ARN) of the vendor rule group that\'s used to
    -- define the published version of your managed rule group.
    ManagedRuleSetVersion -> Maybe Text
associatedRuleGroupArn :: Prelude.Maybe Prelude.Text,
    -- | The web ACL capacity units (WCUs) required for this rule group.
    --
    -- WAF uses WCUs to calculate and control the operating resources that are
    -- used to run your rules, rule groups, and web ACLs. WAF calculates
    -- capacity differently for each rule type, to reflect the relative cost of
    -- each rule. Simple rules that cost little to run use fewer WCUs than more
    -- complex rules that use more processing power. Rule group capacity is
    -- fixed at creation, which helps users plan their web ACL WCU usage when
    -- they use a rule group. The WCU limit for web ACLs is 1,500.
    ManagedRuleSetVersion -> Maybe Natural
capacity :: Prelude.Maybe Prelude.Natural,
    -- | The time that this version is set to expire.
    --
    -- Times are in Coordinated Universal Time (UTC) format. UTC format
    -- includes the special designator, Z. For example, \"2016-09-27T14:50Z\".
    ManagedRuleSetVersion -> Maybe POSIX
expiryTimestamp :: Prelude.Maybe Data.POSIX,
    -- | The amount of time you expect this version of your managed rule group to
    -- last, in days.
    ManagedRuleSetVersion -> Maybe Natural
forecastedLifetime :: Prelude.Maybe Prelude.Natural,
    -- | The last time that you updated this version.
    --
    -- Times are in Coordinated Universal Time (UTC) format. UTC format
    -- includes the special designator, Z. For example, \"2016-09-27T14:50Z\".
    ManagedRuleSetVersion -> Maybe POSIX
lastUpdateTimestamp :: Prelude.Maybe Data.POSIX,
    -- | The time that you first published this version.
    --
    -- Times are in Coordinated Universal Time (UTC) format. UTC format
    -- includes the special designator, Z. For example, \"2016-09-27T14:50Z\".
    ManagedRuleSetVersion -> Maybe POSIX
publishTimestamp :: Prelude.Maybe Data.POSIX
  }
  deriving (ManagedRuleSetVersion -> ManagedRuleSetVersion -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ManagedRuleSetVersion -> ManagedRuleSetVersion -> Bool
$c/= :: ManagedRuleSetVersion -> ManagedRuleSetVersion -> Bool
== :: ManagedRuleSetVersion -> ManagedRuleSetVersion -> Bool
$c== :: ManagedRuleSetVersion -> ManagedRuleSetVersion -> Bool
Prelude.Eq, ReadPrec [ManagedRuleSetVersion]
ReadPrec ManagedRuleSetVersion
Int -> ReadS ManagedRuleSetVersion
ReadS [ManagedRuleSetVersion]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ManagedRuleSetVersion]
$creadListPrec :: ReadPrec [ManagedRuleSetVersion]
readPrec :: ReadPrec ManagedRuleSetVersion
$creadPrec :: ReadPrec ManagedRuleSetVersion
readList :: ReadS [ManagedRuleSetVersion]
$creadList :: ReadS [ManagedRuleSetVersion]
readsPrec :: Int -> ReadS ManagedRuleSetVersion
$creadsPrec :: Int -> ReadS ManagedRuleSetVersion
Prelude.Read, Int -> ManagedRuleSetVersion -> ShowS
[ManagedRuleSetVersion] -> ShowS
ManagedRuleSetVersion -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ManagedRuleSetVersion] -> ShowS
$cshowList :: [ManagedRuleSetVersion] -> ShowS
show :: ManagedRuleSetVersion -> String
$cshow :: ManagedRuleSetVersion -> String
showsPrec :: Int -> ManagedRuleSetVersion -> ShowS
$cshowsPrec :: Int -> ManagedRuleSetVersion -> ShowS
Prelude.Show, forall x. Rep ManagedRuleSetVersion x -> ManagedRuleSetVersion
forall x. ManagedRuleSetVersion -> Rep ManagedRuleSetVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ManagedRuleSetVersion x -> ManagedRuleSetVersion
$cfrom :: forall x. ManagedRuleSetVersion -> Rep ManagedRuleSetVersion x
Prelude.Generic)

-- |
-- Create a value of 'ManagedRuleSetVersion' 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:
--
-- 'associatedRuleGroupArn', 'managedRuleSetVersion_associatedRuleGroupArn' - The Amazon Resource Name (ARN) of the vendor rule group that\'s used to
-- define the published version of your managed rule group.
--
-- 'capacity', 'managedRuleSetVersion_capacity' - The web ACL capacity units (WCUs) required for this rule group.
--
-- WAF uses WCUs to calculate and control the operating resources that are
-- used to run your rules, rule groups, and web ACLs. WAF calculates
-- capacity differently for each rule type, to reflect the relative cost of
-- each rule. Simple rules that cost little to run use fewer WCUs than more
-- complex rules that use more processing power. Rule group capacity is
-- fixed at creation, which helps users plan their web ACL WCU usage when
-- they use a rule group. The WCU limit for web ACLs is 1,500.
--
-- 'expiryTimestamp', 'managedRuleSetVersion_expiryTimestamp' - The time that this version is set to expire.
--
-- Times are in Coordinated Universal Time (UTC) format. UTC format
-- includes the special designator, Z. For example, \"2016-09-27T14:50Z\".
--
-- 'forecastedLifetime', 'managedRuleSetVersion_forecastedLifetime' - The amount of time you expect this version of your managed rule group to
-- last, in days.
--
-- 'lastUpdateTimestamp', 'managedRuleSetVersion_lastUpdateTimestamp' - The last time that you updated this version.
--
-- Times are in Coordinated Universal Time (UTC) format. UTC format
-- includes the special designator, Z. For example, \"2016-09-27T14:50Z\".
--
-- 'publishTimestamp', 'managedRuleSetVersion_publishTimestamp' - The time that you first published this version.
--
-- Times are in Coordinated Universal Time (UTC) format. UTC format
-- includes the special designator, Z. For example, \"2016-09-27T14:50Z\".
newManagedRuleSetVersion ::
  ManagedRuleSetVersion
newManagedRuleSetVersion :: ManagedRuleSetVersion
newManagedRuleSetVersion =
  ManagedRuleSetVersion'
    { $sel:associatedRuleGroupArn:ManagedRuleSetVersion' :: Maybe Text
associatedRuleGroupArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:capacity:ManagedRuleSetVersion' :: Maybe Natural
capacity = forall a. Maybe a
Prelude.Nothing,
      $sel:expiryTimestamp:ManagedRuleSetVersion' :: Maybe POSIX
expiryTimestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:forecastedLifetime:ManagedRuleSetVersion' :: Maybe Natural
forecastedLifetime = forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdateTimestamp:ManagedRuleSetVersion' :: Maybe POSIX
lastUpdateTimestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:publishTimestamp:ManagedRuleSetVersion' :: Maybe POSIX
publishTimestamp = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the vendor rule group that\'s used to
-- define the published version of your managed rule group.
managedRuleSetVersion_associatedRuleGroupArn :: Lens.Lens' ManagedRuleSetVersion (Prelude.Maybe Prelude.Text)
managedRuleSetVersion_associatedRuleGroupArn :: Lens' ManagedRuleSetVersion (Maybe Text)
managedRuleSetVersion_associatedRuleGroupArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleSetVersion' {Maybe Text
associatedRuleGroupArn :: Maybe Text
$sel:associatedRuleGroupArn:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe Text
associatedRuleGroupArn} -> Maybe Text
associatedRuleGroupArn) (\s :: ManagedRuleSetVersion
s@ManagedRuleSetVersion' {} Maybe Text
a -> ManagedRuleSetVersion
s {$sel:associatedRuleGroupArn:ManagedRuleSetVersion' :: Maybe Text
associatedRuleGroupArn = Maybe Text
a} :: ManagedRuleSetVersion)

-- | The web ACL capacity units (WCUs) required for this rule group.
--
-- WAF uses WCUs to calculate and control the operating resources that are
-- used to run your rules, rule groups, and web ACLs. WAF calculates
-- capacity differently for each rule type, to reflect the relative cost of
-- each rule. Simple rules that cost little to run use fewer WCUs than more
-- complex rules that use more processing power. Rule group capacity is
-- fixed at creation, which helps users plan their web ACL WCU usage when
-- they use a rule group. The WCU limit for web ACLs is 1,500.
managedRuleSetVersion_capacity :: Lens.Lens' ManagedRuleSetVersion (Prelude.Maybe Prelude.Natural)
managedRuleSetVersion_capacity :: Lens' ManagedRuleSetVersion (Maybe Natural)
managedRuleSetVersion_capacity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleSetVersion' {Maybe Natural
capacity :: Maybe Natural
$sel:capacity:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe Natural
capacity} -> Maybe Natural
capacity) (\s :: ManagedRuleSetVersion
s@ManagedRuleSetVersion' {} Maybe Natural
a -> ManagedRuleSetVersion
s {$sel:capacity:ManagedRuleSetVersion' :: Maybe Natural
capacity = Maybe Natural
a} :: ManagedRuleSetVersion)

-- | The time that this version is set to expire.
--
-- Times are in Coordinated Universal Time (UTC) format. UTC format
-- includes the special designator, Z. For example, \"2016-09-27T14:50Z\".
managedRuleSetVersion_expiryTimestamp :: Lens.Lens' ManagedRuleSetVersion (Prelude.Maybe Prelude.UTCTime)
managedRuleSetVersion_expiryTimestamp :: Lens' ManagedRuleSetVersion (Maybe UTCTime)
managedRuleSetVersion_expiryTimestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleSetVersion' {Maybe POSIX
expiryTimestamp :: Maybe POSIX
$sel:expiryTimestamp:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe POSIX
expiryTimestamp} -> Maybe POSIX
expiryTimestamp) (\s :: ManagedRuleSetVersion
s@ManagedRuleSetVersion' {} Maybe POSIX
a -> ManagedRuleSetVersion
s {$sel:expiryTimestamp:ManagedRuleSetVersion' :: Maybe POSIX
expiryTimestamp = Maybe POSIX
a} :: ManagedRuleSetVersion) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The amount of time you expect this version of your managed rule group to
-- last, in days.
managedRuleSetVersion_forecastedLifetime :: Lens.Lens' ManagedRuleSetVersion (Prelude.Maybe Prelude.Natural)
managedRuleSetVersion_forecastedLifetime :: Lens' ManagedRuleSetVersion (Maybe Natural)
managedRuleSetVersion_forecastedLifetime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleSetVersion' {Maybe Natural
forecastedLifetime :: Maybe Natural
$sel:forecastedLifetime:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe Natural
forecastedLifetime} -> Maybe Natural
forecastedLifetime) (\s :: ManagedRuleSetVersion
s@ManagedRuleSetVersion' {} Maybe Natural
a -> ManagedRuleSetVersion
s {$sel:forecastedLifetime:ManagedRuleSetVersion' :: Maybe Natural
forecastedLifetime = Maybe Natural
a} :: ManagedRuleSetVersion)

-- | The last time that you updated this version.
--
-- Times are in Coordinated Universal Time (UTC) format. UTC format
-- includes the special designator, Z. For example, \"2016-09-27T14:50Z\".
managedRuleSetVersion_lastUpdateTimestamp :: Lens.Lens' ManagedRuleSetVersion (Prelude.Maybe Prelude.UTCTime)
managedRuleSetVersion_lastUpdateTimestamp :: Lens' ManagedRuleSetVersion (Maybe UTCTime)
managedRuleSetVersion_lastUpdateTimestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleSetVersion' {Maybe POSIX
lastUpdateTimestamp :: Maybe POSIX
$sel:lastUpdateTimestamp:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe POSIX
lastUpdateTimestamp} -> Maybe POSIX
lastUpdateTimestamp) (\s :: ManagedRuleSetVersion
s@ManagedRuleSetVersion' {} Maybe POSIX
a -> ManagedRuleSetVersion
s {$sel:lastUpdateTimestamp:ManagedRuleSetVersion' :: Maybe POSIX
lastUpdateTimestamp = Maybe POSIX
a} :: ManagedRuleSetVersion) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The time that you first published this version.
--
-- Times are in Coordinated Universal Time (UTC) format. UTC format
-- includes the special designator, Z. For example, \"2016-09-27T14:50Z\".
managedRuleSetVersion_publishTimestamp :: Lens.Lens' ManagedRuleSetVersion (Prelude.Maybe Prelude.UTCTime)
managedRuleSetVersion_publishTimestamp :: Lens' ManagedRuleSetVersion (Maybe UTCTime)
managedRuleSetVersion_publishTimestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleSetVersion' {Maybe POSIX
publishTimestamp :: Maybe POSIX
$sel:publishTimestamp:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe POSIX
publishTimestamp} -> Maybe POSIX
publishTimestamp) (\s :: ManagedRuleSetVersion
s@ManagedRuleSetVersion' {} Maybe POSIX
a -> ManagedRuleSetVersion
s {$sel:publishTimestamp:ManagedRuleSetVersion' :: Maybe POSIX
publishTimestamp = Maybe POSIX
a} :: ManagedRuleSetVersion) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON ManagedRuleSetVersion where
  parseJSON :: Value -> Parser ManagedRuleSetVersion
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ManagedRuleSetVersion"
      ( \Object
x ->
          Maybe Text
-> Maybe Natural
-> Maybe POSIX
-> Maybe Natural
-> Maybe POSIX
-> Maybe POSIX
-> ManagedRuleSetVersion
ManagedRuleSetVersion'
            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
"AssociatedRuleGroupArn")
            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
"Capacity")
            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
"ExpiryTimestamp")
            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
"ForecastedLifetime")
            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
"LastUpdateTimestamp")
            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
"PublishTimestamp")
      )

instance Prelude.Hashable ManagedRuleSetVersion where
  hashWithSalt :: Int -> ManagedRuleSetVersion -> Int
hashWithSalt Int
_salt ManagedRuleSetVersion' {Maybe Natural
Maybe Text
Maybe POSIX
publishTimestamp :: Maybe POSIX
lastUpdateTimestamp :: Maybe POSIX
forecastedLifetime :: Maybe Natural
expiryTimestamp :: Maybe POSIX
capacity :: Maybe Natural
associatedRuleGroupArn :: Maybe Text
$sel:publishTimestamp:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe POSIX
$sel:lastUpdateTimestamp:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe POSIX
$sel:forecastedLifetime:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe Natural
$sel:expiryTimestamp:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe POSIX
$sel:capacity:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe Natural
$sel:associatedRuleGroupArn:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
associatedRuleGroupArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
capacity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
expiryTimestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
forecastedLifetime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastUpdateTimestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
publishTimestamp

instance Prelude.NFData ManagedRuleSetVersion where
  rnf :: ManagedRuleSetVersion -> ()
rnf ManagedRuleSetVersion' {Maybe Natural
Maybe Text
Maybe POSIX
publishTimestamp :: Maybe POSIX
lastUpdateTimestamp :: Maybe POSIX
forecastedLifetime :: Maybe Natural
expiryTimestamp :: Maybe POSIX
capacity :: Maybe Natural
associatedRuleGroupArn :: Maybe Text
$sel:publishTimestamp:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe POSIX
$sel:lastUpdateTimestamp:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe POSIX
$sel:forecastedLifetime:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe Natural
$sel:expiryTimestamp:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe POSIX
$sel:capacity:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe Natural
$sel:associatedRuleGroupArn:ManagedRuleSetVersion' :: ManagedRuleSetVersion -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
associatedRuleGroupArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
capacity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
expiryTimestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
forecastedLifetime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastUpdateTimestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
publishTimestamp