{-# 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.DeleteFirewall
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the specified Firewall and its FirewallStatus. This operation
-- requires the firewall\'s @DeleteProtection@ flag to be @FALSE@. You
-- can\'t revert this operation.
--
-- You can check whether a firewall is in use by reviewing the route tables
-- for the Availability Zones where you have firewall subnet mappings.
-- Retrieve the subnet mappings by calling DescribeFirewall. You define and
-- update the route tables through Amazon VPC. As needed, update the route
-- tables for the zones to remove the firewall endpoints. When the route
-- tables no longer use the firewall endpoints, you can remove the firewall
-- safely.
--
-- To delete a firewall, remove the delete protection if you need to using
-- UpdateFirewallDeleteProtection, then delete the firewall by calling
-- DeleteFirewall.
module Amazonka.NetworkFirewall.DeleteFirewall
  ( -- * Creating a Request
    DeleteFirewall (..),
    newDeleteFirewall,

    -- * Request Lenses
    deleteFirewall_firewallArn,
    deleteFirewall_firewallName,

    -- * Destructuring the Response
    DeleteFirewallResponse (..),
    newDeleteFirewallResponse,

    -- * Response Lenses
    deleteFirewallResponse_firewall,
    deleteFirewallResponse_firewallStatus,
    deleteFirewallResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteFirewall' smart constructor.
data DeleteFirewall = DeleteFirewall'
  { -- | The Amazon Resource Name (ARN) of the firewall.
    --
    -- You must specify the ARN or the name, and you can specify both.
    DeleteFirewall -> Maybe Text
firewallArn :: Prelude.Maybe Prelude.Text,
    -- | The descriptive name of the firewall. You can\'t change the name of a
    -- firewall after you create it.
    --
    -- You must specify the ARN or the name, and you can specify both.
    DeleteFirewall -> Maybe Text
firewallName :: Prelude.Maybe Prelude.Text
  }
  deriving (DeleteFirewall -> DeleteFirewall -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteFirewall -> DeleteFirewall -> Bool
$c/= :: DeleteFirewall -> DeleteFirewall -> Bool
== :: DeleteFirewall -> DeleteFirewall -> Bool
$c== :: DeleteFirewall -> DeleteFirewall -> Bool
Prelude.Eq, ReadPrec [DeleteFirewall]
ReadPrec DeleteFirewall
Int -> ReadS DeleteFirewall
ReadS [DeleteFirewall]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteFirewall]
$creadListPrec :: ReadPrec [DeleteFirewall]
readPrec :: ReadPrec DeleteFirewall
$creadPrec :: ReadPrec DeleteFirewall
readList :: ReadS [DeleteFirewall]
$creadList :: ReadS [DeleteFirewall]
readsPrec :: Int -> ReadS DeleteFirewall
$creadsPrec :: Int -> ReadS DeleteFirewall
Prelude.Read, Int -> DeleteFirewall -> ShowS
[DeleteFirewall] -> ShowS
DeleteFirewall -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteFirewall] -> ShowS
$cshowList :: [DeleteFirewall] -> ShowS
show :: DeleteFirewall -> String
$cshow :: DeleteFirewall -> String
showsPrec :: Int -> DeleteFirewall -> ShowS
$cshowsPrec :: Int -> DeleteFirewall -> ShowS
Prelude.Show, forall x. Rep DeleteFirewall x -> DeleteFirewall
forall x. DeleteFirewall -> Rep DeleteFirewall x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteFirewall x -> DeleteFirewall
$cfrom :: forall x. DeleteFirewall -> Rep DeleteFirewall x
Prelude.Generic)

-- |
-- Create a value of 'DeleteFirewall' 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:
--
-- 'firewallArn', 'deleteFirewall_firewallArn' - The Amazon Resource Name (ARN) of the firewall.
--
-- You must specify the ARN or the name, and you can specify both.
--
-- 'firewallName', 'deleteFirewall_firewallName' - The descriptive name of the firewall. You can\'t change the name of a
-- firewall after you create it.
--
-- You must specify the ARN or the name, and you can specify both.
newDeleteFirewall ::
  DeleteFirewall
newDeleteFirewall :: DeleteFirewall
newDeleteFirewall =
  DeleteFirewall'
    { $sel:firewallArn:DeleteFirewall' :: Maybe Text
firewallArn = forall a. Maybe a
Prelude.Nothing,
      $sel:firewallName:DeleteFirewall' :: Maybe Text
firewallName = forall a. Maybe a
Prelude.Nothing
    }

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

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

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

instance Prelude.Hashable DeleteFirewall where
  hashWithSalt :: Int -> DeleteFirewall -> Int
hashWithSalt Int
_salt DeleteFirewall' {Maybe Text
firewallName :: Maybe Text
firewallArn :: Maybe Text
$sel:firewallName:DeleteFirewall' :: DeleteFirewall -> Maybe Text
$sel:firewallArn:DeleteFirewall' :: DeleteFirewall -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
firewallArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
firewallName

instance Prelude.NFData DeleteFirewall where
  rnf :: DeleteFirewall -> ()
rnf DeleteFirewall' {Maybe Text
firewallName :: Maybe Text
firewallArn :: Maybe Text
$sel:firewallName:DeleteFirewall' :: DeleteFirewall -> Maybe Text
$sel:firewallArn:DeleteFirewall' :: DeleteFirewall -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
firewallArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
firewallName

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

instance Data.ToJSON DeleteFirewall where
  toJSON :: DeleteFirewall -> Value
toJSON DeleteFirewall' {Maybe Text
firewallName :: Maybe Text
firewallArn :: Maybe Text
$sel:firewallName:DeleteFirewall' :: DeleteFirewall -> Maybe Text
$sel:firewallArn:DeleteFirewall' :: DeleteFirewall -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"FirewallArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
firewallArn,
            (Key
"FirewallName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
firewallName
          ]
      )

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

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

-- | /See:/ 'newDeleteFirewallResponse' smart constructor.
data DeleteFirewallResponse = DeleteFirewallResponse'
  { DeleteFirewallResponse -> Maybe Firewall
firewall :: Prelude.Maybe Firewall,
    DeleteFirewallResponse -> Maybe FirewallStatus
firewallStatus :: Prelude.Maybe FirewallStatus,
    -- | The response's http status code.
    DeleteFirewallResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteFirewallResponse -> DeleteFirewallResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteFirewallResponse -> DeleteFirewallResponse -> Bool
$c/= :: DeleteFirewallResponse -> DeleteFirewallResponse -> Bool
== :: DeleteFirewallResponse -> DeleteFirewallResponse -> Bool
$c== :: DeleteFirewallResponse -> DeleteFirewallResponse -> Bool
Prelude.Eq, ReadPrec [DeleteFirewallResponse]
ReadPrec DeleteFirewallResponse
Int -> ReadS DeleteFirewallResponse
ReadS [DeleteFirewallResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteFirewallResponse]
$creadListPrec :: ReadPrec [DeleteFirewallResponse]
readPrec :: ReadPrec DeleteFirewallResponse
$creadPrec :: ReadPrec DeleteFirewallResponse
readList :: ReadS [DeleteFirewallResponse]
$creadList :: ReadS [DeleteFirewallResponse]
readsPrec :: Int -> ReadS DeleteFirewallResponse
$creadsPrec :: Int -> ReadS DeleteFirewallResponse
Prelude.Read, Int -> DeleteFirewallResponse -> ShowS
[DeleteFirewallResponse] -> ShowS
DeleteFirewallResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteFirewallResponse] -> ShowS
$cshowList :: [DeleteFirewallResponse] -> ShowS
show :: DeleteFirewallResponse -> String
$cshow :: DeleteFirewallResponse -> String
showsPrec :: Int -> DeleteFirewallResponse -> ShowS
$cshowsPrec :: Int -> DeleteFirewallResponse -> ShowS
Prelude.Show, forall x. Rep DeleteFirewallResponse x -> DeleteFirewallResponse
forall x. DeleteFirewallResponse -> Rep DeleteFirewallResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteFirewallResponse x -> DeleteFirewallResponse
$cfrom :: forall x. DeleteFirewallResponse -> Rep DeleteFirewallResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteFirewallResponse' 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:
--
-- 'firewall', 'deleteFirewallResponse_firewall' - Undocumented member.
--
-- 'firewallStatus', 'deleteFirewallResponse_firewallStatus' - Undocumented member.
--
-- 'httpStatus', 'deleteFirewallResponse_httpStatus' - The response's http status code.
newDeleteFirewallResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteFirewallResponse
newDeleteFirewallResponse :: Int -> DeleteFirewallResponse
newDeleteFirewallResponse Int
pHttpStatus_ =
  DeleteFirewallResponse'
    { $sel:firewall:DeleteFirewallResponse' :: Maybe Firewall
firewall = forall a. Maybe a
Prelude.Nothing,
      $sel:firewallStatus:DeleteFirewallResponse' :: Maybe FirewallStatus
firewallStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteFirewallResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
deleteFirewallResponse_firewall :: Lens.Lens' DeleteFirewallResponse (Prelude.Maybe Firewall)
deleteFirewallResponse_firewall :: Lens' DeleteFirewallResponse (Maybe Firewall)
deleteFirewallResponse_firewall = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFirewallResponse' {Maybe Firewall
firewall :: Maybe Firewall
$sel:firewall:DeleteFirewallResponse' :: DeleteFirewallResponse -> Maybe Firewall
firewall} -> Maybe Firewall
firewall) (\s :: DeleteFirewallResponse
s@DeleteFirewallResponse' {} Maybe Firewall
a -> DeleteFirewallResponse
s {$sel:firewall:DeleteFirewallResponse' :: Maybe Firewall
firewall = Maybe Firewall
a} :: DeleteFirewallResponse)

-- | Undocumented member.
deleteFirewallResponse_firewallStatus :: Lens.Lens' DeleteFirewallResponse (Prelude.Maybe FirewallStatus)
deleteFirewallResponse_firewallStatus :: Lens' DeleteFirewallResponse (Maybe FirewallStatus)
deleteFirewallResponse_firewallStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFirewallResponse' {Maybe FirewallStatus
firewallStatus :: Maybe FirewallStatus
$sel:firewallStatus:DeleteFirewallResponse' :: DeleteFirewallResponse -> Maybe FirewallStatus
firewallStatus} -> Maybe FirewallStatus
firewallStatus) (\s :: DeleteFirewallResponse
s@DeleteFirewallResponse' {} Maybe FirewallStatus
a -> DeleteFirewallResponse
s {$sel:firewallStatus:DeleteFirewallResponse' :: Maybe FirewallStatus
firewallStatus = Maybe FirewallStatus
a} :: DeleteFirewallResponse)

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

instance Prelude.NFData DeleteFirewallResponse where
  rnf :: DeleteFirewallResponse -> ()
rnf DeleteFirewallResponse' {Int
Maybe FirewallStatus
Maybe Firewall
httpStatus :: Int
firewallStatus :: Maybe FirewallStatus
firewall :: Maybe Firewall
$sel:httpStatus:DeleteFirewallResponse' :: DeleteFirewallResponse -> Int
$sel:firewallStatus:DeleteFirewallResponse' :: DeleteFirewallResponse -> Maybe FirewallStatus
$sel:firewall:DeleteFirewallResponse' :: DeleteFirewallResponse -> Maybe Firewall
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Firewall
firewall
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FirewallStatus
firewallStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus