{-# 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.AccessAnalyzer.ListAccessPreviewFindings
-- 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)
--
-- Retrieves a list of access preview findings generated by the specified
-- access preview.
--
-- This operation returns paginated results.
module Amazonka.AccessAnalyzer.ListAccessPreviewFindings
  ( -- * Creating a Request
    ListAccessPreviewFindings (..),
    newListAccessPreviewFindings,

    -- * Request Lenses
    listAccessPreviewFindings_nextToken,
    listAccessPreviewFindings_filter,
    listAccessPreviewFindings_maxResults,
    listAccessPreviewFindings_accessPreviewId,
    listAccessPreviewFindings_analyzerArn,

    -- * Destructuring the Response
    ListAccessPreviewFindingsResponse (..),
    newListAccessPreviewFindingsResponse,

    -- * Response Lenses
    listAccessPreviewFindingsResponse_nextToken,
    listAccessPreviewFindingsResponse_httpStatus,
    listAccessPreviewFindingsResponse_findings,
  )
where

import Amazonka.AccessAnalyzer.Types
import qualified Amazonka.Core as Core
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:/ 'newListAccessPreviewFindings' smart constructor.
data ListAccessPreviewFindings = ListAccessPreviewFindings'
  { -- | A token used for pagination of results returned.
    ListAccessPreviewFindings -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Criteria to filter the returned findings.
    ListAccessPreviewFindings -> Maybe (HashMap Text Criterion)
filter' :: Prelude.Maybe (Prelude.HashMap Prelude.Text Criterion),
    -- | The maximum number of results to return in the response.
    ListAccessPreviewFindings -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int,
    -- | The unique ID for the access preview.
    ListAccessPreviewFindings -> Text
accessPreviewId :: Prelude.Text,
    -- | The
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-getting-started.html#permission-resources ARN of the analyzer>
    -- used to generate the access.
    ListAccessPreviewFindings -> Text
analyzerArn :: Prelude.Text
  }
  deriving (ListAccessPreviewFindings -> ListAccessPreviewFindings -> Bool
(ListAccessPreviewFindings -> ListAccessPreviewFindings -> Bool)
-> (ListAccessPreviewFindings -> ListAccessPreviewFindings -> Bool)
-> Eq ListAccessPreviewFindings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAccessPreviewFindings -> ListAccessPreviewFindings -> Bool
$c/= :: ListAccessPreviewFindings -> ListAccessPreviewFindings -> Bool
== :: ListAccessPreviewFindings -> ListAccessPreviewFindings -> Bool
$c== :: ListAccessPreviewFindings -> ListAccessPreviewFindings -> Bool
Prelude.Eq, ReadPrec [ListAccessPreviewFindings]
ReadPrec ListAccessPreviewFindings
Int -> ReadS ListAccessPreviewFindings
ReadS [ListAccessPreviewFindings]
(Int -> ReadS ListAccessPreviewFindings)
-> ReadS [ListAccessPreviewFindings]
-> ReadPrec ListAccessPreviewFindings
-> ReadPrec [ListAccessPreviewFindings]
-> Read ListAccessPreviewFindings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAccessPreviewFindings]
$creadListPrec :: ReadPrec [ListAccessPreviewFindings]
readPrec :: ReadPrec ListAccessPreviewFindings
$creadPrec :: ReadPrec ListAccessPreviewFindings
readList :: ReadS [ListAccessPreviewFindings]
$creadList :: ReadS [ListAccessPreviewFindings]
readsPrec :: Int -> ReadS ListAccessPreviewFindings
$creadsPrec :: Int -> ReadS ListAccessPreviewFindings
Prelude.Read, Int -> ListAccessPreviewFindings -> ShowS
[ListAccessPreviewFindings] -> ShowS
ListAccessPreviewFindings -> String
(Int -> ListAccessPreviewFindings -> ShowS)
-> (ListAccessPreviewFindings -> String)
-> ([ListAccessPreviewFindings] -> ShowS)
-> Show ListAccessPreviewFindings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAccessPreviewFindings] -> ShowS
$cshowList :: [ListAccessPreviewFindings] -> ShowS
show :: ListAccessPreviewFindings -> String
$cshow :: ListAccessPreviewFindings -> String
showsPrec :: Int -> ListAccessPreviewFindings -> ShowS
$cshowsPrec :: Int -> ListAccessPreviewFindings -> ShowS
Prelude.Show, (forall x.
 ListAccessPreviewFindings -> Rep ListAccessPreviewFindings x)
-> (forall x.
    Rep ListAccessPreviewFindings x -> ListAccessPreviewFindings)
-> Generic ListAccessPreviewFindings
forall x.
Rep ListAccessPreviewFindings x -> ListAccessPreviewFindings
forall x.
ListAccessPreviewFindings -> Rep ListAccessPreviewFindings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListAccessPreviewFindings x -> ListAccessPreviewFindings
$cfrom :: forall x.
ListAccessPreviewFindings -> Rep ListAccessPreviewFindings x
Prelude.Generic)

-- |
-- Create a value of 'ListAccessPreviewFindings' 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:
--
-- 'nextToken', 'listAccessPreviewFindings_nextToken' - A token used for pagination of results returned.
--
-- 'filter'', 'listAccessPreviewFindings_filter' - Criteria to filter the returned findings.
--
-- 'maxResults', 'listAccessPreviewFindings_maxResults' - The maximum number of results to return in the response.
--
-- 'accessPreviewId', 'listAccessPreviewFindings_accessPreviewId' - The unique ID for the access preview.
--
-- 'analyzerArn', 'listAccessPreviewFindings_analyzerArn' - The
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-getting-started.html#permission-resources ARN of the analyzer>
-- used to generate the access.
newListAccessPreviewFindings ::
  -- | 'accessPreviewId'
  Prelude.Text ->
  -- | 'analyzerArn'
  Prelude.Text ->
  ListAccessPreviewFindings
newListAccessPreviewFindings :: Text -> Text -> ListAccessPreviewFindings
newListAccessPreviewFindings
  Text
pAccessPreviewId_
  Text
pAnalyzerArn_ =
    ListAccessPreviewFindings' :: Maybe Text
-> Maybe (HashMap Text Criterion)
-> Maybe Int
-> Text
-> Text
-> ListAccessPreviewFindings
ListAccessPreviewFindings'
      { $sel:nextToken:ListAccessPreviewFindings' :: Maybe Text
nextToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:filter':ListAccessPreviewFindings' :: Maybe (HashMap Text Criterion)
filter' = Maybe (HashMap Text Criterion)
forall a. Maybe a
Prelude.Nothing,
        $sel:maxResults:ListAccessPreviewFindings' :: Maybe Int
maxResults = Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:accessPreviewId:ListAccessPreviewFindings' :: Text
accessPreviewId = Text
pAccessPreviewId_,
        $sel:analyzerArn:ListAccessPreviewFindings' :: Text
analyzerArn = Text
pAnalyzerArn_
      }

-- | A token used for pagination of results returned.
listAccessPreviewFindings_nextToken :: Lens.Lens' ListAccessPreviewFindings (Prelude.Maybe Prelude.Text)
listAccessPreviewFindings_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAccessPreviewFindings -> f ListAccessPreviewFindings
listAccessPreviewFindings_nextToken = (ListAccessPreviewFindings -> Maybe Text)
-> (ListAccessPreviewFindings
    -> Maybe Text -> ListAccessPreviewFindings)
-> Lens
     ListAccessPreviewFindings
     ListAccessPreviewFindings
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessPreviewFindings' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAccessPreviewFindings' :: ListAccessPreviewFindings -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAccessPreviewFindings
s@ListAccessPreviewFindings' {} Maybe Text
a -> ListAccessPreviewFindings
s {$sel:nextToken:ListAccessPreviewFindings' :: Maybe Text
nextToken = Maybe Text
a} :: ListAccessPreviewFindings)

-- | Criteria to filter the returned findings.
listAccessPreviewFindings_filter :: Lens.Lens' ListAccessPreviewFindings (Prelude.Maybe (Prelude.HashMap Prelude.Text Criterion))
listAccessPreviewFindings_filter :: (Maybe (HashMap Text Criterion)
 -> f (Maybe (HashMap Text Criterion)))
