{-# 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.ListControlDomainInsights
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists the latest analytics data for control domains across all of your
-- active assessments.
--
-- A control domain is listed only if at least one of the controls within
-- that domain collected evidence on the @lastUpdated@ date of
-- @controlDomainInsights@. If this condition isn’t met, no data is listed
-- for that control domain.
module Amazonka.AuditManager.ListControlDomainInsights
  ( -- * Creating a Request
    ListControlDomainInsights (..),
    newListControlDomainInsights,

    -- * Request Lenses
    listControlDomainInsights_maxResults,
    listControlDomainInsights_nextToken,

    -- * Destructuring the Response
    ListControlDomainInsightsResponse (..),
    newListControlDomainInsightsResponse,

    -- * Response Lenses
    listControlDomainInsightsResponse_controlDomainInsights,
    listControlDomainInsightsResponse_nextToken,
    listControlDomainInsightsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListControlDomainInsights' smart constructor.
data ListControlDomainInsights = ListControlDomainInsights'
  { -- | Represents the maximum number of results on a page or for an API request
    -- call.
    ListControlDomainInsights -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The pagination token that\'s used to fetch the next set of results.
    ListControlDomainInsights -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListControlDomainInsights -> ListControlDomainInsights -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListControlDomainInsights -> ListControlDomainInsights -> Bool
$c/= :: ListControlDomainInsights -> ListControlDomainInsights -> Bool
== :: ListControlDomainInsights -> ListControlDomainInsights -> Bool
$c== :: ListControlDomainInsights -> ListControlDomainInsights -> Bool
Prelude.Eq, ReadPrec [ListControlDomainInsights]
ReadPrec ListControlDomainInsights
Int -> ReadS ListControlDomainInsights
ReadS [ListControlDomainInsights]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListControlDomainInsights]
$creadListPrec :: ReadPrec [ListControlDomainInsights]
readPrec :: ReadPrec ListControlDomainInsights
$creadPrec :: ReadPrec ListControlDomainInsights
readList :: ReadS [ListControlDomainInsights]
$creadList :: ReadS [ListControlDomainInsights]
readsPrec :: Int -> ReadS ListControlDomainInsights
$creadsPrec :: Int -> ReadS ListControlDomainInsights
Prelude.Read, Int -> ListControlDomainInsights -> ShowS
[ListControlDomainInsights] -> ShowS
ListControlDomainInsights -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListControlDomainInsights] -> ShowS
$cshowList :: [ListControlDomainInsights] -> ShowS
show :: ListControlDomainInsights -> String
$cshow :: ListControlDomainInsights -> String
showsPrec :: Int -> ListControlDomainInsights -> ShowS
$cshowsPrec :: Int -> ListControlDomainInsights -> ShowS
Prelude.Show, forall x.
Rep ListControlDomainInsights x -> ListControlDomainInsights
forall x.
ListControlDomainInsights -> Rep ListControlDomainInsights x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListControlDomainInsights x -> ListControlDomainInsights
$cfrom :: forall x.
ListControlDomainInsights -> Rep ListControlDomainInsights x
Prelude.Generic)

-- |
-- Create a value of 'ListControlDomainInsights' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'maxResults', 'listControlDomainInsights_maxResults' - Represents the maximum number of results on a page or for an API request
-- call.
--
-- 'nextToken', 'listControlDomainInsights_nextToken' - The pagination token that\'s used to fetch the next set of results.
newListControlDomainInsights ::
  ListControlDomainInsights
newListControlDomainInsights :: ListControlDomainInsights
newListControlDomainInsights =
  ListControlDomainInsights'
    { $sel:maxResults:ListControlDomainInsights' :: Maybe Natural
maxResults =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListControlDomainInsights' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | Represents the maximum number of results on a page or for an API request
-- call.
listControlDomainInsights_maxResults :: Lens.Lens' ListControlDomainInsights (Prelude.Maybe Prelude.Natural)
listControlDomainInsights_maxResults :: Lens' ListControlDomainInsights (Maybe Natural)
listControlDomainInsights_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListControlDomainInsights' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListControlDomainInsights' :: ListControlDomainInsights -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListControlDomainInsights
s@ListControlDomainInsights' {} Maybe Natural
a -> ListControlDomainInsights
s {$sel:maxResults:ListControlDomainInsights' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListControlDomainInsights)

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

instance Core.AWSRequest ListControlDomainInsights where
  type
    AWSResponse ListControlDomainInsights =
      ListControlDomainInsightsResponse
  request :: (Service -> Service)
-> ListControlDomainInsights -> Request ListControlDomainInsights
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListControlDomainInsights
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListControlDomainInsights)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [ControlDomainInsights]
-> Maybe Text -> Int -> ListControlDomainInsightsResponse
ListControlDomainInsightsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"controlDomainInsights"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"nextToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListControlDomainInsights where
  hashWithSalt :: Int -> ListControlDomainInsights -> Int
hashWithSalt Int
_salt ListControlDomainInsights' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListControlDomainInsights' :: ListControlDomainInsights -> Maybe Text
$sel:maxResults:ListControlDomainInsights' :: ListControlDomainInsights -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

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

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

instance Data.ToPath ListControlDomainInsights where
  toPath :: ListControlDomainInsights -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/insights/control-domains"

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

-- | /See:/ 'newListControlDomainInsightsResponse' smart constructor.
data ListControlDomainInsightsResponse = ListControlDomainInsightsResponse'
  { -- | The control domain analytics data that the @ListControlDomainInsights@
    -- API returned.
    ListControlDomainInsightsResponse -> Maybe [ControlDomainInsights]
controlDomainInsights :: Prelude.Maybe [ControlDomainInsights],
    -- | The pagination token that\'s used to fetch the next set of results.
    ListControlDomainInsightsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListControlDomainInsightsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListControlDomainInsightsResponse
-> ListControlDomainInsightsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListControlDomainInsightsResponse
-> ListControlDomainInsightsResponse -> Bool
$c/= :: ListControlDomainInsightsResponse
-> ListControlDomainInsightsResponse -> Bool
== :: ListControlDomainInsightsResponse
-> ListControlDomainInsightsResponse -> Bool
$c== :: ListControlDomainInsightsResponse
-> ListControlDomainInsightsResponse -> Bool
Prelude.Eq, ReadPrec [ListControlDomainInsightsResponse]
ReadPrec ListControlDomainInsightsResponse
Int -> ReadS ListControlDomainInsightsResponse
ReadS [ListControlDomainInsightsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListControlDomainInsightsResponse]
$creadListPrec :: ReadPrec [ListControlDomainInsightsResponse]
readPrec :: ReadPrec ListControlDomainInsightsResponse
$creadPrec :: ReadPrec ListControlDomainInsightsResponse
readList :: ReadS [ListControlDomainInsightsResponse]
$creadList :: ReadS [ListControlDomainInsightsResponse]
readsPrec :: Int -> ReadS ListControlDomainInsightsResponse
$creadsPrec :: Int -> ReadS ListControlDomainInsightsResponse
Prelude.Read, Int -> ListControlDomainInsightsResponse -> ShowS
[ListControlDomainInsightsResponse] -> ShowS
ListControlDomainInsightsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListControlDomainInsightsResponse] -> ShowS
$cshowList :: [ListControlDomainInsightsResponse] -> ShowS
show :: ListControlDomainInsightsResponse -> String
$cshow :: ListControlDomainInsightsResponse -> String
showsPrec :: Int -> ListControlDomainInsightsResponse -> ShowS
$cshowsPrec :: Int -> ListControlDomainInsightsResponse -> ShowS
Prelude.Show, forall x.
Rep ListControlDomainInsightsResponse x
-> ListControlDomainInsightsResponse
forall x.
ListControlDomainInsightsResponse
-> Rep ListControlDomainInsightsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListControlDomainInsightsResponse x
-> ListControlDomainInsightsResponse
$cfrom :: forall x.
ListControlDomainInsightsResponse
-> Rep ListControlDomainInsightsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListControlDomainInsightsResponse' 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:
--
-- 'controlDomainInsights', 'listControlDomainInsightsResponse_controlDomainInsights' - The control domain analytics data that the @ListControlDomainInsights@
-- API returned.
--
-- 'nextToken', 'listControlDomainInsightsResponse_nextToken' - The pagination token that\'s used to fetch the next set of results.
--
-- 'httpStatus', 'listControlDomainInsightsResponse_httpStatus' - The response's http status code.
newListControlDomainInsightsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListControlDomainInsightsResponse
newListControlDomainInsightsResponse :: Int -> ListControlDomainInsightsResponse
newListControlDomainInsightsResponse Int
pHttpStatus_ =
  ListControlDomainInsightsResponse'
    { $sel:controlDomainInsights:ListControlDomainInsightsResponse' :: Maybe [ControlDomainInsights]
controlDomainInsights =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListControlDomainInsightsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListControlDomainInsightsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The control domain analytics data that the @ListControlDomainInsights@
-- API returned.
listControlDomainInsightsResponse_controlDomainInsights :: Lens.Lens' ListControlDomainInsightsResponse (Prelude.Maybe [ControlDomainInsights])
listControlDomainInsightsResponse_controlDomainInsights :: Lens'
  ListControlDomainInsightsResponse (Maybe [ControlDomainInsights])
listControlDomainInsightsResponse_controlDomainInsights = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListControlDomainInsightsResponse' {Maybe [ControlDomainInsights]
controlDomainInsights :: Maybe [ControlDomainInsights]
$sel:controlDomainInsights:ListControlDomainInsightsResponse' :: ListControlDomainInsightsResponse -> Maybe [ControlDomainInsights]
controlDomainInsights} -> Maybe [ControlDomainInsights]
controlDomainInsights) (\s :: ListControlDomainInsightsResponse
s@ListControlDomainInsightsResponse' {} Maybe [ControlDomainInsights]
a -> ListControlDomainInsightsResponse
s {$sel:controlDomainInsights:ListControlDomainInsightsResponse' :: Maybe [ControlDomainInsights]
controlDomainInsights = Maybe [ControlDomainInsights]
a} :: ListControlDomainInsightsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

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