{-# 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 #-}
module Network.AWS.CloudWatchEvents.PutRule
(
putRule
, PutRule
, prEventPattern
, prState
, prScheduleExpression
, prDescription
, prRoleARN
, prName
, putRuleResponse
, PutRuleResponse
, prrsRuleARN
, prrsResponseStatus
) where
import Network.AWS.CloudWatchEvents.Types
import Network.AWS.CloudWatchEvents.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data PutRule = PutRule'
{ _prEventPattern :: !(Maybe Text)
, _prState :: !(Maybe RuleState)
, _prScheduleExpression :: !(Maybe Text)
, _prDescription :: !(Maybe Text)
, _prRoleARN :: !(Maybe Text)
, _prName :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
putRule
:: Text
-> PutRule
putRule pName_ =
PutRule'
{ _prEventPattern = Nothing
, _prState = Nothing
, _prScheduleExpression = Nothing
, _prDescription = Nothing
, _prRoleARN = Nothing
, _prName = pName_
}
prEventPattern :: Lens' PutRule (Maybe Text)
prEventPattern = lens _prEventPattern (\ s a -> s{_prEventPattern = a});
prState :: Lens' PutRule (Maybe RuleState)
prState = lens _prState (\ s a -> s{_prState = a});
prScheduleExpression :: Lens' PutRule (Maybe Text)
prScheduleExpression = lens _prScheduleExpression (\ s a -> s{_prScheduleExpression = a});
prDescription :: Lens' PutRule (Maybe Text)
prDescription = lens _prDescription (\ s a -> s{_prDescription = a});
prRoleARN :: Lens' PutRule (Maybe Text)
prRoleARN = lens _prRoleARN (\ s a -> s{_prRoleARN = a});
prName :: Lens' PutRule Text
prName = lens _prName (\ s a -> s{_prName = a});
instance AWSRequest PutRule where
type Rs PutRule = PutRuleResponse
request = postJSON cloudWatchEvents
response
= receiveJSON
(\ s h x ->
PutRuleResponse' <$>
(x .?> "RuleArn") <*> (pure (fromEnum s)))
instance Hashable PutRule
instance NFData PutRule
instance ToHeaders PutRule where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSEvents.PutRule" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON PutRule where
toJSON PutRule'{..}
= object
(catMaybes
[("EventPattern" .=) <$> _prEventPattern,
("State" .=) <$> _prState,
("ScheduleExpression" .=) <$> _prScheduleExpression,
("Description" .=) <$> _prDescription,
("RoleArn" .=) <$> _prRoleARN,
Just ("Name" .= _prName)])
instance ToPath PutRule where
toPath = const "/"
instance ToQuery PutRule where
toQuery = const mempty
data PutRuleResponse = PutRuleResponse'
{ _prrsRuleARN :: !(Maybe Text)
, _prrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
putRuleResponse
:: Int
-> PutRuleResponse
putRuleResponse pResponseStatus_ =
PutRuleResponse'
{ _prrsRuleARN = Nothing
, _prrsResponseStatus = pResponseStatus_
}
prrsRuleARN :: Lens' PutRuleResponse (Maybe Text)
prrsRuleARN = lens _prrsRuleARN (\ s a -> s{_prrsRuleARN = a});
prrsResponseStatus :: Lens' PutRuleResponse Int
prrsResponseStatus = lens _prrsResponseStatus (\ s a -> s{_prrsResponseStatus = a});
instance NFData PutRuleResponse