{-# 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.DeleteBudget
-- 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)
--
-- Deletes a budget. You can delete your budget at any time.
--
-- Deleting a budget also deletes the notifications and subscribers that
-- are associated with that budget.
module Amazonka.Budgets.DeleteBudget
  ( -- * Creating a Request
    DeleteBudget (..),
    newDeleteBudget,

    -- * Request Lenses
    deleteBudget_accountId,
    deleteBudget_budgetName,

    -- * Destructuring the Response
    DeleteBudgetResponse (..),
    newDeleteBudgetResponse,

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

-- |
-- Create a value of 'DeleteBudget' 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', 'deleteBudget_accountId' - The @accountId@ that is associated with the budget that you want to
-- delete.
--
-- 'budgetName', 'deleteBudget_budgetName' - The name of the budget that you want to delete.
newDeleteBudget ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'budgetName'
  Prelude.Text ->
  DeleteBudget
newDeleteBudget :: Text -> Text -> DeleteBudget
newDeleteBudget Text
pAccountId_ Text
pBudgetName_ =
  DeleteBudget' :: Text -> Text -> DeleteBudget
DeleteBudget'
    { $sel:accountId:DeleteBudget' :: Text
accountId = Text
pAccountId_,
      $sel:budgetName:DeleteBudget' :: Text
budgetName = Text
pBudgetName_
    }

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

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

instance Core.AWSRequest DeleteBudget where
  type AWSResponse DeleteBudget = DeleteBudgetResponse
  request :: DeleteBudget -> Request DeleteBudget
request = Service -> DeleteBudget -> Request DeleteBudget
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteBudget
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteBudget)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteBudget))
-> Logger
-> Service
-> Proxy DeleteBudget
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteBudget)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteBudgetResponse
DeleteBudgetResponse'
            (Int -> DeleteBudgetResponse)
-> Either String Int -> Either String DeleteBudgetResponse
forall (f :: * -> *) a b. Functor 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 DeleteBudget

instance Prelude.NFData DeleteBudget

instance Core.ToHeaders DeleteBudget where
  toHeaders :: DeleteBudget -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteBudget -> 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.DeleteBudget" ::
                          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 DeleteBudget where
  toJSON :: DeleteBudget -> Value
toJSON DeleteBudget' {Text
budgetName :: Text
accountId :: Text
$sel:budgetName:DeleteBudget' :: DeleteBudget -> Text
$sel:accountId:DeleteBudget' :: DeleteBudget -> 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 DeleteBudget where
  toPath :: DeleteBudget -> ByteString
toPath = ByteString -> DeleteBudget -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'DeleteBudgetResponse' 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:
--
-- 'httpStatus', 'deleteBudgetResponse_httpStatus' - The response's http status code.
newDeleteBudgetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteBudgetResponse
newDeleteBudgetResponse :: Int -> DeleteBudgetResponse
newDeleteBudgetResponse Int
pHttpStatus_ =
  DeleteBudgetResponse' :: Int -> DeleteBudgetResponse
DeleteBudgetResponse' {$sel:httpStatus:DeleteBudgetResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData DeleteBudgetResponse