{-# 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.WAF.CreateRuleGroup
(
createRuleGroup
, CreateRuleGroup
, crgName
, crgMetricName
, crgChangeToken
, createRuleGroupResponse
, CreateRuleGroupResponse
, crgrsChangeToken
, crgrsRuleGroup
, crgrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.WAF.Types
import Network.AWS.WAF.Types.Product
data CreateRuleGroup = CreateRuleGroup'
{ _crgName :: !Text
, _crgMetricName :: !Text
, _crgChangeToken :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createRuleGroup
:: Text
-> Text
-> Text
-> CreateRuleGroup
createRuleGroup pName_ pMetricName_ pChangeToken_ =
CreateRuleGroup'
{ _crgName = pName_
, _crgMetricName = pMetricName_
, _crgChangeToken = pChangeToken_
}
crgName :: Lens' CreateRuleGroup Text
crgName = lens _crgName (\ s a -> s{_crgName = a})
crgMetricName :: Lens' CreateRuleGroup Text
crgMetricName = lens _crgMetricName (\ s a -> s{_crgMetricName = a})
crgChangeToken :: Lens' CreateRuleGroup Text
crgChangeToken = lens _crgChangeToken (\ s a -> s{_crgChangeToken = a})
instance AWSRequest CreateRuleGroup where
type Rs CreateRuleGroup = CreateRuleGroupResponse
request = postJSON waf
response
= receiveJSON
(\ s h x ->
CreateRuleGroupResponse' <$>
(x .?> "ChangeToken") <*> (x .?> "RuleGroup") <*>
(pure (fromEnum s)))
instance Hashable CreateRuleGroup where
instance NFData CreateRuleGroup where
instance ToHeaders CreateRuleGroup where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSWAF_20150824.CreateRuleGroup" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreateRuleGroup where
toJSON CreateRuleGroup'{..}
= object
(catMaybes
[Just ("Name" .= _crgName),
Just ("MetricName" .= _crgMetricName),
Just ("ChangeToken" .= _crgChangeToken)])
instance ToPath CreateRuleGroup where
toPath = const "/"
instance ToQuery CreateRuleGroup where
toQuery = const mempty
data CreateRuleGroupResponse = CreateRuleGroupResponse'
{ _crgrsChangeToken :: !(Maybe Text)
, _crgrsRuleGroup :: !(Maybe RuleGroup)
, _crgrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createRuleGroupResponse
:: Int
-> CreateRuleGroupResponse
createRuleGroupResponse pResponseStatus_ =
CreateRuleGroupResponse'
{ _crgrsChangeToken = Nothing
, _crgrsRuleGroup = Nothing
, _crgrsResponseStatus = pResponseStatus_
}
crgrsChangeToken :: Lens' CreateRuleGroupResponse (Maybe Text)
crgrsChangeToken = lens _crgrsChangeToken (\ s a -> s{_crgrsChangeToken = a})
crgrsRuleGroup :: Lens' CreateRuleGroupResponse (Maybe RuleGroup)
crgrsRuleGroup = lens _crgrsRuleGroup (\ s a -> s{_crgrsRuleGroup = a})
crgrsResponseStatus :: Lens' CreateRuleGroupResponse Int
crgrsResponseStatus = lens _crgrsResponseStatus (\ s a -> s{_crgrsResponseStatus = a})
instance NFData CreateRuleGroupResponse where