{-# 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.DescribeBudgetPerformanceHistory
-- 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)
--
-- Describes the history for @DAILY@, @MONTHLY@, and @QUARTERLY@ budgets.
-- Budget history isn\'t available for @ANNUAL@ budgets.
--
-- This operation returns paginated results.
module Amazonka.Budgets.DescribeBudgetPerformanceHistory
  ( -- * Creating a Request
    DescribeBudgetPerformanceHistory (..),
    newDescribeBudgetPerformanceHistory,

    -- * Request Lenses
    describeBudgetPerformanceHistory_timePeriod,
    describeBudgetPerformanceHistory_nextToken,
    describeBudgetPerformanceHistory_maxResults,
    describeBudgetPerformanceHistory_accountId,
    describeBudgetPerformanceHistory_budgetName,

    -- * Destructuring the Response
    DescribeBudgetPerformanceHistoryResponse (..),
    newDescribeBudgetPerformanceHistoryResponse,

    -- * Response Lenses
    describeBudgetPerformanceHistoryResponse_budgetPerformanceHistory,
    describeBudgetPerformanceHistoryResponse_nextToken,
    describeBudgetPerformanceHistoryResponse_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

-- | /See:/ 'newDescribeBudgetPerformanceHistory' smart constructor.
data DescribeBudgetPerformanceHistory = DescribeBudgetPerformanceHistory'
  { -- | Retrieves how often the budget went into an @ALARM@ state for the
    -- specified time period.
    DescribeBudgetPerformanceHistory -> Maybe TimePeriod
timePeriod :: Prelude.Maybe TimePeriod,
    DescribeBudgetPerformanceHistory -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    DescribeBudgetPerformanceHistory -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    DescribeBudgetPerformanceHistory -> Text
accountId :: Prelude.Text,
    DescribeBudgetPerformanceHistory -> Text
budgetName :: Prelude.Text
  }
  deriving (DescribeBudgetPerformanceHistory
-> DescribeBudgetPerformanceHistory -> Bool
(DescribeBudgetPerformanceHistory
 -> DescribeBudgetPerformanceHistory -> Bool)
-> (DescribeBudgetPerformanceHistory
    -> DescribeBudgetPerformanceHistory -> Bool)
-> Eq DescribeBudgetPerformanceHistory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeBudgetPerformanceHistory
-> DescribeBudgetPerformanceHistory -> Bool
$c/= :: DescribeBudgetPerformanceHistory
-> DescribeBudgetPerformanceHistory -> Bool
== :: DescribeBudgetPerformanceHistory
-> DescribeBudgetPerformanceHistory -> Bool
$c== :: DescribeBudgetPerformanceHistory
-> DescribeBudgetPerformanceHistory -> Bool
Prelude.Eq, ReadPrec [DescribeBudgetPerformanceHistory]
ReadPrec DescribeBudgetPerformanceHistory
Int -> ReadS DescribeBudgetPerformanceHistory
ReadS [DescribeBudgetPerformanceHistory]
(Int -> ReadS DescribeBudgetPerformanceHistory)
-> ReadS [DescribeBudgetPerformanceHistory]
-> ReadPrec DescribeBudgetPerformanceHistory
-> ReadPrec [DescribeBudgetPerformanceHistory]
-> Read DescribeBudgetPerformanceHistory
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeBudgetPerformanceHistory]
$creadListPrec :: ReadPrec [DescribeBudgetPerformanceHistory]
readPrec :: ReadPrec DescribeBudgetPerformanceHistory
$creadPrec :: ReadPrec DescribeBudgetPerformanceHistory
readList :: ReadS [DescribeBudgetPerformanceHistory]
$creadList :: ReadS [DescribeBudgetPerformanceHistory]
readsPrec :: Int -> ReadS DescribeBudgetPerformanceHistory
$creadsPrec :: Int -> ReadS DescribeBudgetPerformanceHistory
Prelude.Read, Int -> DescribeBudgetPerformanceHistory -> ShowS
[DescribeBudgetPerformanceHistory] -> ShowS
DescribeBudgetPerformanceHistory -> String
(Int -> DescribeBudgetPerformanceHistory -> ShowS)
-> (DescribeBudgetPerformanceHistory -> String)
-> ([DescribeBudgetPerformanceHistory] -> ShowS)
-> Show DescribeBudgetPerformanceHistory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeBudgetPerformanceHistory] -> ShowS
$cshowList :: [DescribeBudgetPerformanceHistory] -> ShowS
show :: DescribeBudgetPerformanceHistory -> String
$cshow :: DescribeBudgetPerformanceHistory -> String
showsPrec :: Int -> DescribeBudgetPerformanceHistory -> ShowS
$cshowsPrec :: Int -> DescribeBudgetPerformanceHistory -> ShowS
Prelude.Show, (forall x.
 DescribeBudgetPerformanceHistory
 -> Rep DescribeBudgetPerformanceHistory x)
-> (forall x.
    Rep DescribeBudgetPerformanceHistory x
    -> DescribeBudgetPerformanceHistory)
-> Generic DescribeBudgetPerformanceHistory
forall x.
Rep DescribeBudgetPerformanceHistory x
-> DescribeBudgetPerformanceHistory
forall x.
DescribeBudgetPerformanceHistory
-> Rep DescribeBudgetPerformanceHistory x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeBudgetPerformanceHistory x
-> DescribeBudgetPerformanceHistory
$cfrom :: forall x.
DescribeBudgetPerformanceHistory
-> Rep DescribeBudgetPerformanceHistory x
Prelude.Generic)

-- |
-- Create a value of 'DescribeBudgetPerformanceHistory' 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:
--
-- 'timePeriod', 'describeBudgetPerformanceHistory_timePeriod' - Retrieves how often the budget went into an @ALARM@ state for the
-- specified time period.
--
-- 'nextToken', 'describeBudgetPerformanceHistory_nextToken' - Undocumented member.
--
-- 'maxResults', 'describeBudgetPerformanceHistory_maxResults' - Undocumented member.
--
-- 'accountId', 'describeBudgetPerformanceHistory_accountId' - Undocumented member.
--
-- 'budgetName', 'describeBudgetPerformanceHistory_budgetName' - Undocumented member.
newDescribeBudgetPerformanceHistory ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'budgetName'
  Prelude.Text ->
  DescribeBudgetPerformanceHistory
newDescribeBudgetPerformanceHistory :: Text -> Text -> DescribeBudgetPerformanceHistory
newDescribeBudgetPerformanceHistory
  Text
pAccountId_
  Text
pBudgetName_ =
    DescribeBudgetPerformanceHistory' :: Maybe TimePeriod
-> Maybe Text
-> Maybe Natural
-> Text
-> Text
-> DescribeBudgetPerformanceHistory
DescribeBudgetPerformanceHistory'
      { $sel:timePeriod:DescribeBudgetPerformanceHistory' :: Maybe TimePeriod
timePeriod =
          Maybe TimePeriod
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:DescribeBudgetPerformanceHistory' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:maxResults:DescribeBudgetPerformanceHistory' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:accountId:DescribeBudgetPerformanceHistory' :: Text
accountId = Text
pAccountId_,
        $sel:budgetName:DescribeBudgetPerformanceHistory' :: Text
budgetName = Text
pBudgetName_
      }

-- | Retrieves how often the budget went into an @ALARM@ state for the
-- specified time period.
describeBudgetPerformanceHistory_timePeriod :: Lens.Lens' DescribeBudgetPerformanceHistory (Prelude.Maybe TimePeriod)
describeBudgetPerformanceHistory_timePeriod :: (Maybe TimePeriod -> f (Maybe TimePeriod))
-> DescribeBudgetPerformanceHistory
-> f DescribeBudgetPerformanceHistory
describeBudgetPerformanceHistory_timePeriod = (DescribeBudgetPerformanceHistory -> Maybe TimePeriod)
-> (DescribeBudgetPerformanceHistory
    -> Maybe TimePeriod -> DescribeBudgetPerformanceHistory)
-> Lens
     DescribeBudgetPerformanceHistory
     DescribeBudgetPerformanceHistory
     (Maybe TimePeriod)
     (Maybe TimePeriod)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBudgetPerformanceHistory' {Maybe TimePeriod
timePeriod :: Maybe TimePeriod
$sel:timePeriod:DescribeBudgetPerformanceHistory' :: DescribeBudgetPerformanceHistory -> Maybe TimePeriod
timePeriod} -> Maybe TimePeriod
timePeriod) (\s :: DescribeBudgetPerformanceHistory
s@DescribeBudgetPerformanceHistory' {} Maybe TimePeriod
a -> DescribeBudgetPerformanceHistory
s {$sel:timePeriod:DescribeBudgetPerformanceHistory' :: Maybe TimePeriod
timePeriod = Maybe TimePeriod
a} :: DescribeBudgetPerformanceHistory)

-- | Undocumented member.
describeBudgetPerformanceHistory_nextToken :: Lens.Lens' DescribeBudgetPerformanceHistory (Prelude.Maybe Prelude.Text)
describeBudgetPerformanceHistory_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeBudgetPerformanceHistory
-> f DescribeBudgetPerformanceHistory
describeBudgetPerformanceHistory_nextToken = (DescribeBudgetPerformanceHistory -> Maybe Text)
-> (DescribeBudgetPerformanceHistory
    -> Maybe Text -> DescribeBudgetPerformanceHistory)
-> Lens
     DescribeBudgetPerformanceHistory
     DescribeBudgetPerformanceHistory
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBudgetPerformanceHistory' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeBudgetPerformanceHistory' :: DescribeBudgetPerformanceHistory -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeBudgetPerformanceHistory
s@DescribeBudgetPerformanceHistory' {} Maybe Text
a -> DescribeBudgetPerformanceHistory
s {$sel:nextToken:DescribeBudgetPerformanceHistory' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeBudgetPerformanceHistory)

-- | Undocumented member.
describeBudgetPerformanceHistory_maxResults :: Lens.Lens' DescribeBudgetPerformanceHistory (Prelude.Maybe Prelude.Natural)
describeBudgetPerformanceHistory_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> DescribeBudgetPerformanceHistory
-> f DescribeBudgetPerformanceHistory
describeBudgetPerformanceHistory_maxResults = (DescribeBudgetPerformanceHistory -> Maybe Natural)
-> (DescribeBudgetPerformanceHistory
    -> Maybe Natural -> DescribeBudgetPerformanceHistory)
-> Lens
     DescribeBudgetPerformanceHistory
     DescribeBudgetPerformanceHistory
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBudgetPerformanceHistory' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:DescribeBudgetPerformanceHistory' :: DescribeBudgetPerformanceHistory -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: DescribeBudgetPerformanceHistory
s@DescribeBudgetPerformanceHistory' {} Maybe Natural
a -> DescribeBudgetPerformanceHistory
s {$sel:maxResults:DescribeBudgetPerformanceHistory' :: Maybe Natural
maxResults = Maybe Natural
a} :: DescribeBudgetPerformanceHistory)

-- | Undocumented member.
describeBudgetPerformanceHistory_accountId :: Lens.Lens' DescribeBudgetPerformanceHistory Prelude.Text
describeBudgetPerformanceHistory_accountId :: (Text -> f Text)
-> DescribeBudgetPerformanceHistory
-> f DescribeBudgetPerformanceHistory
describeBudgetPerformanceHistory_accountId = (DescribeBudgetPerformanceHistory -> Text)
-> (DescribeBudgetPerformanceHistory
    -> Text -> DescribeBudgetPerformanceHistory)
-> Lens
     DescribeBudgetPerformanceHistory
     DescribeBudgetPerformanceHistory
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBudgetPerformanceHistory' {Text
accountId :: Text
$sel:accountId:DescribeBudgetPerformanceHistory' :: DescribeBudgetPerformanceHistory -> Text
accountId} -> Text
accountId) (\s :: DescribeBudgetPerformanceHistory
s@DescribeBudgetPerformanceHistory' {} Text
a -> DescribeBudgetPerformanceHistory
s {$sel:accountId:DescribeBudgetPerformanceHistory' :: Text
accountId = Text
a} :: DescribeBudgetPerformanceHistory)

-- | Undocumented member.
describeBudgetPerformanceHistory_budgetName :: Lens.Lens' DescribeBudgetPerformanceHistory Prelude.Text
describeBudgetPerformanceHistory_budgetName :: (Text -> f Text)
-> DescribeBudgetPerformanceHistory
-> f DescribeBudgetPerformanceHistory
describeBudgetPerformanceHistory_budgetName = (DescribeBudgetPerformanceHistory -> Text)
-> (DescribeBudgetPerformanceHistory
    -> Text -> DescribeBudgetPerformanceHistory)
-> Lens
     DescribeBudgetPerformanceHistory
     DescribeBudgetPerformanceHistory
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBudgetPerformanceHistory' {Text
budgetName :: Text
$sel:budgetName:DescribeBudgetPerformanceHistory' :: DescribeBudgetPerformanceHistory -> Text
budgetName} -> Text
budgetName) (\s :: DescribeBudgetPerformanceHistory
s@DescribeBudgetPerformanceHistory' {} Text
a -> DescribeBudgetPerformanceHistory
s {$sel:budgetName:DescribeBudgetPerformanceHistory' :: Text
budgetName = Text
a} :: DescribeBudgetPerformanceHistory)

instance
  Core.AWSPager
    DescribeBudgetPerformanceHistory
  where
  page :: DescribeBudgetPerformanceHistory
-> AWSResponse DescribeBudgetPerformanceHistory
-> Maybe DescribeBudgetPerformanceHistory
page DescribeBudgetPerformanceHistory
rq AWSResponse DescribeBudgetPerformanceHistory
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeBudgetPerformanceHistory
DescribeBudgetPerformanceHistoryResponse
rs
            DescribeBudgetPerformanceHistoryResponse
-> Getting
     (First Text) DescribeBudgetPerformanceHistoryResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeBudgetPerformanceHistoryResponse
-> Const (First Text) DescribeBudgetPerformanceHistoryResponse
Lens' DescribeBudgetPerformanceHistoryResponse (Maybe Text)
describeBudgetPerformanceHistoryResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeBudgetPerformanceHistoryResponse
 -> Const (First Text) DescribeBudgetPerformanceHistoryResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting
     (First Text) DescribeBudgetPerformanceHistoryResponse 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 DescribeBudgetPerformanceHistory
forall a. Maybe a
Prelude.Nothing
    | Maybe BudgetPerformanceHistory -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeBudgetPerformanceHistory
DescribeBudgetPerformanceHistoryResponse
rs
            DescribeBudgetPerformanceHistoryResponse
-> Getting
     (First BudgetPerformanceHistory)
     DescribeBudgetPerformanceHistoryResponse
     BudgetPerformanceHistory
-> Maybe BudgetPerformanceHistory
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe BudgetPerformanceHistory
 -> Const
      (First BudgetPerformanceHistory) (Maybe BudgetPerformanceHistory))
-> DescribeBudgetPerformanceHistoryResponse
-> Const
     (First BudgetPerformanceHistory)
     DescribeBudgetPerformanceHistoryResponse
Lens'
  DescribeBudgetPerformanceHistoryResponse
  (Maybe BudgetPerformanceHistory)
describeBudgetPerformanceHistoryResponse_budgetPerformanceHistory
              ((Maybe BudgetPerformanceHistory
  -> Const
       (First BudgetPerformanceHistory) (Maybe BudgetPerformanceHistory))
 -> DescribeBudgetPerformanceHistoryResponse
 -> Const
      (First BudgetPerformanceHistory)
      DescribeBudgetPerformanceHistoryResponse)
-> ((BudgetPerformanceHistory
     -> Const (First BudgetPerformanceHistory) BudgetPerformanceHistory)
    -> Maybe BudgetPerformanceHistory
    -> Const
         (First BudgetPerformanceHistory) (Maybe BudgetPerformanceHistory))
-> Getting
     (First BudgetPerformanceHistory)
     DescribeBudgetPerformanceHistoryResponse
     BudgetPerformanceHistory
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (BudgetPerformanceHistory
 -> Const (First BudgetPerformanceHistory) BudgetPerformanceHistory)
-> Maybe BudgetPerformanceHistory
-> Const
     (First BudgetPerformanceHistory) (Maybe BudgetPerformanceHistory)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeBudgetPerformanceHistory
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeBudgetPerformanceHistory
-> Maybe DescribeBudgetPerformanceHistory
forall a. a -> Maybe a
Prelude.Just (DescribeBudgetPerformanceHistory
 -> Maybe DescribeBudgetPerformanceHistory)
-> DescribeBudgetPerformanceHistory
-> Maybe DescribeBudgetPerformanceHistory
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeBudgetPerformanceHistory
rq
          DescribeBudgetPerformanceHistory
-> (DescribeBudgetPerformanceHistory
    -> DescribeBudgetPerformanceHistory)
-> DescribeBudgetPerformanceHistory
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeBudgetPerformanceHistory
-> Identity DescribeBudgetPerformanceHistory
Lens
  DescribeBudgetPerformanceHistory
  DescribeBudgetPerformanceHistory
  (Maybe Text)
  (Maybe Text)
describeBudgetPerformanceHistory_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeBudgetPerformanceHistory
 -> Identity DescribeBudgetPerformanceHistory)
-> Maybe Text
-> DescribeBudgetPerformanceHistory
-> DescribeBudgetPerformanceHistory
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeBudgetPerformanceHistory
DescribeBudgetPerformanceHistoryResponse
rs
          DescribeBudgetPerformanceHistoryResponse
-> Getting
     (First Text) DescribeBudgetPerformanceHistoryResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeBudgetPerformanceHistoryResponse
-> Const (First Text) DescribeBudgetPerformanceHistoryResponse
Lens' DescribeBudgetPerformanceHistoryResponse (Maybe Text)
describeBudgetPerformanceHistoryResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeBudgetPerformanceHistoryResponse
 -> Const (First Text) DescribeBudgetPerformanceHistoryResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting
     (First Text) DescribeBudgetPerformanceHistoryResponse 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
    DescribeBudgetPerformanceHistory
  where
  type
    AWSResponse DescribeBudgetPerformanceHistory =
      DescribeBudgetPerformanceHistoryResponse
  request :: DescribeBudgetPerformanceHistory
-> Request DescribeBudgetPerformanceHistory
request = Service
-> DescribeBudgetPerformanceHistory
-> Request DescribeBudgetPerformanceHistory
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeBudgetPerformanceHistory
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeBudgetPerformanceHistory)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeBudgetPerformanceHistory))
-> Logger
-> Service
-> Proxy DescribeBudgetPerformanceHistory
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeBudgetPerformanceHistory)))
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 BudgetPerformanceHistory
-> Maybe Text -> Int -> DescribeBudgetPerformanceHistoryResponse
DescribeBudgetPerformanceHistoryResponse'
            (Maybe BudgetPerformanceHistory
 -> Maybe Text -> Int -> DescribeBudgetPerformanceHistoryResponse)
-> Either String (Maybe BudgetPerformanceHistory)
-> Either
     String
     (Maybe Text -> Int -> DescribeBudgetPerformanceHistoryResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe BudgetPerformanceHistory)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"BudgetPerformanceHistory")
            Either
  String
  (Maybe Text -> Int -> DescribeBudgetPerformanceHistoryResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeBudgetPerformanceHistoryResponse)
forall (f :: * -> *) a b. Applicative f => 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 (Int -> DescribeBudgetPerformanceHistoryResponse)
-> Either String Int
-> Either String DescribeBudgetPerformanceHistoryResponse
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
    DescribeBudgetPerformanceHistory

instance
  Prelude.NFData
    DescribeBudgetPerformanceHistory

instance
  Core.ToHeaders
    DescribeBudgetPerformanceHistory
  where
  toHeaders :: DescribeBudgetPerformanceHistory -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> DescribeBudgetPerformanceHistory -> 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.DescribeBudgetPerformanceHistory" ::
                          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 DescribeBudgetPerformanceHistory where
  toJSON :: DescribeBudgetPerformanceHistory -> Value
toJSON DescribeBudgetPerformanceHistory' {Maybe Natural
Maybe Text
Maybe TimePeriod
Text
budgetName :: Text
accountId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
timePeriod :: Maybe TimePeriod
$sel:budgetName:DescribeBudgetPerformanceHistory' :: DescribeBudgetPerformanceHistory -> Text
$sel:accountId:DescribeBudgetPerformanceHistory' :: DescribeBudgetPerformanceHistory -> Text
$sel:maxResults:DescribeBudgetPerformanceHistory' :: DescribeBudgetPerformanceHistory -> Maybe Natural
$sel:nextToken:DescribeBudgetPerformanceHistory' :: DescribeBudgetPerformanceHistory -> Maybe Text
$sel:timePeriod:DescribeBudgetPerformanceHistory' :: DescribeBudgetPerformanceHistory -> Maybe TimePeriod
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TimePeriod" Text -> TimePeriod -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TimePeriod -> Pair) -> Maybe TimePeriod -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TimePeriod
timePeriod,
            (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)
          ]
      )

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

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

-- | /See:/ 'newDescribeBudgetPerformanceHistoryResponse' smart constructor.
data DescribeBudgetPerformanceHistoryResponse = DescribeBudgetPerformanceHistoryResponse'
  { -- | The history of how often the budget has gone into an @ALARM@ state.
    --
    -- For @DAILY@ budgets, the history saves the state of the budget for the
    -- last 60 days. For @MONTHLY@ budgets, the history saves the state of the
    -- budget for the current month plus the last 12 months. For @QUARTERLY@
    -- budgets, the history saves the state of the budget for the last four
    -- quarters.
    DescribeBudgetPerformanceHistoryResponse
-> Maybe BudgetPerformanceHistory
budgetPerformanceHistory :: Prelude.Maybe BudgetPerformanceHistory,
    DescribeBudgetPerformanceHistoryResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeBudgetPerformanceHistoryResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeBudgetPerformanceHistoryResponse
-> DescribeBudgetPerformanceHistoryResponse -> Bool
(DescribeBudgetPerformanceHistoryResponse
 -> DescribeBudgetPerformanceHistoryResponse -> Bool)
-> (DescribeBudgetPerformanceHistoryResponse
    -> DescribeBudgetPerformanceHistoryResponse -> Bool)
-> Eq DescribeBudgetPerformanceHistoryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeBudgetPerformanceHistoryResponse
-> DescribeBudgetPerformanceHistoryResponse -> Bool
$c/= :: DescribeBudgetPerformanceHistoryResponse
-> DescribeBudgetPerformanceHistoryResponse -> Bool
== :: DescribeBudgetPerformanceHistoryResponse
-> DescribeBudgetPerformanceHistoryResponse -> Bool
$c== :: DescribeBudgetPerformanceHistoryResponse
-> DescribeBudgetPerformanceHistoryResponse -> Bool
Prelude.Eq, ReadPrec [DescribeBudgetPerformanceHistoryResponse]
ReadPrec DescribeBudgetPerformanceHistoryResponse
Int -> ReadS DescribeBudgetPerformanceHistoryResponse
ReadS [DescribeBudgetPerformanceHistoryResponse]
(Int -> ReadS DescribeBudgetPerformanceHistoryResponse)
-> ReadS [DescribeBudgetPerformanceHistoryResponse]
-> ReadPrec DescribeBudgetPerformanceHistoryResponse
-> ReadPrec [DescribeBudgetPerformanceHistoryResponse]
-> Read DescribeBudgetPerformanceHistoryResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeBudgetPerformanceHistoryResponse]
$creadListPrec :: ReadPrec [DescribeBudgetPerformanceHistoryResponse]
readPrec :: ReadPrec DescribeBudgetPerformanceHistoryResponse
$creadPrec :: ReadPrec DescribeBudgetPerformanceHistoryResponse
readList :: ReadS [DescribeBudgetPerformanceHistoryResponse]
$creadList :: ReadS [DescribeBudgetPerformanceHistoryResponse]
readsPrec :: Int -> ReadS DescribeBudgetPerformanceHistoryResponse
$creadsPrec :: Int -> ReadS DescribeBudgetPerformanceHistoryResponse
Prelude.Read, Int -> DescribeBudgetPerformanceHistoryResponse -> ShowS
[DescribeBudgetPerformanceHistoryResponse] -> ShowS
DescribeBudgetPerformanceHistoryResponse -> String
(Int -> DescribeBudgetPerformanceHistoryResponse -> ShowS)
-> (DescribeBudgetPerformanceHistoryResponse -> String)
-> ([DescribeBudgetPerformanceHistoryResponse] -> ShowS)
-> Show DescribeBudgetPerformanceHistoryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeBudgetPerformanceHistoryResponse] -> ShowS
$cshowList :: [DescribeBudgetPerformanceHistoryResponse] -> ShowS
show :: DescribeBudgetPerformanceHistoryResponse -> String
$cshow :: DescribeBudgetPerformanceHistoryResponse -> String
showsPrec :: Int -> DescribeBudgetPerformanceHistoryResponse -> ShowS
$cshowsPrec :: Int -> DescribeBudgetPerformanceHistoryResponse -> ShowS
Prelude.Show, (forall x.
 DescribeBudgetPerformanceHistoryResponse
 -> Rep DescribeBudgetPerformanceHistoryResponse x)
-> (forall x.
    Rep DescribeBudgetPerformanceHistoryResponse x
    -> DescribeBudgetPerformanceHistoryResponse)
-> Generic DescribeBudgetPerformanceHistoryResponse
forall x.
Rep DescribeBudgetPerformanceHistoryResponse x
-> DescribeBudgetPerformanceHistoryResponse
forall x.
DescribeBudgetPerformanceHistoryResponse
-> Rep DescribeBudgetPerformanceHistoryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeBudgetPerformanceHistoryResponse x
-> DescribeBudgetPerformanceHistoryResponse
$cfrom :: forall x.
DescribeBudgetPerformanceHistoryResponse
-> Rep DescribeBudgetPerformanceHistoryResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeBudgetPerformanceHistoryResponse' 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:
--
-- 'budgetPerformanceHistory', 'describeBudgetPerformanceHistoryResponse_budgetPerformanceHistory' - The history of how often the budget has gone into an @ALARM@ state.
--
-- For @DAILY@ budgets, the history saves the state of the budget for the
-- last 60 days. For @MONTHLY@ budgets, the history saves the state of the
-- budget for the current month plus the last 12 months. For @QUARTERLY@
-- budgets, the history saves the state of the budget for the last four
-- quarters.
--
-- 'nextToken', 'describeBudgetPerformanceHistoryResponse_nextToken' - Undocumented member.
--
-- 'httpStatus', 'describeBudgetPerformanceHistoryResponse_httpStatus' - The response's http status code.
newDescribeBudgetPerformanceHistoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeBudgetPerformanceHistoryResponse
newDescribeBudgetPerformanceHistoryResponse :: Int -> DescribeBudgetPerformanceHistoryResponse
newDescribeBudgetPerformanceHistoryResponse
  Int
pHttpStatus_ =
    DescribeBudgetPerformanceHistoryResponse' :: Maybe BudgetPerformanceHistory
-> Maybe Text -> Int -> DescribeBudgetPerformanceHistoryResponse
DescribeBudgetPerformanceHistoryResponse'
      { $sel:budgetPerformanceHistory:DescribeBudgetPerformanceHistoryResponse' :: Maybe BudgetPerformanceHistory
budgetPerformanceHistory =
          Maybe BudgetPerformanceHistory
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:DescribeBudgetPerformanceHistoryResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DescribeBudgetPerformanceHistoryResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The history of how often the budget has gone into an @ALARM@ state.
--
-- For @DAILY@ budgets, the history saves the state of the budget for the
-- last 60 days. For @MONTHLY@ budgets, the history saves the state of the
-- budget for the current month plus the last 12 months. For @QUARTERLY@
-- budgets, the history saves the state of the budget for the last four
-- quarters.
describeBudgetPerformanceHistoryResponse_budgetPerformanceHistory :: Lens.Lens' DescribeBudgetPerformanceHistoryResponse (Prelude.Maybe BudgetPerformanceHistory)
describeBudgetPerformanceHistoryResponse_budgetPerformanceHistory :: (Maybe BudgetPerformanceHistory
 -> f (Maybe BudgetPerformanceHistory))
-> DescribeBudgetPerformanceHistoryResponse
-> f DescribeBudgetPerformanceHistoryResponse
describeBudgetPerformanceHistoryResponse_budgetPerformanceHistory = (DescribeBudgetPerformanceHistoryResponse
 -> Maybe BudgetPerformanceHistory)
-> (DescribeBudgetPerformanceHistoryResponse
    -> Maybe BudgetPerformanceHistory
    -> DescribeBudgetPerformanceHistoryResponse)
-> Lens'
     DescribeBudgetPerformanceHistoryResponse
     (Maybe BudgetPerformanceHistory)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBudgetPerformanceHistoryResponse' {Maybe BudgetPerformanceHistory
budgetPerformanceHistory :: Maybe BudgetPerformanceHistory
$sel:budgetPerformanceHistory:DescribeBudgetPerformanceHistoryResponse' :: DescribeBudgetPerformanceHistoryResponse
-> Maybe BudgetPerformanceHistory
budgetPerformanceHistory} -> Maybe BudgetPerformanceHistory
budgetPerformanceHistory) (\s :: DescribeBudgetPerformanceHistoryResponse
s@DescribeBudgetPerformanceHistoryResponse' {} Maybe BudgetPerformanceHistory
a -> DescribeBudgetPerformanceHistoryResponse
s {$sel:budgetPerformanceHistory:DescribeBudgetPerformanceHistoryResponse' :: Maybe BudgetPerformanceHistory
budgetPerformanceHistory = Maybe BudgetPerformanceHistory
a} :: DescribeBudgetPerformanceHistoryResponse)

-- | Undocumented member.
describeBudgetPerformanceHistoryResponse_nextToken :: Lens.Lens' DescribeBudgetPerformanceHistoryResponse (Prelude.Maybe Prelude.Text)
describeBudgetPerformanceHistoryResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeBudgetPerformanceHistoryResponse
-> f DescribeBudgetPerformanceHistoryResponse
describeBudgetPerformanceHistoryResponse_nextToken = (DescribeBudgetPerformanceHistoryResponse -> Maybe Text)
-> (DescribeBudgetPerformanceHistoryResponse
    -> Maybe Text -> DescribeBudgetPerformanceHistoryResponse)
-> Lens' DescribeBudgetPerformanceHistoryResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBudgetPerformanceHistoryResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeBudgetPerformanceHistoryResponse' :: DescribeBudgetPerformanceHistoryResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeBudgetPerformanceHistoryResponse
s@DescribeBudgetPerformanceHistoryResponse' {} Maybe Text
a -> DescribeBudgetPerformanceHistoryResponse
s {$sel:nextToken:DescribeBudgetPerformanceHistoryResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeBudgetPerformanceHistoryResponse)

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

instance
  Prelude.NFData
    DescribeBudgetPerformanceHistoryResponse