{-# 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.WAFV2.PutManagedRuleSetVersions
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Defines the versions of your managed rule set that you are offering to
-- the customers. Customers see your offerings as managed rule groups with
-- versioning.
--
-- 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@.
--
-- Customers retrieve their managed rule group list by calling
-- ListAvailableManagedRuleGroups. The name that you provide here for your
-- managed rule set is the name the customer sees for the corresponding
-- managed rule group. Customers can retrieve the available versions for a
-- managed rule group by calling ListAvailableManagedRuleGroupVersions. You
-- provide a rule group specification for each version. For each managed
-- rule set, you must specify a version that you recommend using.
--
-- To initiate the expiration of a managed rule group version, use
-- UpdateManagedRuleSetVersionExpiryDate.
module Amazonka.WAFV2.PutManagedRuleSetVersions
  ( -- * Creating a Request
    PutManagedRuleSetVersions (..),
    newPutManagedRuleSetVersions,

    -- * Request Lenses
    putManagedRuleSetVersions_recommendedVersion,
    putManagedRuleSetVersions_versionsToPublish,
    putManagedRuleSetVersions_name,
    putManagedRuleSetVersions_scope,
    putManagedRuleSetVersions_id,
    putManagedRuleSetVersions_lockToken,

    -- * Destructuring the Response
    PutManagedRuleSetVersionsResponse (..),
    newPutManagedRuleSetVersionsResponse,

    -- * Response Lenses
    putManagedRuleSetVersionsResponse_nextLockToken,
    putManagedRuleSetVersionsResponse_httpStatus,
  )
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.WAFV2.Types

-- | /See:/ 'newPutManagedRuleSetVersions' smart constructor.
data PutManagedRuleSetVersions = PutManagedRuleSetVersions'
  { -- | The version of the named managed rule group that you\'d like your
    -- customers to choose, from among your version offerings.
    PutManagedRuleSetVersions -> Maybe Text
recommendedVersion :: Prelude.Maybe Prelude.Text,
    -- | The versions of the named managed rule group that you want to offer to
    -- your customers.
    PutManagedRuleSetVersions -> Maybe (HashMap Text VersionToPublish)
versionsToPublish :: Prelude.Maybe (Prelude.HashMap Prelude.Text VersionToPublish),
    -- | The name of the managed rule set. You use this, along with the rule set
    -- ID, to identify the rule set.
    --
    -- This name is assigned to the corresponding managed rule group, which
    -- your customers can access and use.
    PutManagedRuleSetVersions -> Text
name :: Prelude.Text,
    -- | Specifies whether this is for an Amazon CloudFront distribution or for a
    -- regional application. A regional application can be an Application Load
    -- Balancer (ALB), an Amazon API Gateway REST API, an AppSync GraphQL API,
    -- or an Amazon Cognito user pool.
    --
    -- To work with CloudFront, you must also specify the Region US East (N.
    -- Virginia) as follows:
    --
    -- -   CLI - Specify the Region when you use the CloudFront scope:
    --     @--scope=CLOUDFRONT --region=us-east-1@.
    --
    -- -   API and SDKs - For all calls, use the Region endpoint us-east-1.
    PutManagedRuleSetVersions -> Scope
scope :: Scope,
    -- | A unique identifier for the managed rule set. The ID is returned in the
    -- responses to commands like @list@. You provide it to operations like
    -- @get@ and @update@.
    PutManagedRuleSetVersions -> Text
id :: Prelude.Text,
    -- | A token used for optimistic locking. WAF returns a token to your @get@
    -- and @list@ requests, to mark the state of the entity at the time of the
    -- request. To make changes to the entity associated with the token, you
    -- provide the token to operations like @update@ and @delete@. WAF uses the
    -- token to ensure that no changes have been made to the entity since you
    -- last retrieved it. If a change has been made, the update fails with a
    -- @WAFOptimisticLockException@. If this happens, perform another @get@,
    -- and use the new token returned by that operation.
    PutManagedRuleSetVersions -> Text
lockToken :: Prelude.Text
  }
  deriving (PutManagedRuleSetVersions -> PutManagedRuleSetVersions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutManagedRuleSetVersions -> PutManagedRuleSetVersions -> Bool
$c/= :: PutManagedRuleSetVersions -> PutManagedRuleSetVersions -> Bool
== :: PutManagedRuleSetVersions -> PutManagedRuleSetVersions -> Bool
$c== :: PutManagedRuleSetVersions -> PutManagedRuleSetVersions -> Bool
Prelude.Eq, ReadPrec [PutManagedRuleSetVersions]
ReadPrec PutManagedRuleSetVersions
Int -> ReadS PutManagedRuleSetVersions
ReadS [PutManagedRuleSetVersions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutManagedRuleSetVersions]
$creadListPrec :: ReadPrec [PutManagedRuleSetVersions]
readPrec :: ReadPrec PutManagedRuleSetVersions
$creadPrec :: ReadPrec PutManagedRuleSetVersions
readList :: ReadS [PutManagedRuleSetVersions]
$creadList :: ReadS [PutManagedRuleSetVersions]
readsPrec :: Int -> ReadS PutManagedRuleSetVersions
$creadsPrec :: Int -> ReadS PutManagedRuleSetVersions
Prelude.Read, Int -> PutManagedRuleSetVersions -> ShowS
[PutManagedRuleSetVersions] -> ShowS
PutManagedRuleSetVersions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutManagedRuleSetVersions] -> ShowS
$cshowList :: [PutManagedRuleSetVersions] -> ShowS
show :: PutManagedRuleSetVersions -> String
$cshow :: PutManagedRuleSetVersions -> String
showsPrec :: Int -> PutManagedRuleSetVersions -> ShowS
$cshowsPrec :: Int -> PutManagedRuleSetVersions -> ShowS
Prelude.Show, forall x.
Rep PutManagedRuleSetVersions x -> PutManagedRuleSetVersions
forall x.
PutManagedRuleSetVersions -> Rep PutManagedRuleSetVersions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutManagedRuleSetVersions x -> PutManagedRuleSetVersions
$cfrom :: forall x.
PutManagedRuleSetVersions -> Rep PutManagedRuleSetVersions x
Prelude.Generic)

-- |
-- Create a value of 'PutManagedRuleSetVersions' 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:
--
-- 'recommendedVersion', 'putManagedRuleSetVersions_recommendedVersion' - The version of the named managed rule group that you\'d like your
-- customers to choose, from among your version offerings.
--
-- 'versionsToPublish', 'putManagedRuleSetVersions_versionsToPublish' - The versions of the named managed rule group that you want to offer to
-- your customers.
--
-- 'name', 'putManagedRuleSetVersions_name' - The name of the managed rule set. You use this, along with the rule set
-- ID, to identify the rule set.
--
-- This name is assigned to the corresponding managed rule group, which
-- your customers can access and use.
--
-- 'scope', 'putManagedRuleSetVersions_scope' - Specifies whether this is for an Amazon CloudFront distribution or for a
-- regional application. A regional application can be an Application Load
-- Balancer (ALB), an Amazon API Gateway REST API, an AppSync GraphQL API,
-- or an Amazon Cognito user pool.
--
-- To work with CloudFront, you must also specify the Region US East (N.
-- Virginia) as follows:
--
-- -   CLI - Specify the Region when you use the CloudFront scope:
--     @--scope=CLOUDFRONT --region=us-east-1@.
--
-- -   API and SDKs - For all calls, use the Region endpoint us-east-1.
--
-- 'id', 'putManagedRuleSetVersions_id' - A unique identifier for the managed rule set. The ID is returned in the
-- responses to commands like @list@. You provide it to operations like
-- @get@ and @update@.
--
-- 'lockToken', 'putManagedRuleSetVersions_lockToken' - A token used for optimistic locking. WAF returns a token to your @get@
-- and @list@ requests, to mark the state of the entity at the time of the
-- request. To make changes to the entity associated with the token, you
-- provide the token to operations like @update@ and @delete@. WAF uses the
-- token to ensure that no changes have been made to the entity since you
-- last retrieved it. If a change has been made, the update fails with a
-- @WAFOptimisticLockException@. If this happens, perform another @get@,
-- and use the new token returned by that operation.
newPutManagedRuleSetVersions ::
  -- | 'name'
  Prelude.Text ->
  -- | 'scope'
  Scope ->
  -- | 'id'
  Prelude.Text ->
  -- | 'lockToken'
  Prelude.Text ->
  PutManagedRuleSetVersions
newPutManagedRuleSetVersions :: Text -> Scope -> Text -> Text -> PutManagedRuleSetVersions
newPutManagedRuleSetVersions
  Text
pName_
  Scope
pScope_
  Text
pId_
  Text
pLockToken_ =
    PutManagedRuleSetVersions'
      { $sel:recommendedVersion:PutManagedRuleSetVersions' :: Maybe Text
recommendedVersion =
          forall a. Maybe a
Prelude.Nothing,
        $sel:versionsToPublish:PutManagedRuleSetVersions' :: Maybe (HashMap Text VersionToPublish)
versionsToPublish = forall a. Maybe a
Prelude.Nothing,
        $sel:name:PutManagedRuleSetVersions' :: Text
name = Text
pName_,
        $sel:scope:PutManagedRuleSetVersions' :: Scope
scope = Scope
pScope_,
        $sel:id:PutManagedRuleSetVersions' :: Text
id = Text
pId_,
        $sel:lockToken:PutManagedRuleSetVersions' :: Text
lockToken = Text
pLockToken_
      }

-- | The version of the named managed rule group that you\'d like your
-- customers to choose, from among your version offerings.
putManagedRuleSetVersions_recommendedVersion :: Lens.Lens' PutManagedRuleSetVersions (Prelude.Maybe Prelude.Text)
putManagedRuleSetVersions_recommendedVersion :: Lens' PutManagedRuleSetVersions (Maybe Text)
putManagedRuleSetVersions_recommendedVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutManagedRuleSetVersions' {Maybe Text
recommendedVersion :: Maybe Text
$sel:recommendedVersion:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Maybe Text
recommendedVersion} -> Maybe Text
recommendedVersion) (\s :: PutManagedRuleSetVersions
s@PutManagedRuleSetVersions' {} Maybe Text
a -> PutManagedRuleSetVersions
s {$sel:recommendedVersion:PutManagedRuleSetVersions' :: Maybe Text
recommendedVersion = Maybe Text
a} :: PutManagedRuleSetVersions)

-- | The versions of the named managed rule group that you want to offer to
-- your customers.
putManagedRuleSetVersions_versionsToPublish :: Lens.Lens' PutManagedRuleSetVersions (Prelude.Maybe (Prelude.HashMap Prelude.Text VersionToPublish))
putManagedRuleSetVersions_versionsToPublish :: Lens'
  PutManagedRuleSetVersions (Maybe (HashMap Text VersionToPublish))
putManagedRuleSetVersions_versionsToPublish = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutManagedRuleSetVersions' {Maybe (HashMap Text VersionToPublish)
versionsToPublish :: Maybe (HashMap Text VersionToPublish)
$sel:versionsToPublish:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Maybe (HashMap Text VersionToPublish)
versionsToPublish} -> Maybe (HashMap Text VersionToPublish)
versionsToPublish) (\s :: PutManagedRuleSetVersions
s@PutManagedRuleSetVersions' {} Maybe (HashMap Text VersionToPublish)
a -> PutManagedRuleSetVersions
s {$sel:versionsToPublish:PutManagedRuleSetVersions' :: Maybe (HashMap Text VersionToPublish)
versionsToPublish = Maybe (HashMap Text VersionToPublish)
a} :: PutManagedRuleSetVersions) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the managed rule set. You use this, along with the rule set
-- ID, to identify the rule set.
--
-- This name is assigned to the corresponding managed rule group, which
-- your customers can access and use.
putManagedRuleSetVersions_name :: Lens.Lens' PutManagedRuleSetVersions Prelude.Text
putManagedRuleSetVersions_name :: Lens' PutManagedRuleSetVersions Text
putManagedRuleSetVersions_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutManagedRuleSetVersions' {Text
name :: Text
$sel:name:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Text
name} -> Text
name) (\s :: PutManagedRuleSetVersions
s@PutManagedRuleSetVersions' {} Text
a -> PutManagedRuleSetVersions
s {$sel:name:PutManagedRuleSetVersions' :: Text
name = Text
a} :: PutManagedRuleSetVersions)

-- | Specifies whether this is for an Amazon CloudFront distribution or for a
-- regional application. A regional application can be an Application Load
-- Balancer (ALB), an Amazon API Gateway REST API, an AppSync GraphQL API,
-- or an Amazon Cognito user pool.
--
-- To work with CloudFront, you must also specify the Region US East (N.
-- Virginia) as follows:
--
-- -   CLI - Specify the Region when you use the CloudFront scope:
--     @--scope=CLOUDFRONT --region=us-east-1@.
--
-- -   API and SDKs - For all calls, use the Region endpoint us-east-1.
putManagedRuleSetVersions_scope :: Lens.Lens' PutManagedRuleSetVersions Scope
putManagedRuleSetVersions_scope :: Lens' PutManagedRuleSetVersions Scope
putManagedRuleSetVersions_scope = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutManagedRuleSetVersions' {Scope
scope :: Scope
$sel:scope:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Scope
scope} -> Scope
scope) (\s :: PutManagedRuleSetVersions
s@PutManagedRuleSetVersions' {} Scope
a -> PutManagedRuleSetVersions
s {$sel:scope:PutManagedRuleSetVersions' :: Scope
scope = Scope
a} :: PutManagedRuleSetVersions)

-- | A unique identifier for the managed rule set. The ID is returned in the
-- responses to commands like @list@. You provide it to operations like
-- @get@ and @update@.
putManagedRuleSetVersions_id :: Lens.Lens' PutManagedRuleSetVersions Prelude.Text
putManagedRuleSetVersions_id :: Lens' PutManagedRuleSetVersions Text
putManagedRuleSetVersions_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutManagedRuleSetVersions' {Text
id :: Text
$sel:id:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Text
id} -> Text
id) (\s :: PutManagedRuleSetVersions
s@PutManagedRuleSetVersions' {} Text
a -> PutManagedRuleSetVersions
s {$sel:id:PutManagedRuleSetVersions' :: Text
id = Text
a} :: PutManagedRuleSetVersions)

-- | A token used for optimistic locking. WAF returns a token to your @get@
-- and @list@ requests, to mark the state of the entity at the time of the
-- request. To make changes to the entity associated with the token, you
-- provide the token to operations like @update@ and @delete@. WAF uses the
-- token to ensure that no changes have been made to the entity since you
-- last retrieved it. If a change has been made, the update fails with a
-- @WAFOptimisticLockException@. If this happens, perform another @get@,
-- and use the new token returned by that operation.
putManagedRuleSetVersions_lockToken :: Lens.Lens' PutManagedRuleSetVersions Prelude.Text
putManagedRuleSetVersions_lockToken :: Lens' PutManagedRuleSetVersions Text
putManagedRuleSetVersions_lockToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutManagedRuleSetVersions' {Text
lockToken :: Text
$sel:lockToken:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Text
lockToken} -> Text
lockToken) (\s :: PutManagedRuleSetVersions
s@PutManagedRuleSetVersions' {} Text
a -> PutManagedRuleSetVersions
s {$sel:lockToken:PutManagedRuleSetVersions' :: Text
lockToken = Text
a} :: PutManagedRuleSetVersions)

instance Core.AWSRequest PutManagedRuleSetVersions where
  type
    AWSResponse PutManagedRuleSetVersions =
      PutManagedRuleSetVersionsResponse
  request :: (Service -> Service)
-> PutManagedRuleSetVersions -> Request PutManagedRuleSetVersions
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PutManagedRuleSetVersions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutManagedRuleSetVersions)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> PutManagedRuleSetVersionsResponse
PutManagedRuleSetVersionsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"NextLockToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable PutManagedRuleSetVersions where
  hashWithSalt :: Int -> PutManagedRuleSetVersions -> Int
hashWithSalt Int
_salt PutManagedRuleSetVersions' {Maybe Text
Maybe (HashMap Text VersionToPublish)
Text
Scope
lockToken :: Text
id :: Text
scope :: Scope
name :: Text
versionsToPublish :: Maybe (HashMap Text VersionToPublish)
recommendedVersion :: Maybe Text
$sel:lockToken:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Text
$sel:id:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Text
$sel:scope:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Scope
$sel:name:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Text
$sel:versionsToPublish:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Maybe (HashMap Text VersionToPublish)
$sel:recommendedVersion:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
recommendedVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text VersionToPublish)
versionsToPublish
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Scope
scope
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
lockToken

instance Prelude.NFData PutManagedRuleSetVersions where
  rnf :: PutManagedRuleSetVersions -> ()
rnf PutManagedRuleSetVersions' {Maybe Text
Maybe (HashMap Text VersionToPublish)
Text
Scope
lockToken :: Text
id :: Text
scope :: Scope
name :: Text
versionsToPublish :: Maybe (HashMap Text VersionToPublish)
recommendedVersion :: Maybe Text
$sel:lockToken:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Text
$sel:id:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Text
$sel:scope:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Scope
$sel:name:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Text
$sel:versionsToPublish:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Maybe (HashMap Text VersionToPublish)
$sel:recommendedVersion:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
recommendedVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text VersionToPublish)
versionsToPublish
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Scope
scope
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
lockToken

instance Data.ToHeaders PutManagedRuleSetVersions where
  toHeaders :: PutManagedRuleSetVersions -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSWAF_20190729.PutManagedRuleSetVersions" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON PutManagedRuleSetVersions where
  toJSON :: PutManagedRuleSetVersions -> Value
toJSON PutManagedRuleSetVersions' {Maybe Text
Maybe (HashMap Text VersionToPublish)
Text
Scope
lockToken :: Text
id :: Text
scope :: Scope
name :: Text
versionsToPublish :: Maybe (HashMap Text VersionToPublish)
recommendedVersion :: Maybe Text
$sel:lockToken:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Text
$sel:id:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Text
$sel:scope:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Scope
$sel:name:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Text
$sel:versionsToPublish:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Maybe (HashMap Text VersionToPublish)
$sel:recommendedVersion:PutManagedRuleSetVersions' :: PutManagedRuleSetVersions -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"RecommendedVersion" 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 Text
recommendedVersion,
            (Key
"VersionsToPublish" 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 (HashMap Text VersionToPublish)
versionsToPublish,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Scope" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Scope
scope),
            forall a. a -> Maybe a
Prelude.Just (Key
"Id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id),
            forall a. a -> Maybe a
Prelude.Just (Key
"LockToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
lockToken)
          ]
      )

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

instance Data.ToQuery PutManagedRuleSetVersions where
  toQuery :: PutManagedRuleSetVersions -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newPutManagedRuleSetVersionsResponse' smart constructor.
data PutManagedRuleSetVersionsResponse = PutManagedRuleSetVersionsResponse'
  { -- | A token used for optimistic locking. WAF returns a token to your @get@
    -- and @list@ requests, to mark the state of the entity at the time of the
    -- request. To make changes to the entity associated with the token, you
    -- provide the token to operations like @update@ and @delete@. WAF uses the
    -- token to ensure that no changes have been made to the entity since you
    -- last retrieved it. If a change has been made, the update fails with a
    -- @WAFOptimisticLockException@. If this happens, perform another @get@,
    -- and use the new token returned by that operation.
    PutManagedRuleSetVersionsResponse -> Maybe Text
nextLockToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    PutManagedRuleSetVersionsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutManagedRuleSetVersionsResponse
-> PutManagedRuleSetVersionsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutManagedRuleSetVersionsResponse
-> PutManagedRuleSetVersionsResponse -> Bool
$c/= :: PutManagedRuleSetVersionsResponse
-> PutManagedRuleSetVersionsResponse -> Bool
== :: PutManagedRuleSetVersionsResponse
-> PutManagedRuleSetVersionsResponse -> Bool
$c== :: PutManagedRuleSetVersionsResponse
-> PutManagedRuleSetVersionsResponse -> Bool
Prelude.Eq, ReadPrec [PutManagedRuleSetVersionsResponse]
ReadPrec PutManagedRuleSetVersionsResponse
Int -> ReadS PutManagedRuleSetVersionsResponse
ReadS [PutManagedRuleSetVersionsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutManagedRuleSetVersionsResponse]
$creadListPrec :: ReadPrec [PutManagedRuleSetVersionsResponse]
readPrec :: ReadPrec PutManagedRuleSetVersionsResponse
$creadPrec :: ReadPrec PutManagedRuleSetVersionsResponse
readList :: ReadS [PutManagedRuleSetVersionsResponse]
$creadList :: ReadS [PutManagedRuleSetVersionsResponse]
readsPrec :: Int -> ReadS PutManagedRuleSetVersionsResponse
$creadsPrec :: Int -> ReadS PutManagedRuleSetVersionsResponse
Prelude.Read, Int -> PutManagedRuleSetVersionsResponse -> ShowS
[PutManagedRuleSetVersionsResponse] -> ShowS
PutManagedRuleSetVersionsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutManagedRuleSetVersionsResponse] -> ShowS
$cshowList :: [PutManagedRuleSetVersionsResponse] -> ShowS
show :: PutManagedRuleSetVersionsResponse -> String
$cshow :: PutManagedRuleSetVersionsResponse -> String
showsPrec :: Int -> PutManagedRuleSetVersionsResponse -> ShowS
$cshowsPrec :: Int -> PutManagedRuleSetVersionsResponse -> ShowS
Prelude.Show, forall x.
Rep PutManagedRuleSetVersionsResponse x
-> PutManagedRuleSetVersionsResponse
forall x.
PutManagedRuleSetVersionsResponse
-> Rep PutManagedRuleSetVersionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutManagedRuleSetVersionsResponse x
-> PutManagedRuleSetVersionsResponse
$cfrom :: forall x.
PutManagedRuleSetVersionsResponse
-> Rep PutManagedRuleSetVersionsResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutManagedRuleSetVersionsResponse' 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:
--
-- 'nextLockToken', 'putManagedRuleSetVersionsResponse_nextLockToken' - A token used for optimistic locking. WAF returns a token to your @get@
-- and @list@ requests, to mark the state of the entity at the time of the
-- request. To make changes to the entity associated with the token, you
-- provide the token to operations like @update@ and @delete@. WAF uses the
-- token to ensure that no changes have been made to the entity since you
-- last retrieved it. If a change has been made, the update fails with a
-- @WAFOptimisticLockException@. If this happens, perform another @get@,
-- and use the new token returned by that operation.
--
-- 'httpStatus', 'putManagedRuleSetVersionsResponse_httpStatus' - The response's http status code.
newPutManagedRuleSetVersionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutManagedRuleSetVersionsResponse
newPutManagedRuleSetVersionsResponse :: Int -> PutManagedRuleSetVersionsResponse
newPutManagedRuleSetVersionsResponse Int
pHttpStatus_ =
  PutManagedRuleSetVersionsResponse'
    { $sel:nextLockToken:PutManagedRuleSetVersionsResponse' :: Maybe Text
nextLockToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutManagedRuleSetVersionsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A token used for optimistic locking. WAF returns a token to your @get@
-- and @list@ requests, to mark the state of the entity at the time of the
-- request. To make changes to the entity associated with the token, you
-- provide the token to operations like @update@ and @delete@. WAF uses the
-- token to ensure that no changes have been made to the entity since you
-- last retrieved it. If a change has been made, the update fails with a
-- @WAFOptimisticLockException@. If this happens, perform another @get@,
-- and use the new token returned by that operation.
putManagedRuleSetVersionsResponse_nextLockToken :: Lens.Lens' PutManagedRuleSetVersionsResponse (Prelude.Maybe Prelude.Text)
putManagedRuleSetVersionsResponse_nextLockToken :: Lens' PutManagedRuleSetVersionsResponse (Maybe Text)
putManagedRuleSetVersionsResponse_nextLockToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutManagedRuleSetVersionsResponse' {Maybe Text
nextLockToken :: Maybe Text
$sel:nextLockToken:PutManagedRuleSetVersionsResponse' :: PutManagedRuleSetVersionsResponse -> Maybe Text
nextLockToken} -> Maybe Text
nextLockToken) (\s :: PutManagedRuleSetVersionsResponse
s@PutManagedRuleSetVersionsResponse' {} Maybe Text
a -> PutManagedRuleSetVersionsResponse
s {$sel:nextLockToken:PutManagedRuleSetVersionsResponse' :: Maybe Text
nextLockToken = Maybe Text
a} :: PutManagedRuleSetVersionsResponse)

-- | The response's http status code.
putManagedRuleSetVersionsResponse_httpStatus :: Lens.Lens' PutManagedRuleSetVersionsResponse Prelude.Int
putManagedRuleSetVersionsResponse_httpStatus :: Lens' PutManagedRuleSetVersionsResponse Int
putManagedRuleSetVersionsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutManagedRuleSetVersionsResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutManagedRuleSetVersionsResponse' :: PutManagedRuleSetVersionsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutManagedRuleSetVersionsResponse
s@PutManagedRuleSetVersionsResponse' {} Int
a -> PutManagedRuleSetVersionsResponse
s {$sel:httpStatus:PutManagedRuleSetVersionsResponse' :: Int
httpStatus = Int
a} :: PutManagedRuleSetVersionsResponse)

instance
  Prelude.NFData
    PutManagedRuleSetVersionsResponse
  where
  rnf :: PutManagedRuleSetVersionsResponse -> ()
rnf PutManagedRuleSetVersionsResponse' {Int
Maybe Text
httpStatus :: Int
nextLockToken :: Maybe Text
$sel:httpStatus:PutManagedRuleSetVersionsResponse' :: PutManagedRuleSetVersionsResponse -> Int
$sel:nextLockToken:PutManagedRuleSetVersionsResponse' :: PutManagedRuleSetVersionsResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextLockToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus