{-# 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.ListAuditTasks
-- 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 Device Defender audits that have been performed during a given
-- time period.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions ListAuditTasks>
-- action.
--
-- This operation returns paginated results.
module Amazonka.IoT.ListAuditTasks
  ( -- * Creating a Request
    ListAuditTasks (..),
    newListAuditTasks,

    -- * Request Lenses
    listAuditTasks_taskType,
    listAuditTasks_nextToken,
    listAuditTasks_maxResults,
    listAuditTasks_taskStatus,
    listAuditTasks_startTime,
    listAuditTasks_endTime,

    -- * Destructuring the Response
    ListAuditTasksResponse (..),
    newListAuditTasksResponse,

    -- * Response Lenses
    listAuditTasksResponse_tasks,
    listAuditTasksResponse_nextToken,
    listAuditTasksResponse_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:/ 'newListAuditTasks' smart constructor.
data ListAuditTasks = ListAuditTasks'
  { -- | A filter to limit the output to the specified type of audit: can be one
    -- of \"ON_DEMAND_AUDIT_TASK\" or \"SCHEDULED__AUDIT_TASK\".
    ListAuditTasks -> Maybe AuditTaskType
taskType :: Prelude.Maybe AuditTaskType,
    -- | The token for the next set of results.
    ListAuditTasks -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return at one time. The default is 25.
    ListAuditTasks -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A filter to limit the output to audits with the specified completion
    -- status: can be one of \"IN_PROGRESS\", \"COMPLETED\", \"FAILED\", or
    -- \"CANCELED\".
    ListAuditTasks -> Maybe AuditTaskStatus
taskStatus :: Prelude.Maybe AuditTaskStatus,
    -- | The beginning of the time period. Audit information is retained for a
    -- limited time (90 days). Requesting a start time prior to what is
    -- retained results in an \"InvalidRequestException\".
    ListAuditTasks -> POSIX
startTime :: Core.POSIX,
    -- | The end of the time period.
    ListAuditTasks -> POSIX
endTime :: Core.POSIX
  }
  deriving (ListAuditTasks -> ListAuditTasks -> Bool
(ListAuditTasks -> ListAuditTasks -> Bool)
-> (ListAuditTasks -> ListAuditTasks -> Bool) -> Eq ListAuditTasks
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAuditTasks -> ListAuditTasks -> Bool
$c/= :: ListAuditTasks -> ListAuditTasks -> Bool
== :: ListAuditTasks -> ListAuditTasks -> Bool
$c== :: ListAuditTasks -> ListAuditTasks -> Bool
Prelude.Eq, ReadPrec [ListAuditTasks]
ReadPrec ListAuditTasks
Int -> ReadS ListAuditTasks
ReadS [ListAuditTasks]
(Int -> ReadS ListAuditTasks)
-> ReadS [ListAuditTasks]
-> ReadPrec ListAuditTasks
-> ReadPrec [ListAuditTasks]
-> Read ListAuditTasks
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAuditTasks]
$creadListPrec :: ReadPrec [ListAuditTasks]
readPrec :: ReadPrec ListAuditTasks
$creadPrec :: ReadPrec ListAuditTasks
readList :: ReadS [ListAuditTasks]
$creadList :: ReadS [ListAuditTasks]
readsPrec :: Int -> ReadS ListAuditTasks
$creadsPrec :: Int -> ReadS ListAuditTasks
Prelude.Read, Int -> ListAuditTasks -> ShowS
[ListAuditTasks] -> ShowS
ListAuditTasks -> String
(Int -> ListAuditTasks -> ShowS)
-> (ListAuditTasks -> String)
-> ([ListAuditTasks] -> ShowS)
-> Show ListAuditTasks
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAuditTasks] -> ShowS
$cshowList :: [ListAuditTasks] -> ShowS
show :: ListAuditTasks -> String
$cshow :: ListAuditTasks -> String
showsPrec :: Int -> ListAuditTasks -> ShowS
$cshowsPrec :: Int -> ListAuditTasks -> ShowS
Prelude.Show, (forall x. ListAuditTasks -> Rep ListAuditTasks x)
-> (forall x. Rep ListAuditTasks x -> ListAuditTasks)
-> Generic ListAuditTasks
forall x. Rep ListAuditTasks x -> ListAuditTasks
forall x. ListAuditTasks -> Rep ListAuditTasks x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAuditTasks x -> ListAuditTasks
$cfrom :: forall x. ListAuditTasks -> Rep ListAuditTasks x
Prelude.Generic)

-- |
-- Create a value of 'ListAuditTasks' 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:
--
-- 'taskType', 'listAuditTasks_taskType' - A filter to limit the output to the specified type of audit: can be one
-- of \"ON_DEMAND_AUDIT_TASK\" or \"SCHEDULED__AUDIT_TASK\".
--
-- 'nextToken', 'listAuditTasks_nextToken' - The token for the next set of results.
--
-- 'maxResults', 'listAuditTasks_maxResults' - The maximum number of results to return at one time. The default is 25.
--
-- 'taskStatus', 'listAuditTasks_taskStatus' - A filter to limit the output to audits with the specified completion
-- status: can be one of \"IN_PROGRESS\", \"COMPLETED\", \"FAILED\", or
-- \"CANCELED\".
--
-- 'startTime', 'listAuditTasks_startTime' - The beginning of the time period. Audit information is retained for a
-- limited time (90 days). Requesting a start time prior to what is
-- retained results in an \"InvalidRequestException\".
--
-- 'endTime', 'listAuditTasks_endTime' - The end of the time period.
newListAuditTasks ::
  -- | 'startTime'
  Prelude.UTCTime ->
  -- | 'endTime'
  Prelude.UTCTime ->
  ListAuditTasks
newListAuditTasks :: UTCTime -> UTCTime -> ListAuditTasks
newListAuditTasks UTCTime
pStartTime_ UTCTime
pEndTime_ =
  ListAuditTasks' :: Maybe AuditTaskType
-> Maybe Text
-> Maybe Natural
-> Maybe AuditTaskStatus
-> POSIX
-> POSIX
-> ListAuditTasks
ListAuditTasks'
    { $sel:taskType:ListAuditTasks' :: Maybe AuditTaskType
taskType = Maybe AuditTaskType
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAuditTasks' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListAuditTasks' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:taskStatus:ListAuditTasks' :: Maybe AuditTaskStatus
taskStatus = Maybe AuditTaskStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:ListAuditTasks' :: POSIX
startTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_,
      $sel:endTime:ListAuditTasks' :: POSIX
endTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pEndTime_
    }

-- | A filter to limit the output to the specified type of audit: can be one
-- of \"ON_DEMAND_AUDIT_TASK\" or \"SCHEDULED__AUDIT_TASK\".
listAuditTasks_taskType :: Lens.Lens' ListAuditTasks (Prelude.Maybe AuditTaskType)
listAuditTasks_taskType :: (Maybe AuditTaskType -> f (Maybe AuditTaskType))
-> ListAuditTasks -> f ListAuditTasks
listAuditTasks_taskType = (ListAuditTasks -> Maybe AuditTaskType)
-> (ListAuditTasks -> Maybe AuditTaskType -> ListAuditTasks)
-> Lens
     ListAuditTasks
     ListAuditTasks
     (Maybe AuditTaskType)
     (Maybe AuditTaskType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAuditTasks' {Maybe AuditTaskType
taskType :: Maybe AuditTaskType
$sel:taskType:ListAuditTasks' :: ListAuditTasks -> Maybe AuditTaskType
taskType} -> Maybe AuditTaskType
taskType) (\s :: ListAuditTasks
s@ListAuditTasks' {} Maybe AuditTaskType
a -> ListAuditTasks
s {$sel:taskType:ListAuditTasks' :: Maybe AuditTaskType
taskType = Maybe AuditTaskType
a} :: ListAuditTasks)

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

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

-- | A filter to limit the output to audits with the specified completion
-- status: can be one of \"IN_PROGRESS\", \"COMPLETED\", \"FAILED\", or
-- \"CANCELED\".
listAuditTasks_taskStatus :: Lens.Lens' ListAuditTasks (Prelude.Maybe AuditTaskStatus)
listAuditTasks_taskStatus :: (Maybe AuditTaskStatus -> f (Maybe AuditTaskStatus))
-> ListAuditTasks -> f ListAuditTasks
listAuditTasks_taskStatus = (ListAuditTasks -> Maybe AuditTaskStatus)
-> (ListAuditTasks -> Maybe AuditTaskStatus -> ListAuditTasks)
-> Lens
     ListAuditTasks
     ListAuditTasks
     (Maybe AuditTaskStatus)
     (Maybe AuditTaskStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAuditTasks' {Maybe AuditTaskStatus
taskStatus :: Maybe AuditTaskStatus
$sel:taskStatus:ListAuditTasks' :: ListAuditTasks -> Maybe AuditTaskStatus
taskStatus} -> Maybe AuditTaskStatus
taskStatus) (\s :: ListAuditTasks
s@ListAuditTasks' {} Maybe AuditTaskStatus
a -> ListAuditTasks
s {$sel:taskStatus:ListAuditTasks' :: Maybe AuditTaskStatus
taskStatus = Maybe AuditTaskStatus
a} :: ListAuditTasks)

-- | The beginning of the time period. Audit information is retained for a
-- limited time (90 days). Requesting a start time prior to what is
-- retained results in an \"InvalidRequestException\".
listAuditTasks_startTime :: Lens.Lens' ListAuditTasks Prelude.UTCTime
listAuditTasks_startTime :: (UTCTime -> f UTCTime) -> ListAuditTasks -> f ListAuditTasks
listAuditTasks_startTime = (ListAuditTasks -> POSIX)
-> (ListAuditTasks -> POSIX -> ListAuditTasks)
-> Lens ListAuditTasks ListAuditTasks POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAuditTasks' {POSIX
startTime :: POSIX
$sel:startTime:ListAuditTasks' :: ListAuditTasks -> POSIX
startTime} -> POSIX
startTime) (\s :: ListAuditTasks
s@ListAuditTasks' {} POSIX
a -> ListAuditTasks
s {$sel:startTime:ListAuditTasks' :: POSIX
startTime = POSIX
a} :: ListAuditTasks) ((POSIX -> f POSIX) -> ListAuditTasks -> f ListAuditTasks)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ListAuditTasks
-> f ListAuditTasks
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The end of the time period.
listAuditTasks_endTime :: Lens.Lens' ListAuditTasks Prelude.UTCTime
listAuditTasks_endTime :: (UTCTime -> f UTCTime) -> ListAuditTasks -> f ListAuditTasks
listAuditTasks_endTime = (ListAuditTasks -> POSIX)
-> (ListAuditTasks -> POSIX -> ListAuditTasks)
-> Lens ListAuditTasks ListAuditTasks POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAuditTasks' {POSIX
endTime :: POSIX
$sel:endTime:ListAuditTasks' :: ListAuditTasks -> POSIX
endTime} -> POSIX
endTime) (\s :: ListAuditTasks
s@ListAuditTasks' {} POSIX
a -> ListAuditTasks
s {$sel:endTime:ListAuditTasks' :: POSIX
endTime = POSIX
a} :: ListAuditTasks) ((POSIX -> f POSIX) -> ListAuditTasks -> f ListAuditTasks)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ListAuditTasks
-> f ListAuditTasks
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

instance Prelude.NFData ListAuditTasks

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

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

instance Core.ToQuery ListAuditTasks where
  toQuery :: ListAuditTasks -> QueryString
toQuery ListAuditTasks' {Maybe Natural
Maybe Text
Maybe AuditTaskStatus
Maybe AuditTaskType
POSIX
endTime :: POSIX
startTime :: POSIX
taskStatus :: Maybe AuditTaskStatus
maxResults :: Maybe Natural
nextToken :: Maybe Text
taskType :: Maybe AuditTaskType
$sel:endTime:ListAuditTasks' :: ListAuditTasks -> POSIX
$sel:startTime:ListAuditTasks' :: ListAuditTasks -> POSIX
$sel:taskStatus:ListAuditTasks' :: ListAuditTasks -> Maybe AuditTaskStatus
$sel:maxResults:ListAuditTasks' :: ListAuditTasks -> Maybe Natural
$sel:nextToken:ListAuditTasks' :: ListAuditTasks -> Maybe Text
$sel:taskType:ListAuditTasks' :: ListAuditTasks -> Maybe AuditTaskType
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"taskType" ByteString -> Maybe AuditTaskType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe AuditTaskType
taskType,
        ByteString
"nextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"maxResults" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxResults,
        ByteString
"taskStatus" ByteString -> Maybe AuditTaskStatus -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe AuditTaskStatus
taskStatus,
        ByteString
"startTime" ByteString -> POSIX -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: POSIX
startTime,
        ByteString
"endTime" ByteString -> POSIX -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: POSIX
endTime
      ]

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

-- |
-- Create a value of 'ListAuditTasksResponse' 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:
--
-- 'tasks', 'listAuditTasksResponse_tasks' - The audits that were performed during the specified time period.
--
-- 'nextToken', 'listAuditTasksResponse_nextToken' - A token that can be used to retrieve the next set of results, or @null@
-- if there are no additional results.
--
-- 'httpStatus', 'listAuditTasksResponse_httpStatus' - The response's http status code.
newListAuditTasksResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAuditTasksResponse
newListAuditTasksResponse :: Int -> ListAuditTasksResponse
newListAuditTasksResponse Int
pHttpStatus_ =
  ListAuditTasksResponse' :: Maybe [AuditTaskMetadata]
-> Maybe Text -> Int -> ListAuditTasksResponse
ListAuditTasksResponse'
    { $sel:tasks:ListAuditTasksResponse' :: Maybe [AuditTaskMetadata]
tasks = Maybe [AuditTaskMetadata]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAuditTasksResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAuditTasksResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The audits that were performed during the specified time period.
listAuditTasksResponse_tasks :: Lens.Lens' ListAuditTasksResponse (Prelude.Maybe [AuditTaskMetadata])
listAuditTasksResponse_tasks :: (Maybe [AuditTaskMetadata] -> f (Maybe [AuditTaskMetadata]))
-> ListAuditTasksResponse -> f ListAuditTasksResponse
listAuditTasksResponse_tasks = (ListAuditTasksResponse -> Maybe [AuditTaskMetadata])
-> (ListAuditTasksResponse
    -> Maybe [AuditTaskMetadata] -> ListAuditTasksResponse)
-> Lens' ListAuditTasksResponse (Maybe [AuditTaskMetadata])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAuditTasksResponse' {Maybe [AuditTaskMetadata]
tasks :: Maybe [AuditTaskMetadata]
$sel:tasks:ListAuditTasksResponse' :: ListAuditTasksResponse -> Maybe [AuditTaskMetadata]
tasks} -> Maybe [AuditTaskMetadata]
tasks) (\s :: ListAuditTasksResponse
s@ListAuditTasksResponse' {} Maybe [AuditTaskMetadata]
a -> ListAuditTasksResponse
s {$sel:tasks:ListAuditTasksResponse' :: Maybe [AuditTaskMetadata]
tasks = Maybe [AuditTaskMetadata]
a} :: ListAuditTasksResponse) ((Maybe [AuditTaskMetadata] -> f (Maybe [AuditTaskMetadata]))
 -> ListAuditTasksResponse -> f ListAuditTasksResponse)
-> ((Maybe [AuditTaskMetadata] -> f (Maybe [AuditTaskMetadata]))
    -> Maybe [AuditTaskMetadata] -> f (Maybe [AuditTaskMetadata]))
-> (Maybe [AuditTaskMetadata] -> f (Maybe [AuditTaskMetadata]))
-> ListAuditTasksResponse
-> f ListAuditTasksResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AuditTaskMetadata]
  [AuditTaskMetadata]
  [AuditTaskMetadata]
  [AuditTaskMetadata]
-> Iso
     (Maybe [AuditTaskMetadata])
     (Maybe [AuditTaskMetadata])
     (Maybe [AuditTaskMetadata])
     (Maybe [AuditTaskMetadata])
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
  [AuditTaskMetadata]
  [AuditTaskMetadata]
  [AuditTaskMetadata]
  [AuditTaskMetadata]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

instance Prelude.NFData ListAuditTasksResponse