{-# 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.Budgets.DescribeSubscribersForNotification
-- 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 subscribers that are associated with a notification.
--
-- This operation returns paginated results.
module Amazonka.Budgets.DescribeSubscribersForNotification
  ( -- * Creating a Request
    DescribeSubscribersForNotification (..),
    newDescribeSubscribersForNotification,

    -- * Request Lenses
    describeSubscribersForNotification_nextToken,
    describeSubscribersForNotification_maxResults,
    describeSubscribersForNotification_accountId,
    describeSubscribersForNotification_budgetName,
    describeSubscribersForNotification_notification,

    -- * Destructuring the Response
    DescribeSubscribersForNotificationResponse (..),
    newDescribeSubscribersForNotificationResponse,

    -- * Response Lenses
    describeSubscribersForNotificationResponse_nextToken,
    describeSubscribersForNotificationResponse_subscribers,
    describeSubscribersForNotificationResponse_httpStatus,
  )
where

import Amazonka.Budgets.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

-- | Request of DescribeSubscribersForNotification
--
-- /See:/ 'newDescribeSubscribersForNotification' smart constructor.
data DescribeSubscribersForNotification = DescribeSubscribersForNotification'
  { -- | The pagination token that you include in your request to indicate the
    -- next set of results that you want to retrieve.
    DescribeSubscribersForNotification -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An optional integer that represents how many entries a paginated
    -- response contains. The maximum is 100.
    DescribeSubscribersForNotification -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The @accountId@ that is associated with the budget whose subscribers you
    -- want descriptions of.
    DescribeSubscribersForNotification -> Text
accountId :: Prelude.Text,
    -- | The name of the budget whose subscribers you want descriptions of.
    DescribeSubscribersForNotification -> Text
budgetName :: Prelude.Text,
    -- | The notification whose subscribers you want to list.
    DescribeSubscribersForNotification -> Notification
notification :: Notification
  }
  deriving (DescribeSubscribersForNotification
-> DescribeSubscribersForNotification -> Bool
(DescribeSubscribersForNotification
 -> DescribeSubscribersForNotification -> Bool)
-> (DescribeSubscribersForNotification
    -> DescribeSubscribersForNotification -> Bool)
-> Eq DescribeSubscribersForNotification
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeSubscribersForNotification
-> DescribeSubscribersForNotification -> Bool
$c/= :: DescribeSubscribersForNotification
-> DescribeSubscribersForNotification -> Bool
== :: DescribeSubscribersForNotification
-> DescribeSubscribersForNotification -> Bool
$c== :: DescribeSubscribersForNotification
-> DescribeSubscribersForNotification -> Bool
Prelude.Eq, ReadPrec [DescribeSubscribersForNotification]
ReadPrec DescribeSubscribersForNotification
Int -> ReadS DescribeSubscribersForNotification
ReadS [DescribeSubscribersForNotification]
(Int -> ReadS DescribeSubscribersForNotification)
-> ReadS [DescribeSubscribersForNotification]
-> ReadPrec DescribeSubscribersForNotification
-> ReadPrec [DescribeSubscribersForNotification]
-> Read DescribeSubscribersForNotification
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeSubscribersForNotification]
$creadListPrec :: ReadPrec [DescribeSubscribersForNotification]
readPrec :: ReadPrec DescribeSubscribersForNotification
$creadPrec :: ReadPrec DescribeSubscribersForNotification
readList :: ReadS [DescribeSubscribersForNotification]
$creadList :: ReadS [DescribeSubscribersForNotification]
readsPrec :: Int -> ReadS DescribeSubscribersForNotification
$creadsPrec :: Int -> ReadS DescribeSubscribersForNotification
Prelude.Read, Int -> DescribeSubscribersForNotification -> ShowS
[DescribeSubscribersForNotification] -> ShowS
DescribeSubscribersForNotification -> String
(Int -> DescribeSubscribersForNotification -> ShowS)
-> (DescribeSubscribersForNotification -> String)
-> ([DescribeSubscribersForNotification] -> ShowS)
-> Show DescribeSubscribersForNotification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeSubscribersForNotification] -> ShowS
$cshowList :: [DescribeSubscribersForNotification] -> ShowS
show :: DescribeSubscribersForNotification -> String
$cshow :: DescribeSubscribersForNotification -> String
showsPrec :: Int -> DescribeSubscribersForNotification -> ShowS
$cshowsPrec :: Int -> DescribeSubscribersForNotification -> ShowS
Prelude.Show, (forall x.
 DescribeSubscribersForNotification
 -> Rep DescribeSubscribersForNotification x)
-> (forall x.
    Rep DescribeSubscribersForNotification x
    -> DescribeSubscribersForNotification)
-> Generic DescribeSubscribersForNotification
forall x.
Rep DescribeSubscribersForNotification x
-> DescribeSubscribersForNotification
forall x.
DescribeSubscribersForNotification
-> Rep DescribeSubscribersForNotification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeSubscribersForNotification x
-> DescribeSubscribersForNotification
$cfrom :: forall x.
DescribeSubscribersForNotification
-> Rep DescribeSubscribersForNotification x
Prelude.Generic)

-- |
-- Create a value of 'DescribeSubscribersForNotification' 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', 'describeSubscribersForNotification_nextToken' - The pagination token that you include in your request to indicate the
-- next set of results that you want to retrieve.
--
-- 'maxResults', 'describeSubscribersForNotification_maxResults' - An optional integer that represents how many entries a paginated
-- response contains. The maximum is 100.
--
-- 'accountId', 'describeSubscribersForNotification_accountId' - The @accountId@ that is associated with the budget whose subscribers you
-- want descriptions of.
--
-- 'budgetName', 'describeSubscribersForNotification_budgetName' - The name of the budget whose subscribers you want descriptions of.
--
-- 'notification', 'describeSubscribersForNotification_notification' - The notification whose subscribers you want to list.
newDescribeSubscribersForNotification ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'budgetName'
  Prelude.Text ->
  -- | 'notification'
  Notification ->
  DescribeSubscribersForNotification
newDescribeSubscribersForNotification :: Text -> Text -> Notification -> DescribeSubscribersForNotification
newDescribeSubscribersForNotification
  Text
pAccountId_
  Text
pBudgetName_
  Notification
pNotification_ =
    DescribeSubscribersForNotification' :: Maybe Text
-> Maybe Natural
-> Text
-> Text
-> Notification
-> DescribeSubscribersForNotification
DescribeSubscribersForNotification'
      { $sel:nextToken:DescribeSubscribersForNotification' :: Maybe Text
nextToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:maxResults:DescribeSubscribersForNotification' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:accountId:DescribeSubscribersForNotification' :: Text
accountId = Text
pAccountId_,
        $sel:budgetName:DescribeSubscribersForNotification' :: Text
budgetName = Text
pBudgetName_,
        $sel:notification:DescribeSubscribersForNotification' :: Notification
notification = Notification
pNotification_
      }

-- | The pagination token that you include in your request to indicate the
-- next set of results that you want to retrieve.
describeSubscribersForNotification_nextToken :: Lens.Lens' DescribeSubscribersForNotification (Prelude.Maybe Prelude.Text)
describeSubscribersForNotification_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeSubscribersForNotification
-> f DescribeSubscribersForNotification
describeSubscribersForNotification_nextToken = (DescribeSubscribersForNotification -> Maybe Text)
-> (DescribeSubscribersForNotification
    -> Maybe Text -> DescribeSubscribersForNotification)
-> Lens
     DescribeSubscribersForNotification
     DescribeSubscribersForNotification
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSubscribersForNotification' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeSubscribersForNotification' :: DescribeSubscribersForNotification -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeSubscribersForNotification
s@DescribeSubscribersForNotification' {} Maybe Text
a -> DescribeSubscribersForNotification
s {$sel:nextToken:DescribeSubscribersForNotification' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeSubscribersForNotification)

-- | An optional integer that represents how many entries a paginated
-- response contains. The maximum is 100.
describeSubscribersForNotification_maxResults :: Lens.Lens' DescribeSubscribersForNotification (Prelude.Maybe Prelude.Natural)
describeSubscribersForNotification_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> DescribeSubscribersForNotification
-> f DescribeSubscribersForNotification
describeSubscribersForNotification_maxResults = (DescribeSubscribersForNotification -> Maybe Natural)
-> (DescribeSubscribersForNotification
    -> Maybe Natural -> DescribeSubscribersForNotification)
-> Lens
     DescribeSubscribersForNotification
     DescribeSubscribersForNotification
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSubscribersForNotification' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:DescribeSubscribersForNotification' :: DescribeSubscribersForNotification -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: DescribeSubscribersForNotification
s@DescribeSubscribersForNotification' {} Maybe Natural
a -> DescribeSubscribersForNotification
s {$sel:maxResults:DescribeSubscribersForNotification' :: Maybe Natural
maxResults = Maybe Natural
a} :: DescribeSubscribersForNotification)

-- | The @accountId@ that is associated with the budget whose subscribers you
-- want descriptions of.
describeSubscribersForNotification_accountId :: Lens.Lens' DescribeSubscribersForNotification Prelude.Text
describeSubscribersForNotification_accountId :: (Text -> f Text)
-> DescribeSubscribersForNotification
-> f DescribeSubscribersForNotification
describeSubscribersForNotification_accountId = (DescribeSubscribersForNotification -> Text)
-> (DescribeSubscribersForNotification
    -> Text -> DescribeSubscribersForNotification)
-> Lens
     DescribeSubscribersForNotification
     DescribeSubscribersForNotification
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSubscribersForNotification' {Text
accountId :: Text
$sel:accountId:DescribeSubscribersForNotification' :: DescribeSubscribersForNotification -> Text
accountId} -> Text
accountId) (\s :: DescribeSubscribersForNotification
s@DescribeSubscribersForNotification' {} Text
a -> DescribeSubscribersForNotification
s {$sel:accountId:DescribeSubscribersForNotification' :: Text
accountId = Text
a} :: DescribeSubscribersForNotification)

-- | The name of the budget whose subscribers you want descriptions of.
describeSubscribersForNotification_budgetName :: Lens.Lens' DescribeSubscribersForNotification Prelude.Text
describeSubscribersForNotification_budgetName :: (Text -> f Text)
-> DescribeSubscribersForNotification
-> f DescribeSubscribersForNotification
describeSubscribersForNotification_budgetName = (DescribeSubscribersForNotification -> Text)
-> (DescribeSubscribersForNotification
    -> Text -> DescribeSubscribersForNotification)
-> Lens
     DescribeSubscribersForNotification
     DescribeSubscribersForNotification
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSubscribersForNotification' {Text
budgetName :: Text
$sel:budgetName:DescribeSubscribersForNotification' :: DescribeSubscribersForNotification -> Text
budgetName} -> Text
budgetName) (\s :: DescribeSubscribersForNotification
s@DescribeSubscribersForNotification' {} Text
a -> DescribeSubscribersForNotification
s {$sel:budgetName:DescribeSubscribersForNotification' :: Text
budgetName = Text
a} :: DescribeSubscribersForNotification)

-- | The notification whose subscribers you want to list.
describeSubscribersForNotification_notification :: Lens.Lens' DescribeSubscribersForNotification Notification
describeSubscribersForNotification_notification :: (Notification -> f Notification)
-> DescribeSubscribersForNotification
-> f DescribeSubscribersForNotification
describeSubscribersForNotification_notification = (DescribeSubscribersForNotification -> Notification)
-> (DescribeSubscribersForNotification
    -> Notification -> DescribeSubscribersForNotification)
-> Lens
     DescribeSubscribersForNotification
     DescribeSubscribersForNotification
     Notification
     Notification
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSubscribersForNotification' {Notification
notification :: Notification
$sel:notification:DescribeSubscribersForNotification' :: DescribeSubscribersForNotification -> Notification
notification} -> Notification
notification) (\s :: DescribeSubscribersForNotification
s@DescribeSubscribersForNotification' {} Notification
a -> DescribeSubscribersForNotification
s {$sel:notification:DescribeSubscribersForNotification' :: Notification
notification = Notification
a} :: DescribeSubscribersForNotification)

instance
  Core.AWSPager
    DescribeSubscribersForNotification
  where
  page :: DescribeSubscribersForNotification
