{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Redshift.ModifyUsageLimit
-- 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)
--
-- Modifies a usage limit in a cluster. You can\'t modify the feature type
-- or period of a usage limit.
module Amazonka.Redshift.ModifyUsageLimit
  ( -- * Creating a Request
    ModifyUsageLimit (..),
    newModifyUsageLimit,

    -- * Request Lenses
    modifyUsageLimit_amount,
    modifyUsageLimit_breachAction,
    modifyUsageLimit_usageLimitId,

    -- * Destructuring the Response
    UsageLimit (..),
    newUsageLimit,

    -- * Response Lenses
    usageLimit_amount,
    usageLimit_limitType,
    usageLimit_usageLimitId,
    usageLimit_period,
    usageLimit_clusterIdentifier,
    usageLimit_breachAction,
    usageLimit_featureType,
    usageLimit_tags,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newModifyUsageLimit' smart constructor.
data ModifyUsageLimit = ModifyUsageLimit'
  { -- | The new limit amount. For more information about this parameter, see
    -- UsageLimit.
    ModifyUsageLimit -> Maybe Integer
amount :: Prelude.Maybe Prelude.Integer,
    -- | The new action that Amazon Redshift takes when the limit is reached. For
    -- more information about this parameter, see UsageLimit.
    ModifyUsageLimit -> Maybe UsageLimitBreachAction
breachAction :: Prelude.Maybe UsageLimitBreachAction,
    -- | The identifier of the usage limit to modify.
    ModifyUsageLimit -> Text
usageLimitId :: Prelude.Text
  }
  deriving (ModifyUsageLimit -> ModifyUsageLimit -> Bool
(ModifyUsageLimit -> ModifyUsageLimit -> Bool)
-> (ModifyUsageLimit -> ModifyUsageLimit -> Bool)
-> Eq ModifyUsageLimit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifyUsageLimit -> ModifyUsageLimit -> Bool
$c/= :: ModifyUsageLimit -> ModifyUsageLimit -> Bool
== :: ModifyUsageLimit -> ModifyUsageLimit -> Bool
$c== :: ModifyUsageLimit -> ModifyUsageLimit -> Bool
Prelude.Eq, ReadPrec [ModifyUsageLimit]
ReadPrec ModifyUsageLimit
Int -> ReadS ModifyUsageLimit
ReadS [ModifyUsageLimit]
(Int -> ReadS ModifyUsageLimit)
-> ReadS [ModifyUsageLimit]
-> ReadPrec ModifyUsageLimit
-> ReadPrec [ModifyUsageLimit]
-> Read ModifyUsageLimit
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifyUsageLimit]
$creadListPrec :: ReadPrec [ModifyUsageLimit]
readPrec :: ReadPrec ModifyUsageLimit
$creadPrec :: ReadPrec ModifyUsageLimit
readList :: ReadS [ModifyUsageLimit]
$creadList :: ReadS [ModifyUsageLimit]
readsPrec :: Int -> ReadS ModifyUsageLimit
$creadsPrec :: Int -> ReadS ModifyUsageLimit
Prelude.Read, Int -> ModifyUsageLimit -> ShowS
[ModifyUsageLimit] -> ShowS
ModifyUsageLimit -> String
(Int -> ModifyUsageLimit -> ShowS)
-> (ModifyUsageLimit -> String)
-> ([ModifyUsageLimit] -> ShowS)
-> Show ModifyUsageLimit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifyUsageLimit] -> ShowS
$cshowList :: [ModifyUsageLimit] -> ShowS
show :: ModifyUsageLimit -> String
$cshow :: ModifyUsageLimit -> String
showsPrec :: Int -> ModifyUsageLimit -> ShowS
$cshowsPrec :: Int -> ModifyUsageLimit -> ShowS
Prelude.Show, (forall x. ModifyUsageLimit -> Rep ModifyUsageLimit x)
-> (forall x. Rep ModifyUsageLimit x -> ModifyUsageLimit)
-> Generic ModifyUsageLimit
forall x. Rep ModifyUsageLimit x -> ModifyUsageLimit
forall x. ModifyUsageLimit -> Rep ModifyUsageLimit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModifyUsageLimit x -> ModifyUsageLimit
$cfrom :: forall x. ModifyUsageLimit -> Rep ModifyUsageLimit x
Prelude.Generic)

-- |
-- Create a value of 'ModifyUsageLimit' 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', 'modifyUsageLimit_amount' - The new limit amount. For more information about this parameter, see
-- UsageLimit.
--
-- 'breachAction', 'modifyUsageLimit_breachAction' - The new action that Amazon Redshift takes when the limit is reached. For
-- more information about this parameter, see UsageLimit.
--
-- 'usageLimitId', 'modifyUsageLimit_usageLimitId' - The identifier of the usage limit to modify.
newModifyUsageLimit ::
  -- | 'usageLimitId'
  Prelude.Text ->
  ModifyUsageLimit
newModifyUsageLimit :: Text -> ModifyUsageLimit
newModifyUsageLimit Text
pUsageLimitId_ =
  ModifyUsageLimit' :: Maybe Integer
-> Maybe UsageLimitBreachAction -> Text -> ModifyUsageLimit
ModifyUsageLimit'
    { $sel:amount:ModifyUsageLimit' :: Maybe Integer
amount = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:breachAction:ModifyUsageLimit' :: Maybe UsageLimitBreachAction
breachAction = Maybe UsageLimitBreachAction
forall a. Maybe a
Prelude.Nothing,
      $sel:usageLimitId:ModifyUsageLimit' :: Text
usageLimitId = Text
pUsageLimitId_
    }

-- | The new limit amount. For more information about this parameter, see
-- UsageLimit.
modifyUsageLimit_amount :: Lens.Lens' ModifyUsageLimit (Prelude.Maybe Prelude.Integer)
modifyUsageLimit_amount :: (Maybe Integer -> f (Maybe Integer))
-> ModifyUsageLimit -> f ModifyUsageLimit
modifyUsageLimit_amount = (ModifyUsageLimit -> Maybe Integer)
-> (ModifyUsageLimit -> Maybe Integer -> ModifyUsageLimit)
-> Lens
     ModifyUsageLimit ModifyUsageLimit (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyUsageLimit' {Maybe Integer
amount :: Maybe Integer
$sel:amount:ModifyUsageLimit' :: ModifyUsageLimit -> Maybe Integer
amount} -> Maybe Integer
amount) (\s :: ModifyUsageLimit
s@ModifyUsageLimit' {} Maybe Integer
a -> ModifyUsageLimit
s {$sel:amount:ModifyUsageLimit' :: Maybe Integer
amount = Maybe Integer
a} :: ModifyUsageLimit)

-- | The new action that Amazon Redshift takes when the limit is reached. For
-- more information about this parameter, see UsageLimit.
modifyUsageLimit_breachAction :: Lens.Lens' ModifyUsageLimit (Prelude.Maybe UsageLimitBreachAction)
modifyUsageLimit_breachAction :: (Maybe UsageLimitBreachAction -> f (Maybe UsageLimitBreachAction))
-> ModifyUsageLimit -> f ModifyUsageLimit
modifyUsageLimit_breachAction = (ModifyUsageLimit -> Maybe UsageLimitBreachAction)
-> (ModifyUsageLimit
    -> Maybe UsageLimitBreachAction -> ModifyUsageLimit)
-> Lens
     ModifyUsageLimit
     ModifyUsageLimit
     (Maybe UsageLimitBreachAction)
     (Maybe UsageLimitBreachAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyUsageLimit' {Maybe UsageLimitBreachAction
breachAction :: Maybe UsageLimitBreachAction
$sel:breachAction:ModifyUsageLimit' :: ModifyUsageLimit -> Maybe UsageLimitBreachAction
breachAction} -> Maybe UsageLimitBreachAction
breachAction) (\s :: ModifyUsageLimit
s@ModifyUsageLimit' {} Maybe UsageLimitBreachAction
a -> ModifyUsageLimit
s {$sel:breachAction:ModifyUsageLimit' :: Maybe UsageLimitBreachAction
breachAction = Maybe UsageLimitBreachAction
a} :: ModifyUsageLimit)

-- | The identifier of the usage limit to modify.
modifyUsageLimit_usageLimitId :: Lens.Lens' ModifyUsageLimit Prelude.Text
modifyUsageLimit_usageLimitId :: (Text -> f Text) -> ModifyUsageLimit -> f ModifyUsageLimit
modifyUsageLimit_usageLimitId = (ModifyUsageLimit -> Text)
-> (ModifyUsageLimit -> Text -> ModifyUsageLimit)
-> Lens ModifyUsageLimit ModifyUsageLimit Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyUsageLimit' {Text
usageLimitId :: Text
$sel:usageLimitId:ModifyUsageLimit' :: ModifyUsageLimit -> Text
usageLimitId} -> Text
usageLimitId) (\s :: ModifyUsageLimit
s@ModifyUsageLimit' {} Text
a -> ModifyUsageLimit
s {$sel:usageLimitId:ModifyUsageLimit' :: Text
usageLimitId = Text
a} :: ModifyUsageLimit)

instance Core.AWSRequest ModifyUsageLimit where
  type AWSResponse ModifyUsageLimit = UsageLimit
  request :: ModifyUsageLimit -> Request ModifyUsageLimit
request = Service -> ModifyUsageLimit -> Request ModifyUsageLimit
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ModifyUsageLimit
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ModifyUsageLimit)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ModifyUsageLimit))
-> Logger
-> Service
-> Proxy ModifyUsageLimit
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ModifyUsageLimit)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"ModifyUsageLimitResult"
      (\Int
s ResponseHeaders
h [Node]
x -> [Node] -> Either String UsageLimit
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)

instance Prelude.Hashable ModifyUsageLimit

instance Prelude.NFData ModifyUsageLimit

instance Core.ToHeaders ModifyUsageLimit where
  toHeaders :: ModifyUsageLimit -> ResponseHeaders
toHeaders = ResponseHeaders -> ModifyUsageLimit -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath ModifyUsageLimit where
  toPath :: ModifyUsageLimit -> ByteString
toPath = ByteString -> ModifyUsageLimit -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ModifyUsageLimit where
  toQuery :: ModifyUsageLimit -> QueryString
toQuery ModifyUsageLimit' {Maybe Integer
Maybe UsageLimitBreachAction
Text
usageLimitId :: Text
breachAction :: Maybe UsageLimitBreachAction
amount :: Maybe Integer
$sel:usageLimitId:ModifyUsageLimit' :: ModifyUsageLimit -> Text
$sel:breachAction:ModifyUsageLimit' :: ModifyUsageLimit -> Maybe UsageLimitBreachAction
$sel:amount:ModifyUsageLimit' :: ModifyUsageLimit -> Maybe Integer
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"ModifyUsageLimit" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"Amount" ByteString -> Maybe Integer -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Integer
amount,
        ByteString
"BreachAction" ByteString -> Maybe UsageLimitBreachAction -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe UsageLimitBreachAction
breachAction,
        ByteString
"UsageLimitId" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
usageLimitId
      ]