-> ListAccessPreviewFindings -> f ListAccessPreviewFindings
listAccessPreviewFindings_filter = (ListAccessPreviewFindings -> Maybe (HashMap Text Criterion))
-> (ListAccessPreviewFindings
    -> Maybe (HashMap Text Criterion) -> ListAccessPreviewFindings)
-> Lens
     ListAccessPreviewFindings
     ListAccessPreviewFindings
     (Maybe (HashMap Text Criterion))
     (Maybe (HashMap Text Criterion))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessPreviewFindings' {Maybe (HashMap Text Criterion)
filter' :: Maybe (HashMap Text Criterion)
$sel:filter':ListAccessPreviewFindings' :: ListAccessPreviewFindings -> Maybe (HashMap Text Criterion)
filter'} -> Maybe (HashMap Text Criterion)
filter') (\s :: ListAccessPreviewFindings
s@ListAccessPreviewFindings' {} Maybe (HashMap Text Criterion)
a -> ListAccessPreviewFindings
s {$sel:filter':ListAccessPreviewFindings' :: Maybe (HashMap Text Criterion)
filter' = Maybe (HashMap Text Criterion)
a} :: ListAccessPreviewFindings) ((Maybe (HashMap Text Criterion)
  -> f (Maybe (HashMap Text Criterion)))
 -> ListAccessPreviewFindings -> f ListAccessPreviewFindings)
-> ((Maybe (HashMap Text Criterion)
     -> f (Maybe (HashMap Text Criterion)))
    -> Maybe (HashMap Text Criterion)
    -> f (Maybe (HashMap Text Criterion)))
-> (Maybe (HashMap Text Criterion)
    -> f (Maybe (HashMap Text Criterion)))
-> ListAccessPreviewFindings
-> f ListAccessPreviewFindings
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Criterion)
  (HashMap Text Criterion)
  (HashMap Text Criterion)
  (HashMap Text Criterion)
-> Iso
     (Maybe (HashMap Text Criterion))
     (Maybe (HashMap Text Criterion))
     (Maybe (HashMap Text Criterion))
     (Maybe (HashMap Text Criterion))
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 AnIso
  (HashMap Text Criterion)
  (HashMap Text Criterion)
  (HashMap Text Criterion)
  (HashMap Text Criterion)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The maximum number of results to return in the response.
listAccessPreviewFindings_maxResults :: Lens.Lens' ListAccessPreviewFindings (Prelude.Maybe Prelude.Int)
listAccessPreviewFindings_maxResults :: (Maybe Int -> f (Maybe Int))
-> ListAccessPreviewFindings -> f ListAccessPreviewFindings
listAccessPreviewFindings_maxResults = (ListAccessPreviewFindings -> Maybe Int)
-> (ListAccessPreviewFindings
    -> Maybe Int -> ListAccessPreviewFindings)
-> Lens
     ListAccessPreviewFindings
     ListAccessPreviewFindings
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessPreviewFindings' {Maybe Int
maxResults :: Maybe Int
$sel:maxResults:ListAccessPreviewFindings' :: ListAccessPreviewFindings -> Maybe Int
maxResults} -> Maybe Int
maxResults) (\s :: ListAccessPreviewFindings
s@ListAccessPreviewFindings' {} Maybe Int
a -> ListAccessPreviewFindings
s {$sel:maxResults:ListAccessPreviewFindings' :: Maybe Int
maxResults = Maybe Int
a} :: ListAccessPreviewFindings)

-- | The unique ID for the access preview.
listAccessPreviewFindings_accessPreviewId :: Lens.Lens' ListAccessPreviewFindings Prelude.Text
listAccessPreviewFindings_accessPreviewId :: (Text -> f Text)
-> ListAccessPreviewFindings -> f ListAccessPreviewFindings
listAccessPreviewFindings_accessPreviewId = (ListAccessPreviewFindings -> Text)
-> (ListAccessPreviewFindings -> Text -> ListAccessPreviewFindings)
-> Lens
     ListAccessPreviewFindings ListAccessPreviewFindings Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessPreviewFindings' {Text
accessPreviewId :: Text
$sel:accessPreviewId:ListAccessPreviewFindings' :: ListAccessPreviewFindings -> Text
accessPreviewId} -> Text
accessPreviewId) (\s :: ListAccessPreviewFindings
s@ListAccessPreviewFindings' {} Text
a -> ListAccessPreviewFindings
s {$sel:accessPreviewId:ListAccessPreviewFindings' :: Text
accessPreviewId = Text
a} :: ListAccessPreviewFindings)

-- | The
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-getting-started.html#permission-resources ARN of the analyzer>
-- used to generate the access.
listAccessPreviewFindings_analyzerArn :: Lens.Lens' ListAccessPreviewFindings Prelude.Text
listAccessPreviewFindings_analyzerArn :: (Text -> f Text)
-> ListAccessPreviewFindings -> f ListAccessPreviewFindings
listAccessPreviewFindings_analyzerArn = (ListAccessPreviewFindings -> Text)
-> (ListAccessPreviewFindings -> Text -> ListAccessPreviewFindings)
-> Lens
     ListAccessPreviewFindings ListAccessPreviewFindings Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessPreviewFindings' {Text
analyzerArn :: Text
$sel:analyzerArn:ListAccessPreviewFindings' :: ListAccessPreviewFindings -> Text
analyzerArn} -> Text
analyzerArn) (\s :: ListAccessPreviewFindings
s@ListAccessPreviewFindings' {} Text
a -> ListAccessPreviewFindings
s {$sel:analyzerArn:ListAccessPreviewFindings' :: Text
analyzerArn = Text
a} :: ListAccessPreviewFindings)

instance Core.AWSPager ListAccessPreviewFindings where
  page :: ListAccessPreviewFindings
-> AWSResponse ListAccessPreviewFindings
-> Maybe ListAccessPreviewFindings
page ListAccessPreviewFindings
rq AWSResponse ListAccessPreviewFindings
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAccessPreviewFindings
ListAccessPreviewFindingsResponse
rs
            ListAccessPreviewFindingsResponse
-> Getting (First Text) ListAccessPreviewFindingsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAccessPreviewFindingsResponse
-> Const (First Text) ListAccessPreviewFindingsResponse
Lens' ListAccessPreviewFindingsResponse (Maybe Text)
listAccessPreviewFindingsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAccessPreviewFindingsResponse
 -> Const (First Text) ListAccessPreviewFindingsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAccessPreviewFindingsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListAccessPreviewFindings
forall a. Maybe a
Prelude.Nothing
    | [AccessPreviewFinding] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAccessPreviewFindings
ListAccessPreviewFindingsResponse
rs
            ListAccessPreviewFindingsResponse
-> Getting
     [AccessPreviewFinding]
     ListAccessPreviewFindingsResponse
     [AccessPreviewFinding]
-> [AccessPreviewFinding]
forall s a. s -> Getting a s a -> a
Lens.^. Getting
  [AccessPreviewFinding]
  ListAccessPreviewFindingsResponse
  [AccessPreviewFinding]
Lens' ListAccessPreviewFindingsResponse [AccessPreviewFinding]
listAccessPreviewFindingsResponse_findings
        ) =
      Maybe ListAccessPreviewFindings
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListAccessPreviewFindings -> Maybe ListAccessPreviewFindings
forall a. a -> Maybe a
Prelude.Just (ListAccessPreviewFindings -> Maybe ListAccessPreviewFindings)
-> ListAccessPreviewFindings -> Maybe ListAccessPreviewFindings
forall a b. (a -> b) -> a -> b
Prelude.$
        ListAccessPreviewFindings
rq
          ListAccessPreviewFindings
-> (ListAccessPreviewFindings -> ListAccessPreviewFindings)
-> ListAccessPreviewFindings
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListAccessPreviewFindings -> Identity ListAccessPreviewFindings
Lens
  ListAccessPreviewFindings
  ListAccessPreviewFindings
  (Maybe Text)
  (Maybe Text)
listAccessPreviewFindings_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListAccessPreviewFindings -> Identity ListAccessPreviewFindings)
-> Maybe Text
-> ListAccessPreviewFindings
-> ListAccessPreviewFindings
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListAccessPreviewFindings
ListAccessPreviewFindingsResponse
rs
          ListAccessPreviewFindingsResponse
-> Getting (First Text) ListAccessPreviewFindingsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAccessPreviewFindingsResponse
-> Const (First Text) ListAccessPreviewFindingsResponse
Lens' ListAccessPreviewFindingsResponse (Maybe Text)
listAccessPreviewFindingsResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAccessPreviewFindingsResponse
 -> Const (First Text) ListAccessPreviewFindingsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAccessPreviewFindingsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListAccessPreviewFindings where
  type
    AWSResponse ListAccessPreviewFindings =
      ListAccessPreviewFindingsResponse
  request :: ListAccessPreviewFindings -> Request ListAccessPreviewFindings
request = Service
-> ListAccessPreviewFindings -> Request ListAccessPreviewFindings
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListAccessPreviewFindings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAccessPreviewFindings)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListAccessPreviewFindings))
-> Logger
-> Service
-> Proxy ListAccessPreviewFindings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAccessPreviewFindings)))
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
-> Int
-> [AccessPreviewFinding]
-> ListAccessPreviewFindingsResponse
ListAccessPreviewFindingsResponse'
            (Maybe Text
 -> Int
 -> [AccessPreviewFinding]
 -> ListAccessPreviewFindingsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Int
      -> [AccessPreviewFinding] -> ListAccessPreviewFindingsResponse)
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
"nextToken")
            Either
  String
  (Int
   -> [AccessPreviewFinding] -> ListAccessPreviewFindingsResponse)
-> Either String Int
-> Either
     String
     ([AccessPreviewFinding] -> ListAccessPreviewFindingsResponse)
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))
            Either
  String
  ([AccessPreviewFinding] -> ListAccessPreviewFindingsResponse)
-> Either String [AccessPreviewFinding]
-> Either String ListAccessPreviewFindingsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe [AccessPreviewFinding])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"findings" Either String (Maybe [AccessPreviewFinding])
-> [AccessPreviewFinding] -> Either String [AccessPreviewFinding]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [AccessPreviewFinding]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ListAccessPreviewFindings

instance Prelude.NFData ListAccessPreviewFindings

instance Core.ToHeaders ListAccessPreviewFindings where
  toHeaders :: ListAccessPreviewFindings -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListAccessPreviewFindings -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 ListAccessPreviewFindings where
  toJSON :: ListAccessPreviewFindings -> Value
toJSON ListAccessPreviewFindings' {Maybe Int
Maybe Text
Maybe (HashMap Text Criterion)
Text
analyzerArn :: Text
accessPreviewId :: Text
maxResults :: Maybe Int
filter' :: Maybe (HashMap Text Criterion)
nextToken :: Maybe Text
$sel:analyzerArn:ListAccessPreviewFindings' :: ListAccessPreviewFindings -> Text
$sel:accessPreviewId:ListAccessPreviewFindings' :: ListAccessPreviewFindings -> Text
$sel:maxResults:ListAccessPreviewFindings' :: ListAccessPreviewFindings -> Maybe Int
$sel:filter':ListAccessPreviewFindings' :: ListAccessPreviewFindings -> Maybe (HashMap Text Criterion)
$sel:nextToken:ListAccessPreviewFindings' :: ListAccessPreviewFindings -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"nextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"filter" Text -> HashMap Text Criterion -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Criterion -> Pair)
-> Maybe (HashMap Text Criterion) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Criterion)
filter',
            (Text
"maxResults" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
maxResults,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"analyzerArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
analyzerArn)
          ]
      )

instance Core.ToPath ListAccessPreviewFindings where
  toPath :: ListAccessPreviewFindings -> ByteString
toPath ListAccessPreviewFindings' {Maybe Int
Maybe Text
Maybe (HashMap Text Criterion)
Text
analyzerArn :: Text
accessPreviewId :: Text
maxResults :: Maybe Int
filter' :: Maybe (HashMap Text Criterion)
nextToken :: Maybe Text
$sel:analyzerArn:ListAccessPreviewFindings' :: ListAccessPreviewFindings -> Text
$sel:accessPreviewId:ListAccessPreviewFindings' :: ListAccessPreviewFindings -> Text
$sel:maxResults:ListAccessPreviewFindings' :: ListAccessPreviewFindings -> Maybe Int
$sel:filter':ListAccessPreviewFindings' :: ListAccessPreviewFindings -> Maybe (HashMap Text Criterion)
$sel:nextToken:ListAccessPreviewFindings' :: ListAccessPreviewFindings -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/access-preview/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
accessPreviewId]

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

-- | /See:/ 'newListAccessPreviewFindingsResponse' smart constructor.
data ListAccessPreviewFindingsResponse = ListAccessPreviewFindingsResponse'
  { -- | A token used for pagination of results returned.
    ListAccessPreviewFindingsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListAccessPreviewFindingsResponse -> Int
httpStatus :: Prelude.Int,
    -- | A list of access preview findings that match the specified filter
    -- criteria.
    ListAccessPreviewFindingsResponse -> [AccessPreviewFinding]
findings :: [AccessPreviewFinding]
  }
  deriving (ListAccessPreviewFindingsResponse
-> ListAccessPreviewFindingsResponse -> Bool
(ListAccessPreviewFindingsResponse
 -> ListAccessPreviewFindingsResponse -> Bool)
-> (ListAccessPreviewFindingsResponse
    -> ListAccessPreviewFindingsResponse -> Bool)
-> Eq ListAccessPreviewFindingsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAccessPreviewFindingsResponse
-> ListAccessPreviewFindingsResponse -> Bool
$c/= :: ListAccessPreviewFindingsResponse
-> ListAccessPreviewFindingsResponse -> Bool
== :: ListAccessPreviewFindingsResponse
-> ListAccessPreviewFindingsResponse -> Bool
$c== :: ListAccessPreviewFindingsResponse
-> ListAccessPreviewFindingsResponse -> Bool
Prelude.Eq, ReadPrec [ListAccessPreviewFindingsResponse]
ReadPrec ListAccessPreviewFindingsResponse
Int -> ReadS ListAccessPreviewFindingsResponse
ReadS [ListAccessPreviewFindingsResponse]
(Int -> ReadS ListAccessPreviewFindingsResponse)
-> ReadS [ListAccessPreviewFindingsResponse]
-> ReadPrec ListAccessPreviewFindingsResponse
-> ReadPrec [ListAccessPreviewFindingsResponse]
-> Read ListAccessPreviewFindingsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAccessPreviewFindingsResponse]
$creadListPrec :: ReadPrec [ListAccessPreviewFindingsResponse]
readPrec :: ReadPrec ListAccessPreviewFindingsResponse
$creadPrec :: ReadPrec ListAccessPreviewFindingsResponse
readList :: ReadS [ListAccessPreviewFindingsResponse]
$creadList :: ReadS [ListAccessPreviewFindingsResponse]
readsPrec :: Int -> ReadS ListAccessPreviewFindingsResponse
$creadsPrec :: Int -> ReadS ListAccessPreviewFindingsResponse
Prelude.Read, Int -> ListAccessPreviewFindingsResponse -> ShowS
[ListAccessPreviewFindingsResponse] -> ShowS
ListAccessPreviewFindingsResponse -> String
(Int -> ListAccessPreviewFindingsResponse -> ShowS)
-> (ListAccessPreviewFindingsResponse -> String)
-> ([ListAccessPreviewFindingsResponse] -> ShowS)
-> Show ListAccessPreviewFindingsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAccessPreviewFindingsResponse] -> ShowS
$cshowList :: [ListAccessPreviewFindingsResponse] -> ShowS
show :: ListAccessPreviewFindingsResponse -> String
$cshow :: ListAccessPreviewFindingsResponse -> String
showsPrec :: Int -> ListAccessPreviewFindingsResponse -> ShowS
$cshowsPrec :: Int -> ListAccessPreviewFindingsResponse -> ShowS
Prelude.Show, (forall x.
 ListAccessPreviewFindingsResponse
 -> Rep ListAccessPreviewFindingsResponse x)
-> (forall x.
    Rep ListAccessPreviewFindingsResponse x
    -> ListAccessPreviewFindingsResponse)
-> Generic ListAccessPreviewFindingsResponse
forall x.
Rep ListAccessPreviewFindingsResponse x
-> ListAccessPreviewFindingsResponse
forall x.
ListAccessPreviewFindingsResponse
-> Rep ListAccessPreviewFindingsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListAccessPreviewFindingsResponse x
-> ListAccessPreviewFindingsResponse
$cfrom :: forall x.
ListAccessPreviewFindingsResponse
-> Rep ListAccessPreviewFindingsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAccessPreviewFindingsResponse' 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:
--
-- 'nextToken', 'listAccessPreviewFindingsResponse_nextToken' - A token used for pagination of results returned.
--
-- 'httpStatus', 'listAccessPreviewFindingsResponse_httpStatus' - The response's http status code.
--
-- 'findings', 'listAccessPreviewFindingsResponse_findings' - A list of access preview findings that match the specified filter
-- criteria.
newListAccessPreviewFindingsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAccessPreviewFindingsResponse
newListAccessPreviewFindingsResponse :: Int -> ListAccessPreviewFindingsResponse
newListAccessPreviewFindingsResponse Int
pHttpStatus_ =
  ListAccessPreviewFindingsResponse' :: Maybe Text
-> Int
-> [AccessPreviewFinding]
-> ListAccessPreviewFindingsResponse
ListAccessPreviewFindingsResponse'
    { $sel:nextToken:ListAccessPreviewFindingsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAccessPreviewFindingsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:findings:ListAccessPreviewFindingsResponse' :: [AccessPreviewFinding]
findings = [AccessPreviewFinding]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A token used for pagination of results returned.
listAccessPreviewFindingsResponse_nextToken :: Lens.Lens' ListAccessPreviewFindingsResponse (Prelude.Maybe Prelude.Text)
listAccessPreviewFindingsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAccessPreviewFindingsResponse
-> f ListAccessPreviewFindingsResponse
listAccessPreviewFindingsResponse_nextToken = (ListAccessPreviewFindingsResponse -> Maybe Text)
-> (ListAccessPreviewFindingsResponse
    -> Maybe Text -> ListAccessPreviewFindingsResponse)
-> Lens' ListAccessPreviewFindingsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessPreviewFindingsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAccessPreviewFindingsResponse' :: ListAccessPreviewFindingsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAccessPreviewFindingsResponse
s@ListAccessPreviewFindingsResponse' {} Maybe Text
a -> ListAccessPreviewFindingsResponse
s {$sel:nextToken:ListAccessPreviewFindingsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAccessPreviewFindingsResponse)

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

-- | A list of access preview findings that match the specified filter
-- criteria.
listAccessPreviewFindingsResponse_findings :: Lens.Lens' ListAccessPreviewFindingsResponse [AccessPreviewFinding]
listAccessPreviewFindingsResponse_findings :: ([AccessPreviewFinding] -> f [AccessPreviewFinding])
-> ListAccessPreviewFindingsResponse
-> f ListAccessPreviewFindingsResponse
listAccessPreviewFindingsResponse_findings = (ListAccessPreviewFindingsResponse -> [AccessPreviewFinding])
-> (ListAccessPreviewFindingsResponse
    -> [AccessPreviewFinding] -> ListAccessPreviewFindingsResponse)
-> Lens' ListAccessPreviewFindingsResponse [AccessPreviewFinding]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessPreviewFindingsResponse' {[AccessPreviewFinding]
findings :: [AccessPreviewFinding]
$sel:findings:ListAccessPreviewFindingsResponse' :: ListAccessPreviewFindingsResponse -> [AccessPreviewFinding]
findings} -> [AccessPreviewFinding]
findings) (\s :: ListAccessPreviewFindingsResponse
s@ListAccessPreviewFindingsResponse' {} [AccessPreviewFinding]
a -> ListAccessPreviewFindingsResponse
s {$sel:findings:ListAccessPreviewFindingsResponse' :: [AccessPreviewFinding]
findings = [AccessPreviewFinding]
a} :: ListAccessPreviewFindingsResponse) (([AccessPreviewFinding] -> f [AccessPreviewFinding])
 -> ListAccessPreviewFindingsResponse
 -> f ListAccessPreviewFindingsResponse)
-> (([AccessPreviewFinding] -> f [AccessPreviewFinding])
    -> [AccessPreviewFinding] -> f [AccessPreviewFinding])
-> ([AccessPreviewFinding] -> f [AccessPreviewFinding])
-> ListAccessPreviewFindingsResponse
-> f ListAccessPreviewFindingsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([AccessPreviewFinding] -> f [AccessPreviewFinding])
-> [AccessPreviewFinding] -> f [AccessPreviewFinding]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Prelude.NFData
    ListAccessPreviewFindingsResponse