{-# 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.EC2.CreateFlowLogs
(
createFlowLogs
, CreateFlowLogs
, cflClientToken
, cflDeliverLogsPermissionARN
, cflLogGroupName
, cflResourceIds
, cflResourceType
, cflTrafficType
, createFlowLogsResponse
, CreateFlowLogsResponse
, cflrsUnsuccessful
, cflrsClientToken
, cflrsFlowLogIds
, cflrsResponseStatus
) where
import Network.AWS.EC2.Types
import Network.AWS.EC2.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreateFlowLogs = CreateFlowLogs'
{ _cflClientToken :: !(Maybe Text)
, _cflDeliverLogsPermissionARN :: !Text
, _cflLogGroupName :: !Text
, _cflResourceIds :: ![Text]
, _cflResourceType :: !FlowLogsResourceType
, _cflTrafficType :: !TrafficType
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createFlowLogs
:: Text
-> Text
-> FlowLogsResourceType
-> TrafficType
-> CreateFlowLogs
createFlowLogs pDeliverLogsPermissionARN_ pLogGroupName_ pResourceType_ pTrafficType_ =
CreateFlowLogs'
{ _cflClientToken = Nothing
, _cflDeliverLogsPermissionARN = pDeliverLogsPermissionARN_
, _cflLogGroupName = pLogGroupName_
, _cflResourceIds = mempty
, _cflResourceType = pResourceType_
, _cflTrafficType = pTrafficType_
}
cflClientToken :: Lens' CreateFlowLogs (Maybe Text)
cflClientToken = lens _cflClientToken (\ s a -> s{_cflClientToken = a})
cflDeliverLogsPermissionARN :: Lens' CreateFlowLogs Text
cflDeliverLogsPermissionARN = lens _cflDeliverLogsPermissionARN (\ s a -> s{_cflDeliverLogsPermissionARN = a})
cflLogGroupName :: Lens' CreateFlowLogs Text
cflLogGroupName = lens _cflLogGroupName (\ s a -> s{_cflLogGroupName = a})
cflResourceIds :: Lens' CreateFlowLogs [Text]
cflResourceIds = lens _cflResourceIds (\ s a -> s{_cflResourceIds = a}) . _Coerce
cflResourceType :: Lens' CreateFlowLogs FlowLogsResourceType
cflResourceType = lens _cflResourceType (\ s a -> s{_cflResourceType = a})
cflTrafficType :: Lens' CreateFlowLogs TrafficType
cflTrafficType = lens _cflTrafficType (\ s a -> s{_cflTrafficType = a})
instance AWSRequest CreateFlowLogs where
type Rs CreateFlowLogs = CreateFlowLogsResponse
request = postQuery ec2
response
= receiveXML
(\ s h x ->
CreateFlowLogsResponse' <$>
(x .@? "unsuccessful" .!@ mempty >>=
may (parseXMLList "item"))
<*> (x .@? "clientToken")
<*>
(x .@? "flowLogIdSet" .!@ mempty >>=
may (parseXMLList "item"))
<*> (pure (fromEnum s)))
instance Hashable CreateFlowLogs where
instance NFData CreateFlowLogs where
instance ToHeaders CreateFlowLogs where
toHeaders = const mempty
instance ToPath CreateFlowLogs where
toPath = const "/"
instance ToQuery CreateFlowLogs where
toQuery CreateFlowLogs'{..}
= mconcat
["Action" =: ("CreateFlowLogs" :: ByteString),
"Version" =: ("2016-11-15" :: ByteString),
"ClientToken" =: _cflClientToken,
"DeliverLogsPermissionArn" =:
_cflDeliverLogsPermissionARN,
"LogGroupName" =: _cflLogGroupName,
toQueryList "ResourceId" _cflResourceIds,
"ResourceType" =: _cflResourceType,
"TrafficType" =: _cflTrafficType]
data CreateFlowLogsResponse = CreateFlowLogsResponse'
{ _cflrsUnsuccessful :: !(Maybe [UnsuccessfulItem])
, _cflrsClientToken :: !(Maybe Text)
, _cflrsFlowLogIds :: !(Maybe [Text])
, _cflrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createFlowLogsResponse
:: Int
-> CreateFlowLogsResponse
createFlowLogsResponse pResponseStatus_ =
CreateFlowLogsResponse'
{ _cflrsUnsuccessful = Nothing
, _cflrsClientToken = Nothing
, _cflrsFlowLogIds = Nothing
, _cflrsResponseStatus = pResponseStatus_
}
cflrsUnsuccessful :: Lens' CreateFlowLogsResponse [UnsuccessfulItem]
cflrsUnsuccessful = lens _cflrsUnsuccessful (\ s a -> s{_cflrsUnsuccessful = a}) . _Default . _Coerce
cflrsClientToken :: Lens' CreateFlowLogsResponse (Maybe Text)
cflrsClientToken = lens _cflrsClientToken (\ s a -> s{_cflrsClientToken = a})
cflrsFlowLogIds :: Lens' CreateFlowLogsResponse [Text]
cflrsFlowLogIds = lens _cflrsFlowLogIds (\ s a -> s{_cflrsFlowLogIds = a}) . _Default . _Coerce
cflrsResponseStatus :: Lens' CreateFlowLogsResponse Int
cflrsResponseStatus = lens _cflrsResponseStatus (\ s a -> s{_cflrsResponseStatus = a})
instance NFData CreateFlowLogsResponse where