{-# 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 #-}
module Amazonka.Budgets.DescribeBudget
(
DescribeBudget (..),
newDescribeBudget,
describeBudget_accountId,
describeBudget_budgetName,
DescribeBudgetResponse (..),
newDescribeBudgetResponse,
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
data DescribeBudget = DescribeBudget'
{
DescribeBudget -> Text
accountId :: Prelude.Text,
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)
newDescribeBudget ::
Prelude.Text ->
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_
}
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)
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
data DescribeBudgetResponse = DescribeBudgetResponse'
{
DescribeBudgetResponse -> Maybe Budget
budget :: Prelude.Maybe Budget,
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)
newDescribeBudgetResponse ::
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_
}
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)
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