{-# 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.UpdateFirewallPolicy
-- 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 properties of the specified firewall policy.
module Amazonka.NetworkFirewall.UpdateFirewallPolicy
  ( -- * Creating a Request
    UpdateFirewallPolicy (..),
    newUpdateFirewallPolicy,

    -- * Request Lenses
    updateFirewallPolicy_firewallPolicyName,
    updateFirewallPolicy_firewallPolicyArn,
    updateFirewallPolicy_description,
    updateFirewallPolicy_dryRun,
    updateFirewallPolicy_updateToken,
    updateFirewallPolicy_firewallPolicy,

    -- * Destructuring the Response
    UpdateFirewallPolicyResponse (..),
    newUpdateFirewallPolicyResponse,

    -- * Response Lenses
    updateFirewallPolicyResponse_httpStatus,
    updateFirewallPolicyResponse_updateToken,
    updateFirewallPolicyResponse_firewallPolicyResponse,
  )
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:/ 'newUpdateFirewallPolicy' smart constructor.
data UpdateFirewallPolicy = UpdateFirewallPolicy'
  { -- | The descriptive name of the firewall policy. You can\'t change the name
    -- of a firewall policy after you create it.
    --
    -- You must specify the ARN or the name, and you can specify both.
    UpdateFirewallPolicy -> Maybe Text
firewallPolicyName :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the firewall policy.
    --
    -- You must specify the ARN or the name, and you can specify both.
    UpdateFirewallPolicy -> Maybe Text
firewallPolicyArn :: Prelude.Maybe Prelude.Text,
    -- | A description of the firewall policy.
    UpdateFirewallPolicy -> Maybe Text
description :: 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.
    UpdateFirewallPolicy -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | A token used for optimistic locking. Network Firewall returns a token to
    -- your requests that access the firewall policy. The token marks the state
    -- of the policy resource at the time of the request.
    --
    -- To make changes to the policy, you provide the token in your request.
    -- Network Firewall uses the token to ensure that the policy hasn\'t
    -- changed since you last retrieved it. If it has changed, the operation
    -- fails with an @InvalidTokenException@. If this happens, retrieve the
    -- firewall policy again to get a current copy of it with current token.
    -- Reapply your changes as needed, then try the operation again using the
    -- new token.
    UpdateFirewallPolicy -> Text
updateToken :: Prelude.Text,
    -- | The updated firewall policy to use for the firewall.
    UpdateFirewallPolicy -> FirewallPolicy
firewallPolicy :: FirewallPolicy
  }
  deriving (UpdateFirewallPolicy -> UpdateFirewallPolicy -> Bool
(UpdateFirewallPolicy -> UpdateFirewallPolicy -> Bool)
-> (UpdateFirewallPolicy -> UpdateFirewallPolicy -> Bool)
-> Eq UpdateFirewallPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateFirewallPolicy -> UpdateFirewallPolicy -> Bool
$c/= :: UpdateFirewallPolicy -> UpdateFirewallPolicy -> Bool
== :: UpdateFirewallPolicy -> UpdateFirewallPolicy -> Bool
$c== :: UpdateFirewallPolicy -> UpdateFirewallPolicy -> Bool
Prelude.Eq, ReadPrec [UpdateFirewallPolicy]
ReadPrec UpdateFirewallPolicy
Int -> ReadS UpdateFirewallPolicy
ReadS [UpdateFirewallPolicy]
(Int -> ReadS UpdateFirewallPolicy)
-> ReadS [UpdateFirewallPolicy]
-> ReadPrec UpdateFirewallPolicy
-> ReadPrec [UpdateFirewallPolicy]
-> Read UpdateFirewallPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateFirewallPolicy]
$creadListPrec :: ReadPrec [UpdateFirewallPolicy]
readPrec :: ReadPrec UpdateFirewallPolicy
$creadPrec :: ReadPrec UpdateFirewallPolicy
readList :: ReadS [UpdateFirewallPolicy]
$creadList :: ReadS [UpdateFirewallPolicy]
readsPrec :: Int -> ReadS UpdateFirewallPolicy
$creadsPrec :: Int -> ReadS UpdateFirewallPolicy
Prelude.Read, Int -> UpdateFirewallPolicy -> ShowS
[UpdateFirewallPolicy] -> ShowS
UpdateFirewallPolicy -> String
(Int -> UpdateFirewallPolicy -> ShowS)
-> (UpdateFirewallPolicy -> String)
-> ([UpdateFirewallPolicy] -> ShowS)
-> Show UpdateFirewallPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateFirewallPolicy] -> ShowS
$cshowList :: [UpdateFirewallPolicy] -> ShowS
show :: UpdateFirewallPolicy -> String
$cshow :: UpdateFirewallPolicy -> String
showsPrec :: Int -> UpdateFirewallPolicy -> ShowS
$cshowsPrec :: Int -> UpdateFirewallPolicy -> ShowS
Prelude.Show, (forall x. UpdateFirewallPolicy -> Rep UpdateFirewallPolicy x)
-> (forall x. Rep UpdateFirewallPolicy x -> UpdateFirewallPolicy)
-> Generic UpdateFirewallPolicy
forall x. Rep UpdateFirewallPolicy x -> UpdateFirewallPolicy
forall x. UpdateFirewallPolicy -> Rep UpdateFirewallPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateFirewallPolicy x -> UpdateFirewallPolicy
$cfrom :: forall x. UpdateFirewallPolicy -> Rep UpdateFirewallPolicy x
Prelude.Generic)

-- |
-- Create a value of 'UpdateFirewallPolicy' 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:
--
-- 'firewallPolicyName', 'updateFirewallPolicy_firewallPolicyName' - The descriptive name of the firewall policy. You can\'t change the name
-- of a firewall policy after you create it.
--
-- You must specify the ARN or the name, and you can specify both.
--
-- 'firewallPolicyArn', 'updateFirewallPolicy_firewallPolicyArn' - The Amazon Resource Name (ARN) of the firewall policy.
--
-- You must specify the ARN or the name, and you can specify both.
--
-- 'description', 'updateFirewallPolicy_description' - A description of the firewall policy.
--
-- 'dryRun', 'updateFirewallPolicy_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.
--
-- 'updateToken', 'updateFirewallPolicy_updateToken' - A token used for optimistic locking. Network Firewall returns a token to
-- your requests that access the firewall policy. The token marks the state
-- of the policy resource at the time of the request.
--
-- To make changes to the policy, you provide the token in your request.
-- Network Firewall uses the token to ensure that the policy hasn\'t
-- changed since you last retrieved it. If it has changed, the operation
-- fails with an @InvalidTokenException@. If this happens, retrieve the
-- firewall policy again to get a current copy of it with current token.
-- Reapply your changes as needed, then try the operation again using the
-- new token.
--
-- 'firewallPolicy', 'updateFirewallPolicy_firewallPolicy' - The updated firewall policy to use for the firewall.
newUpdateFirewallPolicy ::
  -- | 'updateToken'
  Prelude.Text ->
  -- | 'firewallPolicy'
  FirewallPolicy ->
  UpdateFirewallPolicy
newUpdateFirewallPolicy :: Text -> FirewallPolicy -> UpdateFirewallPolicy
newUpdateFirewallPolicy
  Text
pUpdateToken_
  FirewallPolicy
pFirewallPolicy_ =
    UpdateFirewallPolicy' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Text
-> FirewallPolicy
-> UpdateFirewallPolicy
UpdateFirewallPolicy'
      { $sel:firewallPolicyName:UpdateFirewallPolicy' :: Maybe Text
firewallPolicyName =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:firewallPolicyArn:UpdateFirewallPolicy' :: Maybe Text
firewallPolicyArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:description:UpdateFirewallPolicy' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:dryRun:UpdateFirewallPolicy' :: Maybe Bool
dryRun = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:updateToken:UpdateFirewallPolicy' :: Text
updateToken = Text
pUpdateToken_,
        $sel:firewallPolicy:UpdateFirewallPolicy' :: FirewallPolicy
firewallPolicy = FirewallPolicy
pFirewallPolicy_
      }

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

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

-- | A description of the firewall policy.
updateFirewallPolicy_description :: Lens.Lens' UpdateFirewallPolicy (Prelude.Maybe Prelude.Text)
updateFirewallPolicy_description :: (Maybe Text -> f (Maybe Text))
-> UpdateFirewallPolicy -> f UpdateFirewallPolicy
updateFirewallPolicy_description = (UpdateFirewallPolicy -> Maybe Text)
-> (UpdateFirewallPolicy -> Maybe Text -> UpdateFirewallPolicy)
-> Lens
     UpdateFirewallPolicy UpdateFirewallPolicy (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFirewallPolicy' {Maybe Text
description :: Maybe Text
$sel:description:UpdateFirewallPolicy' :: UpdateFirewallPolicy -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateFirewallPolicy
s@UpdateFirewallPolicy' {} Maybe Text
a -> UpdateFirewallPolicy
s {$sel:description:UpdateFirewallPolicy' :: Maybe Text
description = Maybe Text
a} :: UpdateFirewallPolicy)

-- | 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.
updateFirewallPolicy_dryRun :: Lens.Lens' UpdateFirewallPolicy (Prelude.Maybe Prelude.Bool)
updateFirewallPolicy_dryRun :: (Maybe Bool -> f (Maybe Bool))
-> UpdateFirewallPolicy -> f UpdateFirewallPolicy
updateFirewallPolicy_dryRun = (UpdateFirewallPolicy -> Maybe Bool)
-> (UpdateFirewallPolicy -> Maybe Bool -> UpdateFirewallPolicy)
-> Lens
     UpdateFirewallPolicy UpdateFirewallPolicy (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFirewallPolicy' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:UpdateFirewallPolicy' :: UpdateFirewallPolicy -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: UpdateFirewallPolicy
s@UpdateFirewallPolicy' {} Maybe Bool
a -> UpdateFirewallPolicy
s {$sel:dryRun:UpdateFirewallPolicy' :: Maybe Bool
dryRun = Maybe Bool
a} :: UpdateFirewallPolicy)

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

-- | The updated firewall policy to use for the firewall.
updateFirewallPolicy_firewallPolicy :: Lens.Lens' UpdateFirewallPolicy FirewallPolicy
updateFirewallPolicy_firewallPolicy :: (FirewallPolicy -> f FirewallPolicy)
-> UpdateFirewallPolicy -> f UpdateFirewallPolicy
updateFirewallPolicy_firewallPolicy = (UpdateFirewallPolicy -> FirewallPolicy)
-> (UpdateFirewallPolicy -> FirewallPolicy -> UpdateFirewallPolicy)
-> Lens
     UpdateFirewallPolicy
     UpdateFirewallPolicy
     FirewallPolicy
     FirewallPolicy
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFirewallPolicy' {FirewallPolicy
firewallPolicy :: FirewallPolicy
$sel:firewallPolicy:UpdateFirewallPolicy' :: UpdateFirewallPolicy -> FirewallPolicy
firewallPolicy} -> FirewallPolicy
firewallPolicy) (\s :: UpdateFirewallPolicy
s@UpdateFirewallPolicy' {} FirewallPolicy
a -> UpdateFirewallPolicy
s {$sel:firewallPolicy:UpdateFirewallPolicy' :: FirewallPolicy
firewallPolicy = FirewallPolicy
a} :: UpdateFirewallPolicy)

instance Core.AWSRequest UpdateFirewallPolicy where
  type
    AWSResponse UpdateFirewallPolicy =
      UpdateFirewallPolicyResponse
  request :: UpdateFirewallPolicy -> Request UpdateFirewallPolicy
request = Service -> UpdateFirewallPolicy -> Request UpdateFirewallPolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateFirewallPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateFirewallPolicy)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateFirewallPolicy))
-> Logger
-> Service
-> Proxy UpdateFirewallPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateFirewallPolicy)))
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 -> FirewallPolicyResponse -> UpdateFirewallPolicyResponse
UpdateFirewallPolicyResponse'
            (Int
 -> Text -> FirewallPolicyResponse -> UpdateFirewallPolicyResponse)
-> Either String Int
-> Either
     String
     (Text -> FirewallPolicyResponse -> UpdateFirewallPolicyResponse)
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 -> FirewallPolicyResponse -> UpdateFirewallPolicyResponse)
-> Either String Text
-> Either
     String (FirewallPolicyResponse -> UpdateFirewallPolicyResponse)
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 (FirewallPolicyResponse -> UpdateFirewallPolicyResponse)
-> Either String FirewallPolicyResponse
-> Either String UpdateFirewallPolicyResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String FirewallPolicyResponse
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"FirewallPolicyResponse")
      )

instance Prelude.Hashable UpdateFirewallPolicy

instance Prelude.NFData UpdateFirewallPolicy

instance Core.ToHeaders UpdateFirewallPolicy where
  toHeaders :: UpdateFirewallPolicy -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateFirewallPolicy -> 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.UpdateFirewallPolicy" ::
                          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 UpdateFirewallPolicy where
  toJSON :: UpdateFirewallPolicy -> Value
toJSON UpdateFirewallPolicy' {Maybe Bool
Maybe Text
Text
FirewallPolicy
firewallPolicy :: FirewallPolicy
updateToken :: Text
dryRun :: Maybe Bool
description :: Maybe Text
firewallPolicyArn :: Maybe Text
firewallPolicyName :: Maybe Text
$sel:firewallPolicy:UpdateFirewallPolicy' :: UpdateFirewallPolicy -> FirewallPolicy
$sel:updateToken:UpdateFirewallPolicy' :: UpdateFirewallPolicy -> Text
$sel:dryRun:UpdateFirewallPolicy' :: UpdateFirewallPolicy -> Maybe Bool
$sel:description:UpdateFirewallPolicy' :: UpdateFirewallPolicy -> Maybe Text
$sel:firewallPolicyArn:UpdateFirewallPolicy' :: UpdateFirewallPolicy -> Maybe Text
$sel:firewallPolicyName:UpdateFirewallPolicy' :: UpdateFirewallPolicy -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"FirewallPolicyName" 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
firewallPolicyName,
            (Text
"FirewallPolicyArn" 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
firewallPolicyArn,
            (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
"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,
            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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"FirewallPolicy" Text -> FirewallPolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= FirewallPolicy
firewallPolicy)
          ]
      )

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

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

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

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

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

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

-- | The high-level properties of a firewall policy. This, along with the
-- FirewallPolicy, define the policy. You can retrieve all objects for a
-- firewall policy by calling DescribeFirewallPolicy.
updateFirewallPolicyResponse_firewallPolicyResponse :: Lens.Lens' UpdateFirewallPolicyResponse FirewallPolicyResponse
updateFirewallPolicyResponse_firewallPolicyResponse :: (FirewallPolicyResponse -> f FirewallPolicyResponse)
-> UpdateFirewallPolicyResponse -> f UpdateFirewallPolicyResponse
updateFirewallPolicyResponse_firewallPolicyResponse = (UpdateFirewallPolicyResponse -> FirewallPolicyResponse)
-> (UpdateFirewallPolicyResponse
    -> FirewallPolicyResponse -> UpdateFirewallPolicyResponse)
-> Lens
     UpdateFirewallPolicyResponse
     UpdateFirewallPolicyResponse
     FirewallPolicyResponse
     FirewallPolicyResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFirewallPolicyResponse' {FirewallPolicyResponse
firewallPolicyResponse :: FirewallPolicyResponse
$sel:firewallPolicyResponse:UpdateFirewallPolicyResponse' :: UpdateFirewallPolicyResponse -> FirewallPolicyResponse
firewallPolicyResponse} -> FirewallPolicyResponse
firewallPolicyResponse) (\s :: UpdateFirewallPolicyResponse
s@UpdateFirewallPolicyResponse' {} FirewallPolicyResponse
a -> UpdateFirewallPolicyResponse
s {$sel:firewallPolicyResponse:UpdateFirewallPolicyResponse' :: FirewallPolicyResponse
firewallPolicyResponse = FirewallPolicyResponse
a} :: UpdateFirewallPolicyResponse)

instance Prelude.NFData UpdateFirewallPolicyResponse