{-# 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.AuditManager.ListAssessments
-- 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)
--
-- Returns a list of current and past assessments from Audit Manager.
module Amazonka.AuditManager.ListAssessments
  ( -- * Creating a Request
    ListAssessments (..),
    newListAssessments,

    -- * Request Lenses
    listAssessments_nextToken,
    listAssessments_maxResults,

    -- * Destructuring the Response
    ListAssessmentsResponse (..),
    newListAssessmentsResponse,

    -- * Response Lenses
    listAssessmentsResponse_nextToken,
    listAssessmentsResponse_assessmentMetadata,
    listAssessmentsResponse_httpStatus,
  )
where

import Amazonka.AuditManager.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:/ 'newListAssessments' smart constructor.
data ListAssessments = ListAssessments'
  { -- | The pagination token used to fetch the next set of results.
    ListAssessments -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Represents the maximum number of results per page, or per API request
    -- call.
    ListAssessments -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListAssessments -> ListAssessments -> Bool
(ListAssessments -> ListAssessments -> Bool)
-> (ListAssessments -> ListAssessments -> Bool)
-> Eq ListAssessments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAssessments -> ListAssessments -> Bool
$c/= :: ListAssessments -> ListAssessments -> Bool
== :: ListAssessments -> ListAssessments -> Bool
$c== :: ListAssessments -> ListAssessments -> Bool
Prelude.Eq, ReadPrec [ListAssessments]
ReadPrec ListAssessments
Int -> ReadS ListAssessments
ReadS [ListAssessments]
(Int -> ReadS ListAssessments)
-> ReadS [ListAssessments]
-> ReadPrec ListAssessments
-> ReadPrec [ListAssessments]
-> Read ListAssessments
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAssessments]
$creadListPrec :: ReadPrec [ListAssessments]
readPrec :: ReadPrec ListAssessments
$creadPrec :: ReadPrec ListAssessments
readList :: ReadS [ListAssessments]
$creadList :: ReadS [ListAssessments]
readsPrec :: Int -> ReadS ListAssessments
$creadsPrec :: Int -> ReadS ListAssessments
Prelude.Read, Int -> ListAssessments -> ShowS
[ListAssessments] -> ShowS
ListAssessments -> String
(Int -> ListAssessments -> ShowS)
-> (ListAssessments -> String)
-> ([ListAssessments] -> ShowS)
-> Show ListAssessments
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAssessments] -> ShowS
$cshowList :: [ListAssessments] -> ShowS
show :: ListAssessments -> String
$cshow :: ListAssessments -> String
showsPrec :: Int -> ListAssessments -> ShowS
$cshowsPrec :: Int -> ListAssessments -> ShowS
Prelude.Show, (forall x. ListAssessments -> Rep ListAssessments x)
-> (forall x. Rep ListAssessments x -> ListAssessments)
-> Generic ListAssessments
forall x. Rep ListAssessments x -> ListAssessments
forall x. ListAssessments -> Rep ListAssessments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAssessments x -> ListAssessments
$cfrom :: forall x. ListAssessments -> Rep ListAssessments x
Prelude.Generic)

-- |
-- Create a value of 'ListAssessments' 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', 'listAssessments_nextToken' - The pagination token used to fetch the next set of results.
--
-- 'maxResults', 'listAssessments_maxResults' - Represents the maximum number of results per page, or per API request
-- call.
newListAssessments ::
  ListAssessments
newListAssessments :: ListAssessments
newListAssessments =
  ListAssessments' :: Maybe Text -> Maybe Natural -> ListAssessments
ListAssessments'
    { $sel:nextToken:ListAssessments' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListAssessments' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The pagination token used to fetch the next set of results.
listAssessments_nextToken :: Lens.Lens' ListAssessments (Prelude.Maybe Prelude.Text)
listAssessments_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAssessments -> f ListAssessments
listAssessments_nextToken = (ListAssessments -> Maybe Text)
-> (ListAssessments -> Maybe Text -> ListAssessments)
-> Lens ListAssessments ListAssessments (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssessments' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAssessments' :: ListAssessments -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAssessments
s@ListAssessments' {} Maybe Text
a -> ListAssessments
s {$sel:nextToken:ListAssessments' :: Maybe Text
nextToken = Maybe Text
a} :: ListAssessments)

-- | Represents the maximum number of results per page, or per API request
-- call.
listAssessments_maxResults :: Lens.Lens' ListAssessments (Prelude.Maybe Prelude.Natural)
listAssessments_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListAssessments -> f ListAssessments
listAssessments_maxResults = (ListAssessments -> Maybe Natural)
-> (ListAssessments -> Maybe Natural -> ListAssessments)
-> Lens
     ListAssessments ListAssessments (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssessments' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListAssessments' :: ListAssessments -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListAssessments
s@ListAssessments' {} Maybe Natural
a -> ListAssessments
s {$sel:maxResults:ListAssessments' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListAssessments)

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

instance Prelude.NFData ListAssessments

instance Core.ToHeaders ListAssessments where
  toHeaders :: ListAssessments -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListAssessments -> 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.ToPath ListAssessments where
  toPath :: ListAssessments -> ByteString
toPath = ByteString -> ListAssessments -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/assessments"

instance Core.ToQuery ListAssessments where
  toQuery :: ListAssessments -> QueryString
toQuery ListAssessments' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:maxResults:ListAssessments' :: ListAssessments -> Maybe Natural
$sel:nextToken:ListAssessments' :: ListAssessments -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ 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
      ]

-- | /See:/ 'newListAssessmentsResponse' smart constructor.
data ListAssessmentsResponse = ListAssessmentsResponse'
  { -- | The pagination token used to fetch the next set of results.
    ListAssessmentsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The metadata associated with the assessment.
    ListAssessmentsResponse -> Maybe [AssessmentMetadataItem]
assessmentMetadata :: Prelude.Maybe [AssessmentMetadataItem],
    -- | The response's http status code.
    ListAssessmentsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListAssessmentsResponse -> ListAssessmentsResponse -> Bool
(ListAssessmentsResponse -> ListAssessmentsResponse -> Bool)
-> (ListAssessmentsResponse -> ListAssessmentsResponse -> Bool)
-> Eq ListAssessmentsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAssessmentsResponse -> ListAssessmentsResponse -> Bool
$c/= :: ListAssessmentsResponse -> ListAssessmentsResponse -> Bool
== :: ListAssessmentsResponse -> ListAssessmentsResponse -> Bool
$c== :: ListAssessmentsResponse -> ListAssessmentsResponse -> Bool
Prelude.Eq, ReadPrec [ListAssessmentsResponse]
ReadPrec ListAssessmentsResponse
Int -> ReadS ListAssessmentsResponse
ReadS [ListAssessmentsResponse]
(Int -> ReadS ListAssessmentsResponse)
-> ReadS [ListAssessmentsResponse]
-> ReadPrec ListAssessmentsResponse
-> ReadPrec [ListAssessmentsResponse]
-> Read ListAssessmentsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAssessmentsResponse]
$creadListPrec :: ReadPrec [ListAssessmentsResponse]
readPrec :: ReadPrec ListAssessmentsResponse
$creadPrec :: ReadPrec ListAssessmentsResponse
readList :: ReadS [ListAssessmentsResponse]
$creadList :: ReadS [ListAssessmentsResponse]
readsPrec :: Int -> ReadS ListAssessmentsResponse
$creadsPrec :: Int -> ReadS ListAssessmentsResponse
Prelude.Read, Int -> ListAssessmentsResponse -> ShowS
[ListAssessmentsResponse] -> ShowS
ListAssessmentsResponse -> String
(Int -> ListAssessmentsResponse -> ShowS)
-> (ListAssessmentsResponse -> String)
-> ([ListAssessmentsResponse] -> ShowS)
-> Show ListAssessmentsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAssessmentsResponse] -> ShowS
$cshowList :: [ListAssessmentsResponse] -> ShowS
show :: ListAssessmentsResponse -> String
$cshow :: ListAssessmentsResponse -> String
showsPrec :: Int -> ListAssessmentsResponse -> ShowS
$cshowsPrec :: Int -> ListAssessmentsResponse -> ShowS
Prelude.Show, (forall x.
 ListAssessmentsResponse -> Rep ListAssessmentsResponse x)
-> (forall x.
    Rep ListAssessmentsResponse x -> ListAssessmentsResponse)
-> Generic ListAssessmentsResponse
forall x. Rep ListAssessmentsResponse x -> ListAssessmentsResponse
forall x. ListAssessmentsResponse -> Rep ListAssessmentsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAssessmentsResponse x -> ListAssessmentsResponse
$cfrom :: forall x. ListAssessmentsResponse -> Rep ListAssessmentsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAssessmentsResponse' 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', 'listAssessmentsResponse_nextToken' - The pagination token used to fetch the next set of results.
--
-- 'assessmentMetadata', 'listAssessmentsResponse_assessmentMetadata' - The metadata associated with the assessment.
--
-- 'httpStatus', 'listAssessmentsResponse_httpStatus' - The response's http status code.
newListAssessmentsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAssessmentsResponse
newListAssessmentsResponse :: Int -> ListAssessmentsResponse
newListAssessmentsResponse Int
pHttpStatus_ =
  ListAssessmentsResponse' :: Maybe Text
-> Maybe [AssessmentMetadataItem] -> Int -> ListAssessmentsResponse
ListAssessmentsResponse'
    { $sel:nextToken:ListAssessmentsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:assessmentMetadata:ListAssessmentsResponse' :: Maybe [AssessmentMetadataItem]
assessmentMetadata = Maybe [AssessmentMetadataItem]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAssessmentsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The pagination token used to fetch the next set of results.
listAssessmentsResponse_nextToken :: Lens.Lens' ListAssessmentsResponse (Prelude.Maybe Prelude.Text)
listAssessmentsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAssessmentsResponse -> f ListAssessmentsResponse
listAssessmentsResponse_nextToken = (ListAssessmentsResponse -> Maybe Text)
-> (ListAssessmentsResponse
    -> Maybe Text -> ListAssessmentsResponse)
-> Lens
     ListAssessmentsResponse
     ListAssessmentsResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssessmentsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAssessmentsResponse' :: ListAssessmentsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAssessmentsResponse
s@ListAssessmentsResponse' {} Maybe Text
a -> ListAssessmentsResponse
s {$sel:nextToken:ListAssessmentsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAssessmentsResponse)

-- | The metadata associated with the assessment.
listAssessmentsResponse_assessmentMetadata :: Lens.Lens' ListAssessmentsResponse (Prelude.Maybe [AssessmentMetadataItem])
listAssessmentsResponse_assessmentMetadata :: (Maybe [AssessmentMetadataItem]
 -> f (Maybe [AssessmentMetadataItem]))
-> ListAssessmentsResponse -> f ListAssessmentsResponse
listAssessmentsResponse_assessmentMetadata = (ListAssessmentsResponse -> Maybe [AssessmentMetadataItem])
-> (ListAssessmentsResponse
    -> Maybe [AssessmentMetadataItem] -> ListAssessmentsResponse)
-> Lens
     ListAssessmentsResponse
     ListAssessmentsResponse
     (Maybe [AssessmentMetadataItem])
     (Maybe [AssessmentMetadataItem])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssessmentsResponse' {Maybe [AssessmentMetadataItem]
assessmentMetadata :: Maybe [AssessmentMetadataItem]
$sel:assessmentMetadata:ListAssessmentsResponse' :: ListAssessmentsResponse -> Maybe [AssessmentMetadataItem]
assessmentMetadata} -> Maybe [AssessmentMetadataItem]
assessmentMetadata) (\s :: ListAssessmentsResponse
s@ListAssessmentsResponse' {} Maybe [AssessmentMetadataItem]
a -> ListAssessmentsResponse
s {$sel:assessmentMetadata:ListAssessmentsResponse' :: Maybe [AssessmentMetadataItem]
assessmentMetadata = Maybe [AssessmentMetadataItem]
a} :: ListAssessmentsResponse) ((Maybe [AssessmentMetadataItem]
  -> f (Maybe [AssessmentMetadataItem]))
 -> ListAssessmentsResponse -> f ListAssessmentsResponse)
-> ((Maybe [AssessmentMetadataItem]
     -> f (Maybe [AssessmentMetadataItem]))
    -> Maybe [AssessmentMetadataItem]
    -> f (Maybe [AssessmentMetadataItem]))
-> (Maybe [AssessmentMetadataItem]
    -> f (Maybe [AssessmentMetadataItem]))
-> ListAssessmentsResponse
-> f ListAssessmentsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AssessmentMetadataItem]
  [AssessmentMetadataItem]
  [AssessmentMetadataItem]
  [AssessmentMetadataItem]
-> Iso
     (Maybe [AssessmentMetadataItem])
     (Maybe [AssessmentMetadataItem])
     (Maybe [AssessmentMetadataItem])
     (Maybe [AssessmentMetadataItem])
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
  [AssessmentMetadataItem]
  [AssessmentMetadataItem]
  [AssessmentMetadataItem]
  [AssessmentMetadataItem]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListAssessmentsResponse