{-# 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.FMS.GetProtocolsList
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns information about the specified Firewall Manager protocols list.
module Amazonka.FMS.GetProtocolsList
  ( -- * Creating a Request
    GetProtocolsList (..),
    newGetProtocolsList,

    -- * Request Lenses
    getProtocolsList_defaultList,
    getProtocolsList_listId,

    -- * Destructuring the Response
    GetProtocolsListResponse (..),
    newGetProtocolsListResponse,

    -- * Response Lenses
    getProtocolsListResponse_protocolsList,
    getProtocolsListResponse_protocolsListArn,
    getProtocolsListResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetProtocolsList' smart constructor.
data GetProtocolsList = GetProtocolsList'
  { -- | Specifies whether the list to retrieve is a default list owned by
    -- Firewall Manager.
    GetProtocolsList -> Maybe Bool
defaultList :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the Firewall Manager protocols list that you want the details
    -- for.
    GetProtocolsList -> Text
listId :: Prelude.Text
  }
  deriving (GetProtocolsList -> GetProtocolsList -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetProtocolsList -> GetProtocolsList -> Bool
$c/= :: GetProtocolsList -> GetProtocolsList -> Bool
== :: GetProtocolsList -> GetProtocolsList -> Bool
$c== :: GetProtocolsList -> GetProtocolsList -> Bool
Prelude.Eq, ReadPrec [GetProtocolsList]
ReadPrec GetProtocolsList
Int -> ReadS GetProtocolsList
ReadS [GetProtocolsList]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetProtocolsList]
$creadListPrec :: ReadPrec [GetProtocolsList]
readPrec :: ReadPrec GetProtocolsList
$creadPrec :: ReadPrec GetProtocolsList
readList :: ReadS [GetProtocolsList]
$creadList :: ReadS [GetProtocolsList]
readsPrec :: Int -> ReadS GetProtocolsList
$creadsPrec :: Int -> ReadS GetProtocolsList
Prelude.Read, Int -> GetProtocolsList -> ShowS
[GetProtocolsList] -> ShowS
GetProtocolsList -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetProtocolsList] -> ShowS
$cshowList :: [GetProtocolsList] -> ShowS
show :: GetProtocolsList -> String
$cshow :: GetProtocolsList -> String
showsPrec :: Int -> GetProtocolsList -> ShowS
$cshowsPrec :: Int -> GetProtocolsList -> ShowS
Prelude.Show, forall x. Rep GetProtocolsList x -> GetProtocolsList
forall x. GetProtocolsList -> Rep GetProtocolsList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetProtocolsList x -> GetProtocolsList
$cfrom :: forall x. GetProtocolsList -> Rep GetProtocolsList x
Prelude.Generic)

-- |
-- Create a value of 'GetProtocolsList' 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:
--
-- 'defaultList', 'getProtocolsList_defaultList' - Specifies whether the list to retrieve is a default list owned by
-- Firewall Manager.
--
-- 'listId', 'getProtocolsList_listId' - The ID of the Firewall Manager protocols list that you want the details
-- for.
newGetProtocolsList ::
  -- | 'listId'
  Prelude.Text ->
  GetProtocolsList
newGetProtocolsList :: Text -> GetProtocolsList
newGetProtocolsList Text
pListId_ =
  GetProtocolsList'
    { $sel:defaultList:GetProtocolsList' :: Maybe Bool
defaultList = forall a. Maybe a
Prelude.Nothing,
      $sel:listId:GetProtocolsList' :: Text
listId = Text
pListId_
    }

-- | Specifies whether the list to retrieve is a default list owned by
-- Firewall Manager.
getProtocolsList_defaultList :: Lens.Lens' GetProtocolsList (Prelude.Maybe Prelude.Bool)
getProtocolsList_defaultList :: Lens' GetProtocolsList (Maybe Bool)
getProtocolsList_defaultList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetProtocolsList' {Maybe Bool
defaultList :: Maybe Bool
$sel:defaultList:GetProtocolsList' :: GetProtocolsList -> Maybe Bool
defaultList} -> Maybe Bool
defaultList) (\s :: GetProtocolsList
s@GetProtocolsList' {} Maybe Bool
a -> GetProtocolsList
s {$sel:defaultList:GetProtocolsList' :: Maybe Bool
defaultList = Maybe Bool
a} :: GetProtocolsList)

-- | The ID of the Firewall Manager protocols list that you want the details
-- for.
getProtocolsList_listId :: Lens.Lens' GetProtocolsList Prelude.Text
getProtocolsList_listId :: Lens' GetProtocolsList Text
getProtocolsList_listId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetProtocolsList' {Text
listId :: Text
$sel:listId:GetProtocolsList' :: GetProtocolsList -> Text
listId} -> Text
listId) (\s :: GetProtocolsList
s@GetProtocolsList' {} Text
a -> GetProtocolsList
s {$sel:listId:GetProtocolsList' :: Text
listId = Text
a} :: GetProtocolsList)

instance Core.AWSRequest GetProtocolsList where
  type
    AWSResponse GetProtocolsList =
      GetProtocolsListResponse
  request :: (Service -> Service)
-> GetProtocolsList -> Request GetProtocolsList
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 GetProtocolsList
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetProtocolsList)))
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 ProtocolsListData
-> Maybe Text -> Int -> GetProtocolsListResponse
GetProtocolsListResponse'
            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
"ProtocolsList")
            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
"ProtocolsListArn")
            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 GetProtocolsList where
  hashWithSalt :: Int -> GetProtocolsList -> Int
hashWithSalt Int
_salt GetProtocolsList' {Maybe Bool
Text
listId :: Text
defaultList :: Maybe Bool
$sel:listId:GetProtocolsList' :: GetProtocolsList -> Text
$sel:defaultList:GetProtocolsList' :: GetProtocolsList -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
defaultList
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
listId

instance Prelude.NFData GetProtocolsList where
  rnf :: GetProtocolsList -> ()
rnf GetProtocolsList' {Maybe Bool
Text
listId :: Text
defaultList :: Maybe Bool
$sel:listId:GetProtocolsList' :: GetProtocolsList -> Text
$sel:defaultList:GetProtocolsList' :: GetProtocolsList -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
defaultList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
listId

instance Data.ToHeaders GetProtocolsList where
  toHeaders :: GetProtocolsList -> 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
"AWSFMS_20180101.GetProtocolsList" ::
                          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 GetProtocolsList where
  toJSON :: GetProtocolsList -> Value
toJSON GetProtocolsList' {Maybe Bool
Text
listId :: Text
defaultList :: Maybe Bool
$sel:listId:GetProtocolsList' :: GetProtocolsList -> Text
$sel:defaultList:GetProtocolsList' :: GetProtocolsList -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DefaultList" 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 Bool
defaultList,
            forall a. a -> Maybe a
Prelude.Just (Key
"ListId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
listId)
          ]
      )

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

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

-- | /See:/ 'newGetProtocolsListResponse' smart constructor.
data GetProtocolsListResponse = GetProtocolsListResponse'
  { -- | Information about the specified Firewall Manager protocols list.
    GetProtocolsListResponse -> Maybe ProtocolsListData
protocolsList :: Prelude.Maybe ProtocolsListData,
    -- | The Amazon Resource Name (ARN) of the specified protocols list.
    GetProtocolsListResponse -> Maybe Text
protocolsListArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetProtocolsListResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetProtocolsListResponse -> GetProtocolsListResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetProtocolsListResponse -> GetProtocolsListResponse -> Bool
$c/= :: GetProtocolsListResponse -> GetProtocolsListResponse -> Bool
== :: GetProtocolsListResponse -> GetProtocolsListResponse -> Bool
$c== :: GetProtocolsListResponse -> GetProtocolsListResponse -> Bool
Prelude.Eq, ReadPrec [GetProtocolsListResponse]
ReadPrec GetProtocolsListResponse
Int -> ReadS GetProtocolsListResponse
ReadS [GetProtocolsListResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetProtocolsListResponse]
$creadListPrec :: ReadPrec [GetProtocolsListResponse]
readPrec :: ReadPrec GetProtocolsListResponse
$creadPrec :: ReadPrec GetProtocolsListResponse
readList :: ReadS [GetProtocolsListResponse]
$creadList :: ReadS [GetProtocolsListResponse]
readsPrec :: Int -> ReadS GetProtocolsListResponse
$creadsPrec :: Int -> ReadS GetProtocolsListResponse
Prelude.Read, Int -> GetProtocolsListResponse -> ShowS
[GetProtocolsListResponse] -> ShowS
GetProtocolsListResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetProtocolsListResponse] -> ShowS
$cshowList :: [GetProtocolsListResponse] -> ShowS
show :: GetProtocolsListResponse -> String
$cshow :: GetProtocolsListResponse -> String
showsPrec :: Int -> GetProtocolsListResponse -> ShowS
$cshowsPrec :: Int -> GetProtocolsListResponse -> ShowS
Prelude.Show, forall x.
Rep GetProtocolsListResponse x -> GetProtocolsListResponse
forall x.
GetProtocolsListResponse -> Rep GetProtocolsListResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetProtocolsListResponse x -> GetProtocolsListResponse
$cfrom :: forall x.
GetProtocolsListResponse -> Rep GetProtocolsListResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetProtocolsListResponse' 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:
--
-- 'protocolsList', 'getProtocolsListResponse_protocolsList' - Information about the specified Firewall Manager protocols list.
--
-- 'protocolsListArn', 'getProtocolsListResponse_protocolsListArn' - The Amazon Resource Name (ARN) of the specified protocols list.
--
-- 'httpStatus', 'getProtocolsListResponse_httpStatus' - The response's http status code.
newGetProtocolsListResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetProtocolsListResponse
newGetProtocolsListResponse :: Int -> GetProtocolsListResponse
newGetProtocolsListResponse Int
pHttpStatus_ =
  GetProtocolsListResponse'
    { $sel:protocolsList:GetProtocolsListResponse' :: Maybe ProtocolsListData
protocolsList =
        forall a. Maybe a
Prelude.Nothing,
      $sel:protocolsListArn:GetProtocolsListResponse' :: Maybe Text
protocolsListArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetProtocolsListResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the specified Firewall Manager protocols list.
getProtocolsListResponse_protocolsList :: Lens.Lens' GetProtocolsListResponse (Prelude.Maybe ProtocolsListData)
getProtocolsListResponse_protocolsList :: Lens' GetProtocolsListResponse (Maybe ProtocolsListData)
getProtocolsListResponse_protocolsList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetProtocolsListResponse' {Maybe ProtocolsListData
protocolsList :: Maybe ProtocolsListData
$sel:protocolsList:GetProtocolsListResponse' :: GetProtocolsListResponse -> Maybe ProtocolsListData
protocolsList} -> Maybe ProtocolsListData
protocolsList) (\s :: GetProtocolsListResponse
s@GetProtocolsListResponse' {} Maybe ProtocolsListData
a -> GetProtocolsListResponse
s {$sel:protocolsList:GetProtocolsListResponse' :: Maybe ProtocolsListData
protocolsList = Maybe ProtocolsListData
a} :: GetProtocolsListResponse)

-- | The Amazon Resource Name (ARN) of the specified protocols list.
getProtocolsListResponse_protocolsListArn :: Lens.Lens' GetProtocolsListResponse (Prelude.Maybe Prelude.Text)
getProtocolsListResponse_protocolsListArn :: Lens' GetProtocolsListResponse (Maybe Text)
getProtocolsListResponse_protocolsListArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetProtocolsListResponse' {Maybe Text
protocolsListArn :: Maybe Text
$sel:protocolsListArn:GetProtocolsListResponse' :: GetProtocolsListResponse -> Maybe Text
protocolsListArn} -> Maybe Text
protocolsListArn) (\s :: GetProtocolsListResponse
s@GetProtocolsListResponse' {} Maybe Text
a -> GetProtocolsListResponse
s {$sel:protocolsListArn:GetProtocolsListResponse' :: Maybe Text
protocolsListArn = Maybe Text
a} :: GetProtocolsListResponse)

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

instance Prelude.NFData GetProtocolsListResponse where
  rnf :: GetProtocolsListResponse -> ()
rnf GetProtocolsListResponse' {Int
Maybe Text
Maybe ProtocolsListData
httpStatus :: Int
protocolsListArn :: Maybe Text
protocolsList :: Maybe ProtocolsListData
$sel:httpStatus:GetProtocolsListResponse' :: GetProtocolsListResponse -> Int
$sel:protocolsListArn:GetProtocolsListResponse' :: GetProtocolsListResponse -> Maybe Text
$sel:protocolsList:GetProtocolsListResponse' :: GetProtocolsListResponse -> Maybe ProtocolsListData
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ProtocolsListData
protocolsList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
protocolsListArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus