{-# 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.GetAppsList
-- 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 applications
-- list.
module Amazonka.FMS.GetAppsList
  ( -- * Creating a Request
    GetAppsList (..),
    newGetAppsList,

    -- * Request Lenses
    getAppsList_defaultList,
    getAppsList_listId,

    -- * Destructuring the Response
    GetAppsListResponse (..),
    newGetAppsListResponse,

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

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

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

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

instance Core.AWSRequest GetAppsList where
  type AWSResponse GetAppsList = GetAppsListResponse
  request :: GetAppsList -> Request GetAppsList
request = Service -> GetAppsList -> Request GetAppsList
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetAppsList
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAppsList)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetAppsList))
-> Logger
-> Service
-> Proxy GetAppsList
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAppsList)))
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 Text -> Maybe AppsListData -> Int -> GetAppsListResponse
GetAppsListResponse'
            (Maybe Text -> Maybe AppsListData -> Int -> GetAppsListResponse)
-> Either String (Maybe Text)
-> Either String (Maybe AppsListData -> Int -> GetAppsListResponse)
forall (f :: * -> *) a b. Functor 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
"AppsListArn")
            Either String (Maybe AppsListData -> Int -> GetAppsListResponse)
-> Either String (Maybe AppsListData)
-> Either String (Int -> GetAppsListResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe AppsListData)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AppsList")
            Either String (Int -> GetAppsListResponse)
-> Either String Int -> Either String GetAppsListResponse
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 GetAppsList

instance Prelude.NFData GetAppsList

instance Core.ToHeaders GetAppsList where
  toHeaders :: GetAppsList -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetAppsList -> 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.GetAppsList" ::
                          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 GetAppsList where
  toJSON :: GetAppsList -> Value
toJSON GetAppsList' {Maybe Bool
Text
listId :: Text
defaultList :: Maybe Bool
$sel:listId:GetAppsList' :: GetAppsList -> Text
$sel:defaultList:GetAppsList' :: GetAppsList -> 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 GetAppsList where
  toPath :: GetAppsList -> ByteString
toPath = ByteString -> GetAppsList -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'GetAppsListResponse' 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:
--
-- 'appsListArn', 'getAppsListResponse_appsListArn' - The Amazon Resource Name (ARN) of the applications list.
--
-- 'appsList', 'getAppsListResponse_appsList' - Information about the specified Firewall Manager applications list.
--
-- 'httpStatus', 'getAppsListResponse_httpStatus' - The response's http status code.
newGetAppsListResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetAppsListResponse
newGetAppsListResponse :: Int -> GetAppsListResponse
newGetAppsListResponse Int
pHttpStatus_ =
  GetAppsListResponse' :: Maybe Text -> Maybe AppsListData -> Int -> GetAppsListResponse
GetAppsListResponse'
    { $sel:appsListArn:GetAppsListResponse' :: Maybe Text
appsListArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:appsList:GetAppsListResponse' :: Maybe AppsListData
appsList = Maybe AppsListData
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetAppsListResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the applications list.
getAppsListResponse_appsListArn :: Lens.Lens' GetAppsListResponse (Prelude.Maybe Prelude.Text)
getAppsListResponse_appsListArn :: (Maybe Text -> f (Maybe Text))
-> GetAppsListResponse -> f GetAppsListResponse
getAppsListResponse_appsListArn = (GetAppsListResponse -> Maybe Text)
-> (GetAppsListResponse -> Maybe Text -> GetAppsListResponse)
-> Lens
     GetAppsListResponse GetAppsListResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAppsListResponse' {Maybe Text
appsListArn :: Maybe Text
$sel:appsListArn:GetAppsListResponse' :: GetAppsListResponse -> Maybe Text
appsListArn} -> Maybe Text
appsListArn) (\s :: GetAppsListResponse
s@GetAppsListResponse' {} Maybe Text
a -> GetAppsListResponse
s {$sel:appsListArn:GetAppsListResponse' :: Maybe Text
appsListArn = Maybe Text
a} :: GetAppsListResponse)

-- | Information about the specified Firewall Manager applications list.
getAppsListResponse_appsList :: Lens.Lens' GetAppsListResponse (Prelude.Maybe AppsListData)
getAppsListResponse_appsList :: (Maybe AppsListData -> f (Maybe AppsListData))
-> GetAppsListResponse -> f GetAppsListResponse
getAppsListResponse_appsList = (GetAppsListResponse -> Maybe AppsListData)
-> (GetAppsListResponse
    -> Maybe AppsListData -> GetAppsListResponse)
-> Lens
     GetAppsListResponse
     GetAppsListResponse
     (Maybe AppsListData)
     (Maybe AppsListData)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAppsListResponse' {Maybe AppsListData
appsList :: Maybe AppsListData
$sel:appsList:GetAppsListResponse' :: GetAppsListResponse -> Maybe AppsListData
appsList} -> Maybe AppsListData
appsList) (\s :: GetAppsListResponse
s@GetAppsListResponse' {} Maybe AppsListData
a -> GetAppsListResponse
s {$sel:appsList:GetAppsListResponse' :: Maybe AppsListData
appsList = Maybe AppsListData
a} :: GetAppsListResponse)

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

instance Prelude.NFData GetAppsListResponse