{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric      #-}
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE RecordWildCards    #-}
{-# LANGUAGE TypeFamilies       #-}

{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds   #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Network.AWS.Budgets.UpdateBudget
-- Copyright   : (c) 2013-2016 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Update the information of a budget already created
module Network.AWS.Budgets.UpdateBudget
    (
    -- * Creating a Request
      updateBudget
    , UpdateBudget
    -- * Request Lenses
    , ubAccountId
    , ubNewBudget

    -- * Destructuring the Response
    , updateBudgetResponse
    , UpdateBudgetResponse
    -- * Response Lenses
    , ubrsResponseStatus
    ) where

import           Network.AWS.Budgets.Types
import           Network.AWS.Budgets.Types.Product
import           Network.AWS.Lens
import           Network.AWS.Prelude
import           Network.AWS.Request
import           Network.AWS.Response

-- | Request of UpdateBudget
--
-- /See:/ 'updateBudget' smart constructor.
data UpdateBudget = UpdateBudget'
    { _ubAccountId :: !Text
    , _ubNewBudget :: !Budget
    } deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'UpdateBudget' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'ubAccountId' - Undocumented member.
--
-- * 'ubNewBudget' - Undocumented member.
updateBudget
    :: Text -- ^ 'ubAccountId'
    -> Budget -- ^ 'ubNewBudget'
    -> UpdateBudget
updateBudget pAccountId_ pNewBudget_ =
    UpdateBudget'
    { _ubAccountId = pAccountId_
    , _ubNewBudget = pNewBudget_
    }

-- | Undocumented member.
ubAccountId :: Lens' UpdateBudget Text
ubAccountId = lens _ubAccountId (\ s a -> s{_ubAccountId = a});

-- | Undocumented member.
ubNewBudget :: Lens' UpdateBudget Budget
ubNewBudget = lens _ubNewBudget (\ s a -> s{_ubNewBudget = a});

instance AWSRequest UpdateBudget where
        type Rs UpdateBudget = UpdateBudgetResponse
        request = postJSON budgets
        response
          = receiveEmpty
              (\ s h x ->
                 UpdateBudgetResponse' <$> (pure (fromEnum s)))

instance Hashable UpdateBudget

instance NFData UpdateBudget

instance ToHeaders UpdateBudget where
        toHeaders
          = const
              (mconcat
                 ["X-Amz-Target" =#
                    ("AWSBudgetServiceGateway.UpdateBudget" ::
                       ByteString),
                  "Content-Type" =#
                    ("application/x-amz-json-1.1" :: ByteString)])

instance ToJSON UpdateBudget where
        toJSON UpdateBudget'{..}
          = object
              (catMaybes
                 [Just ("AccountId" .= _ubAccountId),
                  Just ("NewBudget" .= _ubNewBudget)])

instance ToPath UpdateBudget where
        toPath = const "/"

instance ToQuery UpdateBudget where
        toQuery = const mempty

-- | Response of UpdateBudget
--
-- /See:/ 'updateBudgetResponse' smart constructor.
newtype UpdateBudgetResponse = UpdateBudgetResponse'
    { _ubrsResponseStatus :: Int
    } deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'UpdateBudgetResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'ubrsResponseStatus' - -- | The response status code.
updateBudgetResponse
    :: Int -- ^ 'ubrsResponseStatus'
    -> UpdateBudgetResponse
updateBudgetResponse pResponseStatus_ =
    UpdateBudgetResponse'
    { _ubrsResponseStatus = pResponseStatus_
    }

-- | -- | The response status code.
ubrsResponseStatus :: Lens' UpdateBudgetResponse Int
ubrsResponseStatus = lens _ubrsResponseStatus (\ s a -> s{_ubrsResponseStatus = a});

instance NFData UpdateBudgetResponse