{-# 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.DescribeBudget
-- 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 a budget.
--
-- The Request Syntax section shows the @BudgetLimit@ syntax. For
-- @PlannedBudgetLimits@, see the
-- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_budgets_DescribeBudget.html#API_DescribeBudget_Examples Examples>
-- section.
module Amazonka.Budgets.DescribeBudget
  ( -- * Creating a Request
    DescribeBudget (..),
    newDescribeBudget,

    -- * Request Lenses
    describeBudget_accountId,
    describeBudget_budgetName,

    -- * Destructuring the Response
    DescribeBudgetResponse (..),
    newDescribeBudgetResponse,

    -- * Response Lenses
    describeBudgetResponse_budget,
    describeBudgetResponse_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 DescribeBudget
--
-- /See:/ 'newDescribeBudget' smart constructor.
data DescribeBudget = DescribeBudget'
  { -- | The @accountId@ that is associated with the budget that you want a
    -- description of.
    DescribeBudget -> Text
accountId :: Prelude.Text,
    -- | The name of the budget that you want a description of.
    DescribeBudget -> Text
budgetName :: Prelude.Text
  }
  deriving (DescribeBudget -> DescribeBudget -> Bool
(DescribeBudget -> DescribeBudget -> Bool)
-> (DescribeBudget -> DescribeBudget -> Bool) -> Eq DescribeBudget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeBudget -> DescribeBudget -> Bool
$c/= :: DescribeBudget -> DescribeBudget -> Bool
== :: DescribeBudget -> DescribeBudget -> Bool
$c== :: DescribeBudget -> DescribeBudget -> Bool
Prelude.Eq, ReadPrec [DescribeBudget]
ReadPrec DescribeBudget
Int -> ReadS DescribeBudget
ReadS [DescribeBudget]
(Int -> ReadS DescribeBudget)
-> ReadS [DescribeBudget]
-> ReadPrec DescribeBudget
-> ReadPrec [DescribeBudget]
-> Read DescribeBudget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeBudget]
$creadListPrec :: ReadPrec [DescribeBudget]
readPrec :: ReadPrec DescribeBudget
$creadPrec :: ReadPrec DescribeBudget
readList :: ReadS [DescribeBudget]
$creadList :: ReadS [DescribeBudget]
readsPrec :: Int -> ReadS DescribeBudget
$creadsPrec :: Int -> ReadS DescribeBudget
Prelude.Read, Int -> DescribeBudget -> ShowS
[DescribeBudget] -> ShowS
DescribeBudget -> String
(Int -> DescribeBudget -> ShowS)
-> (DescribeBudget -> String)
-> ([DescribeBudget] -> ShowS)
-> Show DescribeBudget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeBudget] -> ShowS
$cshowList :: [DescribeBudget] -> ShowS
show :: DescribeBudget -> String
$cshow :: DescribeBudget -> String
showsPrec :: Int -> DescribeBudget -> ShowS
$cshowsPrec :: Int -> DescribeBudget -> ShowS
Prelude.Show, (forall x. DescribeBudget -> Rep DescribeBudget x)
-> (forall x. Rep DescribeBudget x -> DescribeBudget)
-> Generic DescribeBudget
forall x. Rep DescribeBudget x -> DescribeBudget
forall x. DescribeBudget -> Rep DescribeBudget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeBudget x -> DescribeBudget
$cfrom :: forall x. DescribeBudget -> Rep DescribeBudget x
Prelude.Generic)

-- |
-- Create a value of 'DescribeBudget' 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:
--
-- 'accountId', 'describeBudget_accountId' - The @accountId@ that is associated with the budget that you want a
-- description of.
--
-- 'budgetName', 'describeBudget_budgetName' - The name of the budget that you want a description of.
newDescribeBudget ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'budgetName'
  Prelude.Text ->
  DescribeBudget
newDescribeBudget :: Text -> Text -> DescribeBudget
newDescribeBudget Text
pAccountId_ Text
pBudgetName_ =
  DescribeBudget' :: Text -> Text -> DescribeBudget
DescribeBudget'
    { $sel:accountId:DescribeBudget' :: Text
accountId = Text
pAccountId_,
      $sel:budgetName:DescribeBudget' :: Text
budgetName = Text
pBudgetName_
    }

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

-- | The name of the budget that you want a description of.
describeBudget_budgetName :: Lens.Lens' DescribeBudget Prelude.Text
describeBudget_budgetName :: (Text -> f Text) -> DescribeBudget -> f DescribeBudget
describeBudget_budgetName = (DescribeBudget -> Text)
-> (DescribeBudget -> Text -> DescribeBudget)
-> Lens DescribeBudget DescribeBudget Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBudget' {Text
budgetName :: Text
$sel:budgetName:DescribeBudget' :: DescribeBudget -> Text
budgetName} -> Text
budgetName) (\s :: DescribeBudget
s@DescribeBudget' {} Text
a -> DescribeBudget
s {$sel:budgetName:DescribeBudget' :: Text
budgetName = Text
a} :: DescribeBudget)

instance Core.AWSRequest DescribeBudget where
  type
    AWSResponse DescribeBudget =
      DescribeBudgetResponse
  request :: DescribeBudget -> Request DescribeBudget
request = Service -> DescribeBudget -> Request DescribeBudget
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeBudget
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeBudget)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeBudget))
-> Logger
-> Service
-> Proxy DescribeBudget
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeBudget)))
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 Budget -> Int -> DescribeBudgetResponse
DescribeBudgetResponse'
            (Maybe Budget -> Int -> DescribeBudgetResponse)
-> Either String (Maybe Budget)
-> Either String (Int -> DescribeBudgetResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Budget)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Budget")
            Either String (Int -> DescribeBudgetResponse)
-> Either String Int -> Either String DescribeBudgetResponse
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 DescribeBudget

instance Prelude.NFData DescribeBudget

instance Core.ToHeaders DescribeBudget where
  toHeaders :: DescribeBudget -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeBudget -> 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.DescribeBudget" ::
                          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 DescribeBudget where
  toJSON :: DescribeBudget -> Value
toJSON DescribeBudget' {Text
budgetName :: Text
accountId :: Text
$sel:budgetName:DescribeBudget' :: DescribeBudget -> Text
$sel:accountId:DescribeBudget' :: DescribeBudget -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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 DescribeBudget where
  toPath :: DescribeBudget -> ByteString
toPath = ByteString -> DescribeBudget -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | Response of DescribeBudget
--
-- /See:/ 'newDescribeBudgetResponse' smart constructor.
data DescribeBudgetResponse = DescribeBudgetResponse'
  { -- | The description of the budget.
    DescribeBudgetResponse -> Maybe Budget
budget :: Prelude.Maybe Budget,
    -- | The response's http status code.
    DescribeBudgetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeBudgetResponse -> DescribeBudgetResponse -> Bool
(DescribeBudgetResponse -> DescribeBudgetResponse -> Bool)
-> (DescribeBudgetResponse -> DescribeBudgetResponse -> Bool)
-> Eq DescribeBudgetResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeBudgetResponse -> DescribeBudgetResponse -> Bool
$c/= :: DescribeBudgetResponse -> DescribeBudgetResponse -> Bool
== :: DescribeBudgetResponse -> DescribeBudgetResponse -> Bool
$c== :: DescribeBudgetResponse -> DescribeBudgetResponse -> Bool
Prelude.Eq, ReadPrec [DescribeBudgetResponse]
ReadPrec DescribeBudgetResponse
Int -> ReadS DescribeBudgetResponse
ReadS [DescribeBudgetResponse]
(Int -> ReadS DescribeBudgetResponse)
-> ReadS [DescribeBudgetResponse]
-> ReadPrec DescribeBudgetResponse
-> ReadPrec [DescribeBudgetResponse]
-> Read DescribeBudgetResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeBudgetResponse]
$creadListPrec :: ReadPrec [DescribeBudgetResponse]
readPrec :: ReadPrec DescribeBudgetResponse
$creadPrec :: ReadPrec DescribeBudgetResponse
readList :: ReadS [DescribeBudgetResponse]
$creadList :: ReadS [DescribeBudgetResponse]
readsPrec :: Int -> ReadS DescribeBudgetResponse
$creadsPrec :: Int -> ReadS DescribeBudgetResponse
Prelude.Read, Int -> DescribeBudgetResponse -> ShowS
[DescribeBudgetResponse] -> ShowS
DescribeBudgetResponse -> String
(Int -> DescribeBudgetResponse -> ShowS)
-> (DescribeBudgetResponse -> String)
-> ([DescribeBudgetResponse] -> ShowS)
-> Show DescribeBudgetResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeBudgetResponse] -> ShowS
$cshowList :: [DescribeBudgetResponse] -> ShowS
show :: DescribeBudgetResponse -> String
$cshow :: DescribeBudgetResponse -> String
showsPrec :: Int -> DescribeBudgetResponse -> ShowS
$cshowsPrec :: Int -> DescribeBudgetResponse -> ShowS
Prelude.Show, (forall x. DescribeBudgetResponse -> Rep DescribeBudgetResponse x)
-> (forall x.
    Rep DescribeBudgetResponse x -> DescribeBudgetResponse)
-> Generic DescribeBudgetResponse
forall x. Rep DescribeBudgetResponse x -> DescribeBudgetResponse
forall x. DescribeBudgetResponse -> Rep DescribeBudgetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeBudgetResponse x -> DescribeBudgetResponse
$cfrom :: forall x. DescribeBudgetResponse -> Rep DescribeBudgetResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeBudgetResponse' 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:
--
-- 'budget', 'describeBudgetResponse_budget' - The description of the budget.
--
-- 'httpStatus', 'describeBudgetResponse_httpStatus' - The response's http status code.
newDescribeBudgetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeBudgetResponse
newDescribeBudgetResponse :: Int -> DescribeBudgetResponse
newDescribeBudgetResponse Int
pHttpStatus_ =
  DescribeBudgetResponse' :: Maybe Budget -> Int -> DescribeBudgetResponse
DescribeBudgetResponse'
    { $sel:budget:DescribeBudgetResponse' :: Maybe Budget
budget = Maybe Budget
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeBudgetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The description of the budget.
describeBudgetResponse_budget :: Lens.Lens' DescribeBudgetResponse (Prelude.Maybe Budget)
describeBudgetResponse_budget :: (Maybe Budget -> f (Maybe Budget))
-> DescribeBudgetResponse -> f DescribeBudgetResponse
describeBudgetResponse_budget = (DescribeBudgetResponse -> Maybe Budget)
-> (DescribeBudgetResponse
    -> Maybe Budget -> DescribeBudgetResponse)
-> Lens
     DescribeBudgetResponse
     DescribeBudgetResponse
     (Maybe Budget)
     (Maybe Budget)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBudgetResponse' {Maybe Budget
budget :: Maybe Budget
$sel:budget:DescribeBudgetResponse' :: DescribeBudgetResponse -> Maybe Budget
budget} -> Maybe Budget
budget) (\s :: DescribeBudgetResponse
s@DescribeBudgetResponse' {} Maybe Budget
a -> DescribeBudgetResponse
s {$sel:budget:DescribeBudgetResponse' :: Maybe Budget
budget = Maybe Budget
a} :: DescribeBudgetResponse)

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

instance Prelude.NFData DescribeBudgetResponse