{-# 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.IoT.ListAuditFindings
-- 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)
--
-- Lists the findings (results) of a Device Defender audit or of the audits
-- performed during a specified time period. (Findings are retained for 90
-- days.)
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions ListAuditFindings>
-- action.
--
-- This operation returns paginated results.
module Amazonka.IoT.ListAuditFindings
  ( -- * Creating a Request
    ListAuditFindings (..),
    newListAuditFindings,

    -- * Request Lenses
    listAuditFindings_startTime,
    listAuditFindings_taskId,
    listAuditFindings_checkName,
    listAuditFindings_listSuppressedFindings,
    listAuditFindings_nextToken,
    listAuditFindings_endTime,
    listAuditFindings_maxResults,
    listAuditFindings_resourceIdentifier,

    -- * Destructuring the Response
    ListAuditFindingsResponse (..),
    newListAuditFindingsResponse,

    -- * Response Lenses
    listAuditFindingsResponse_nextToken,
    listAuditFindingsResponse_findings,
    listAuditFindingsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT.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:/ 'newListAuditFindings' smart constructor.
data ListAuditFindings = ListAuditFindings'
  { -- | A filter to limit results to those found after the specified time. You
    -- must specify either the startTime and endTime or the taskId, but not
    -- both.
    ListAuditFindings -> Maybe POSIX
startTime :: Prelude.Maybe Core.POSIX,
    -- | A filter to limit results to the audit with the specified ID. You must
    -- specify either the taskId or the startTime and endTime, but not both.
    ListAuditFindings -> Maybe Text
taskId :: Prelude.Maybe Prelude.Text,
    -- | A filter to limit results to the findings for the specified audit check.
    ListAuditFindings -> Maybe Text
checkName :: Prelude.Maybe Prelude.Text,
    -- | Boolean flag indicating whether only the suppressed findings or the
    -- unsuppressed findings should be listed. If this parameter isn\'t
    -- provided, the response will list both suppressed and unsuppressed
    -- findings.
    ListAuditFindings -> Maybe Bool
listSuppressedFindings :: Prelude.Maybe Prelude.Bool,
    -- | The token for the next set of results.
    ListAuditFindings -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A filter to limit results to those found before the specified time. You
    -- must specify either the startTime and endTime or the taskId, but not
    -- both.
    ListAuditFindings -> Maybe POSIX
endTime :: Prelude.Maybe Core.POSIX,
    -- | The maximum number of results to return at one time. The default is 25.
    ListAuditFindings -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | Information identifying the noncompliant resource.
    ListAuditFindings -> Maybe ResourceIdentifier
resourceIdentifier :: Prelude.Maybe ResourceIdentifier
  }
  deriving (ListAuditFindings -> ListAuditFindings -> Bool
(ListAuditFindings -> ListAuditFindings -> Bool)
-> (ListAuditFindings -> ListAuditFindings -> Bool)
-> Eq ListAuditFindings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAuditFindings -> ListAuditFindings -> Bool
$c/= :: ListAuditFindings -> ListAuditFindings -> Bool
== :: ListAuditFindings -> ListAuditFindings -> Bool
$c== :: ListAuditFindings -> ListAuditFindings -> Bool
Prelude.Eq, ReadPrec [ListAuditFindings]
ReadPrec ListAuditFindings
Int -> ReadS ListAuditFindings
ReadS [ListAuditFindings]
(Int -> ReadS ListAuditFindings)
-> ReadS [ListAuditFindings]
-> ReadPrec ListAuditFindings
-> ReadPrec [ListAuditFindings]
-> Read ListAuditFindings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAuditFindings]
$creadListPrec :: ReadPrec [ListAuditFindings]
readPrec :: ReadPrec ListAuditFindings
$creadPrec :: ReadPrec ListAuditFindings
readList :: ReadS [ListAuditFindings]
$creadList :: ReadS [ListAuditFindings]
readsPrec :: Int -> ReadS ListAuditFindings
$creadsPrec :: Int -> ReadS ListAuditFindings
Prelude.Read, Int -> ListAuditFindings -> ShowS
[ListAuditFindings] -> ShowS
ListAuditFindings -> String
(Int -> ListAuditFindings -> ShowS)
-> (ListAuditFindings -> String)
-> ([ListAuditFindings] -> ShowS)
-> Show ListAuditFindings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAuditFindings] -> ShowS
$cshowList :: [ListAuditFindings] -> ShowS
show :: ListAuditFindings -> String
$cshow :: ListAuditFindings -> String
showsPrec :: Int -> ListAuditFindings -> ShowS
$cshowsPrec :: Int -> ListAuditFindings -> ShowS
Prelude.Show, (forall x. ListAuditFindings -> Rep ListAuditFindings x)
-> (forall x. Rep ListAuditFindings x -> ListAuditFindings)
-> Generic ListAuditFindings
forall x. Rep ListAuditFindings x -> ListAuditFindings
forall x. ListAuditFindings -> Rep ListAuditFindings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAuditFindings x -> ListAuditFindings
$cfrom :: forall x. ListAuditFindings -> Rep ListAuditFindings x
Prelude.Generic)

-- |
-- Create a value of 'ListAuditFindings' 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:
--
-- 'startTime', 'listAuditFindings_startTime' - A filter to limit results to those found after the specified time. You
-- must specify either the startTime and endTime or the taskId, but not
-- both.
--
-- 'taskId', 'listAuditFindings_taskId' - A filter to limit results to the audit with the specified ID. You must
-- specify either the taskId or the startTime and endTime, but not both.
--
-- 'checkName', 'listAuditFindings_checkName' - A filter to limit results to the findings for the specified audit check.
--
-- 'listSuppressedFindings', 'listAuditFindings_listSuppressedFindings' - Boolean flag indicating whether only the suppressed findings or the
-- unsuppressed findings should be listed. If this parameter isn\'t
-- provided, the response will list both suppressed and unsuppressed
-- findings.
--
-- 'nextToken', 'listAuditFindings_nextToken' - The token for the next set of results.
--
-- 'endTime', 'listAuditFindings_endTime' - A filter to limit results to those found before the specified time. You
-- must specify either the startTime and endTime or the taskId, but not
-- both.
--
-- 'maxResults', 'listAuditFindings_maxResults' - The maximum number of results to return at one time. The default is 25.
--
-- 'resourceIdentifier', 'listAuditFindings_resourceIdentifier' - Information identifying the noncompliant resource.
newListAuditFindings ::
  ListAuditFindings
newListAuditFindings :: ListAuditFindings
newListAuditFindings =
  ListAuditFindings' :: Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe POSIX
-> Maybe Natural
-> Maybe ResourceIdentifier
-> ListAuditFindings
ListAuditFindings'
    { $sel:startTime:ListAuditFindings' :: Maybe POSIX
startTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:taskId:ListAuditFindings' :: Maybe Text
taskId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:checkName:ListAuditFindings' :: Maybe Text
checkName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:listSuppressedFindings:ListAuditFindings' :: Maybe Bool
listSuppressedFindings = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAuditFindings' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:ListAuditFindings' :: Maybe POSIX
endTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListAuditFindings' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceIdentifier:ListAuditFindings' :: Maybe ResourceIdentifier
resourceIdentifier = Maybe ResourceIdentifier
forall a. Maybe a
Prelude.Nothing
    }

-- | A filter to limit results to those found after the specified time. You
-- must specify either the startTime and endTime or the taskId, but not
-- both.
listAuditFindings_startTime :: Lens.Lens' ListAuditFindings (Prelude.Maybe Prelude.UTCTime)
listAuditFindings_startTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListAuditFindings -> f ListAuditFindings
listAuditFindings_startTime = (ListAuditFindings -> Maybe POSIX)
-> (ListAuditFindings -> Maybe POSIX -> ListAuditFindings)
-> Lens
     ListAuditFindings ListAuditFindings (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAuditFindings' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:ListAuditFindings' :: ListAuditFindings -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: ListAuditFindings
s@ListAuditFindings' {} Maybe POSIX
a -> ListAuditFindings
s {$sel:startTime:ListAuditFindings' :: Maybe POSIX
startTime = Maybe POSIX
a} :: ListAuditFindings) ((Maybe POSIX -> f (Maybe POSIX))
 -> ListAuditFindings -> f ListAuditFindings)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListAuditFindings
-> f ListAuditFindings
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | A filter to limit results to the audit with the specified ID. You must
-- specify either the taskId or the startTime and endTime, but not both.
listAuditFindings_taskId :: Lens.Lens' ListAuditFindings (Prelude.Maybe Prelude.Text)
listAuditFindings_taskId :: (Maybe Text -> f (Maybe Text))
-> ListAuditFindings -> f ListAuditFindings
listAuditFindings_taskId = (ListAuditFindings -> Maybe Text)
-> (ListAuditFindings -> Maybe Text -> ListAuditFindings)
-> Lens
     ListAuditFindings ListAuditFindings (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAuditFindings' {Maybe Text
taskId :: Maybe Text
$sel:taskId:ListAuditFindings' :: ListAuditFindings -> Maybe Text
taskId} -> Maybe Text
taskId) (\s :: ListAuditFindings
s@ListAuditFindings' {} Maybe Text
a -> ListAuditFindings
s {$sel:taskId:ListAuditFindings' :: Maybe Text
taskId = Maybe Text
a} :: ListAuditFindings)

-- | A filter to limit results to the findings for the specified audit check.
listAuditFindings_checkName :: Lens.Lens' ListAuditFindings (Prelude.Maybe Prelude.Text)
listAuditFindings_checkName :: (Maybe Text -> f (Maybe Text))
-> ListAuditFindings -> f ListAuditFindings
listAuditFindings_checkName = (ListAuditFindings -> Maybe Text)
-> (ListAuditFindings -> Maybe Text -> ListAuditFindings)
-> Lens
     ListAuditFindings ListAuditFindings (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAuditFindings' {Maybe Text
checkName :: Maybe Text
$sel:checkName:ListAuditFindings' :: ListAuditFindings -> Maybe Text
checkName} -> Maybe Text
checkName) (\s :: ListAuditFindings
s@ListAuditFindings' {} Maybe Text
a -> ListAuditFindings
s {$sel:checkName:ListAuditFindings' :: Maybe Text
checkName = Maybe Text
a} :: ListAuditFindings)

-- | Boolean flag indicating whether only the suppressed findings or the
-- unsuppressed findings should be listed. If this parameter isn\'t
-- provided, the response will list both suppressed and unsuppressed
-- findings.
listAuditFindings_listSuppressedFindings :: Lens.Lens' ListAuditFindings (Prelude.Maybe Prelude.Bool)
listAuditFindings_listSuppressedFindings :: (Maybe Bool -> f (Maybe Bool))
-> ListAuditFindings -> f ListAuditFindings
listAuditFindings_listSuppressedFindings = (ListAuditFindings -> Maybe Bool)
-> (ListAuditFindings -> Maybe Bool -> ListAuditFindings)
-> Lens
     ListAuditFindings ListAuditFindings (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAuditFindings' {Maybe Bool
listSuppressedFindings :: Maybe Bool
$sel:listSuppressedFindings:ListAuditFindings' :: ListAuditFindings -> Maybe Bool
listSuppressedFindings} -> Maybe Bool
listSuppressedFindings) (\s :: ListAuditFindings
s@ListAuditFindings' {} Maybe Bool
a -> ListAuditFindings
s {$sel:listSuppressedFindings:ListAuditFindings' :: Maybe Bool
listSuppressedFindings = Maybe Bool
a} :: ListAuditFindings)

-- | The token for the next set of results.
listAuditFindings_nextToken :: Lens.Lens' ListAuditFindings (Prelude.Maybe Prelude.Text)
listAuditFindings_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAuditFindings -> f ListAuditFindings
listAuditFindings_nextToken = (ListAuditFindings -> Maybe Text)
-> (ListAuditFindings -> Maybe Text -> ListAuditFindings)
-> Lens
     ListAuditFindings ListAuditFindings (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAuditFindings' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAuditFindings' :: ListAuditFindings -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAuditFindings
s@ListAuditFindings' {} Maybe Text
a -> ListAuditFindings
s {$sel:nextToken:ListAuditFindings' :: Maybe Text
nextToken = Maybe Text
a} :: ListAuditFindings)

-- | A filter to limit results to those found before the specified time. You
-- must specify either the startTime and endTime or the taskId, but not
-- both.
listAuditFindings_endTime :: Lens.Lens' ListAuditFindings (Prelude.Maybe Prelude.UTCTime)
listAuditFindings_endTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListAuditFindings -> f ListAuditFindings
listAuditFindings_endTime = (ListAuditFindings -> Maybe POSIX)
-> (ListAuditFindings -> Maybe POSIX -> ListAuditFindings)
-> Lens
     ListAuditFindings ListAuditFindings (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAuditFindings' {Maybe POSIX
endTime :: Maybe POSIX
$sel:endTime:ListAuditFindings' :: ListAuditFindings -> Maybe POSIX
endTime} -> Maybe POSIX
endTime) (\s :: ListAuditFindings
s@ListAuditFindings' {} Maybe POSIX
a -> ListAuditFindings
s {$sel:endTime:ListAuditFindings' :: Maybe POSIX
endTime = Maybe POSIX
a} :: ListAuditFindings) ((Maybe POSIX -> f (Maybe POSIX))
 -> ListAuditFindings -> f ListAuditFindings)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListAuditFindings
-> f ListAuditFindings
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The maximum number of results to return at one time. The default is 25.
listAuditFindings_maxResults :: Lens.Lens' ListAuditFindings (Prelude.Maybe Prelude.Natural)
listAuditFindings_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListAuditFindings -> f ListAuditFindings
listAuditFindings_maxResults = (ListAuditFindings -> Maybe Natural)
-> (ListAuditFindings -> Maybe Natural -> ListAuditFindings)
-> Lens
     ListAuditFindings ListAuditFindings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAuditFindings' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListAuditFindings' :: ListAuditFindings -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListAuditFindings
s@ListAuditFindings' {} Maybe Natural
a -> ListAuditFindings
s {$sel:maxResults:ListAuditFindings' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListAuditFindings)

-- | Information identifying the noncompliant resource.
listAuditFindings_resourceIdentifier :: Lens.Lens' ListAuditFindings (Prelude.Maybe ResourceIdentifier)
listAuditFindings_resourceIdentifier :: (Maybe ResourceIdentifier -> f (Maybe ResourceIdentifier))
-> ListAuditFindings -> f ListAuditFindings
listAuditFindings_resourceIdentifier = (ListAuditFindings -> Maybe ResourceIdentifier)
-> (ListAuditFindings
    -> Maybe ResourceIdentifier -> ListAuditFindings)
-> Lens
     ListAuditFindings
     ListAuditFindings
     (Maybe ResourceIdentifier)
     (Maybe ResourceIdentifier)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAuditFindings' {Maybe ResourceIdentifier
resourceIdentifier :: Maybe ResourceIdentifier
$sel:resourceIdentifier:ListAuditFindings' :: ListAuditFindings -> Maybe ResourceIdentifier
resourceIdentifier} -> Maybe ResourceIdentifier
resourceIdentifier) (\s :: ListAuditFindings
s@ListAuditFindings' {} Maybe ResourceIdentifier
a -> ListAuditFindings
s {$sel:resourceIdentifier:ListAuditFindings' :: Maybe ResourceIdentifier
resourceIdentifier = Maybe ResourceIdentifier
a} :: ListAuditFindings)

instance Core.AWSPager ListAuditFindings where
  page :: ListAuditFindings
-> AWSResponse ListAuditFindings -> Maybe ListAuditFindings
page ListAuditFindings
rq AWSResponse ListAuditFindings
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAuditFindings
ListAuditFindingsResponse
rs
            ListAuditFindingsResponse
-> Getting (First Text) ListAuditFindingsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAuditFindingsResponse
-> Const (First Text) ListAuditFindingsResponse
Lens' ListAuditFindingsResponse (Maybe Text)
listAuditFindingsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAuditFindingsResponse
 -> Const (First Text) ListAuditFindingsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAuditFindingsResponse 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 ListAuditFindings
forall a. Maybe a
Prelude.Nothing
    | Maybe [AuditFinding] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAuditFindings
ListAuditFindingsResponse
rs
            ListAuditFindingsResponse
-> Getting
     (First [AuditFinding]) ListAuditFindingsResponse [AuditFinding]
-> Maybe [AuditFinding]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [AuditFinding]
 -> Const (First [AuditFinding]) (Maybe [AuditFinding]))
-> ListAuditFindingsResponse
-> Const (First [AuditFinding]) ListAuditFindingsResponse
Lens' ListAuditFindingsResponse (Maybe [AuditFinding])
listAuditFindingsResponse_findings
              ((Maybe [AuditFinding]
  -> Const (First [AuditFinding]) (Maybe [AuditFinding]))
 -> ListAuditFindingsResponse
 -> Const (First [AuditFinding]) ListAuditFindingsResponse)
-> (([AuditFinding] -> Const (First [AuditFinding]) [AuditFinding])
    -> Maybe [AuditFinding]
    -> Const (First [AuditFinding]) (Maybe [AuditFinding]))
-> Getting
     (First [AuditFinding]) ListAuditFindingsResponse [AuditFinding]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([AuditFinding] -> Const (First [AuditFinding]) [AuditFinding])
-> Maybe [AuditFinding]
-> Const (First [AuditFinding]) (Maybe [AuditFinding])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListAuditFindings
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListAuditFindings -> Maybe ListAuditFindings
forall a. a -> Maybe a
Prelude.Just (ListAuditFindings -> Maybe ListAuditFindings)
-> ListAuditFindings -> Maybe ListAuditFindings
forall a b. (a -> b) -> a -> b
Prelude.$
        ListAuditFindings
rq
          ListAuditFindings
-> (ListAuditFindings -> ListAuditFindings) -> ListAuditFindings
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListAuditFindings -> Identity ListAuditFindings
Lens ListAuditFindings ListAuditFindings (Maybe Text) (Maybe Text)
listAuditFindings_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListAuditFindings -> Identity ListAuditFindings)
-> Maybe Text -> ListAuditFindings -> ListAuditFindings
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListAuditFindings
ListAuditFindingsResponse
rs
          ListAuditFindingsResponse
-> Getting (First Text) ListAuditFindingsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAuditFindingsResponse
-> Const (First Text) ListAuditFindingsResponse
Lens' ListAuditFindingsResponse (Maybe Text)
listAuditFindingsResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAuditFindingsResponse
 -> Const (First Text) ListAuditFindingsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAuditFindingsResponse 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 ListAuditFindings where
  type
    AWSResponse ListAuditFindings =
      ListAuditFindingsResponse
  request :: ListAuditFindings -> Request ListAuditFindings
request = Service -> ListAuditFindings -> Request ListAuditFindings
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListAuditFindings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAuditFindings)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListAuditFindings))
-> Logger
-> Service
-> Proxy ListAuditFindings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAuditFindings)))
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 [AuditFinding] -> Int -> ListAuditFindingsResponse
ListAuditFindingsResponse'
            (Maybe Text
 -> Maybe [AuditFinding] -> Int -> ListAuditFindingsResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [AuditFinding] -> Int -> ListAuditFindingsResponse)
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 (Maybe [AuditFinding] -> Int -> ListAuditFindingsResponse)
-> Either String (Maybe [AuditFinding])
-> Either String (Int -> ListAuditFindingsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [AuditFinding]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"findings" Either String (Maybe (Maybe [AuditFinding]))
-> Maybe [AuditFinding] -> Either String (Maybe [AuditFinding])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [AuditFinding]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListAuditFindingsResponse)
-> Either String Int -> Either String ListAuditFindingsResponse
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 ListAuditFindings

instance Prelude.NFData ListAuditFindings

instance Core.ToHeaders ListAuditFindings where
  toHeaders :: ListAuditFindings -> ResponseHeaders
toHeaders = ResponseHeaders -> ListAuditFindings -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON ListAuditFindings where
  toJSON :: ListAuditFindings -> Value
toJSON ListAuditFindings' {Maybe Bool
Maybe Natural
Maybe Text
Maybe POSIX
Maybe ResourceIdentifier
resourceIdentifier :: Maybe ResourceIdentifier
maxResults :: Maybe Natural
endTime :: Maybe POSIX
nextToken :: Maybe Text
listSuppressedFindings :: Maybe Bool
checkName :: Maybe Text
taskId :: Maybe Text
startTime :: Maybe POSIX
$sel:resourceIdentifier:ListAuditFindings' :: ListAuditFindings -> Maybe ResourceIdentifier
$sel:maxResults:ListAuditFindings' :: ListAuditFindings -> Maybe Natural
$sel:endTime:ListAuditFindings' :: ListAuditFindings -> Maybe POSIX
$sel:nextToken:ListAuditFindings' :: ListAuditFindings -> Maybe Text
$sel:listSuppressedFindings:ListAuditFindings' :: ListAuditFindings -> Maybe Bool
$sel:checkName:ListAuditFindings' :: ListAuditFindings -> Maybe Text
$sel:taskId:ListAuditFindings' :: ListAuditFindings -> Maybe Text
$sel:startTime:ListAuditFindings' :: ListAuditFindings -> Maybe POSIX
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"startTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
startTime,
            (Text
"taskId" 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
taskId,
            (Text
"checkName" 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
checkName,
            (Text
"listSuppressedFindings" 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
listSuppressedFindings,
            (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
"endTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
endTime,
            (Text
"maxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            (Text
"resourceIdentifier" Text -> ResourceIdentifier -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ResourceIdentifier -> Pair)
-> Maybe ResourceIdentifier -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ResourceIdentifier
resourceIdentifier
          ]
      )

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

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

-- | /See:/ 'newListAuditFindingsResponse' smart constructor.
data ListAuditFindingsResponse = ListAuditFindingsResponse'
  { -- | A token that can be used to retrieve the next set of results, or @null@
    -- if there are no additional results.
    ListAuditFindingsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The findings (results) of the audit.
    ListAuditFindingsResponse -> Maybe [AuditFinding]
findings :: Prelude.Maybe [AuditFinding],
    -- | The response's http status code.
    ListAuditFindingsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListAuditFindingsResponse -> ListAuditFindingsResponse -> Bool
(ListAuditFindingsResponse -> ListAuditFindingsResponse -> Bool)
-> (ListAuditFindingsResponse -> ListAuditFindingsResponse -> Bool)
-> Eq ListAuditFindingsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAuditFindingsResponse -> ListAuditFindingsResponse -> Bool
$c/= :: ListAuditFindingsResponse -> ListAuditFindingsResponse -> Bool
== :: ListAuditFindingsResponse -> ListAuditFindingsResponse -> Bool
$c== :: ListAuditFindingsResponse -> ListAuditFindingsResponse -> Bool
Prelude.Eq, ReadPrec [ListAuditFindingsResponse]
ReadPrec ListAuditFindingsResponse
Int -> ReadS ListAuditFindingsResponse
ReadS [ListAuditFindingsResponse]
(Int -> ReadS ListAuditFindingsResponse)
-> ReadS [ListAuditFindingsResponse]
-> ReadPrec ListAuditFindingsResponse
-> ReadPrec [ListAuditFindingsResponse]
-> Read ListAuditFindingsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAuditFindingsResponse]
$creadListPrec :: ReadPrec [ListAuditFindingsResponse]
readPrec :: ReadPrec ListAuditFindingsResponse
$creadPrec :: ReadPrec ListAuditFindingsResponse
readList :: ReadS [ListAuditFindingsResponse]
$creadList :: ReadS [ListAuditFindingsResponse]
readsPrec :: Int -> ReadS ListAuditFindingsResponse
$creadsPrec :: Int -> ReadS ListAuditFindingsResponse
Prelude.Read, Int -> ListAuditFindingsResponse -> ShowS
[ListAuditFindingsResponse] -> ShowS
ListAuditFindingsResponse -> String
(Int -> ListAuditFindingsResponse -> ShowS)
-> (ListAuditFindingsResponse -> String)
-> ([ListAuditFindingsResponse] -> ShowS)
-> Show ListAuditFindingsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAuditFindingsResponse] -> ShowS
$cshowList :: [ListAuditFindingsResponse] -> ShowS
show :: ListAuditFindingsResponse -> String
$cshow :: ListAuditFindingsResponse -> String
showsPrec :: Int -> ListAuditFindingsResponse -> ShowS
$cshowsPrec :: Int -> ListAuditFindingsResponse -> ShowS
Prelude.Show, (forall x.
 ListAuditFindingsResponse -> Rep ListAuditFindingsResponse x)
-> (forall x.
    Rep ListAuditFindingsResponse x -> ListAuditFindingsResponse)
-> Generic ListAuditFindingsResponse
forall x.
Rep ListAuditFindingsResponse x -> ListAuditFindingsResponse
forall x.
ListAuditFindingsResponse -> Rep ListAuditFindingsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListAuditFindingsResponse x -> ListAuditFindingsResponse
$cfrom :: forall x.
ListAuditFindingsResponse -> Rep ListAuditFindingsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAuditFindingsResponse' 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', 'listAuditFindingsResponse_nextToken' - A token that can be used to retrieve the next set of results, or @null@
-- if there are no additional results.
--
-- 'findings', 'listAuditFindingsResponse_findings' - The findings (results) of the audit.
--
-- 'httpStatus', 'listAuditFindingsResponse_httpStatus' - The response's http status code.
newListAuditFindingsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAuditFindingsResponse
newListAuditFindingsResponse :: Int -> ListAuditFindingsResponse
newListAuditFindingsResponse Int
pHttpStatus_ =
  ListAuditFindingsResponse' :: Maybe Text
-> Maybe [AuditFinding] -> Int -> ListAuditFindingsResponse
ListAuditFindingsResponse'
    { $sel:nextToken:ListAuditFindingsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:findings:ListAuditFindingsResponse' :: Maybe [AuditFinding]
findings = Maybe [AuditFinding]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAuditFindingsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A token that can be used to retrieve the next set of results, or @null@
-- if there are no additional results.
listAuditFindingsResponse_nextToken :: Lens.Lens' ListAuditFindingsResponse (Prelude.Maybe Prelude.Text)
listAuditFindingsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAuditFindingsResponse -> f ListAuditFindingsResponse
listAuditFindingsResponse_nextToken = (ListAuditFindingsResponse -> Maybe Text)
-> (ListAuditFindingsResponse
    -> Maybe Text -> ListAuditFindingsResponse)
-> Lens' ListAuditFindingsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAuditFindingsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAuditFindingsResponse' :: ListAuditFindingsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAuditFindingsResponse
s@ListAuditFindingsResponse' {} Maybe Text
a -> ListAuditFindingsResponse
s {$sel:nextToken:ListAuditFindingsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAuditFindingsResponse)

-- | The findings (results) of the audit.
listAuditFindingsResponse_findings :: Lens.Lens' ListAuditFindingsResponse (Prelude.Maybe [AuditFinding])
listAuditFindingsResponse_findings :: (Maybe [AuditFinding] -> f (Maybe [AuditFinding]))
-> ListAuditFindingsResponse -> f ListAuditFindingsResponse
listAuditFindingsResponse_findings = (ListAuditFindingsResponse -> Maybe [AuditFinding])
-> (ListAuditFindingsResponse
    -> Maybe [AuditFinding] -> ListAuditFindingsResponse)
-> Lens' ListAuditFindingsResponse (Maybe [AuditFinding])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAuditFindingsResponse' {Maybe [AuditFinding]
findings :: Maybe [AuditFinding]
$sel:findings:ListAuditFindingsResponse' :: ListAuditFindingsResponse -> Maybe [AuditFinding]
findings} -> Maybe [AuditFinding]
findings) (\s :: ListAuditFindingsResponse
s@ListAuditFindingsResponse' {} Maybe [AuditFinding]
a -> ListAuditFindingsResponse
s {$sel:findings:ListAuditFindingsResponse' :: Maybe [AuditFinding]
findings = Maybe [AuditFinding]
a} :: ListAuditFindingsResponse) ((Maybe [AuditFinding] -> f (Maybe [AuditFinding]))
 -> ListAuditFindingsResponse -> f ListAuditFindingsResponse)
-> ((Maybe [AuditFinding] -> f (Maybe [AuditFinding]))
    -> Maybe [AuditFinding] -> f (Maybe [AuditFinding]))
-> (Maybe [AuditFinding] -> f (Maybe [AuditFinding]))
-> ListAuditFindingsResponse
-> f ListAuditFindingsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [AuditFinding] [AuditFinding] [AuditFinding] [AuditFinding]
-> Iso
     (Maybe [AuditFinding])
     (Maybe [AuditFinding])
     (Maybe [AuditFinding])
     (Maybe [AuditFinding])
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 [AuditFinding] [AuditFinding] [AuditFinding] [AuditFinding]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListAuditFindingsResponse