{-# 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.IoT.DeletePolicyVersion
-- 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)
--
-- Deletes the specified version of the specified policy. The default
-- version of the policy cannot be deleted.
--
-- To delete the default version use the DeletePolicy API or mark the
-- policy as non-default and then delete it.
--
-- /See:/ <https://aws.amazon.com/iot#DeletePolicyVersion.html AWS API Reference> for DeletePolicyVersion.
module Network.AWS.IoT.DeletePolicyVersion
    (
    -- * Creating a Request
      deletePolicyVersion
    , DeletePolicyVersion
    -- * Request Lenses
    , dpvPolicyName
    , dpvPolicyVersionId

    -- * Destructuring the Response
    , deletePolicyVersionResponse
    , DeletePolicyVersionResponse
    ) where

import           Network.AWS.IoT.Types
import           Network.AWS.IoT.Types.Product
import           Network.AWS.Prelude
import           Network.AWS.Request
import           Network.AWS.Response

-- | The input for the DeletePolicyVersion operation.
--
-- /See:/ 'deletePolicyVersion' smart constructor.
data DeletePolicyVersion = DeletePolicyVersion'
    { _dpvPolicyName      :: !Text
    , _dpvPolicyVersionId :: !Text
    } deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'DeletePolicyVersion' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'dpvPolicyName'
--
-- * 'dpvPolicyVersionId'
deletePolicyVersion
    :: Text -- ^ 'dpvPolicyName'
    -> Text -- ^ 'dpvPolicyVersionId'
    -> DeletePolicyVersion
deletePolicyVersion pPolicyName_ pPolicyVersionId_ =
    DeletePolicyVersion'
    { _dpvPolicyName = pPolicyName_
    , _dpvPolicyVersionId = pPolicyVersionId_
    }

-- | The name of the policy.
dpvPolicyName :: Lens' DeletePolicyVersion Text
dpvPolicyName = lens _dpvPolicyName (\ s a -> s{_dpvPolicyName = a});

-- | The policy version ID.
dpvPolicyVersionId :: Lens' DeletePolicyVersion Text
dpvPolicyVersionId = lens _dpvPolicyVersionId (\ s a -> s{_dpvPolicyVersionId = a});

instance AWSRequest DeletePolicyVersion where
        type Rs DeletePolicyVersion =
             DeletePolicyVersionResponse
        request = delete ioT
        response = receiveNull DeletePolicyVersionResponse'

instance ToHeaders DeletePolicyVersion where
        toHeaders = const mempty

instance ToPath DeletePolicyVersion where
        toPath DeletePolicyVersion'{..}
          = mconcat
              ["/policies/", toBS _dpvPolicyName, "/version/",
               toBS _dpvPolicyVersionId]

instance ToQuery DeletePolicyVersion where
        toQuery = const mempty

-- | /See:/ 'deletePolicyVersionResponse' smart constructor.
data DeletePolicyVersionResponse =
    DeletePolicyVersionResponse'
    deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'DeletePolicyVersionResponse' with the minimum fields required to make a request.
--
deletePolicyVersionResponse
    :: DeletePolicyVersionResponse
deletePolicyVersionResponse = DeletePolicyVersionResponse'