{-# 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.ListControls
-- 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 controls from Audit Manager.
module Amazonka.AuditManager.ListControls
  ( -- * Creating a Request
    ListControls (..),
    newListControls,

    -- * Request Lenses
    listControls_nextToken,
    listControls_maxResults,
    listControls_controlType,

    -- * Destructuring the Response
    ListControlsResponse (..),
    newListControlsResponse,

    -- * Response Lenses
    listControlsResponse_nextToken,
    listControlsResponse_controlMetadataList,
    listControlsResponse_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:/ 'newListControls' smart constructor.
data ListControls = ListControls'
  { -- | The pagination token used to fetch the next set of results.
    ListControls -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Represents the maximum number of results per page, or per API request
    -- call.
    ListControls -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The type of control, such as standard or custom.
    ListControls -> ControlType
controlType :: ControlType
  }
  deriving (ListControls -> ListControls -> Bool
(ListControls -> ListControls -> Bool)
-> (ListControls -> ListControls -> Bool) -> Eq ListControls
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListControls -> ListControls -> Bool
$c/= :: ListControls -> ListControls -> Bool
== :: ListControls -> ListControls -> Bool
$c== :: ListControls -> ListControls -> Bool
Prelude.Eq, ReadPrec [ListControls]
ReadPrec ListControls
Int -> ReadS ListControls
ReadS [ListControls]
(Int -> ReadS ListControls)
-> ReadS [ListControls]
-> ReadPrec ListControls
-> ReadPrec [ListControls]
-> Read ListControls
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListControls]
$creadListPrec :: ReadPrec [ListControls]
readPrec :: ReadPrec ListControls
$creadPrec :: ReadPrec ListControls
readList :: ReadS [ListControls]
$creadList :: ReadS [ListControls]
readsPrec :: Int -> ReadS ListControls
$creadsPrec :: Int -> ReadS ListControls
Prelude.Read, Int -> ListControls -> ShowS
[ListControls] -> ShowS
ListControls -> String
(Int -> ListControls -> ShowS)
-> (ListControls -> String)
-> ([ListControls] -> ShowS)
-> Show ListControls
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListControls] -> ShowS
$cshowList :: [ListControls] -> ShowS
show :: ListControls -> String
$cshow :: ListControls -> String
showsPrec :: Int -> ListControls -> ShowS
$cshowsPrec :: Int -> ListControls -> ShowS
Prelude.Show, (forall x. ListControls -> Rep ListControls x)
-> (forall x. Rep ListControls x -> ListControls)
-> Generic ListControls
forall x. Rep ListControls x -> ListControls
forall x. ListControls -> Rep ListControls x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListControls x -> ListControls
$cfrom :: forall x. ListControls -> Rep ListControls x
Prelude.Generic)

-- |
-- Create a value of 'ListControls' 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', 'listControls_nextToken' - The pagination token used to fetch the next set of results.
--
-- 'maxResults', 'listControls_maxResults' - Represents the maximum number of results per page, or per API request
-- call.
--
-- 'controlType', 'listControls_controlType' - The type of control, such as standard or custom.
newListControls ::
  -- | 'controlType'
  ControlType ->
  ListControls
newListControls :: ControlType -> ListControls
newListControls ControlType
pControlType_ =
  ListControls' :: Maybe Text -> Maybe Natural -> ControlType -> ListControls
ListControls'
    { $sel:nextToken:ListControls' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListControls' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:controlType:ListControls' :: ControlType
controlType = ControlType
pControlType_
    }

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

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

-- | The type of control, such as standard or custom.
listControls_controlType :: Lens.Lens' ListControls ControlType
listControls_controlType :: (ControlType -> f ControlType) -> ListControls -> f ListControls
listControls_controlType = (ListControls -> ControlType)
-> (ListControls -> ControlType -> ListControls)
-> Lens ListControls ListControls ControlType ControlType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListControls' {ControlType
controlType :: ControlType
$sel:controlType:ListControls' :: ListControls -> ControlType
controlType} -> ControlType
controlType) (\s :: ListControls
s@ListControls' {} ControlType
a -> ListControls
s {$sel:controlType:ListControls' :: ControlType
controlType = ControlType
a} :: ListControls)

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

instance Prelude.NFData ListControls

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

instance Core.ToQuery ListControls where
  toQuery :: ListControls -> QueryString
toQuery ListControls' {Maybe Natural
Maybe Text
ControlType
controlType :: ControlType
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:controlType:ListControls' :: ListControls -> ControlType
$sel:maxResults:ListControls' :: ListControls -> Maybe Natural
$sel:nextToken:ListControls' :: ListControls -> 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,
        ByteString
"controlType" ByteString -> ControlType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ControlType
controlType
      ]

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

-- |
-- Create a value of 'ListControlsResponse' 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', 'listControlsResponse_nextToken' - The pagination token used to fetch the next set of results.
--
-- 'controlMetadataList', 'listControlsResponse_controlMetadataList' - The list of control metadata objects returned by the @ListControls@ API.
--
-- 'httpStatus', 'listControlsResponse_httpStatus' - The response's http status code.
newListControlsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListControlsResponse
newListControlsResponse :: Int -> ListControlsResponse
newListControlsResponse Int
pHttpStatus_ =
  ListControlsResponse' :: Maybe Text
-> Maybe [ControlMetadata] -> Int -> ListControlsResponse
ListControlsResponse'
    { $sel:nextToken:ListControlsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:controlMetadataList:ListControlsResponse' :: Maybe [ControlMetadata]
controlMetadataList = Maybe [ControlMetadata]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListControlsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

-- | The list of control metadata objects returned by the @ListControls@ API.
listControlsResponse_controlMetadataList :: Lens.Lens' ListControlsResponse (Prelude.Maybe [ControlMetadata])
listControlsResponse_controlMetadataList :: (Maybe [ControlMetadata] -> f (Maybe [ControlMetadata]))
-> ListControlsResponse -> f ListControlsResponse
listControlsResponse_controlMetadataList = (ListControlsResponse -> Maybe [ControlMetadata])
-> (ListControlsResponse
    -> Maybe [ControlMetadata] -> ListControlsResponse)
-> Lens
     ListControlsResponse
     ListControlsResponse
     (Maybe [ControlMetadata])
     (Maybe [ControlMetadata])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListControlsResponse' {Maybe [ControlMetadata]
controlMetadataList :: Maybe [ControlMetadata]
$sel:controlMetadataList:ListControlsResponse' :: ListControlsResponse -> Maybe [ControlMetadata]
controlMetadataList} -> Maybe [ControlMetadata]
controlMetadataList) (\s :: ListControlsResponse
s@ListControlsResponse' {} Maybe [ControlMetadata]
a -> ListControlsResponse
s {$sel:controlMetadataList:ListControlsResponse' :: Maybe [ControlMetadata]
controlMetadataList = Maybe [ControlMetadata]
a} :: ListControlsResponse) ((Maybe [ControlMetadata] -> f (Maybe [ControlMetadata]))
 -> ListControlsResponse -> f ListControlsResponse)
-> ((Maybe [ControlMetadata] -> f (Maybe [ControlMetadata]))
    -> Maybe [ControlMetadata] -> f (Maybe [ControlMetadata]))
-> (Maybe [ControlMetadata] -> f (Maybe [ControlMetadata]))
-> ListControlsResponse
-> f ListControlsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ControlMetadata]
  [ControlMetadata]
  [ControlMetadata]
  [ControlMetadata]
-> Iso
     (Maybe [ControlMetadata])
     (Maybe [ControlMetadata])
     (Maybe [ControlMetadata])
     (Maybe [ControlMetadata])
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
  [ControlMetadata]
  [ControlMetadata]
  [ControlMetadata]
  [ControlMetadata]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListControlsResponse