{-# 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.CloudWatchLogs.TestMetricFilter
(
testMetricFilter
, TestMetricFilter
, tmfFilterPattern
, tmfLogEventMessages
, testMetricFilterResponse
, TestMetricFilterResponse
, tmfrsMatches
, tmfrsResponseStatus
) where
import Network.AWS.CloudWatchLogs.Types
import Network.AWS.CloudWatchLogs.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data TestMetricFilter = TestMetricFilter'
{ _tmfFilterPattern :: !Text
, _tmfLogEventMessages :: !(List1 Text)
} deriving (Eq,Read,Show,Data,Typeable,Generic)
testMetricFilter
:: Text
-> NonEmpty Text
-> TestMetricFilter
testMetricFilter pFilterPattern_ pLogEventMessages_ =
TestMetricFilter'
{ _tmfFilterPattern = pFilterPattern_
, _tmfLogEventMessages = _List1 # pLogEventMessages_
}
tmfFilterPattern :: Lens' TestMetricFilter Text
tmfFilterPattern = lens _tmfFilterPattern (\ s a -> s{_tmfFilterPattern = a});
tmfLogEventMessages :: Lens' TestMetricFilter (NonEmpty Text)
tmfLogEventMessages = lens _tmfLogEventMessages (\ s a -> s{_tmfLogEventMessages = a}) . _List1;
instance AWSRequest TestMetricFilter where
type Rs TestMetricFilter = TestMetricFilterResponse
request = postJSON cloudWatchLogs
response
= receiveJSON
(\ s h x ->
TestMetricFilterResponse' <$>
(x .?> "matches" .!@ mempty) <*> (pure (fromEnum s)))
instance Hashable TestMetricFilter
instance NFData TestMetricFilter
instance ToHeaders TestMetricFilter where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("Logs_20140328.TestMetricFilter" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON TestMetricFilter where
toJSON TestMetricFilter'{..}
= object
(catMaybes
[Just ("filterPattern" .= _tmfFilterPattern),
Just ("logEventMessages" .= _tmfLogEventMessages)])
instance ToPath TestMetricFilter where
toPath = const "/"
instance ToQuery TestMetricFilter where
toQuery = const mempty
data TestMetricFilterResponse = TestMetricFilterResponse'
{ _tmfrsMatches :: !(Maybe [MetricFilterMatchRecord])
, _tmfrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
testMetricFilterResponse
:: Int
-> TestMetricFilterResponse
testMetricFilterResponse pResponseStatus_ =
TestMetricFilterResponse'
{ _tmfrsMatches = Nothing
, _tmfrsResponseStatus = pResponseStatus_
}
tmfrsMatches :: Lens' TestMetricFilterResponse [MetricFilterMatchRecord]
tmfrsMatches = lens _tmfrsMatches (\ s a -> s{_tmfrsMatches = a}) . _Default . _Coerce;
tmfrsResponseStatus :: Lens' TestMetricFilterResponse Int
tmfrsResponseStatus = lens _tmfrsResponseStatus (\ s a -> s{_tmfrsResponseStatus = a});
instance NFData TestMetricFilterResponse