{-# 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.CloudWatchLogs.PutRetentionPolicy
-- 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)
--
-- Sets the retention of the specified log group. A retention policy allows
-- you to configure the number of days you want to retain log events in the
-- specified log group.
--
-- /See:/ <http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutRetentionPolicy.html AWS API Reference> for PutRetentionPolicy.
module Network.AWS.CloudWatchLogs.PutRetentionPolicy
    (
    -- * Creating a Request
      putRetentionPolicy
    , PutRetentionPolicy
    -- * Request Lenses
    , prpLogGroupName
    , prpRetentionInDays

    -- * Destructuring the Response
    , putRetentionPolicyResponse
    , PutRetentionPolicyResponse
    ) where

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

-- | /See:/ 'putRetentionPolicy' smart constructor.
data PutRetentionPolicy = PutRetentionPolicy'
    { _prpLogGroupName    :: !Text
    , _prpRetentionInDays :: !Int
    } deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'PutRetentionPolicy' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'prpLogGroupName'
--
-- * 'prpRetentionInDays'
putRetentionPolicy
    :: Text -- ^ 'prpLogGroupName'
    -> Int -- ^ 'prpRetentionInDays'
    -> PutRetentionPolicy
putRetentionPolicy pLogGroupName_ pRetentionInDays_ =
    PutRetentionPolicy'
    { _prpLogGroupName = pLogGroupName_
    , _prpRetentionInDays = pRetentionInDays_
    }

-- | The name of the log group to associate the retention policy with.
prpLogGroupName :: Lens' PutRetentionPolicy Text
prpLogGroupName = lens _prpLogGroupName (\ s a -> s{_prpLogGroupName = a});

-- | Undocumented member.
prpRetentionInDays :: Lens' PutRetentionPolicy Int
prpRetentionInDays = lens _prpRetentionInDays (\ s a -> s{_prpRetentionInDays = a});

instance AWSRequest PutRetentionPolicy where
        type Sv PutRetentionPolicy = CloudWatchLogs
        type Rs PutRetentionPolicy =
             PutRetentionPolicyResponse
        request = postJSON
        response = receiveNull PutRetentionPolicyResponse'

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

instance ToJSON PutRetentionPolicy where
        toJSON PutRetentionPolicy'{..}
          = object
              ["logGroupName" .= _prpLogGroupName,
               "retentionInDays" .= _prpRetentionInDays]

instance ToPath PutRetentionPolicy where
        toPath = const "/"

instance ToQuery PutRetentionPolicy where
        toQuery = const mempty

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

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