{-# 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.ListNotifications
-- 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 all Audit Manager notifications.
module Amazonka.AuditManager.ListNotifications
  ( -- * Creating a Request
    ListNotifications (..),
    newListNotifications,

    -- * Request Lenses
    listNotifications_nextToken,
    listNotifications_maxResults,

    -- * Destructuring the Response
    ListNotificationsResponse (..),
    newListNotificationsResponse,

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

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

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

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

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

instance Prelude.NFData ListNotifications

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

instance Core.ToQuery ListNotifications where
  toQuery :: ListNotifications -> QueryString
toQuery ListNotifications' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:maxResults:ListNotifications' :: ListNotifications -> Maybe Natural
$sel:nextToken:ListNotifications' :: ListNotifications -> 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:/ 'newListNotificationsResponse' smart constructor.
data ListNotificationsResponse = ListNotificationsResponse'
  { -- | The pagination token used to fetch the next set of results.
    ListNotificationsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The returned list of notifications.
    ListNotificationsResponse -> Maybe [Notification]
notifications :: Prelude.Maybe [Notification],
    -- | The response's http status code.
    ListNotificationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListNotificationsResponse -> ListNotificationsResponse -> Bool
(ListNotificationsResponse -> ListNotificationsResponse -> Bool)
-> (ListNotificationsResponse -> ListNotificationsResponse -> Bool)
-> Eq ListNotificationsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListNotificationsResponse -> ListNotificationsResponse -> Bool
$c/= :: ListNotificationsResponse -> ListNotificationsResponse -> Bool
== :: ListNotificationsResponse -> ListNotificationsResponse -> Bool
$c== :: ListNotificationsResponse -> ListNotificationsResponse -> Bool
Prelude.Eq, ReadPrec [ListNotificationsResponse]
ReadPrec ListNotificationsResponse
Int -> ReadS ListNotificationsResponse
ReadS [ListNotificationsResponse]
(Int -> ReadS ListNotificationsResponse)
-> ReadS [ListNotificationsResponse]
-> ReadPrec ListNotificationsResponse
-> ReadPrec [ListNotificationsResponse]
-> Read ListNotificationsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListNotificationsResponse]
$creadListPrec :: ReadPrec [ListNotificationsResponse]
readPrec :: ReadPrec ListNotificationsResponse
$creadPrec :: ReadPrec ListNotificationsResponse
readList :: ReadS [ListNotificationsResponse]
$creadList :: ReadS [ListNotificationsResponse]
readsPrec :: Int -> ReadS ListNotificationsResponse
$creadsPrec :: Int -> ReadS ListNotificationsResponse
Prelude.Read, Int -> ListNotificationsResponse -> ShowS
[ListNotificationsResponse] -> ShowS
ListNotificationsResponse -> String
(Int -> ListNotificationsResponse -> ShowS)
-> (ListNotificationsResponse -> String)
-> ([ListNotificationsResponse] -> ShowS)
-> Show ListNotificationsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListNotificationsResponse] -> ShowS
$cshowList :: [ListNotificationsResponse] -> ShowS
show :: ListNotificationsResponse -> String
$cshow :: ListNotificationsResponse -> String
showsPrec :: Int -> ListNotificationsResponse -> ShowS
$cshowsPrec :: Int -> ListNotificationsResponse -> ShowS
Prelude.Show, (forall x.
 ListNotificationsResponse -> Rep ListNotificationsResponse x)
-> (forall x.
    Rep ListNotificationsResponse x -> ListNotificationsResponse)
-> Generic ListNotificationsResponse
forall x.
Rep ListNotificationsResponse x -> ListNotificationsResponse
forall x.
ListNotificationsResponse -> Rep ListNotificationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListNotificationsResponse x -> ListNotificationsResponse
$cfrom :: forall x.
ListNotificationsResponse -> Rep ListNotificationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListNotificationsResponse' 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', 'listNotificationsResponse_nextToken' - The pagination token used to fetch the next set of results.
--
-- 'notifications', 'listNotificationsResponse_notifications' - The returned list of notifications.
--
-- 'httpStatus', 'listNotificationsResponse_httpStatus' - The response's http status code.
newListNotificationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListNotificationsResponse
newListNotificationsResponse :: Int -> ListNotificationsResponse
newListNotificationsResponse Int
pHttpStatus_ =
  ListNotificationsResponse' :: Maybe Text
-> Maybe [Notification] -> Int -> ListNotificationsResponse
ListNotificationsResponse'
    { $sel:nextToken:ListNotificationsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:notifications:ListNotificationsResponse' :: Maybe [Notification]
notifications = Maybe [Notification]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListNotificationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

-- | The returned list of notifications.
listNotificationsResponse_notifications :: Lens.Lens' ListNotificationsResponse (Prelude.Maybe [Notification])
listNotificationsResponse_notifications :: (Maybe [Notification] -> f (Maybe [Notification]))
-> ListNotificationsResponse -> f ListNotificationsResponse
listNotificationsResponse_notifications = (ListNotificationsResponse -> Maybe [Notification])
-> (ListNotificationsResponse
    -> Maybe [Notification] -> ListNotificationsResponse)
-> Lens
     ListNotificationsResponse
     ListNotificationsResponse
     (Maybe [Notification])
     (Maybe [Notification])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListNotificationsResponse' {Maybe [Notification]
notifications :: Maybe [Notification]
$sel:notifications:ListNotificationsResponse' :: ListNotificationsResponse -> Maybe [Notification]
notifications} -> Maybe [Notification]
notifications) (\s :: ListNotificationsResponse
s@ListNotificationsResponse' {} Maybe [Notification]
a -> ListNotificationsResponse
s {$sel:notifications:ListNotificationsResponse' :: Maybe [Notification]
notifications = Maybe [Notification]
a} :: ListNotificationsResponse) ((Maybe [Notification] -> f (Maybe [Notification]))
 -> ListNotificationsResponse -> f ListNotificationsResponse)
-> ((Maybe [Notification] -> f (Maybe [Notification]))
    -> Maybe [Notification] -> f (Maybe [Notification]))
-> (Maybe [Notification] -> f (Maybe [Notification]))
-> ListNotificationsResponse
-> f ListNotificationsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Notification] [Notification] [Notification] [Notification]
-> Iso
     (Maybe [Notification])
     (Maybe [Notification])
     (Maybe [Notification])
     (Maybe [Notification])
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 [Notification] [Notification] [Notification] [Notification]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListNotificationsResponse