{-# 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.CreateFirewallPolicy
-- 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)
--
-- Creates the firewall policy for the firewall according to the
-- specifications.
--
-- An AWS Network Firewall firewall policy defines the behavior of a
-- firewall, in a collection of stateless and stateful rule groups and
-- other settings. You can use one firewall policy for multiple firewalls.
module Amazonka.NetworkFirewall.CreateFirewallPolicy
  ( -- * Creating a Request
    CreateFirewallPolicy (..),
    newCreateFirewallPolicy,

    -- * Request Lenses
    createFirewallPolicy_description,
    createFirewallPolicy_dryRun,
    createFirewallPolicy_tags,
    createFirewallPolicy_firewallPolicyName,
    createFirewallPolicy_firewallPolicy,

    -- * Destructuring the Response
    CreateFirewallPolicyResponse (..),
    newCreateFirewallPolicyResponse,

    -- * Response Lenses
    createFirewallPolicyResponse_httpStatus,
    createFirewallPolicyResponse_updateToken,
    createFirewallPolicyResponse_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:/ 'newCreateFirewallPolicy' smart constructor.
data CreateFirewallPolicy = CreateFirewallPolicy'
  { -- | A description of the firewall policy.
    CreateFirewallPolicy -> 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.
    CreateFirewallPolicy -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The key:value pairs to associate with the resource.
    CreateFirewallPolicy -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
    -- | The descriptive name of the firewall policy. You can\'t change the name
    -- of a firewall policy after you create it.
    CreateFirewallPolicy -> Text
firewallPolicyName :: Prelude.Text,
    -- | The rule groups and policy actions to use in the firewall policy.
    CreateFirewallPolicy -> FirewallPolicy
firewallPolicy :: FirewallPolicy
  }
  deriving (CreateFirewallPolicy -> CreateFirewallPolicy -> Bool
(CreateFirewallPolicy -> CreateFirewallPolicy -> Bool)
-> (CreateFirewallPolicy -> CreateFirewallPolicy -> Bool)
-> Eq CreateFirewallPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateFirewallPolicy -> CreateFirewallPolicy -> Bool
$c/= :: CreateFirewallPolicy -> CreateFirewallPolicy -> Bool
== :: CreateFirewallPolicy -> CreateFirewallPolicy -> Bool
$c== :: CreateFirewallPolicy -> CreateFirewallPolicy -> Bool
Prelude.Eq, ReadPrec [CreateFirewallPolicy]
ReadPrec CreateFirewallPolicy
Int -> ReadS CreateFirewallPolicy
ReadS [CreateFirewallPolicy]
(Int -> ReadS CreateFirewallPolicy)
-> ReadS [CreateFirewallPolicy]
-> ReadPrec CreateFirewallPolicy
-> ReadPrec [CreateFirewallPolicy]
-> Read CreateFirewallPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateFirewallPolicy]
$creadListPrec :: ReadPrec [CreateFirewallPolicy]
readPrec :: ReadPrec CreateFirewallPolicy
$creadPrec :: ReadPrec CreateFirewallPolicy
readList :: ReadS [CreateFirewallPolicy]
$creadList :: ReadS [CreateFirewallPolicy]
readsPrec :: Int -> ReadS CreateFirewallPolicy
$creadsPrec :: Int -> ReadS CreateFirewallPolicy
Prelude.Read, Int -> CreateFirewallPolicy -> ShowS
[CreateFirewallPolicy] -> ShowS
CreateFirewallPolicy -> String
(Int -> CreateFirewallPolicy -> ShowS)
-> (CreateFirewallPolicy -> String)
-> ([CreateFirewallPolicy] -> ShowS)
-> Show CreateFirewallPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateFirewallPolicy] -> ShowS
$cshowList :: [CreateFirewallPolicy] -> ShowS
show :: CreateFirewallPolicy -> String
$cshow :: CreateFirewallPolicy -> String
showsPrec :: Int -> CreateFirewallPolicy -> ShowS
$cshowsPrec :: Int -> CreateFirewallPolicy -> ShowS
Prelude.Show, (forall x. CreateFirewallPolicy -> Rep CreateFirewallPolicy x)
-> (forall x. Rep CreateFirewallPolicy x -> CreateFirewallPolicy)
-> Generic CreateFirewallPolicy
forall x. Rep CreateFirewallPolicy x -> CreateFirewallPolicy
forall x. CreateFirewallPolicy -> Rep CreateFirewallPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateFirewallPolicy x -> CreateFirewallPolicy
$cfrom :: forall x. CreateFirewallPolicy -> Rep CreateFirewallPolicy x
Prelude.Generic)

-- |
-- Create a value of 'CreateFirewallPolicy' 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:
--
-- 'description', 'createFirewallPolicy_description' - A description of the firewall policy.
--
-- 'dryRun', 'createFirewallPolicy_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.
--
-- 'tags', 'createFirewallPolicy_tags' - The key:value pairs to associate with the resource.
--
-- 'firewallPolicyName', 'createFirewallPolicy_firewallPolicyName' - The descriptive name of the firewall policy. You can\'t change the name
-- of a firewall policy after you create it.
--
-- 'firewallPolicy', 'createFirewallPolicy_firewallPolicy' - The rule groups and policy actions to use in the firewall policy.
newCreateFirewallPolicy ::
  -- | 'firewallPolicyName'
  Prelude.Text ->
  -- | 'firewallPolicy'
  FirewallPolicy ->
  CreateFirewallPolicy
newCreateFirewallPolicy :: Text -> FirewallPolicy -> CreateFirewallPolicy
newCreateFirewallPolicy
  Text
pFirewallPolicyName_
  FirewallPolicy
pFirewallPolicy_ =
    CreateFirewallPolicy' :: Maybe Text
-> Maybe Bool
-> Maybe (NonEmpty Tag)
-> Text
-> FirewallPolicy
-> CreateFirewallPolicy
CreateFirewallPolicy'
      { $sel:description:CreateFirewallPolicy' :: Maybe Text
description =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:dryRun:CreateFirewallPolicy' :: Maybe Bool
dryRun = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateFirewallPolicy' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing,
        $sel:firewallPolicyName:CreateFirewallPolicy' :: Text
firewallPolicyName = Text
pFirewallPolicyName_,
        $sel:firewallPolicy:CreateFirewallPolicy' :: FirewallPolicy
firewallPolicy = FirewallPolicy
pFirewallPolicy_
      }

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

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

-- | The key:value pairs to associate with the resource.
createFirewallPolicy_tags :: Lens.Lens' CreateFirewallPolicy (Prelude.Maybe (Prelude.NonEmpty Tag))
createFirewallPolicy_tags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateFirewallPolicy -> f CreateFirewallPolicy
createFirewallPolicy_tags = (CreateFirewallPolicy -> Maybe (NonEmpty Tag))
-> (CreateFirewallPolicy
    -> Maybe (NonEmpty Tag) -> CreateFirewallPolicy)
-> Lens
     CreateFirewallPolicy
     CreateFirewallPolicy
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFirewallPolicy' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateFirewallPolicy' :: CreateFirewallPolicy -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateFirewallPolicy
s@CreateFirewallPolicy' {} Maybe (NonEmpty Tag)
a -> CreateFirewallPolicy
s {$sel:tags:CreateFirewallPolicy' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateFirewallPolicy) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
 -> CreateFirewallPolicy -> f CreateFirewallPolicy)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
    -> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateFirewallPolicy
-> f CreateFirewallPolicy
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
-> Iso
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
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 AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The descriptive name of the firewall policy. You can\'t change the name
-- of a firewall policy after you create it.
createFirewallPolicy_firewallPolicyName :: Lens.Lens' CreateFirewallPolicy Prelude.Text
createFirewallPolicy_firewallPolicyName :: (Text -> f Text) -> CreateFirewallPolicy -> f CreateFirewallPolicy
createFirewallPolicy_firewallPolicyName = (CreateFirewallPolicy -> Text)
-> (CreateFirewallPolicy -> Text -> CreateFirewallPolicy)
-> Lens CreateFirewallPolicy CreateFirewallPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFirewallPolicy' {Text
firewallPolicyName :: Text
$sel:firewallPolicyName:CreateFirewallPolicy' :: CreateFirewallPolicy -> Text
firewallPolicyName} -> Text
firewallPolicyName) (\s :: CreateFirewallPolicy
s@CreateFirewallPolicy' {} Text
a -> CreateFirewallPolicy
s {$sel:firewallPolicyName:CreateFirewallPolicy' :: Text
firewallPolicyName = Text
a} :: CreateFirewallPolicy)

-- | The rule groups and policy actions to use in the firewall policy.
createFirewallPolicy_firewallPolicy :: Lens.Lens' CreateFirewallPolicy FirewallPolicy
createFirewallPolicy_firewallPolicy :: (FirewallPolicy -> f FirewallPolicy)
-> CreateFirewallPolicy -> f CreateFirewallPolicy
createFirewallPolicy_firewallPolicy = (CreateFirewallPolicy -> FirewallPolicy)
-> (CreateFirewallPolicy -> FirewallPolicy -> CreateFirewallPolicy)
-> Lens
     CreateFirewallPolicy
     CreateFirewallPolicy
     FirewallPolicy
     FirewallPolicy
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFirewallPolicy' {FirewallPolicy
firewallPolicy :: FirewallPolicy
$sel:firewallPolicy:CreateFirewallPolicy' :: CreateFirewallPolicy -> FirewallPolicy
firewallPolicy} -> FirewallPolicy
firewallPolicy) (\s :: CreateFirewallPolicy
s@CreateFirewallPolicy' {} FirewallPolicy
a -> CreateFirewallPolicy
s {$sel:firewallPolicy:CreateFirewallPolicy' :: FirewallPolicy
firewallPolicy = FirewallPolicy
a} :: CreateFirewallPolicy)

instance Core.AWSRequest CreateFirewallPolicy where
  type
    AWSResponse CreateFirewallPolicy =
      CreateFirewallPolicyResponse
  request :: CreateFirewallPolicy -> Request CreateFirewallPolicy
request = Service -> CreateFirewallPolicy -> Request CreateFirewallPolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateFirewallPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateFirewallPolicy)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateFirewallPolicy))
-> Logger
-> Service
-> Proxy CreateFirewallPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateFirewallPolicy)))
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 -> CreateFirewallPolicyResponse
CreateFirewallPolicyResponse'
            (Int
 -> Text -> FirewallPolicyResponse -> CreateFirewallPolicyResponse)
-> Either String Int
-> Either
     String
     (Text -> FirewallPolicyResponse -> CreateFirewallPolicyResponse)
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 -> CreateFirewallPolicyResponse)
-> Either String Text
-> Either
     String (FirewallPolicyResponse -> CreateFirewallPolicyResponse)
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 -> CreateFirewallPolicyResponse)
-> Either String FirewallPolicyResponse
-> Either String CreateFirewallPolicyResponse
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 CreateFirewallPolicy

instance Prelude.NFData CreateFirewallPolicy

instance Core.ToHeaders CreateFirewallPolicy where
  toHeaders :: CreateFirewallPolicy -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateFirewallPolicy -> 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.CreateFirewallPolicy" ::
                          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 CreateFirewallPolicy where
  toJSON :: CreateFirewallPolicy -> Value
toJSON CreateFirewallPolicy' {Maybe Bool
Maybe (NonEmpty Tag)
Maybe Text
Text
FirewallPolicy
firewallPolicy :: FirewallPolicy
firewallPolicyName :: Text
tags :: Maybe (NonEmpty Tag)
dryRun :: Maybe Bool
description :: Maybe Text
$sel:firewallPolicy:CreateFirewallPolicy' :: CreateFirewallPolicy -> FirewallPolicy
$sel:firewallPolicyName:CreateFirewallPolicy' :: CreateFirewallPolicy -> Text
$sel:tags:CreateFirewallPolicy' :: CreateFirewallPolicy -> Maybe (NonEmpty Tag)
$sel:dryRun:CreateFirewallPolicy' :: CreateFirewallPolicy -> Maybe Bool
$sel:description:CreateFirewallPolicy' :: CreateFirewallPolicy -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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,
            (Text
"Tags" Text -> NonEmpty Tag -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Tag -> Pair) -> Maybe (NonEmpty Tag) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Tag)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"FirewallPolicyName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
firewallPolicyName),
            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 CreateFirewallPolicy where
  toPath :: CreateFirewallPolicy -> ByteString
toPath = ByteString -> CreateFirewallPolicy -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newCreateFirewallPolicyResponse' smart constructor.
data CreateFirewallPolicyResponse = CreateFirewallPolicyResponse'
  { -- | The response's http status code.
    CreateFirewallPolicyResponse -> 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.
    CreateFirewallPolicyResponse -> 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.
    CreateFirewallPolicyResponse -> FirewallPolicyResponse
firewallPolicyResponse :: FirewallPolicyResponse
  }
  deriving (CreateFirewallPolicyResponse
-> CreateFirewallPolicyResponse -> Bool
(CreateFirewallPolicyResponse
 -> CreateFirewallPolicyResponse -> Bool)
-> (CreateFirewallPolicyResponse
    -> CreateFirewallPolicyResponse -> Bool)
-> Eq CreateFirewallPolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateFirewallPolicyResponse
-> CreateFirewallPolicyResponse -> Bool
$c/= :: CreateFirewallPolicyResponse
-> CreateFirewallPolicyResponse -> Bool
== :: CreateFirewallPolicyResponse
-> CreateFirewallPolicyResponse -> Bool
$c== :: CreateFirewallPolicyResponse
-> CreateFirewallPolicyResponse -> Bool
Prelude.Eq, ReadPrec [CreateFirewallPolicyResponse]
ReadPrec CreateFirewallPolicyResponse
Int -> ReadS CreateFirewallPolicyResponse
ReadS [CreateFirewallPolicyResponse]
(Int -> ReadS CreateFirewallPolicyResponse)
-> ReadS [CreateFirewallPolicyResponse]
-> ReadPrec CreateFirewallPolicyResponse
-> ReadPrec [CreateFirewallPolicyResponse]
-> Read CreateFirewallPolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateFirewallPolicyResponse]
$creadListPrec :: ReadPrec [CreateFirewallPolicyResponse]
readPrec :: ReadPrec CreateFirewallPolicyResponse
$creadPrec :: ReadPrec CreateFirewallPolicyResponse
readList :: ReadS [CreateFirewallPolicyResponse]
$creadList :: ReadS [CreateFirewallPolicyResponse]
readsPrec :: Int -> ReadS CreateFirewallPolicyResponse
$creadsPrec :: Int -> ReadS CreateFirewallPolicyResponse
Prelude.Read, Int -> CreateFirewallPolicyResponse -> ShowS
[CreateFirewallPolicyResponse] -> ShowS
CreateFirewallPolicyResponse -> String
(Int -> CreateFirewallPolicyResponse -> ShowS)
-> (CreateFirewallPolicyResponse -> String)
-> ([CreateFirewallPolicyResponse] -> ShowS)
-> Show CreateFirewallPolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateFirewallPolicyResponse] -> ShowS
$cshowList :: [CreateFirewallPolicyResponse] -> ShowS
show :: CreateFirewallPolicyResponse -> String
$cshow :: CreateFirewallPolicyResponse -> String
showsPrec :: Int -> CreateFirewallPolicyResponse -> ShowS
$cshowsPrec :: Int -> CreateFirewallPolicyResponse -> ShowS
Prelude.Show, (forall x.
 CreateFirewallPolicyResponse -> Rep CreateFirewallPolicyResponse x)
-> (forall x.
    Rep CreateFirewallPolicyResponse x -> CreateFirewallPolicyResponse)
-> Generic CreateFirewallPolicyResponse
forall x.
Rep CreateFirewallPolicyResponse x -> CreateFirewallPolicyResponse
forall x.
CreateFirewallPolicyResponse -> Rep CreateFirewallPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateFirewallPolicyResponse x -> CreateFirewallPolicyResponse
$cfrom :: forall x.
CreateFirewallPolicyResponse -> Rep CreateFirewallPolicyResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateFirewallPolicyResponse' 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', 'createFirewallPolicyResponse_httpStatus' - The response's http status code.
--
-- 'updateToken', 'createFirewallPolicyResponse_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', 'createFirewallPolicyResponse_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.
newCreateFirewallPolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'updateToken'
  Prelude.Text ->
  -- | 'firewallPolicyResponse'
  FirewallPolicyResponse ->
  CreateFirewallPolicyResponse
newCreateFirewallPolicyResponse :: Int
-> Text -> FirewallPolicyResponse -> CreateFirewallPolicyResponse
newCreateFirewallPolicyResponse
  Int
pHttpStatus_
  Text
pUpdateToken_
  FirewallPolicyResponse
pFirewallPolicyResponse_ =
    CreateFirewallPolicyResponse' :: Int
-> Text -> FirewallPolicyResponse -> CreateFirewallPolicyResponse
CreateFirewallPolicyResponse'
      { $sel:httpStatus:CreateFirewallPolicyResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:updateToken:CreateFirewallPolicyResponse' :: Text
updateToken = Text
pUpdateToken_,
        $sel:firewallPolicyResponse:CreateFirewallPolicyResponse' :: FirewallPolicyResponse
firewallPolicyResponse =
          FirewallPolicyResponse
pFirewallPolicyResponse_
      }

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

-- | 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.
createFirewallPolicyResponse_updateToken :: Lens.Lens' CreateFirewallPolicyResponse Prelude.Text
createFirewallPolicyResponse_updateToken :: (Text -> f Text)
-> CreateFirewallPolicyResponse -> f CreateFirewallPolicyResponse
createFirewallPolicyResponse_updateToken = (CreateFirewallPolicyResponse -> Text)
-> (CreateFirewallPolicyResponse
    -> Text -> CreateFirewallPolicyResponse)
-> Lens
     CreateFirewallPolicyResponse CreateFirewallPolicyResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFirewallPolicyResponse' {Text
updateToken :: Text
$sel:updateToken:CreateFirewallPolicyResponse' :: CreateFirewallPolicyResponse -> Text
updateToken} -> Text
updateToken) (\s :: CreateFirewallPolicyResponse
s@CreateFirewallPolicyResponse' {} Text
a -> CreateFirewallPolicyResponse
s {$sel:updateToken:CreateFirewallPolicyResponse' :: Text
updateToken = Text
a} :: CreateFirewallPolicyResponse)

-- | 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.
createFirewallPolicyResponse_firewallPolicyResponse :: Lens.Lens' CreateFirewallPolicyResponse FirewallPolicyResponse
createFirewallPolicyResponse_firewallPolicyResponse :: (FirewallPolicyResponse -> f FirewallPolicyResponse)
-> CreateFirewallPolicyResponse -> f CreateFirewallPolicyResponse
createFirewallPolicyResponse_firewallPolicyResponse = (CreateFirewallPolicyResponse -> FirewallPolicyResponse)
-> (CreateFirewallPolicyResponse
    -> FirewallPolicyResponse -> CreateFirewallPolicyResponse)
-> Lens
     CreateFirewallPolicyResponse
     CreateFirewallPolicyResponse
     FirewallPolicyResponse
     FirewallPolicyResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFirewallPolicyResponse' {FirewallPolicyResponse
firewallPolicyResponse :: FirewallPolicyResponse
$sel:firewallPolicyResponse:CreateFirewallPolicyResponse' :: CreateFirewallPolicyResponse -> FirewallPolicyResponse
firewallPolicyResponse} -> FirewallPolicyResponse
firewallPolicyResponse) (\s :: CreateFirewallPolicyResponse
s@CreateFirewallPolicyResponse' {} FirewallPolicyResponse
a -> CreateFirewallPolicyResponse
s {$sel:firewallPolicyResponse:CreateFirewallPolicyResponse' :: FirewallPolicyResponse
firewallPolicyResponse = FirewallPolicyResponse
a} :: CreateFirewallPolicyResponse)

instance Prelude.NFData CreateFirewallPolicyResponse