{-# 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.MacieV2.ListAllowLists
-- 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 a subset of information about all the allow lists for an
-- account.
--
-- This operation returns paginated results.
module Amazonka.MacieV2.ListAllowLists
  ( -- * Creating a Request
    ListAllowLists (..),
    newListAllowLists,

    -- * Request Lenses
    listAllowLists_maxResults,
    listAllowLists_nextToken,

    -- * Destructuring the Response
    ListAllowListsResponse (..),
    newListAllowListsResponse,

    -- * Response Lenses
    listAllowListsResponse_allowLists,
    listAllowListsResponse_nextToken,
    listAllowListsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListAllowLists' smart constructor.
data ListAllowLists = ListAllowLists'
  { -- | The maximum number of items to include in each page of a paginated
    -- response.
    ListAllowLists -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The nextToken string that specifies which page of results to return in a
    -- paginated response.
    ListAllowLists -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListAllowLists -> ListAllowLists -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAllowLists -> ListAllowLists -> Bool
$c/= :: ListAllowLists -> ListAllowLists -> Bool
== :: ListAllowLists -> ListAllowLists -> Bool
$c== :: ListAllowLists -> ListAllowLists -> Bool
Prelude.Eq, ReadPrec [ListAllowLists]
ReadPrec ListAllowLists
Int -> ReadS ListAllowLists
ReadS [ListAllowLists]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAllowLists]
$creadListPrec :: ReadPrec [ListAllowLists]
readPrec :: ReadPrec ListAllowLists
$creadPrec :: ReadPrec ListAllowLists
readList :: ReadS [ListAllowLists]
$creadList :: ReadS [ListAllowLists]
readsPrec :: Int -> ReadS ListAllowLists
$creadsPrec :: Int -> ReadS ListAllowLists
Prelude.Read, Int -> ListAllowLists -> ShowS
[ListAllowLists] -> ShowS
ListAllowLists -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAllowLists] -> ShowS
$cshowList :: [ListAllowLists] -> ShowS
show :: ListAllowLists -> String
$cshow :: ListAllowLists -> String
showsPrec :: Int -> ListAllowLists -> ShowS
$cshowsPrec :: Int -> ListAllowLists -> ShowS
Prelude.Show, forall x. Rep ListAllowLists x -> ListAllowLists
forall x. ListAllowLists -> Rep ListAllowLists x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAllowLists x -> ListAllowLists
$cfrom :: forall x. ListAllowLists -> Rep ListAllowLists x
Prelude.Generic)

-- |
-- Create a value of 'ListAllowLists' 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:
--
-- 'maxResults', 'listAllowLists_maxResults' - The maximum number of items to include in each page of a paginated
-- response.
--
-- 'nextToken', 'listAllowLists_nextToken' - The nextToken string that specifies which page of results to return in a
-- paginated response.
newListAllowLists ::
  ListAllowLists
newListAllowLists :: ListAllowLists
newListAllowLists =
  ListAllowLists'
    { $sel:maxResults:ListAllowLists' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAllowLists' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of items to include in each page of a paginated
-- response.
listAllowLists_maxResults :: Lens.Lens' ListAllowLists (Prelude.Maybe Prelude.Natural)
listAllowLists_maxResults :: Lens' ListAllowLists (Maybe Natural)
listAllowLists_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAllowLists' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListAllowLists' :: ListAllowLists -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListAllowLists
s@ListAllowLists' {} Maybe Natural
a -> ListAllowLists
s {$sel:maxResults:ListAllowLists' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListAllowLists)

-- | The nextToken string that specifies which page of results to return in a
-- paginated response.
listAllowLists_nextToken :: Lens.Lens' ListAllowLists (Prelude.Maybe Prelude.Text)
listAllowLists_nextToken :: Lens' ListAllowLists (Maybe Text)
listAllowLists_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAllowLists' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAllowLists' :: ListAllowLists -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAllowLists
s@ListAllowLists' {} Maybe Text
a -> ListAllowLists
s {$sel:nextToken:ListAllowLists' :: Maybe Text
nextToken = Maybe Text
a} :: ListAllowLists)

instance Core.AWSPager ListAllowLists where
  page :: ListAllowLists
-> AWSResponse ListAllowLists -> Maybe ListAllowLists
page ListAllowLists
rq AWSResponse ListAllowLists
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAllowLists
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListAllowListsResponse (Maybe Text)
listAllowListsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAllowLists
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListAllowListsResponse (Maybe [AllowListSummary])
listAllowListsResponse_allowLists
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListAllowLists
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListAllowLists (Maybe Text)
listAllowLists_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListAllowLists
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListAllowListsResponse (Maybe Text)
listAllowListsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListAllowLists where
  type
    AWSResponse ListAllowLists =
      ListAllowListsResponse
  request :: (Service -> Service) -> ListAllowLists -> Request ListAllowLists
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListAllowLists
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListAllowLists)))
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 [AllowListSummary]
-> Maybe Text -> Int -> ListAllowListsResponse
ListAllowListsResponse'
            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
"allowLists" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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
"nextToken")
            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 ListAllowLists where
  hashWithSalt :: Int -> ListAllowLists -> Int
hashWithSalt Int
_salt ListAllowLists' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListAllowLists' :: ListAllowLists -> Maybe Text
$sel:maxResults:ListAllowLists' :: ListAllowLists -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListAllowLists where
  rnf :: ListAllowLists -> ()
rnf ListAllowLists' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListAllowLists' :: ListAllowLists -> Maybe Text
$sel:maxResults:ListAllowLists' :: ListAllowLists -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

instance Data.ToHeaders ListAllowLists where
  toHeaders :: ListAllowLists -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

instance Data.ToQuery ListAllowLists where
  toQuery :: ListAllowLists -> QueryString
toQuery ListAllowLists' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListAllowLists' :: ListAllowLists -> Maybe Text
$sel:maxResults:ListAllowLists' :: ListAllowLists -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListAllowListsResponse' smart constructor.
data ListAllowListsResponse = ListAllowListsResponse'
  { -- | An array of objects, one for each allow list.
    ListAllowListsResponse -> Maybe [AllowListSummary]
allowLists :: Prelude.Maybe [AllowListSummary],
    -- | The string to use in a subsequent request to get the next page of
    -- results in a paginated response. This value is null if there are no
    -- additional pages.
    ListAllowListsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListAllowListsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListAllowListsResponse -> ListAllowListsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAllowListsResponse -> ListAllowListsResponse -> Bool
$c/= :: ListAllowListsResponse -> ListAllowListsResponse -> Bool
== :: ListAllowListsResponse -> ListAllowListsResponse -> Bool
$c== :: ListAllowListsResponse -> ListAllowListsResponse -> Bool
Prelude.Eq, ReadPrec [ListAllowListsResponse]
ReadPrec ListAllowListsResponse
Int -> ReadS ListAllowListsResponse
ReadS [ListAllowListsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAllowListsResponse]
$creadListPrec :: ReadPrec [ListAllowListsResponse]
readPrec :: ReadPrec ListAllowListsResponse
$creadPrec :: ReadPrec ListAllowListsResponse
readList :: ReadS [ListAllowListsResponse]
$creadList :: ReadS [ListAllowListsResponse]
readsPrec :: Int -> ReadS ListAllowListsResponse
$creadsPrec :: Int -> ReadS ListAllowListsResponse
Prelude.Read, Int -> ListAllowListsResponse -> ShowS
[ListAllowListsResponse] -> ShowS
ListAllowListsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAllowListsResponse] -> ShowS
$cshowList :: [ListAllowListsResponse] -> ShowS
show :: ListAllowListsResponse -> String
$cshow :: ListAllowListsResponse -> String
showsPrec :: Int -> ListAllowListsResponse -> ShowS
$cshowsPrec :: Int -> ListAllowListsResponse -> ShowS
Prelude.Show, forall x. Rep ListAllowListsResponse x -> ListAllowListsResponse
forall x. ListAllowListsResponse -> Rep ListAllowListsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAllowListsResponse x -> ListAllowListsResponse
$cfrom :: forall x. ListAllowListsResponse -> Rep ListAllowListsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAllowListsResponse' 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:
--
-- 'allowLists', 'listAllowListsResponse_allowLists' - An array of objects, one for each allow list.
--
-- 'nextToken', 'listAllowListsResponse_nextToken' - The string to use in a subsequent request to get the next page of
-- results in a paginated response. This value is null if there are no
-- additional pages.
--
-- 'httpStatus', 'listAllowListsResponse_httpStatus' - The response's http status code.
newListAllowListsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAllowListsResponse
newListAllowListsResponse :: Int -> ListAllowListsResponse
newListAllowListsResponse Int
pHttpStatus_ =
  ListAllowListsResponse'
    { $sel:allowLists:ListAllowListsResponse' :: Maybe [AllowListSummary]
allowLists =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAllowListsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAllowListsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects, one for each allow list.
listAllowListsResponse_allowLists :: Lens.Lens' ListAllowListsResponse (Prelude.Maybe [AllowListSummary])
listAllowListsResponse_allowLists :: Lens' ListAllowListsResponse (Maybe [AllowListSummary])
listAllowListsResponse_allowLists = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAllowListsResponse' {Maybe [AllowListSummary]
allowLists :: Maybe [AllowListSummary]
$sel:allowLists:ListAllowListsResponse' :: ListAllowListsResponse -> Maybe [AllowListSummary]
allowLists} -> Maybe [AllowListSummary]
allowLists) (\s :: ListAllowListsResponse
s@ListAllowListsResponse' {} Maybe [AllowListSummary]
a -> ListAllowListsResponse
s {$sel:allowLists:ListAllowListsResponse' :: Maybe [AllowListSummary]
allowLists = Maybe [AllowListSummary]
a} :: ListAllowListsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The string to use in a subsequent request to get the next page of
-- results in a paginated response. This value is null if there are no
-- additional pages.
listAllowListsResponse_nextToken :: Lens.Lens' ListAllowListsResponse (Prelude.Maybe Prelude.Text)
listAllowListsResponse_nextToken :: Lens' ListAllowListsResponse (Maybe Text)
listAllowListsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAllowListsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAllowListsResponse' :: ListAllowListsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAllowListsResponse
s@ListAllowListsResponse' {} Maybe Text
a -> ListAllowListsResponse
s {$sel:nextToken:ListAllowListsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAllowListsResponse)

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

instance Prelude.NFData ListAllowListsResponse where
  rnf :: ListAllowListsResponse -> ()
rnf ListAllowListsResponse' {Int
Maybe [AllowListSummary]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
allowLists :: Maybe [AllowListSummary]
$sel:httpStatus:ListAllowListsResponse' :: ListAllowListsResponse -> Int
$sel:nextToken:ListAllowListsResponse' :: ListAllowListsResponse -> Maybe Text
$sel:allowLists:ListAllowListsResponse' :: ListAllowListsResponse -> Maybe [AllowListSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AllowListSummary]
allowLists
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus