{-# 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.RedshiftServerLess.Types.UsageLimit
-- 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.RedshiftServerLess.Types.UsageLimit 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.RedshiftServerLess.Types.UsageLimitBreachAction
import Amazonka.RedshiftServerLess.Types.UsageLimitPeriod
import Amazonka.RedshiftServerLess.Types.UsageLimitUsageType

-- | The usage limit object.
--
-- /See:/ 'newUsageLimit' smart constructor.
data UsageLimit = UsageLimit'
  { -- | The limit amount. If time-based, this amount is in RPUs consumed per
    -- hour. If data-based, this amount is in terabytes (TB). The value must be
    -- a positive number.
    UsageLimit -> Maybe Integer
amount :: Prelude.Maybe Prelude.Integer,
    -- | The action that Amazon Redshift Serverless takes when the limit is
    -- reached.
    UsageLimit -> Maybe UsageLimitBreachAction
breachAction :: Prelude.Maybe UsageLimitBreachAction,
    -- | The time period that the amount applies to. A weekly period begins on
    -- Sunday. The default is monthly.
    UsageLimit -> Maybe UsageLimitPeriod
period :: Prelude.Maybe UsageLimitPeriod,
    -- | The Amazon Resource Name (ARN) that identifies the Amazon Redshift
    -- Serverless resource.
    UsageLimit -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the resource associated with the usage
    -- limit.
    UsageLimit -> Maybe Text
usageLimitArn :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the usage limit.
    UsageLimit -> Maybe Text
usageLimitId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Redshift Serverless feature to limit.
    UsageLimit -> Maybe UsageLimitUsageType
usageType :: Prelude.Maybe UsageLimitUsageType
  }
  deriving (UsageLimit -> UsageLimit -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UsageLimit -> UsageLimit -> Bool
$c/= :: UsageLimit -> UsageLimit -> Bool
== :: UsageLimit -> UsageLimit -> Bool
$c== :: UsageLimit -> UsageLimit -> Bool
Prelude.Eq, ReadPrec [UsageLimit]
ReadPrec UsageLimit
Int -> ReadS UsageLimit
ReadS [UsageLimit]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UsageLimit]
$creadListPrec :: ReadPrec [UsageLimit]
readPrec :: ReadPrec UsageLimit
$creadPrec :: ReadPrec UsageLimit
readList :: ReadS [UsageLimit]
$creadList :: ReadS [UsageLimit]
readsPrec :: Int -> ReadS UsageLimit
$creadsPrec :: Int -> ReadS UsageLimit
Prelude.Read, Int -> UsageLimit -> ShowS
[UsageLimit] -> ShowS
UsageLimit -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UsageLimit] -> ShowS
$cshowList :: [UsageLimit] -> ShowS
show :: UsageLimit -> String
$cshow :: UsageLimit -> String
showsPrec :: Int -> UsageLimit -> ShowS
$cshowsPrec :: Int -> UsageLimit -> ShowS
Prelude.Show, forall x. Rep UsageLimit x -> UsageLimit
forall x. UsageLimit -> Rep UsageLimit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UsageLimit x -> UsageLimit
$cfrom :: forall x. UsageLimit -> Rep UsageLimit x
Prelude.Generic)

-- |
-- Create a value of 'UsageLimit' 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:
--
-- 'amount', 'usageLimit_amount' - The limit amount. If time-based, this amount is in RPUs consumed per
-- hour. If data-based, this amount is in terabytes (TB). The value must be
-- a positive number.
--
-- 'breachAction', 'usageLimit_breachAction' - The action that Amazon Redshift Serverless takes when the limit is
-- reached.
--
-- 'period', 'usageLimit_period' - The time period that the amount applies to. A weekly period begins on
-- Sunday. The default is monthly.
--
-- 'resourceArn', 'usageLimit_resourceArn' - The Amazon Resource Name (ARN) that identifies the Amazon Redshift
-- Serverless resource.
--
-- 'usageLimitArn', 'usageLimit_usageLimitArn' - The Amazon Resource Name (ARN) of the resource associated with the usage
-- limit.
--
-- 'usageLimitId', 'usageLimit_usageLimitId' - The identifier of the usage limit.
--
-- 'usageType', 'usageLimit_usageType' - The Amazon Redshift Serverless feature to limit.
newUsageLimit ::
  UsageLimit
newUsageLimit :: UsageLimit
newUsageLimit =
  UsageLimit'
    { $sel:amount:UsageLimit' :: Maybe Integer
amount = forall a. Maybe a
Prelude.Nothing,
      $sel:breachAction:UsageLimit' :: Maybe UsageLimitBreachAction
breachAction = forall a. Maybe a
Prelude.Nothing,
      $sel:period:UsageLimit' :: Maybe UsageLimitPeriod
period = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:UsageLimit' :: Maybe Text
resourceArn = forall a. Maybe a
Prelude.Nothing,
      $sel:usageLimitArn:UsageLimit' :: Maybe Text
usageLimitArn = forall a. Maybe a
Prelude.Nothing,
      $sel:usageLimitId:UsageLimit' :: Maybe Text
usageLimitId = forall a. Maybe a
Prelude.Nothing,
      $sel:usageType:UsageLimit' :: Maybe UsageLimitUsageType
usageType = forall a. Maybe a
Prelude.Nothing
    }

-- | The limit amount. If time-based, this amount is in RPUs consumed per
-- hour. If data-based, this amount is in terabytes (TB). The value must be
-- a positive number.
usageLimit_amount :: Lens.Lens' UsageLimit (Prelude.Maybe Prelude.Integer)
usageLimit_amount :: Lens' UsageLimit (Maybe Integer)
usageLimit_amount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageLimit' {Maybe Integer
amount :: Maybe Integer
$sel:amount:UsageLimit' :: UsageLimit -> Maybe Integer
amount} -> Maybe Integer
amount) (\s :: UsageLimit
s@UsageLimit' {} Maybe Integer
a -> UsageLimit
s {$sel:amount:UsageLimit' :: Maybe Integer
amount = Maybe Integer
a} :: UsageLimit)

-- | The action that Amazon Redshift Serverless takes when the limit is
-- reached.
usageLimit_breachAction :: Lens.Lens' UsageLimit (Prelude.Maybe UsageLimitBreachAction)
usageLimit_breachAction :: Lens' UsageLimit (Maybe UsageLimitBreachAction)
usageLimit_breachAction = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageLimit' {Maybe UsageLimitBreachAction
breachAction :: Maybe UsageLimitBreachAction
$sel:breachAction:UsageLimit' :: UsageLimit -> Maybe UsageLimitBreachAction
breachAction} -> Maybe UsageLimitBreachAction
breachAction) (\s :: UsageLimit
s@UsageLimit' {} Maybe UsageLimitBreachAction
a -> UsageLimit
s {$sel:breachAction:UsageLimit' :: Maybe UsageLimitBreachAction
breachAction = Maybe UsageLimitBreachAction
a} :: UsageLimit)

-- | The time period that the amount applies to. A weekly period begins on
-- Sunday. The default is monthly.
usageLimit_period :: Lens.Lens' UsageLimit (Prelude.Maybe UsageLimitPeriod)
usageLimit_period :: Lens' UsageLimit (Maybe UsageLimitPeriod)
usageLimit_period = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageLimit' {Maybe UsageLimitPeriod
period :: Maybe UsageLimitPeriod
$sel:period:UsageLimit' :: UsageLimit -> Maybe UsageLimitPeriod
period} -> Maybe UsageLimitPeriod
period) (\s :: UsageLimit
s@UsageLimit' {} Maybe UsageLimitPeriod
a -> UsageLimit
s {$sel:period:UsageLimit' :: Maybe UsageLimitPeriod
period = Maybe UsageLimitPeriod
a} :: UsageLimit)

-- | The Amazon Resource Name (ARN) that identifies the Amazon Redshift
-- Serverless resource.
usageLimit_resourceArn :: Lens.Lens' UsageLimit (Prelude.Maybe Prelude.Text)
usageLimit_resourceArn :: Lens' UsageLimit (Maybe Text)
usageLimit_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageLimit' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:UsageLimit' :: UsageLimit -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: UsageLimit
s@UsageLimit' {} Maybe Text
a -> UsageLimit
s {$sel:resourceArn:UsageLimit' :: Maybe Text
resourceArn = Maybe Text
a} :: UsageLimit)

-- | The Amazon Resource Name (ARN) of the resource associated with the usage
-- limit.
usageLimit_usageLimitArn :: Lens.Lens' UsageLimit (Prelude.Maybe Prelude.Text)
usageLimit_usageLimitArn :: Lens' UsageLimit (Maybe Text)
usageLimit_usageLimitArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageLimit' {Maybe Text
usageLimitArn :: Maybe Text
$sel:usageLimitArn:UsageLimit' :: UsageLimit -> Maybe Text
usageLimitArn} -> Maybe Text
usageLimitArn) (\s :: UsageLimit
s@UsageLimit' {} Maybe Text
a -> UsageLimit
s {$sel:usageLimitArn:UsageLimit' :: Maybe Text
usageLimitArn = Maybe Text
a} :: UsageLimit)

-- | The identifier of the usage limit.
usageLimit_usageLimitId :: Lens.Lens' UsageLimit (Prelude.Maybe Prelude.Text)
usageLimit_usageLimitId :: Lens' UsageLimit (Maybe Text)
usageLimit_usageLimitId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageLimit' {Maybe Text
usageLimitId :: Maybe Text
$sel:usageLimitId:UsageLimit' :: UsageLimit -> Maybe Text
usageLimitId} -> Maybe Text
usageLimitId) (\s :: UsageLimit
s@UsageLimit' {} Maybe Text
a -> UsageLimit
s {$sel:usageLimitId:UsageLimit' :: Maybe Text
usageLimitId = Maybe Text
a} :: UsageLimit)

-- | The Amazon Redshift Serverless feature to limit.
usageLimit_usageType :: Lens.Lens' UsageLimit (Prelude.Maybe UsageLimitUsageType)
usageLimit_usageType :: Lens' UsageLimit (Maybe UsageLimitUsageType)
usageLimit_usageType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageLimit' {Maybe UsageLimitUsageType
usageType :: Maybe UsageLimitUsageType
$sel:usageType:UsageLimit' :: UsageLimit -> Maybe UsageLimitUsageType
usageType} -> Maybe UsageLimitUsageType
usageType) (\s :: UsageLimit
s@UsageLimit' {} Maybe UsageLimitUsageType
a -> UsageLimit
s {$sel:usageType:UsageLimit' :: Maybe UsageLimitUsageType
usageType = Maybe UsageLimitUsageType
a} :: UsageLimit)

instance Data.FromJSON UsageLimit where
  parseJSON :: Value -> Parser UsageLimit
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UsageLimit"
      ( \Object
x ->
          Maybe Integer
-> Maybe UsageLimitBreachAction
-> Maybe UsageLimitPeriod
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe UsageLimitUsageType
-> UsageLimit
UsageLimit'
            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
"amount")
            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
"breachAction")
            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
"period")
            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
"resourceArn")
            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
"usageLimitArn")
            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
"usageLimitId")
            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
"usageType")
      )

instance Prelude.Hashable UsageLimit where
  hashWithSalt :: Int -> UsageLimit -> Int
hashWithSalt Int
_salt UsageLimit' {Maybe Integer
Maybe Text
Maybe UsageLimitBreachAction
Maybe UsageLimitPeriod
Maybe UsageLimitUsageType
usageType :: Maybe UsageLimitUsageType
usageLimitId :: Maybe Text
usageLimitArn :: Maybe Text
resourceArn :: Maybe Text
period :: Maybe UsageLimitPeriod
breachAction :: Maybe UsageLimitBreachAction
amount :: Maybe Integer
$sel:usageType:UsageLimit' :: UsageLimit -> Maybe UsageLimitUsageType
$sel:usageLimitId:UsageLimit' :: UsageLimit -> Maybe Text
$sel:usageLimitArn:UsageLimit' :: UsageLimit -> Maybe Text
$sel:resourceArn:UsageLimit' :: UsageLimit -> Maybe Text
$sel:period:UsageLimit' :: UsageLimit -> Maybe UsageLimitPeriod
$sel:breachAction:UsageLimit' :: UsageLimit -> Maybe UsageLimitBreachAction
$sel:amount:UsageLimit' :: UsageLimit -> Maybe Integer
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
amount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UsageLimitBreachAction
breachAction
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UsageLimitPeriod
period
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
usageLimitArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
usageLimitId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UsageLimitUsageType
usageType

instance Prelude.NFData UsageLimit where
  rnf :: UsageLimit -> ()
rnf UsageLimit' {Maybe Integer
Maybe Text
Maybe UsageLimitBreachAction
Maybe UsageLimitPeriod
Maybe UsageLimitUsageType
usageType :: Maybe UsageLimitUsageType
usageLimitId :: Maybe Text
usageLimitArn :: Maybe Text
resourceArn :: Maybe Text
period :: Maybe UsageLimitPeriod
breachAction :: Maybe UsageLimitBreachAction
amount :: Maybe Integer
$sel:usageType:UsageLimit' :: UsageLimit -> Maybe UsageLimitUsageType
$sel:usageLimitId:UsageLimit' :: UsageLimit -> Maybe Text
$sel:usageLimitArn:UsageLimit' :: UsageLimit -> Maybe Text
$sel:resourceArn:UsageLimit' :: UsageLimit -> Maybe Text
$sel:period:UsageLimit' :: UsageLimit -> Maybe UsageLimitPeriod
$sel:breachAction:UsageLimit' :: UsageLimit -> Maybe UsageLimitBreachAction
$sel:amount:UsageLimit' :: UsageLimit -> Maybe Integer
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
amount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UsageLimitBreachAction
breachAction
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UsageLimitPeriod
period
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
usageLimitArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
usageLimitId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UsageLimitUsageType
usageType