{-# 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.APIGateway.UpdateBasePathMapping
-- Copyright   : (c) 2013-2015 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)
--
-- Changes information about the BasePathMapping resource.
--
-- /See:/ <http://docs.aws.amazon.com/apigateway/api-reference/resource/UpdateBasePathMapping.html AWS API Reference> for UpdateBasePathMapping.
module Network.AWS.APIGateway.UpdateBasePathMapping
    (
    -- * Creating a Request
      updateBasePathMapping
    , UpdateBasePathMapping
    -- * Request Lenses
    , ubpmPatchOperations
    , ubpmDomainName
    , ubpmBasePath

    -- * Destructuring the Response
    , basePathMapping
    , BasePathMapping
    -- * Response Lenses
    , bpmStage
    , bpmBasePath
    , bpmRestAPIId
    ) where

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

-- | A request to change information about the BasePathMapping resource.
--
-- /See:/ 'updateBasePathMapping' smart constructor.
data UpdateBasePathMapping = UpdateBasePathMapping'
    { _ubpmPatchOperations :: !(Maybe [PatchOperation])
    , _ubpmDomainName      :: !Text
    , _ubpmBasePath        :: !Text
    } deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'UpdateBasePathMapping' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'ubpmPatchOperations'
--
-- * 'ubpmDomainName'
--
-- * 'ubpmBasePath'
updateBasePathMapping
    :: Text -- ^ 'ubpmDomainName'
    -> Text -- ^ 'ubpmBasePath'
    -> UpdateBasePathMapping
updateBasePathMapping pDomainName_ pBasePath_ =
    UpdateBasePathMapping'
    { _ubpmPatchOperations = Nothing
    , _ubpmDomainName = pDomainName_
    , _ubpmBasePath = pBasePath_
    }

-- | A list of operations describing the updates to apply to the specified
-- resource. The patches are applied in the order specified in the list.
ubpmPatchOperations :: Lens' UpdateBasePathMapping [PatchOperation]
ubpmPatchOperations = lens _ubpmPatchOperations (\ s a -> s{_ubpmPatchOperations = a}) . _Default . _Coerce;

-- | The domain name of the BasePathMapping resource to change.
ubpmDomainName :: Lens' UpdateBasePathMapping Text
ubpmDomainName = lens _ubpmDomainName (\ s a -> s{_ubpmDomainName = a});

-- | The base path of the BasePathMapping resource to change.
ubpmBasePath :: Lens' UpdateBasePathMapping Text
ubpmBasePath = lens _ubpmBasePath (\ s a -> s{_ubpmBasePath = a});

instance AWSRequest UpdateBasePathMapping where
        type Rs UpdateBasePathMapping = BasePathMapping
        request = patchJSON aPIGateway
        response = receiveJSON (\ s h x -> eitherParseJSON x)

instance ToHeaders UpdateBasePathMapping where
        toHeaders = const mempty

instance ToJSON UpdateBasePathMapping where
        toJSON UpdateBasePathMapping'{..}
          = object
              (catMaybes
                 [("patchOperations" .=) <$> _ubpmPatchOperations])

instance ToPath UpdateBasePathMapping where
        toPath UpdateBasePathMapping'{..}
          = mconcat
              ["/domainnames/", toBS _ubpmDomainName,
               "/basepathmappings/", toBS _ubpmBasePath]

instance ToQuery UpdateBasePathMapping where
        toQuery = const mempty