module Network.AWS.CloudWatchLogs.TestMetricFilter
(
TestMetricFilter
, testMetricFilter
, tmfFilterPattern
, tmfLogEventMessages
, TestMetricFilterResponse
, testMetricFilterResponse
, tmfrMatches
) where
import Network.AWS.Prelude
import Network.AWS.Request.JSON
import Network.AWS.CloudWatchLogs.Types
import qualified GHC.Exts
data TestMetricFilter = TestMetricFilter
{ _tmfFilterPattern :: Text
, _tmfLogEventMessages :: List1 "logEventMessages" Text
} deriving (Eq, Ord, Show)
testMetricFilter :: Text
-> NonEmpty Text
-> TestMetricFilter
testMetricFilter p1 p2 = TestMetricFilter
{ _tmfFilterPattern = p1
, _tmfLogEventMessages = withIso _List1 (const id) p2
}
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
newtype TestMetricFilterResponse = TestMetricFilterResponse
{ _tmfrMatches :: List "matches" MetricFilterMatchRecord
} deriving (Eq, Show, Monoid, Semigroup)
instance GHC.Exts.IsList TestMetricFilterResponse where
type Item TestMetricFilterResponse = MetricFilterMatchRecord
fromList = TestMetricFilterResponse . GHC.Exts.fromList
toList = GHC.Exts.toList . _tmfrMatches
testMetricFilterResponse :: TestMetricFilterResponse
testMetricFilterResponse = TestMetricFilterResponse
{ _tmfrMatches = mempty
}
tmfrMatches :: Lens' TestMetricFilterResponse [MetricFilterMatchRecord]
tmfrMatches = lens _tmfrMatches (\s a -> s { _tmfrMatches = a }) . _List
instance ToPath TestMetricFilter where
toPath = const "/"
instance ToQuery TestMetricFilter where
toQuery = const mempty
instance ToHeaders TestMetricFilter
instance ToJSON TestMetricFilter where
toJSON TestMetricFilter{..} = object
[ "filterPattern" .= _tmfFilterPattern
, "logEventMessages" .= _tmfLogEventMessages
]
instance AWSRequest TestMetricFilter where
type Sv TestMetricFilter = CloudWatchLogs
type Rs TestMetricFilter = TestMetricFilterResponse
request = post "TestMetricFilter"
response = jsonResponse
instance FromJSON TestMetricFilterResponse where
parseJSON = withObject "TestMetricFilterResponse" $ \o -> TestMetricFilterResponse
<$> o .:? "matches" .!= mempty