{-# 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-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 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_appsList,
    getAppsListResponse_appsListArn,
    getAppsListResponse_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:/ '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
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]
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
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. 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'
    { $sel:defaultList:GetAppsList' :: Maybe Bool
defaultList = 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 :: Lens' GetAppsList (Maybe Bool)
getAppsList_defaultList = 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 :: Lens' GetAppsList Text
getAppsList_listId = 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 :: (Service -> Service) -> GetAppsList -> Request GetAppsList
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 GetAppsList
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAppsList)))
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 AppsListData -> Maybe Text -> Int -> GetAppsListResponse
GetAppsListResponse'
            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
"AppsList")
            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
"AppsListArn")
            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 GetAppsList where
  hashWithSalt :: Int -> GetAppsList -> Int
hashWithSalt Int
_salt GetAppsList' {Maybe Bool
Text
listId :: Text
defaultList :: Maybe Bool
$sel:listId:GetAppsList' :: GetAppsList -> Text
$sel:defaultList:GetAppsList' :: GetAppsList -> 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 GetAppsList where
  rnf :: GetAppsList -> ()
rnf GetAppsList' {Maybe Bool
Text
listId :: Text
defaultList :: Maybe Bool
$sel:listId:GetAppsList' :: GetAppsList -> Text
$sel:defaultList:GetAppsList' :: GetAppsList -> 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 GetAppsList where
  toHeaders :: GetAppsList -> 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.GetAppsList" ::
                          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 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
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 GetAppsList where
  toPath :: GetAppsList -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- | Information about the specified Firewall Manager applications list.
getAppsListResponse_appsList :: Lens.Lens' GetAppsListResponse (Prelude.Maybe AppsListData)
getAppsListResponse_appsList :: Lens' GetAppsListResponse (Maybe AppsListData)
getAppsListResponse_appsList = 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 Amazon Resource Name (ARN) of the applications list.
getAppsListResponse_appsListArn :: Lens.Lens' GetAppsListResponse (Prelude.Maybe Prelude.Text)
getAppsListResponse_appsListArn :: Lens' GetAppsListResponse (Maybe Text)
getAppsListResponse_appsListArn = 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)

-- | The response's http status code.
getAppsListResponse_httpStatus :: Lens.Lens' GetAppsListResponse Prelude.Int
getAppsListResponse_httpStatus :: Lens' GetAppsListResponse Int
getAppsListResponse_httpStatus = 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 where
  rnf :: GetAppsListResponse -> ()
rnf GetAppsListResponse' {Int
Maybe Text
Maybe AppsListData
httpStatus :: Int
appsListArn :: Maybe Text
appsList :: Maybe AppsListData
$sel:httpStatus:GetAppsListResponse' :: GetAppsListResponse -> Int
$sel:appsListArn:GetAppsListResponse' :: GetAppsListResponse -> Maybe Text
$sel:appsList:GetAppsListResponse' :: GetAppsListResponse -> Maybe AppsListData
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AppsListData
appsList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
appsListArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus