{-# 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-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)
--
-- 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_firewallStatus,
    deleteFirewallResponse_firewall,
    deleteFirewallResponse_httpStatus,
  )
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:/ '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
(DeleteFirewall -> DeleteFirewall -> Bool)
-> (DeleteFirewall -> DeleteFirewall -> Bool) -> Eq DeleteFirewall
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]
(Int -> ReadS DeleteFirewall)
-> ReadS [DeleteFirewall]
-> ReadPrec DeleteFirewall
-> ReadPrec [DeleteFirewall]
-> Read 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
(Int -> DeleteFirewall -> ShowS)
-> (DeleteFirewall -> String)
-> ([DeleteFirewall] -> ShowS)
-> Show DeleteFirewall
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. DeleteFirewall -> Rep DeleteFirewall x)
-> (forall x. Rep DeleteFirewall x -> DeleteFirewall)
-> Generic DeleteFirewall
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' :: Maybe Text -> Maybe Text -> DeleteFirewall
DeleteFirewall'
    { $sel:firewallArn:DeleteFirewall' :: Maybe Text
firewallArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:firewallName:DeleteFirewall' :: Maybe Text
firewallName = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DeleteFirewall -> f DeleteFirewall
deleteFirewall_firewallArn = (DeleteFirewall -> Maybe Text)
-> (DeleteFirewall -> Maybe Text -> DeleteFirewall)
-> Lens DeleteFirewall DeleteFirewall (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> DeleteFirewall -> f DeleteFirewall
deleteFirewall_firewallName = (DeleteFirewall -> Maybe Text)
-> (DeleteFirewall -> Maybe Text -> DeleteFirewall)
-> Lens DeleteFirewall DeleteFirewall (Maybe Text) (Maybe Text)
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 :: DeleteFirewall -> Request DeleteFirewall
request = Service -> DeleteFirewall -> Request DeleteFirewall
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteFirewall
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteFirewall)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteFirewall))
-> Logger
-> Service
-> Proxy DeleteFirewall
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteFirewall)))
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 ->
          Maybe FirewallStatus
-> Maybe Firewall -> Int -> DeleteFirewallResponse
DeleteFirewallResponse'
            (Maybe FirewallStatus
 -> Maybe Firewall -> Int -> DeleteFirewallResponse)
-> Either String (Maybe FirewallStatus)
-> Either String (Maybe Firewall -> Int -> DeleteFirewallResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe FirewallStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"FirewallStatus")
            Either String (Maybe Firewall -> Int -> DeleteFirewallResponse)
-> Either String (Maybe Firewall)
-> Either String (Int -> DeleteFirewallResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Firewall)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Firewall")
            Either String (Int -> DeleteFirewallResponse)
-> Either String Int -> Either String DeleteFirewallResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable DeleteFirewall

instance Prelude.NFData DeleteFirewall

instance Core.ToHeaders DeleteFirewall where
  toHeaders :: DeleteFirewall -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteFirewall -> 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.DeleteFirewall" ::
                          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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"FirewallArn" 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
firewallArn,
            (Text
"FirewallName" 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
firewallName
          ]
      )

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

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

-- | /See:/ 'newDeleteFirewallResponse' smart constructor.
data DeleteFirewallResponse = DeleteFirewallResponse'
  { DeleteFirewallResponse -> Maybe FirewallStatus
firewallStatus :: Prelude.Maybe FirewallStatus,
    DeleteFirewallResponse -> Maybe Firewall
firewall :: Prelude.Maybe Firewall,
    -- | The response's http status code.
    DeleteFirewallResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteFirewallResponse -> DeleteFirewallResponse -> Bool
(DeleteFirewallResponse -> DeleteFirewallResponse -> Bool)
-> (DeleteFirewallResponse -> DeleteFirewallResponse -> Bool)
-> Eq DeleteFirewallResponse
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]
(Int -> ReadS DeleteFirewallResponse)
-> ReadS [DeleteFirewallResponse]
-> ReadPrec DeleteFirewallResponse
-> ReadPrec [DeleteFirewallResponse]
-> Read 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
(Int -> DeleteFirewallResponse -> ShowS)
-> (DeleteFirewallResponse -> String)
-> ([DeleteFirewallResponse] -> ShowS)
-> Show DeleteFirewallResponse
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. DeleteFirewallResponse -> Rep DeleteFirewallResponse x)
-> (forall x.
    Rep DeleteFirewallResponse x -> DeleteFirewallResponse)
-> Generic DeleteFirewallResponse
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:
--
-- 'firewallStatus', 'deleteFirewallResponse_firewallStatus' - Undocumented member.
--
-- 'firewall', 'deleteFirewallResponse_firewall' - Undocumented member.
--
-- 'httpStatus', 'deleteFirewallResponse_httpStatus' - The response's http status code.
newDeleteFirewallResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteFirewallResponse
newDeleteFirewallResponse :: Int -> DeleteFirewallResponse
newDeleteFirewallResponse Int
pHttpStatus_ =
  DeleteFirewallResponse' :: Maybe FirewallStatus
-> Maybe Firewall -> Int -> DeleteFirewallResponse
DeleteFirewallResponse'
    { $sel:firewallStatus:DeleteFirewallResponse' :: Maybe FirewallStatus
firewallStatus =
        Maybe FirewallStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:firewall:DeleteFirewallResponse' :: Maybe Firewall
firewall = Maybe Firewall
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteFirewallResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
deleteFirewallResponse_firewallStatus :: Lens.Lens' DeleteFirewallResponse (Prelude.Maybe FirewallStatus)
deleteFirewallResponse_firewallStatus :: (Maybe FirewallStatus -> f (Maybe FirewallStatus))
-> DeleteFirewallResponse -> f DeleteFirewallResponse
deleteFirewallResponse_firewallStatus = (DeleteFirewallResponse -> Maybe FirewallStatus)
-> (DeleteFirewallResponse
    -> Maybe FirewallStatus -> DeleteFirewallResponse)
-> Lens
     DeleteFirewallResponse
     DeleteFirewallResponse
     (Maybe FirewallStatus)
     (Maybe 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)

-- | Undocumented member.
deleteFirewallResponse_firewall :: Lens.Lens' DeleteFirewallResponse (Prelude.Maybe Firewall)
deleteFirewallResponse_firewall :: (Maybe Firewall -> f (Maybe Firewall))
-> DeleteFirewallResponse -> f DeleteFirewallResponse
deleteFirewallResponse_firewall = (DeleteFirewallResponse -> Maybe Firewall)
-> (DeleteFirewallResponse
    -> Maybe Firewall -> DeleteFirewallResponse)
-> Lens
     DeleteFirewallResponse
     DeleteFirewallResponse
     (Maybe Firewall)
     (Maybe 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)

-- | The response's http status code.
deleteFirewallResponse_httpStatus :: Lens.Lens' DeleteFirewallResponse Prelude.Int
deleteFirewallResponse_httpStatus :: (Int -> f Int)
-> DeleteFirewallResponse -> f DeleteFirewallResponse
deleteFirewallResponse_httpStatus = (DeleteFirewallResponse -> Int)
-> (DeleteFirewallResponse -> Int -> DeleteFirewallResponse)
-> Lens DeleteFirewallResponse DeleteFirewallResponse Int Int
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