{-# 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.Shield.CreateProtection
(
createProtection
, CreateProtection
, cpName
, cpResourceARN
, createProtectionResponse
, CreateProtectionResponse
, cprsProtectionId
, cprsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.Shield.Types
import Network.AWS.Shield.Types.Product
data CreateProtection = CreateProtection'
{ _cpName :: !Text
, _cpResourceARN :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
createProtection
:: Text
-> Text
-> CreateProtection
createProtection pName_ pResourceARN_ =
CreateProtection'
{ _cpName = pName_
, _cpResourceARN = pResourceARN_
}
cpName :: Lens' CreateProtection Text
cpName = lens _cpName (\ s a -> s{_cpName = a});
cpResourceARN :: Lens' CreateProtection Text
cpResourceARN = lens _cpResourceARN (\ s a -> s{_cpResourceARN = a});
instance AWSRequest CreateProtection where
type Rs CreateProtection = CreateProtectionResponse
request = postJSON shield
response
= receiveJSON
(\ s h x ->
CreateProtectionResponse' <$>
(x .?> "ProtectionId") <*> (pure (fromEnum s)))
instance Hashable CreateProtection
instance NFData CreateProtection
instance ToHeaders CreateProtection where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSShield_20160616.CreateProtection" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreateProtection where
toJSON CreateProtection'{..}
= object
(catMaybes
[Just ("Name" .= _cpName),
Just ("ResourceArn" .= _cpResourceARN)])
instance ToPath CreateProtection where
toPath = const "/"
instance ToQuery CreateProtection where
toQuery = const mempty
data CreateProtectionResponse = CreateProtectionResponse'
{ _cprsProtectionId :: !(Maybe Text)
, _cprsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
createProtectionResponse
:: Int
-> CreateProtectionResponse
createProtectionResponse pResponseStatus_ =
CreateProtectionResponse'
{ _cprsProtectionId = Nothing
, _cprsResponseStatus = pResponseStatus_
}
cprsProtectionId :: Lens' CreateProtectionResponse (Maybe Text)
cprsProtectionId = lens _cprsProtectionId (\ s a -> s{_cprsProtectionId = a});
cprsResponseStatus :: Lens' CreateProtectionResponse Int
cprsResponseStatus = lens _cprsResponseStatus (\ s a -> s{_cprsResponseStatus = a});
instance NFData CreateProtectionResponse