{-# 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.Route53Resolver.GetFirewallConfig
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the configuration of the firewall behavior provided by DNS
-- Firewall for a single VPC from Amazon Virtual Private Cloud (Amazon
-- VPC).
module Amazonka.Route53Resolver.GetFirewallConfig
  ( -- * Creating a Request
    GetFirewallConfig (..),
    newGetFirewallConfig,

    -- * Request Lenses
    getFirewallConfig_resourceId,

    -- * Destructuring the Response
    GetFirewallConfigResponse (..),
    newGetFirewallConfigResponse,

    -- * Response Lenses
    getFirewallConfigResponse_firewallConfig,
    getFirewallConfigResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetFirewallConfig' smart constructor.
data GetFirewallConfig = GetFirewallConfig'
  { -- | The ID of the VPC from Amazon VPC that the configuration is for.
    GetFirewallConfig -> Text
resourceId :: Prelude.Text
  }
  deriving (GetFirewallConfig -> GetFirewallConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetFirewallConfig -> GetFirewallConfig -> Bool
$c/= :: GetFirewallConfig -> GetFirewallConfig -> Bool
== :: GetFirewallConfig -> GetFirewallConfig -> Bool
$c== :: GetFirewallConfig -> GetFirewallConfig -> Bool
Prelude.Eq, ReadPrec [GetFirewallConfig]
ReadPrec GetFirewallConfig
Int -> ReadS GetFirewallConfig
ReadS [GetFirewallConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetFirewallConfig]
$creadListPrec :: ReadPrec [GetFirewallConfig]
readPrec :: ReadPrec GetFirewallConfig
$creadPrec :: ReadPrec GetFirewallConfig
readList :: ReadS [GetFirewallConfig]
$creadList :: ReadS [GetFirewallConfig]
readsPrec :: Int -> ReadS GetFirewallConfig
$creadsPrec :: Int -> ReadS GetFirewallConfig
Prelude.Read, Int -> GetFirewallConfig -> ShowS
[GetFirewallConfig] -> ShowS
GetFirewallConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetFirewallConfig] -> ShowS
$cshowList :: [GetFirewallConfig] -> ShowS
show :: GetFirewallConfig -> String
$cshow :: GetFirewallConfig -> String
showsPrec :: Int -> GetFirewallConfig -> ShowS
$cshowsPrec :: Int -> GetFirewallConfig -> ShowS
Prelude.Show, forall x. Rep GetFirewallConfig x -> GetFirewallConfig
forall x. GetFirewallConfig -> Rep GetFirewallConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetFirewallConfig x -> GetFirewallConfig
$cfrom :: forall x. GetFirewallConfig -> Rep GetFirewallConfig x
Prelude.Generic)

-- |
-- Create a value of 'GetFirewallConfig' 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:
--
-- 'resourceId', 'getFirewallConfig_resourceId' - The ID of the VPC from Amazon VPC that the configuration is for.
newGetFirewallConfig ::
  -- | 'resourceId'
  Prelude.Text ->
  GetFirewallConfig
newGetFirewallConfig :: Text -> GetFirewallConfig
newGetFirewallConfig Text
pResourceId_ =
  GetFirewallConfig' {$sel:resourceId:GetFirewallConfig' :: Text
resourceId = Text
pResourceId_}

-- | The ID of the VPC from Amazon VPC that the configuration is for.
getFirewallConfig_resourceId :: Lens.Lens' GetFirewallConfig Prelude.Text
getFirewallConfig_resourceId :: Lens' GetFirewallConfig Text
getFirewallConfig_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFirewallConfig' {Text
resourceId :: Text
$sel:resourceId:GetFirewallConfig' :: GetFirewallConfig -> Text
resourceId} -> Text
resourceId) (\s :: GetFirewallConfig
s@GetFirewallConfig' {} Text
a -> GetFirewallConfig
s {$sel:resourceId:GetFirewallConfig' :: Text
resourceId = Text
a} :: GetFirewallConfig)

instance Core.AWSRequest GetFirewallConfig where
  type
    AWSResponse GetFirewallConfig =
      GetFirewallConfigResponse
  request :: (Service -> Service)
-> GetFirewallConfig -> Request GetFirewallConfig
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 GetFirewallConfig
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetFirewallConfig)))
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 FirewallConfig -> Int -> GetFirewallConfigResponse
GetFirewallConfigResponse'
            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
"FirewallConfig")
            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 GetFirewallConfig where
  hashWithSalt :: Int -> GetFirewallConfig -> Int
hashWithSalt Int
_salt GetFirewallConfig' {Text
resourceId :: Text
$sel:resourceId:GetFirewallConfig' :: GetFirewallConfig -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceId

instance Prelude.NFData GetFirewallConfig where
  rnf :: GetFirewallConfig -> ()
rnf GetFirewallConfig' {Text
resourceId :: Text
$sel:resourceId:GetFirewallConfig' :: GetFirewallConfig -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
resourceId

instance Data.ToHeaders GetFirewallConfig where
  toHeaders :: GetFirewallConfig -> 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
"Route53Resolver.GetFirewallConfig" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON GetFirewallConfig where
  toJSON :: GetFirewallConfig -> Value
toJSON GetFirewallConfig' {Text
resourceId :: Text
$sel:resourceId:GetFirewallConfig' :: GetFirewallConfig -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"ResourceId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceId)]
      )

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

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

-- | /See:/ 'newGetFirewallConfigResponse' smart constructor.
data GetFirewallConfigResponse = GetFirewallConfigResponse'
  { -- | Configuration of the firewall behavior provided by DNS Firewall for a
    -- single VPC from AmazonVPC.
    GetFirewallConfigResponse -> Maybe FirewallConfig
firewallConfig :: Prelude.Maybe FirewallConfig,
    -- | The response's http status code.
    GetFirewallConfigResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetFirewallConfigResponse -> GetFirewallConfigResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetFirewallConfigResponse -> GetFirewallConfigResponse -> Bool
$c/= :: GetFirewallConfigResponse -> GetFirewallConfigResponse -> Bool
== :: GetFirewallConfigResponse -> GetFirewallConfigResponse -> Bool
$c== :: GetFirewallConfigResponse -> GetFirewallConfigResponse -> Bool
Prelude.Eq, ReadPrec [GetFirewallConfigResponse]
ReadPrec GetFirewallConfigResponse
Int -> ReadS GetFirewallConfigResponse
ReadS [GetFirewallConfigResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetFirewallConfigResponse]
$creadListPrec :: ReadPrec [GetFirewallConfigResponse]
readPrec :: ReadPrec GetFirewallConfigResponse
$creadPrec :: ReadPrec GetFirewallConfigResponse
readList :: ReadS [GetFirewallConfigResponse]
$creadList :: ReadS [GetFirewallConfigResponse]
readsPrec :: Int -> ReadS GetFirewallConfigResponse
$creadsPrec :: Int -> ReadS GetFirewallConfigResponse
Prelude.Read, Int -> GetFirewallConfigResponse -> ShowS
[GetFirewallConfigResponse] -> ShowS
GetFirewallConfigResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetFirewallConfigResponse] -> ShowS
$cshowList :: [GetFirewallConfigResponse] -> ShowS
show :: GetFirewallConfigResponse -> String
$cshow :: GetFirewallConfigResponse -> String
showsPrec :: Int -> GetFirewallConfigResponse -> ShowS
$cshowsPrec :: Int -> GetFirewallConfigResponse -> ShowS
Prelude.Show, forall x.
Rep GetFirewallConfigResponse x -> GetFirewallConfigResponse
forall x.
GetFirewallConfigResponse -> Rep GetFirewallConfigResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetFirewallConfigResponse x -> GetFirewallConfigResponse
$cfrom :: forall x.
GetFirewallConfigResponse -> Rep GetFirewallConfigResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetFirewallConfigResponse' 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:
--
-- 'firewallConfig', 'getFirewallConfigResponse_firewallConfig' - Configuration of the firewall behavior provided by DNS Firewall for a
-- single VPC from AmazonVPC.
--
-- 'httpStatus', 'getFirewallConfigResponse_httpStatus' - The response's http status code.
newGetFirewallConfigResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetFirewallConfigResponse
newGetFirewallConfigResponse :: Int -> GetFirewallConfigResponse
newGetFirewallConfigResponse Int
pHttpStatus_ =
  GetFirewallConfigResponse'
    { $sel:firewallConfig:GetFirewallConfigResponse' :: Maybe FirewallConfig
firewallConfig =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetFirewallConfigResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Configuration of the firewall behavior provided by DNS Firewall for a
-- single VPC from AmazonVPC.
getFirewallConfigResponse_firewallConfig :: Lens.Lens' GetFirewallConfigResponse (Prelude.Maybe FirewallConfig)
getFirewallConfigResponse_firewallConfig :: Lens' GetFirewallConfigResponse (Maybe FirewallConfig)
getFirewallConfigResponse_firewallConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFirewallConfigResponse' {Maybe FirewallConfig
firewallConfig :: Maybe FirewallConfig
$sel:firewallConfig:GetFirewallConfigResponse' :: GetFirewallConfigResponse -> Maybe FirewallConfig
firewallConfig} -> Maybe FirewallConfig
firewallConfig) (\s :: GetFirewallConfigResponse
s@GetFirewallConfigResponse' {} Maybe FirewallConfig
a -> GetFirewallConfigResponse
s {$sel:firewallConfig:GetFirewallConfigResponse' :: Maybe FirewallConfig
firewallConfig = Maybe FirewallConfig
a} :: GetFirewallConfigResponse)

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

instance Prelude.NFData GetFirewallConfigResponse where
  rnf :: GetFirewallConfigResponse -> ()
rnf GetFirewallConfigResponse' {Int
Maybe FirewallConfig
httpStatus :: Int
firewallConfig :: Maybe FirewallConfig
$sel:httpStatus:GetFirewallConfigResponse' :: GetFirewallConfigResponse -> Int
$sel:firewallConfig:GetFirewallConfigResponse' :: GetFirewallConfigResponse -> Maybe FirewallConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FirewallConfig
firewallConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus