{-# 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-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)
--
-- 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 Amazonka.FMS.Types
import qualified Amazonka.Lens as Lens
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
(GetProtocolsList -> GetProtocolsList -> Bool)
-> (GetProtocolsList -> GetProtocolsList -> Bool)
-> Eq GetProtocolsList
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]
(Int -> ReadS GetProtocolsList)
-> ReadS [GetProtocolsList]
-> ReadPrec GetProtocolsList
-> ReadPrec [GetProtocolsList]
-> Read 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
(Int -> GetProtocolsList -> ShowS)
-> (GetProtocolsList -> String)
-> ([GetProtocolsList] -> ShowS)
-> Show GetProtocolsList
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. GetProtocolsList -> Rep GetProtocolsList x)
-> (forall x. Rep GetProtocolsList x -> GetProtocolsList)
-> Generic GetProtocolsList
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' :: Maybe Bool -> Text -> GetProtocolsList
GetProtocolsList'
    { $sel:defaultList:GetProtocolsList' :: Maybe Bool
defaultList = Maybe Bool
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 :: (Maybe Bool -> f (Maybe Bool))
-> GetProtocolsList -> f GetProtocolsList
getProtocolsList_defaultList = (GetProtocolsList -> Maybe Bool)
-> (GetProtocolsList -> Maybe Bool -> GetProtocolsList)
-> Lens GetProtocolsList GetProtocolsList (Maybe Bool) (Maybe Bool)
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 :: (Text -> f Text) -> GetProtocolsList -> f GetProtocolsList
getProtocolsList_listId = (GetProtocolsList -> Text)
-> (GetProtocolsList -> Text -> GetProtocolsList)
-> Lens GetProtocolsList GetProtocolsList Text Text
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 :: GetProtocolsList -> Request GetProtocolsList
request = Service -> GetProtocolsList -> Request GetProtocolsList
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetProtocolsList
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetProtocolsList)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetProtocolsList))
-> Logger
-> Service
-> Proxy GetProtocolsList
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetProtocolsList)))
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 ProtocolsListData
-> Maybe Text -> Int -> GetProtocolsListResponse
GetProtocolsListResponse'
            (Maybe ProtocolsListData
 -> Maybe Text -> Int -> GetProtocolsListResponse)
-> Either String (Maybe ProtocolsListData)
-> Either String (Maybe Text -> Int -> GetProtocolsListResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ProtocolsListData)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ProtocolsList")
            Either String (Maybe Text -> Int -> GetProtocolsListResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetProtocolsListResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ProtocolsListArn")
            Either String (Int -> GetProtocolsListResponse)
-> Either String Int -> Either String GetProtocolsListResponse
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 GetProtocolsList

instance Prelude.NFData GetProtocolsList

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DefaultList" 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
defaultList,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ListId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
listId)
          ]
      )

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

instance Core.ToQuery GetProtocolsList where
  toQuery :: GetProtocolsList -> QueryString
toQuery = QueryString -> GetProtocolsList -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetProtocolsListResponse -> GetProtocolsListResponse -> Bool)
-> (GetProtocolsListResponse -> GetProtocolsListResponse -> Bool)
-> Eq GetProtocolsListResponse
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]
(Int -> ReadS GetProtocolsListResponse)
-> ReadS [GetProtocolsListResponse]
-> ReadPrec GetProtocolsListResponse
-> ReadPrec [GetProtocolsListResponse]
-> Read 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
(Int -> GetProtocolsListResponse -> ShowS)
-> (GetProtocolsListResponse -> String)
-> ([GetProtocolsListResponse] -> ShowS)
-> Show GetProtocolsListResponse
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.
 GetProtocolsListResponse -> Rep GetProtocolsListResponse x)
-> (forall x.
    Rep GetProtocolsListResponse x -> GetProtocolsListResponse)
-> Generic GetProtocolsListResponse
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' :: Maybe ProtocolsListData
-> Maybe Text -> Int -> GetProtocolsListResponse
GetProtocolsListResponse'
    { $sel:protocolsList:GetProtocolsListResponse' :: Maybe ProtocolsListData
protocolsList =
        Maybe ProtocolsListData
forall a. Maybe a
Prelude.Nothing,
      $sel:protocolsListArn:GetProtocolsListResponse' :: Maybe Text
protocolsListArn = Maybe Text
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 :: (Maybe ProtocolsListData -> f (Maybe ProtocolsListData))
-> GetProtocolsListResponse -> f GetProtocolsListResponse
getProtocolsListResponse_protocolsList = (GetProtocolsListResponse -> Maybe ProtocolsListData)
-> (GetProtocolsListResponse
    -> Maybe ProtocolsListData -> GetProtocolsListResponse)
-> Lens
     GetProtocolsListResponse
     GetProtocolsListResponse
     (Maybe ProtocolsListData)
     (Maybe ProtocolsListData)
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 :: (Maybe Text -> f (Maybe Text))
-> GetProtocolsListResponse -> f GetProtocolsListResponse
getProtocolsListResponse_protocolsListArn = (GetProtocolsListResponse -> Maybe Text)
-> (GetProtocolsListResponse
    -> Maybe Text -> GetProtocolsListResponse)
-> Lens
     GetProtocolsListResponse
     GetProtocolsListResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int)
-> GetProtocolsListResponse -> f GetProtocolsListResponse
getProtocolsListResponse_httpStatus = (GetProtocolsListResponse -> Int)
-> (GetProtocolsListResponse -> Int -> GetProtocolsListResponse)
-> Lens GetProtocolsListResponse GetProtocolsListResponse Int Int
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