{-# 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.NetworkFirewall.UpdateRuleGroup
-- 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)
--
-- Updates the rule settings for the specified rule group. You use a rule
-- group by reference in one or more firewall policies. When you modify a
-- rule group, you modify all firewall policies that use the rule group.
--
-- To update a rule group, first call DescribeRuleGroup to retrieve the
-- current RuleGroup object, update the object as needed, and then provide
-- the updated object to this call.
module Amazonka.NetworkFirewall.UpdateRuleGroup
  ( -- * Creating a Request
    UpdateRuleGroup (..),
    newUpdateRuleGroup,

    -- * Request Lenses
    updateRuleGroup_ruleGroupArn,
    updateRuleGroup_rules,
    updateRuleGroup_type,
    updateRuleGroup_description,
    updateRuleGroup_ruleGroupName,
    updateRuleGroup_dryRun,
    updateRuleGroup_ruleGroup,
    updateRuleGroup_updateToken,

    -- * Destructuring the Response
    UpdateRuleGroupResponse (..),
    newUpdateRuleGroupResponse,

    -- * Response Lenses
    updateRuleGroupResponse_httpStatus,
    updateRuleGroupResponse_updateToken,
    updateRuleGroupResponse_ruleGroupResponse,
  )
where

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

-- | /See:/ 'newUpdateRuleGroup' smart constructor.
data UpdateRuleGroup = UpdateRuleGroup'
  { -- | The Amazon Resource Name (ARN) of the rule group.
    --
    -- You must specify the ARN or the name, and you can specify both.
    UpdateRuleGroup -> Maybe Text
ruleGroupArn :: Prelude.Maybe Prelude.Text,
    -- | A string containing stateful rule group rules specifications in Suricata
    -- flat format, with one rule per line. Use this to import your existing
    -- Suricata compatible rule groups.
    --
    -- You must provide either this rules setting or a populated @RuleGroup@
    -- setting, but not both.
    --
    -- You can provide your rule group specification in Suricata flat format
    -- through this setting when you create or update your rule group. The call
    -- response returns a RuleGroup object that Network Firewall has populated
    -- from your string.
    UpdateRuleGroup -> Maybe Text
rules :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether the rule group is stateless or stateful. If the rule
    -- group is stateless, it contains stateless rules. If it is stateful, it
    -- contains stateful rules.
    --
    -- This setting is required for requests that do not include the
    -- @RuleGroupARN@.
    UpdateRuleGroup -> Maybe RuleGroupType
type' :: Prelude.Maybe RuleGroupType,
    -- | A description of the rule group.
    UpdateRuleGroup -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The descriptive name of the rule group. You can\'t change the name of a
    -- rule group after you create it.
    --
    -- You must specify the ARN or the name, and you can specify both.
    UpdateRuleGroup -> Maybe Text
ruleGroupName :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether you want Network Firewall to just check the validity
    -- of the request, rather than run the request.
    --
    -- If set to @TRUE@, Network Firewall checks whether the request can run
    -- successfully, but doesn\'t actually make the requested changes. The call
    -- returns the value that the request would return if you ran it with dry
    -- run set to @FALSE@, but doesn\'t make additions or changes to your
    -- resources. This option allows you to make sure that you have the
    -- required permissions to run the request and that your request parameters
    -- are valid.
    --
    -- If set to @FALSE@, Network Firewall makes the requested changes to your
    -- resources.
    UpdateRuleGroup -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | An object that defines the rule group rules.
    --
    -- You must provide either this rule group setting or a @Rules@ setting,
    -- but not both.
    UpdateRuleGroup -> Maybe RuleGroup
ruleGroup :: Prelude.Maybe RuleGroup,
    -- | A token used for optimistic locking. Network Firewall returns a token to
    -- your requests that access the rule group. The token marks the state of
    -- the rule group resource at the time of the request.
    --
    -- To make changes to the rule group, you provide the token in your
    -- request. Network Firewall uses the token to ensure that the rule group
    -- hasn\'t changed since you last retrieved it. If it has changed, the
    -- operation fails with an @InvalidTokenException@. If this happens,
    -- retrieve the rule group again to get a current copy of it with a current
    -- token. Reapply your changes as needed, then try the operation again
    -- using the new token.
    UpdateRuleGroup -> Text
updateToken :: Prelude.Text
  }
  deriving (UpdateRuleGroup -> UpdateRuleGroup -> Bool
(UpdateRuleGroup -> UpdateRuleGroup -> Bool)
-> (UpdateRuleGroup -> UpdateRuleGroup -> Bool)
-> Eq UpdateRuleGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRuleGroup -> UpdateRuleGroup -> Bool
$c/= :: UpdateRuleGroup -> UpdateRuleGroup -> Bool
== :: UpdateRuleGroup -> UpdateRuleGroup -> Bool
$c== :: UpdateRuleGroup -> UpdateRuleGroup -> Bool
Prelude.Eq, ReadPrec [UpdateRuleGroup]
ReadPrec UpdateRuleGroup
Int -> ReadS UpdateRuleGroup
ReadS [UpdateRuleGroup]
(Int -> ReadS UpdateRuleGroup)
-> ReadS [UpdateRuleGroup]
-> ReadPrec UpdateRuleGroup
-> ReadPrec [UpdateRuleGroup]
-> Read UpdateRuleGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRuleGroup]
$creadListPrec :: ReadPrec [UpdateRuleGroup]
readPrec :: ReadPrec UpdateRuleGroup
$creadPrec :: ReadPrec UpdateRuleGroup
readList :: ReadS [UpdateRuleGroup]
$creadList :: ReadS [UpdateRuleGroup]
readsPrec :: Int -> ReadS UpdateRuleGroup
$creadsPrec :: Int -> ReadS UpdateRuleGroup
Prelude.Read, Int -> UpdateRuleGroup -> ShowS
[UpdateRuleGroup] -> ShowS
UpdateRuleGroup -> String
(Int -> UpdateRuleGroup -> ShowS)
-> (UpdateRuleGroup -> String)
-> ([UpdateRuleGroup] -> ShowS)
-> Show UpdateRuleGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRuleGroup] -> ShowS
$cshowList :: [UpdateRuleGroup] -> ShowS
show :: UpdateRuleGroup -> String
$cshow :: UpdateRuleGroup -> String
showsPrec :: Int -> UpdateRuleGroup -> ShowS
$cshowsPrec :: Int -> UpdateRuleGroup -> ShowS
Prelude.Show, (forall x. UpdateRuleGroup -> Rep UpdateRuleGroup x)
-> (forall x. Rep UpdateRuleGroup x -> UpdateRuleGroup)
-> Generic UpdateRuleGroup
forall x. Rep UpdateRuleGroup x -> UpdateRuleGroup
forall x. UpdateRuleGroup -> Rep UpdateRuleGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRuleGroup x -> UpdateRuleGroup
$cfrom :: forall x. UpdateRuleGroup -> Rep UpdateRuleGroup x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRuleGroup' 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:
--
-- 'ruleGroupArn', 'updateRuleGroup_ruleGroupArn' - The Amazon Resource Name (ARN) of the rule group.
--
-- You must specify the ARN or the name, and you can specify both.
--
-- 'rules', 'updateRuleGroup_rules' - A string containing stateful rule group rules specifications in Suricata
-- flat format, with one rule per line. Use this to import your existing
-- Suricata compatible rule groups.
--
-- You must provide either this rules setting or a populated @RuleGroup@
-- setting, but not both.
--
-- You can provide your rule group specification in Suricata flat format
-- through this setting when you create or update your rule group. The call
-- response returns a RuleGroup object that Network Firewall has populated
-- from your string.
--
-- 'type'', 'updateRuleGroup_type' - Indicates whether the rule group is stateless or stateful. If the rule
-- group is stateless, it contains stateless rules. If it is stateful, it
-- contains stateful rules.
--
-- This setting is required for requests that do not include the
-- @RuleGroupARN@.
--
-- 'description', 'updateRuleGroup_description' - A description of the rule group.
--
-- 'ruleGroupName', 'updateRuleGroup_ruleGroupName' - The descriptive name of the rule group. You can\'t change the name of a
-- rule group after you create it.
--
-- You must specify the ARN or the name, and you can specify both.
--
-- 'dryRun', 'updateRuleGroup_dryRun' - Indicates whether you want Network Firewall to just check the validity
-- of the request, rather than run the request.
--
-- If set to @TRUE@, Network Firewall checks whether the request can run
-- successfully, but doesn\'t actually make the requested changes. The call
-- returns the value that the request would return if you ran it with dry
-- run set to @FALSE@, but doesn\'t make additions or changes to your
-- resources. This option allows you to make sure that you have the
-- required permissions to run the request and that your request parameters
-- are valid.
--
-- If set to @FALSE@, Network Firewall makes the requested changes to your
-- resources.
--
-- 'ruleGroup', 'updateRuleGroup_ruleGroup' - An object that defines the rule group rules.
--
-- You must provide either this rule group setting or a @Rules@ setting,
-- but not both.
--
-- 'updateToken', 'updateRuleGroup_updateToken' - A token used for optimistic locking. Network Firewall returns a token to
-- your requests that access the rule group. The token marks the state of
-- the rule group resource at the time of the request.
--
-- To make changes to the rule group, you provide the token in your
-- request. Network Firewall uses the token to ensure that the rule group
-- hasn\'t changed since you last retrieved it. If it has changed, the
-- operation fails with an @InvalidTokenException@. If this happens,
-- retrieve the rule group again to get a current copy of it with a current
-- token. Reapply your changes as needed, then try the operation again
-- using the new token.
newUpdateRuleGroup ::
  -- | 'updateToken'
  Prelude.Text ->
  UpdateRuleGroup
newUpdateRuleGroup :: Text -> UpdateRuleGroup
newUpdateRuleGroup Text
pUpdateToken_ =
  UpdateRuleGroup' :: Maybe Text
-> Maybe Text
-> Maybe RuleGroupType
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Maybe RuleGroup
-> Text
-> UpdateRuleGroup
UpdateRuleGroup'
    { $sel:ruleGroupArn:UpdateRuleGroup' :: Maybe Text
ruleGroupArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:rules:UpdateRuleGroup' :: Maybe Text
rules = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':UpdateRuleGroup' :: Maybe RuleGroupType
type' = Maybe RuleGroupType
forall a. Maybe a
Prelude.Nothing,
      $sel:description:UpdateRuleGroup' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleGroupName:UpdateRuleGroup' :: Maybe Text
ruleGroupName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dryRun:UpdateRuleGroup' :: Maybe Bool
dryRun = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleGroup:UpdateRuleGroup' :: Maybe RuleGroup
ruleGroup = Maybe RuleGroup
forall a. Maybe a
Prelude.Nothing,
      $sel:updateToken:UpdateRuleGroup' :: Text
updateToken = Text
pUpdateToken_
    }

-- | The Amazon Resource Name (ARN) of the rule group.
--
-- You must specify the ARN or the name, and you can specify both.
updateRuleGroup_ruleGroupArn :: Lens.Lens' UpdateRuleGroup (Prelude.Maybe Prelude.Text)
updateRuleGroup_ruleGroupArn :: (Maybe Text -> f (Maybe Text))
-> UpdateRuleGroup -> f UpdateRuleGroup
updateRuleGroup_ruleGroupArn = (UpdateRuleGroup -> Maybe Text)
-> (UpdateRuleGroup -> Maybe Text -> UpdateRuleGroup)
-> Lens UpdateRuleGroup UpdateRuleGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleGroup' {Maybe Text
ruleGroupArn :: Maybe Text
$sel:ruleGroupArn:UpdateRuleGroup' :: UpdateRuleGroup -> Maybe Text
ruleGroupArn} -> Maybe Text
ruleGroupArn) (\s :: UpdateRuleGroup
s@UpdateRuleGroup' {} Maybe Text
a -> UpdateRuleGroup
s {$sel:ruleGroupArn:UpdateRuleGroup' :: Maybe Text
ruleGroupArn = Maybe Text
a} :: UpdateRuleGroup)

-- | A string containing stateful rule group rules specifications in Suricata
-- flat format, with one rule per line. Use this to import your existing
-- Suricata compatible rule groups.
--
-- You must provide either this rules setting or a populated @RuleGroup@
-- setting, but not both.
--
-- You can provide your rule group specification in Suricata flat format
-- through this setting when you create or update your rule group. The call
-- response returns a RuleGroup object that Network Firewall has populated
-- from your string.
updateRuleGroup_rules :: Lens.Lens' UpdateRuleGroup (Prelude.Maybe Prelude.Text)
updateRuleGroup_rules :: (Maybe Text -> f (Maybe Text))
-> UpdateRuleGroup -> f UpdateRuleGroup
updateRuleGroup_rules = (UpdateRuleGroup -> Maybe Text)
-> (UpdateRuleGroup -> Maybe Text -> UpdateRuleGroup)
-> Lens UpdateRuleGroup UpdateRuleGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleGroup' {Maybe Text
rules :: Maybe Text
$sel:rules:UpdateRuleGroup' :: UpdateRuleGroup -> Maybe Text
rules} -> Maybe Text
rules) (\s :: UpdateRuleGroup
s@UpdateRuleGroup' {} Maybe Text
a -> UpdateRuleGroup
s {$sel:rules:UpdateRuleGroup' :: Maybe Text
rules = Maybe Text
a} :: UpdateRuleGroup)

-- | Indicates whether the rule group is stateless or stateful. If the rule
-- group is stateless, it contains stateless rules. If it is stateful, it
-- contains stateful rules.
--
-- This setting is required for requests that do not include the
-- @RuleGroupARN@.
updateRuleGroup_type :: Lens.Lens' UpdateRuleGroup (Prelude.Maybe RuleGroupType)
updateRuleGroup_type :: (Maybe RuleGroupType -> f (Maybe RuleGroupType))
-> UpdateRuleGroup -> f UpdateRuleGroup
updateRuleGroup_type = (UpdateRuleGroup -> Maybe RuleGroupType)
-> (UpdateRuleGroup -> Maybe RuleGroupType -> UpdateRuleGroup)
-> Lens
     UpdateRuleGroup
     UpdateRuleGroup
     (Maybe RuleGroupType)
     (Maybe RuleGroupType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleGroup' {Maybe RuleGroupType
type' :: Maybe RuleGroupType
$sel:type':UpdateRuleGroup' :: UpdateRuleGroup -> Maybe RuleGroupType
type'} -> Maybe RuleGroupType
type') (\s :: UpdateRuleGroup
s@UpdateRuleGroup' {} Maybe RuleGroupType
a -> UpdateRuleGroup
s {$sel:type':UpdateRuleGroup' :: Maybe RuleGroupType
type' = Maybe RuleGroupType
a} :: UpdateRuleGroup)

-- | A description of the rule group.
updateRuleGroup_description :: Lens.Lens' UpdateRuleGroup (Prelude.Maybe Prelude.Text)
updateRuleGroup_description :: (Maybe Text -> f (Maybe Text))
-> UpdateRuleGroup -> f UpdateRuleGroup
updateRuleGroup_description = (UpdateRuleGroup -> Maybe Text)
-> (UpdateRuleGroup -> Maybe Text -> UpdateRuleGroup)
-> Lens UpdateRuleGroup UpdateRuleGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleGroup' {Maybe Text
description :: Maybe Text
$sel:description:UpdateRuleGroup' :: UpdateRuleGroup -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateRuleGroup
s@UpdateRuleGroup' {} Maybe Text
a -> UpdateRuleGroup
s {$sel:description:UpdateRuleGroup' :: Maybe Text
description = Maybe Text
a} :: UpdateRuleGroup)

-- | The descriptive name of the rule group. You can\'t change the name of a
-- rule group after you create it.
--
-- You must specify the ARN or the name, and you can specify both.
updateRuleGroup_ruleGroupName :: Lens.Lens' UpdateRuleGroup (Prelude.Maybe Prelude.Text)
updateRuleGroup_ruleGroupName :: (Maybe Text -> f (Maybe Text))
-> UpdateRuleGroup -> f UpdateRuleGroup
updateRuleGroup_ruleGroupName = (UpdateRuleGroup -> Maybe Text)
-> (UpdateRuleGroup -> Maybe Text -> UpdateRuleGroup)
-> Lens UpdateRuleGroup UpdateRuleGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleGroup' {Maybe Text
ruleGroupName :: Maybe Text
$sel:ruleGroupName:UpdateRuleGroup' :: UpdateRuleGroup -> Maybe Text
ruleGroupName} -> Maybe Text
ruleGroupName) (\s :: UpdateRuleGroup
s@UpdateRuleGroup' {} Maybe Text
a -> UpdateRuleGroup
s {$sel:ruleGroupName:UpdateRuleGroup' :: Maybe Text
ruleGroupName = Maybe Text
a} :: UpdateRuleGroup)

-- | Indicates whether you want Network Firewall to just check the validity
-- of the request, rather than run the request.
--
-- If set to @TRUE@, Network Firewall checks whether the request can run
-- successfully, but doesn\'t actually make the requested changes. The call
-- returns the value that the request would return if you ran it with dry
-- run set to @FALSE@, but doesn\'t make additions or changes to your
-- resources. This option allows you to make sure that you have the
-- required permissions to run the request and that your request parameters
-- are valid.
--
-- If set to @FALSE@, Network Firewall makes the requested changes to your
-- resources.
updateRuleGroup_dryRun :: Lens.Lens' UpdateRuleGroup (Prelude.Maybe Prelude.Bool)
updateRuleGroup_dryRun :: (Maybe Bool -> f (Maybe Bool))
-> UpdateRuleGroup -> f UpdateRuleGroup
updateRuleGroup_dryRun = (UpdateRuleGroup -> Maybe Bool)
-> (UpdateRuleGroup -> Maybe Bool -> UpdateRuleGroup)
-> Lens UpdateRuleGroup UpdateRuleGroup (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleGroup' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:UpdateRuleGroup' :: UpdateRuleGroup -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: UpdateRuleGroup
s@UpdateRuleGroup' {} Maybe Bool
a -> UpdateRuleGroup
s {$sel:dryRun:UpdateRuleGroup' :: Maybe Bool
dryRun = Maybe Bool
a} :: UpdateRuleGroup)

-- | An object that defines the rule group rules.
--
-- You must provide either this rule group setting or a @Rules@ setting,
-- but not both.
updateRuleGroup_ruleGroup :: Lens.Lens' UpdateRuleGroup (Prelude.Maybe RuleGroup)
updateRuleGroup_ruleGroup :: (Maybe RuleGroup -> f (Maybe RuleGroup))
-> UpdateRuleGroup -> f UpdateRuleGroup
updateRuleGroup_ruleGroup = (UpdateRuleGroup -> Maybe RuleGroup)
-> (UpdateRuleGroup -> Maybe RuleGroup -> UpdateRuleGroup)
-> Lens
     UpdateRuleGroup UpdateRuleGroup (Maybe RuleGroup) (Maybe RuleGroup)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleGroup' {Maybe RuleGroup
ruleGroup :: Maybe RuleGroup
$sel:ruleGroup:UpdateRuleGroup' :: UpdateRuleGroup -> Maybe RuleGroup
ruleGroup} -> Maybe RuleGroup
ruleGroup) (\s :: UpdateRuleGroup
s@UpdateRuleGroup' {} Maybe RuleGroup
a -> UpdateRuleGroup
s {$sel:ruleGroup:UpdateRuleGroup' :: Maybe RuleGroup
ruleGroup = Maybe RuleGroup
a} :: UpdateRuleGroup)

-- | A token used for optimistic locking. Network Firewall returns a token to
-- your requests that access the rule group. The token marks the state of
-- the rule group resource at the time of the request.
--
-- To make changes to the rule group, you provide the token in your
-- request. Network Firewall uses the token to ensure that the rule group
-- hasn\'t changed since you last retrieved it. If it has changed, the
-- operation fails with an @InvalidTokenException@. If this happens,
-- retrieve the rule group again to get a current copy of it with a current
-- token. Reapply your changes as needed, then try the operation again
-- using the new token.
updateRuleGroup_updateToken :: Lens.Lens' UpdateRuleGroup Prelude.Text
updateRuleGroup_updateToken :: (Text -> f Text) -> UpdateRuleGroup -> f UpdateRuleGroup
updateRuleGroup_updateToken = (UpdateRuleGroup -> Text)
-> (UpdateRuleGroup -> Text -> UpdateRuleGroup)
-> Lens UpdateRuleGroup UpdateRuleGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleGroup' {Text
updateToken :: Text
$sel:updateToken:UpdateRuleGroup' :: UpdateRuleGroup -> Text
updateToken} -> Text
updateToken) (\s :: UpdateRuleGroup
s@UpdateRuleGroup' {} Text
a -> UpdateRuleGroup
s {$sel:updateToken:UpdateRuleGroup' :: Text
updateToken = Text
a} :: UpdateRuleGroup)

instance Core.AWSRequest UpdateRuleGroup where
  type
    AWSResponse UpdateRuleGroup =
      UpdateRuleGroupResponse
  request :: UpdateRuleGroup -> Request UpdateRuleGroup
request = Service -> UpdateRuleGroup -> Request UpdateRuleGroup
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateRuleGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateRuleGroup)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateRuleGroup))
-> Logger
-> Service
-> Proxy UpdateRuleGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateRuleGroup)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> Text -> RuleGroupResponse -> UpdateRuleGroupResponse
UpdateRuleGroupResponse'
            (Int -> Text -> RuleGroupResponse -> UpdateRuleGroupResponse)
-> Either String Int
-> Either
     String (Text -> RuleGroupResponse -> UpdateRuleGroupResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either
  String (Text -> RuleGroupResponse -> UpdateRuleGroupResponse)
-> Either String Text
-> Either String (RuleGroupResponse -> UpdateRuleGroupResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"UpdateToken")
            Either String (RuleGroupResponse -> UpdateRuleGroupResponse)
-> Either String RuleGroupResponse
-> Either String UpdateRuleGroupResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String RuleGroupResponse
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"RuleGroupResponse")
      )

instance Prelude.Hashable UpdateRuleGroup

instance Prelude.NFData UpdateRuleGroup

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

instance Core.ToJSON UpdateRuleGroup where
  toJSON :: UpdateRuleGroup -> Value
toJSON UpdateRuleGroup' {Maybe Bool
Maybe Text
Maybe RuleGroupType
Maybe RuleGroup
Text
updateToken :: Text
ruleGroup :: Maybe RuleGroup
dryRun :: Maybe Bool
ruleGroupName :: Maybe Text
description :: Maybe Text
type' :: Maybe RuleGroupType
rules :: Maybe Text
ruleGroupArn :: Maybe Text
$sel:updateToken:UpdateRuleGroup' :: UpdateRuleGroup -> Text
$sel:ruleGroup:UpdateRuleGroup' :: UpdateRuleGroup -> Maybe RuleGroup
$sel:dryRun:UpdateRuleGroup' :: UpdateRuleGroup -> Maybe Bool
$sel:ruleGroupName:UpdateRuleGroup' :: UpdateRuleGroup -> Maybe Text
$sel:description:UpdateRuleGroup' :: UpdateRuleGroup -> Maybe Text
$sel:type':UpdateRuleGroup' :: UpdateRuleGroup -> Maybe RuleGroupType
$sel:rules:UpdateRuleGroup' :: UpdateRuleGroup -> Maybe Text
$sel:ruleGroupArn:UpdateRuleGroup' :: UpdateRuleGroup -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RuleGroupArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
ruleGroupArn,
            (Text
"Rules" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
rules,
            (Text
"Type" Text -> RuleGroupType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (RuleGroupType -> Pair) -> Maybe RuleGroupType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RuleGroupType
type',
            (Text
"Description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Text
"RuleGroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
ruleGroupName,
            (Text
"DryRun" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
dryRun,
            (Text
"RuleGroup" Text -> RuleGroup -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (RuleGroup -> Pair) -> Maybe RuleGroup -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RuleGroup
ruleGroup,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"UpdateToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
updateToken)
          ]
      )

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

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

-- | /See:/ 'newUpdateRuleGroupResponse' smart constructor.
data UpdateRuleGroupResponse = UpdateRuleGroupResponse'
  { -- | The response's http status code.
    UpdateRuleGroupResponse -> Int
httpStatus :: Prelude.Int,
    -- | A token used for optimistic locking. Network Firewall returns a token to
    -- your requests that access the rule group. The token marks the state of
    -- the rule group resource at the time of the request.
    --
    -- To make changes to the rule group, you provide the token in your
    -- request. Network Firewall uses the token to ensure that the rule group
    -- hasn\'t changed since you last retrieved it. If it has changed, the
    -- operation fails with an @InvalidTokenException@. If this happens,
    -- retrieve the rule group again to get a current copy of it with a current
    -- token. Reapply your changes as needed, then try the operation again
    -- using the new token.
    UpdateRuleGroupResponse -> Text
updateToken :: Prelude.Text,
    -- | The high-level properties of a rule group. This, along with the
    -- RuleGroup, define the rule group. You can retrieve all objects for a
    -- rule group by calling DescribeRuleGroup.
    UpdateRuleGroupResponse -> RuleGroupResponse
ruleGroupResponse :: RuleGroupResponse
  }
  deriving (UpdateRuleGroupResponse -> UpdateRuleGroupResponse -> Bool
(UpdateRuleGroupResponse -> UpdateRuleGroupResponse -> Bool)
-> (UpdateRuleGroupResponse -> UpdateRuleGroupResponse -> Bool)
-> Eq UpdateRuleGroupResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRuleGroupResponse -> UpdateRuleGroupResponse -> Bool
$c/= :: UpdateRuleGroupResponse -> UpdateRuleGroupResponse -> Bool
== :: UpdateRuleGroupResponse -> UpdateRuleGroupResponse -> Bool
$c== :: UpdateRuleGroupResponse -> UpdateRuleGroupResponse -> Bool
Prelude.Eq, ReadPrec [UpdateRuleGroupResponse]
ReadPrec UpdateRuleGroupResponse
Int -> ReadS UpdateRuleGroupResponse
ReadS [UpdateRuleGroupResponse]
(Int -> ReadS UpdateRuleGroupResponse)
-> ReadS [UpdateRuleGroupResponse]
-> ReadPrec UpdateRuleGroupResponse
-> ReadPrec [UpdateRuleGroupResponse]
-> Read UpdateRuleGroupResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRuleGroupResponse]
$creadListPrec :: ReadPrec [UpdateRuleGroupResponse]
readPrec :: ReadPrec UpdateRuleGroupResponse
$creadPrec :: ReadPrec UpdateRuleGroupResponse
readList :: ReadS [UpdateRuleGroupResponse]
$creadList :: ReadS [UpdateRuleGroupResponse]
readsPrec :: Int -> ReadS UpdateRuleGroupResponse
$creadsPrec :: Int -> ReadS UpdateRuleGroupResponse
Prelude.Read, Int -> UpdateRuleGroupResponse -> ShowS
[UpdateRuleGroupResponse] -> ShowS
UpdateRuleGroupResponse -> String
(Int -> UpdateRuleGroupResponse -> ShowS)
-> (UpdateRuleGroupResponse -> String)
-> ([UpdateRuleGroupResponse] -> ShowS)
-> Show UpdateRuleGroupResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRuleGroupResponse] -> ShowS
$cshowList :: [UpdateRuleGroupResponse] -> ShowS
show :: UpdateRuleGroupResponse -> String
$cshow :: UpdateRuleGroupResponse -> String
showsPrec :: Int -> UpdateRuleGroupResponse -> ShowS
$cshowsPrec :: Int -> UpdateRuleGroupResponse -> ShowS
Prelude.Show, (forall x.
 UpdateRuleGroupResponse -> Rep UpdateRuleGroupResponse x)
-> (forall x.
    Rep UpdateRuleGroupResponse x -> UpdateRuleGroupResponse)
-> Generic UpdateRuleGroupResponse
forall x. Rep UpdateRuleGroupResponse x -> UpdateRuleGroupResponse
forall x. UpdateRuleGroupResponse -> Rep UpdateRuleGroupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRuleGroupResponse x -> UpdateRuleGroupResponse
$cfrom :: forall x. UpdateRuleGroupResponse -> Rep UpdateRuleGroupResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRuleGroupResponse' 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:
--
-- 'httpStatus', 'updateRuleGroupResponse_httpStatus' - The response's http status code.
--
-- 'updateToken', 'updateRuleGroupResponse_updateToken' - A token used for optimistic locking. Network Firewall returns a token to
-- your requests that access the rule group. The token marks the state of
-- the rule group resource at the time of the request.
--
-- To make changes to the rule group, you provide the token in your
-- request. Network Firewall uses the token to ensure that the rule group
-- hasn\'t changed since you last retrieved it. If it has changed, the
-- operation fails with an @InvalidTokenException@. If this happens,
-- retrieve the rule group again to get a current copy of it with a current
-- token. Reapply your changes as needed, then try the operation again
-- using the new token.
--
-- 'ruleGroupResponse', 'updateRuleGroupResponse_ruleGroupResponse' - The high-level properties of a rule group. This, along with the
-- RuleGroup, define the rule group. You can retrieve all objects for a
-- rule group by calling DescribeRuleGroup.
newUpdateRuleGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'updateToken'
  Prelude.Text ->
  -- | 'ruleGroupResponse'
  RuleGroupResponse ->
  UpdateRuleGroupResponse
newUpdateRuleGroupResponse :: Int -> Text -> RuleGroupResponse -> UpdateRuleGroupResponse
newUpdateRuleGroupResponse
  Int
pHttpStatus_
  Text
pUpdateToken_
  RuleGroupResponse
pRuleGroupResponse_ =
    UpdateRuleGroupResponse' :: Int -> Text -> RuleGroupResponse -> UpdateRuleGroupResponse
UpdateRuleGroupResponse'
      { $sel:httpStatus:UpdateRuleGroupResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:updateToken:UpdateRuleGroupResponse' :: Text
updateToken = Text
pUpdateToken_,
        $sel:ruleGroupResponse:UpdateRuleGroupResponse' :: RuleGroupResponse
ruleGroupResponse = RuleGroupResponse
pRuleGroupResponse_
      }

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

-- | A token used for optimistic locking. Network Firewall returns a token to
-- your requests that access the rule group. The token marks the state of
-- the rule group resource at the time of the request.
--
-- To make changes to the rule group, you provide the token in your
-- request. Network Firewall uses the token to ensure that the rule group
-- hasn\'t changed since you last retrieved it. If it has changed, the
-- operation fails with an @InvalidTokenException@. If this happens,
-- retrieve the rule group again to get a current copy of it with a current
-- token. Reapply your changes as needed, then try the operation again
-- using the new token.
updateRuleGroupResponse_updateToken :: Lens.Lens' UpdateRuleGroupResponse Prelude.Text
updateRuleGroupResponse_updateToken :: (Text -> f Text)
-> UpdateRuleGroupResponse -> f UpdateRuleGroupResponse
updateRuleGroupResponse_updateToken = (UpdateRuleGroupResponse -> Text)
-> (UpdateRuleGroupResponse -> Text -> UpdateRuleGroupResponse)
-> Lens UpdateRuleGroupResponse UpdateRuleGroupResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleGroupResponse' {Text
updateToken :: Text
$sel:updateToken:UpdateRuleGroupResponse' :: UpdateRuleGroupResponse -> Text
updateToken} -> Text
updateToken) (\s :: UpdateRuleGroupResponse
s@UpdateRuleGroupResponse' {} Text
a -> UpdateRuleGroupResponse
s {$sel:updateToken:UpdateRuleGroupResponse' :: Text
updateToken = Text
a} :: UpdateRuleGroupResponse)

-- | The high-level properties of a rule group. This, along with the
-- RuleGroup, define the rule group. You can retrieve all objects for a
-- rule group by calling DescribeRuleGroup.
updateRuleGroupResponse_ruleGroupResponse :: Lens.Lens' UpdateRuleGroupResponse RuleGroupResponse
updateRuleGroupResponse_ruleGroupResponse :: (RuleGroupResponse -> f RuleGroupResponse)
-> UpdateRuleGroupResponse -> f UpdateRuleGroupResponse
updateRuleGroupResponse_ruleGroupResponse = (UpdateRuleGroupResponse -> RuleGroupResponse)
-> (UpdateRuleGroupResponse
    -> RuleGroupResponse -> UpdateRuleGroupResponse)
-> Lens
     UpdateRuleGroupResponse
     UpdateRuleGroupResponse
     RuleGroupResponse
     RuleGroupResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleGroupResponse' {RuleGroupResponse
ruleGroupResponse :: RuleGroupResponse
$sel:ruleGroupResponse:UpdateRuleGroupResponse' :: UpdateRuleGroupResponse -> RuleGroupResponse
ruleGroupResponse} -> RuleGroupResponse
ruleGroupResponse) (\s :: UpdateRuleGroupResponse
s@UpdateRuleGroupResponse' {} RuleGroupResponse
a -> UpdateRuleGroupResponse
s {$sel:ruleGroupResponse:UpdateRuleGroupResponse' :: RuleGroupResponse
ruleGroupResponse = RuleGroupResponse
a} :: UpdateRuleGroupResponse)

instance Prelude.NFData UpdateRuleGroupResponse