-> AWSResponse DescribeSubscribersForNotification
-> Maybe DescribeSubscribersForNotification
page DescribeSubscribersForNotification
rq AWSResponse DescribeSubscribersForNotification
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeSubscribersForNotification
DescribeSubscribersForNotificationResponse
rs
            DescribeSubscribersForNotificationResponse
-> Getting
     (First Text) DescribeSubscribersForNotificationResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeSubscribersForNotificationResponse
-> Const (First Text) DescribeSubscribersForNotificationResponse
Lens' DescribeSubscribersForNotificationResponse (Maybe Text)
describeSubscribersForNotificationResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeSubscribersForNotificationResponse
 -> Const (First Text) DescribeSubscribersForNotificationResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting
     (First Text) DescribeSubscribersForNotificationResponse 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 DescribeSubscribersForNotification
forall a. Maybe a
Prelude.Nothing
    | Maybe [Subscriber] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeSubscribersForNotification
DescribeSubscribersForNotificationResponse
rs
            DescribeSubscribersForNotificationResponse
-> Getting
     (First [Subscriber])
     DescribeSubscribersForNotificationResponse
     [Subscriber]
-> Maybe [Subscriber]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe (NonEmpty Subscriber)
 -> Const (First [Subscriber]) (Maybe (NonEmpty Subscriber)))
-> DescribeSubscribersForNotificationResponse
-> Const
     (First [Subscriber]) DescribeSubscribersForNotificationResponse
Lens'
  DescribeSubscribersForNotificationResponse
  (Maybe (NonEmpty Subscriber))
describeSubscribersForNotificationResponse_subscribers
              ((Maybe (NonEmpty Subscriber)
  -> Const (First [Subscriber]) (Maybe (NonEmpty Subscriber)))
 -> DescribeSubscribersForNotificationResponse
 -> Const
      (First [Subscriber]) DescribeSubscribersForNotificationResponse)
-> (([Subscriber] -> Const (First [Subscriber]) [Subscriber])
    -> Maybe (NonEmpty Subscriber)
    -> Const (First [Subscriber]) (Maybe (NonEmpty Subscriber)))
-> Getting
     (First [Subscriber])
     DescribeSubscribersForNotificationResponse
     [Subscriber]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Subscriber
 -> Const (First [Subscriber]) (NonEmpty Subscriber))
-> Maybe (NonEmpty Subscriber)
-> Const (First [Subscriber]) (Maybe (NonEmpty Subscriber))
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
              ((NonEmpty Subscriber
  -> Const (First [Subscriber]) (NonEmpty Subscriber))
 -> Maybe (NonEmpty Subscriber)
 -> Const (First [Subscriber]) (Maybe (NonEmpty Subscriber)))
-> (([Subscriber] -> Const (First [Subscriber]) [Subscriber])
    -> NonEmpty Subscriber
    -> Const (First [Subscriber]) (NonEmpty Subscriber))
-> ([Subscriber] -> Const (First [Subscriber]) [Subscriber])
-> Maybe (NonEmpty Subscriber)
-> Const (First [Subscriber]) (Maybe (NonEmpty Subscriber))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Subscriber -> [Subscriber])
-> ([Subscriber] -> Const (First [Subscriber]) [Subscriber])
-> NonEmpty Subscriber
-> Const (First [Subscriber]) (NonEmpty Subscriber)
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to NonEmpty Subscriber -> [Subscriber]
forall l. IsList l => l -> [Item l]
Prelude.toList
        ) =
      Maybe DescribeSubscribersForNotification
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeSubscribersForNotification
-> Maybe DescribeSubscribersForNotification
forall a. a -> Maybe a
Prelude.Just (DescribeSubscribersForNotification
 -> Maybe DescribeSubscribersForNotification)
-> DescribeSubscribersForNotification
-> Maybe DescribeSubscribersForNotification
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeSubscribersForNotification
rq
          DescribeSubscribersForNotification
-> (DescribeSubscribersForNotification
    -> DescribeSubscribersForNotification)
-> DescribeSubscribersForNotification
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeSubscribersForNotification
-> Identity DescribeSubscribersForNotification
Lens
  DescribeSubscribersForNotification
  DescribeSubscribersForNotification
  (Maybe Text)
  (Maybe Text)
describeSubscribersForNotification_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeSubscribersForNotification
 -> Identity DescribeSubscribersForNotification)
-> Maybe Text
-> DescribeSubscribersForNotification
-> DescribeSubscribersForNotification
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeSubscribersForNotification
DescribeSubscribersForNotificationResponse
rs
          DescribeSubscribersForNotificationResponse
-> Getting
     (First Text) DescribeSubscribersForNotificationResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeSubscribersForNotificationResponse
-> Const (First Text) DescribeSubscribersForNotificationResponse
Lens' DescribeSubscribersForNotificationResponse (Maybe Text)
describeSubscribersForNotificationResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeSubscribersForNotificationResponse
 -> Const (First Text) DescribeSubscribersForNotificationResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting
     (First Text) DescribeSubscribersForNotificationResponse 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
    DescribeSubscribersForNotification
  where
  type
    AWSResponse DescribeSubscribersForNotification =
      DescribeSubscribersForNotificationResponse
  request :: DescribeSubscribersForNotification
-> Request DescribeSubscribersForNotification
request = Service
-> DescribeSubscribersForNotification
-> Request DescribeSubscribersForNotification
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeSubscribersForNotification
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeSubscribersForNotification)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeSubscribersForNotification))
-> Logger
-> Service
-> Proxy DescribeSubscribersForNotification
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeSubscribersForNotification)))
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 (NonEmpty Subscriber)
-> Int
-> DescribeSubscribersForNotificationResponse
DescribeSubscribersForNotificationResponse'
            (Maybe Text
 -> Maybe (NonEmpty Subscriber)
 -> Int
 -> DescribeSubscribersForNotificationResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe (NonEmpty Subscriber)
      -> Int -> DescribeSubscribersForNotificationResponse)
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 (NonEmpty Subscriber)
   -> Int -> DescribeSubscribersForNotificationResponse)
-> Either String (Maybe (NonEmpty Subscriber))
-> Either
     String (Int -> DescribeSubscribersForNotificationResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (NonEmpty Subscriber))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Subscribers")
              Either String (Int -> DescribeSubscribersForNotificationResponse)
-> Either String Int
-> Either String DescribeSubscribersForNotificationResponse
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
    DescribeSubscribersForNotification

instance
  Prelude.NFData
    DescribeSubscribersForNotification

instance
  Core.ToHeaders
    DescribeSubscribersForNotification
  where
  toHeaders :: DescribeSubscribersForNotification -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> DescribeSubscribersForNotification -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSBudgetServiceGateway.DescribeSubscribersForNotification" ::
                          Prelude.ByteString
                      ),
            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.ToJSON
    DescribeSubscribersForNotification
  where
  toJSON :: DescribeSubscribersForNotification -> Value
toJSON DescribeSubscribersForNotification' {Maybe Natural
Maybe Text
Text
Notification
notification :: Notification
budgetName :: Text
accountId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:notification:DescribeSubscribersForNotification' :: DescribeSubscribersForNotification -> Notification
$sel:budgetName:DescribeSubscribersForNotification' :: DescribeSubscribersForNotification -> Text
$sel:accountId:DescribeSubscribersForNotification' :: DescribeSubscribersForNotification -> Text
$sel:maxResults:DescribeSubscribersForNotification' :: DescribeSubscribersForNotification -> Maybe Natural
$sel:nextToken:DescribeSubscribersForNotification' :: DescribeSubscribersForNotification -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AccountId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
accountId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"BudgetName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
budgetName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Notification" Text -> Notification -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Notification
notification)
          ]
      )

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

instance
  Core.ToQuery
    DescribeSubscribersForNotification
  where
  toQuery :: DescribeSubscribersForNotification -> QueryString
toQuery = QueryString -> DescribeSubscribersForNotification -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | Response of DescribeSubscribersForNotification
--
-- /See:/ 'newDescribeSubscribersForNotificationResponse' smart constructor.
data DescribeSubscribersForNotificationResponse = DescribeSubscribersForNotificationResponse'
  { -- | The pagination token in the service response that indicates the next set
    -- of results that you can retrieve.
    DescribeSubscribersForNotificationResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of subscribers that are associated with a notification.
    DescribeSubscribersForNotificationResponse
-> Maybe (NonEmpty Subscriber)
subscribers :: Prelude.Maybe (Prelude.NonEmpty Subscriber),
    -- | The response's http status code.
    DescribeSubscribersForNotificationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeSubscribersForNotificationResponse
-> DescribeSubscribersForNotificationResponse -> Bool
(DescribeSubscribersForNotificationResponse
 -> DescribeSubscribersForNotificationResponse -> Bool)
-> (DescribeSubscribersForNotificationResponse
    -> DescribeSubscribersForNotificationResponse -> Bool)
-> Eq DescribeSubscribersForNotificationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeSubscribersForNotificationResponse
-> DescribeSubscribersForNotificationResponse -> Bool
$c/= :: DescribeSubscribersForNotificationResponse
-> DescribeSubscribersForNotificationResponse -> Bool
== :: DescribeSubscribersForNotificationResponse
-> DescribeSubscribersForNotificationResponse -> Bool
$c== :: DescribeSubscribersForNotificationResponse
-> DescribeSubscribersForNotificationResponse -> Bool
Prelude.Eq, Int -> DescribeSubscribersForNotificationResponse -> ShowS
[DescribeSubscribersForNotificationResponse] -> ShowS
DescribeSubscribersForNotificationResponse -> String
(Int -> DescribeSubscribersForNotificationResponse -> ShowS)
-> (DescribeSubscribersForNotificationResponse -> String)
-> ([DescribeSubscribersForNotificationResponse] -> ShowS)
-> Show DescribeSubscribersForNotificationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeSubscribersForNotificationResponse] -> ShowS
$cshowList :: [DescribeSubscribersForNotificationResponse] -> ShowS
show :: DescribeSubscribersForNotificationResponse -> String
$cshow :: DescribeSubscribersForNotificationResponse -> String
showsPrec :: Int -> DescribeSubscribersForNotificationResponse -> ShowS
$cshowsPrec :: Int -> DescribeSubscribersForNotificationResponse -> ShowS
Prelude.Show, (forall x.
 DescribeSubscribersForNotificationResponse
 -> Rep DescribeSubscribersForNotificationResponse x)
-> (forall x.
    Rep DescribeSubscribersForNotificationResponse x
    -> DescribeSubscribersForNotificationResponse)
-> Generic DescribeSubscribersForNotificationResponse
forall x.
Rep DescribeSubscribersForNotificationResponse x
-> DescribeSubscribersForNotificationResponse
forall x.
DescribeSubscribersForNotificationResponse
-> Rep DescribeSubscribersForNotificationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeSubscribersForNotificationResponse x
-> DescribeSubscribersForNotificationResponse
$cfrom :: forall x.
DescribeSubscribersForNotificationResponse
-> Rep DescribeSubscribersForNotificationResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeSubscribersForNotificationResponse' 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', 'describeSubscribersForNotificationResponse_nextToken' - The pagination token in the service response that indicates the next set
-- of results that you can retrieve.
--
-- 'subscribers', 'describeSubscribersForNotificationResponse_subscribers' - A list of subscribers that are associated with a notification.
--
-- 'httpStatus', 'describeSubscribersForNotificationResponse_httpStatus' - The response's http status code.
newDescribeSubscribersForNotificationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeSubscribersForNotificationResponse
newDescribeSubscribersForNotificationResponse :: Int -> DescribeSubscribersForNotificationResponse
newDescribeSubscribersForNotificationResponse
  Int
pHttpStatus_ =
    DescribeSubscribersForNotificationResponse' :: Maybe Text
-> Maybe (NonEmpty Subscriber)
-> Int
-> DescribeSubscribersForNotificationResponse
DescribeSubscribersForNotificationResponse'
      { $sel:nextToken:DescribeSubscribersForNotificationResponse' :: Maybe Text
nextToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:subscribers:DescribeSubscribersForNotificationResponse' :: Maybe (NonEmpty Subscriber)
subscribers = Maybe (NonEmpty Subscriber)
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DescribeSubscribersForNotificationResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The pagination token in the service response that indicates the next set
-- of results that you can retrieve.
describeSubscribersForNotificationResponse_nextToken :: Lens.Lens' DescribeSubscribersForNotificationResponse (Prelude.Maybe Prelude.Text)
describeSubscribersForNotificationResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeSubscribersForNotificationResponse
-> f DescribeSubscribersForNotificationResponse
describeSubscribersForNotificationResponse_nextToken = (DescribeSubscribersForNotificationResponse -> Maybe Text)
-> (DescribeSubscribersForNotificationResponse
    -> Maybe Text -> DescribeSubscribersForNotificationResponse)
-> Lens' DescribeSubscribersForNotificationResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSubscribersForNotificationResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeSubscribersForNotificationResponse' :: DescribeSubscribersForNotificationResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeSubscribersForNotificationResponse
s@DescribeSubscribersForNotificationResponse' {} Maybe Text
a -> DescribeSubscribersForNotificationResponse
s {$sel:nextToken:DescribeSubscribersForNotificationResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeSubscribersForNotificationResponse)

-- | A list of subscribers that are associated with a notification.
describeSubscribersForNotificationResponse_subscribers :: Lens.Lens' DescribeSubscribersForNotificationResponse (Prelude.Maybe (Prelude.NonEmpty Subscriber))
describeSubscribersForNotificationResponse_subscribers :: (Maybe (NonEmpty Subscriber) -> f (Maybe (NonEmpty Subscriber)))
-> DescribeSubscribersForNotificationResponse
-> f DescribeSubscribersForNotificationResponse
describeSubscribersForNotificationResponse_subscribers = (DescribeSubscribersForNotificationResponse
 -> Maybe (NonEmpty Subscriber))
-> (DescribeSubscribersForNotificationResponse
    -> Maybe (NonEmpty Subscriber)
    -> DescribeSubscribersForNotificationResponse)
-> Lens'
     DescribeSubscribersForNotificationResponse
     (Maybe (NonEmpty Subscriber))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSubscribersForNotificationResponse' {Maybe (NonEmpty Subscriber)
subscribers :: Maybe (NonEmpty Subscriber)
$sel:subscribers:DescribeSubscribersForNotificationResponse' :: DescribeSubscribersForNotificationResponse
-> Maybe (NonEmpty Subscriber)
subscribers} -> Maybe (NonEmpty Subscriber)
subscribers) (\s :: DescribeSubscribersForNotificationResponse
s@DescribeSubscribersForNotificationResponse' {} Maybe (NonEmpty Subscriber)
a -> DescribeSubscribersForNotificationResponse
s {$sel:subscribers:DescribeSubscribersForNotificationResponse' :: Maybe (NonEmpty Subscriber)
subscribers = Maybe (NonEmpty Subscriber)
a} :: DescribeSubscribersForNotificationResponse) ((Maybe (NonEmpty Subscriber) -> f (Maybe (NonEmpty Subscriber)))
 -> DescribeSubscribersForNotificationResponse
 -> f DescribeSubscribersForNotificationResponse)
-> ((Maybe (NonEmpty Subscriber)
     -> f (Maybe (NonEmpty Subscriber)))
    -> Maybe (NonEmpty Subscriber) -> f (Maybe (NonEmpty Subscriber)))
-> (Maybe (NonEmpty Subscriber) -> f (Maybe (NonEmpty Subscriber)))
-> DescribeSubscribersForNotificationResponse
-> f DescribeSubscribersForNotificationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Subscriber)
  (NonEmpty Subscriber)
  (NonEmpty Subscriber)
  (NonEmpty Subscriber)
-> Iso
     (Maybe (NonEmpty Subscriber))
     (Maybe (NonEmpty Subscriber))
     (Maybe (NonEmpty Subscriber))
     (Maybe (NonEmpty Subscriber))
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
  (NonEmpty Subscriber)
  (NonEmpty Subscriber)
  (NonEmpty Subscriber)
  (NonEmpty Subscriber)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    DescribeSubscribersForNotificationResponse