{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.CloudWatchLogs.TestMetricFilter
(
TestMetricFilter (..),
newTestMetricFilter,
testMetricFilter_filterPattern,
testMetricFilter_logEventMessages,
TestMetricFilterResponse (..),
newTestMetricFilterResponse,
testMetricFilterResponse_matches,
testMetricFilterResponse_httpStatus,
)
where
import Amazonka.CloudWatchLogs.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data TestMetricFilter = TestMetricFilter'
{ TestMetricFilter -> Text
filterPattern :: Prelude.Text,
TestMetricFilter -> NonEmpty Text
logEventMessages :: Prelude.NonEmpty Prelude.Text
}
deriving (TestMetricFilter -> TestMetricFilter -> Bool
(TestMetricFilter -> TestMetricFilter -> Bool)
-> (TestMetricFilter -> TestMetricFilter -> Bool)
-> Eq TestMetricFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestMetricFilter -> TestMetricFilter -> Bool
$c/= :: TestMetricFilter -> TestMetricFilter -> Bool
== :: TestMetricFilter -> TestMetricFilter -> Bool
$c== :: TestMetricFilter -> TestMetricFilter -> Bool
Prelude.Eq, ReadPrec [TestMetricFilter]
ReadPrec TestMetricFilter
Int -> ReadS TestMetricFilter
ReadS [TestMetricFilter]
(Int -> ReadS TestMetricFilter)
-> ReadS [TestMetricFilter]
-> ReadPrec TestMetricFilter
-> ReadPrec [TestMetricFilter]
-> Read TestMetricFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TestMetricFilter]
$creadListPrec :: ReadPrec [TestMetricFilter]
readPrec :: ReadPrec TestMetricFilter
$creadPrec :: ReadPrec TestMetricFilter
readList :: ReadS [TestMetricFilter]
$creadList :: ReadS [TestMetricFilter]
readsPrec :: Int -> ReadS TestMetricFilter
$creadsPrec :: Int -> ReadS TestMetricFilter
Prelude.Read, Int -> TestMetricFilter -> ShowS
[TestMetricFilter] -> ShowS
TestMetricFilter -> String
(Int -> TestMetricFilter -> ShowS)
-> (TestMetricFilter -> String)
-> ([TestMetricFilter] -> ShowS)
-> Show TestMetricFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestMetricFilter] -> ShowS
$cshowList :: [TestMetricFilter] -> ShowS
show :: TestMetricFilter -> String
$cshow :: TestMetricFilter -> String
showsPrec :: Int -> TestMetricFilter -> ShowS
$cshowsPrec :: Int -> TestMetricFilter -> ShowS
Prelude.Show, (forall x. TestMetricFilter -> Rep TestMetricFilter x)
-> (forall x. Rep TestMetricFilter x -> TestMetricFilter)
-> Generic TestMetricFilter
forall x. Rep TestMetricFilter x -> TestMetricFilter
forall x. TestMetricFilter -> Rep TestMetricFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TestMetricFilter x -> TestMetricFilter
$cfrom :: forall x. TestMetricFilter -> Rep TestMetricFilter x
Prelude.Generic)
newTestMetricFilter ::
Prelude.Text ->
Prelude.NonEmpty Prelude.Text ->
TestMetricFilter
newTestMetricFilter :: Text -> NonEmpty Text -> TestMetricFilter
newTestMetricFilter
Text
pFilterPattern_
NonEmpty Text
pLogEventMessages_ =
TestMetricFilter' :: Text -> NonEmpty Text -> TestMetricFilter
TestMetricFilter'
{ $sel:filterPattern:TestMetricFilter' :: Text
filterPattern = Text
pFilterPattern_,
$sel:logEventMessages:TestMetricFilter' :: NonEmpty Text
logEventMessages =
Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pLogEventMessages_
}
testMetricFilter_filterPattern :: Lens.Lens' TestMetricFilter Prelude.Text
testMetricFilter_filterPattern :: (Text -> f Text) -> TestMetricFilter -> f TestMetricFilter
testMetricFilter_filterPattern = (TestMetricFilter -> Text)
-> (TestMetricFilter -> Text -> TestMetricFilter)
-> Lens TestMetricFilter TestMetricFilter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestMetricFilter' {Text
filterPattern :: Text
$sel:filterPattern:TestMetricFilter' :: TestMetricFilter -> Text
filterPattern} -> Text
filterPattern) (\s :: TestMetricFilter
s@TestMetricFilter' {} Text
a -> TestMetricFilter
s {$sel:filterPattern:TestMetricFilter' :: Text
filterPattern = Text
a} :: TestMetricFilter)
testMetricFilter_logEventMessages :: Lens.Lens' TestMetricFilter (Prelude.NonEmpty Prelude.Text)
testMetricFilter_logEventMessages :: (NonEmpty Text -> f (NonEmpty Text))
-> TestMetricFilter -> f TestMetricFilter
testMetricFilter_logEventMessages = (TestMetricFilter -> NonEmpty Text)
-> (TestMetricFilter -> NonEmpty Text -> TestMetricFilter)
-> Lens
TestMetricFilter TestMetricFilter (NonEmpty Text) (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestMetricFilter' {NonEmpty Text
logEventMessages :: NonEmpty Text
$sel:logEventMessages:TestMetricFilter' :: TestMetricFilter -> NonEmpty Text
logEventMessages} -> NonEmpty Text
logEventMessages) (\s :: TestMetricFilter
s@TestMetricFilter' {} NonEmpty Text
a -> TestMetricFilter
s {$sel:logEventMessages:TestMetricFilter' :: NonEmpty Text
logEventMessages = NonEmpty Text
a} :: TestMetricFilter) ((NonEmpty Text -> f (NonEmpty Text))
-> TestMetricFilter -> f TestMetricFilter)
-> ((NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> TestMetricFilter
-> f TestMetricFilter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest TestMetricFilter where
type
AWSResponse TestMetricFilter =
TestMetricFilterResponse
request :: TestMetricFilter -> Request TestMetricFilter
request = Service -> TestMetricFilter -> Request TestMetricFilter
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy TestMetricFilter
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse TestMetricFilter)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse TestMetricFilter))
-> Logger
-> Service
-> Proxy TestMetricFilter
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse TestMetricFilter)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe [MetricFilterMatchRecord] -> Int -> TestMetricFilterResponse
TestMetricFilterResponse'
(Maybe [MetricFilterMatchRecord]
-> Int -> TestMetricFilterResponse)
-> Either String (Maybe [MetricFilterMatchRecord])
-> Either String (Int -> TestMetricFilterResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Either String (Maybe (Maybe [MetricFilterMatchRecord]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"matches" Either String (Maybe (Maybe [MetricFilterMatchRecord]))
-> Maybe [MetricFilterMatchRecord]
-> Either String (Maybe [MetricFilterMatchRecord])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [MetricFilterMatchRecord]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> TestMetricFilterResponse)
-> Either String Int -> Either String TestMetricFilterResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable TestMetricFilter
instance Prelude.NFData TestMetricFilter
instance Core.ToHeaders TestMetricFilter where
toHeaders :: TestMetricFilter -> ResponseHeaders
toHeaders =
ResponseHeaders -> TestMetricFilter -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Logs_20140328.TestMetricFilter" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON TestMetricFilter where
toJSON :: TestMetricFilter -> Value
toJSON TestMetricFilter' {NonEmpty Text
Text
logEventMessages :: NonEmpty Text
filterPattern :: Text
$sel:logEventMessages:TestMetricFilter' :: TestMetricFilter -> NonEmpty Text
$sel:filterPattern:TestMetricFilter' :: TestMetricFilter -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"filterPattern" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
filterPattern),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"logEventMessages" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
logEventMessages)
]
)
instance Core.ToPath TestMetricFilter where
toPath :: TestMetricFilter -> ByteString
toPath = ByteString -> TestMetricFilter -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery TestMetricFilter where
toQuery :: TestMetricFilter -> QueryString
toQuery = QueryString -> TestMetricFilter -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data TestMetricFilterResponse = TestMetricFilterResponse'
{
TestMetricFilterResponse -> Maybe [MetricFilterMatchRecord]
matches :: Prelude.Maybe [MetricFilterMatchRecord],
TestMetricFilterResponse -> Int
httpStatus :: Prelude.Int
}
deriving (TestMetricFilterResponse -> TestMetricFilterResponse -> Bool
(TestMetricFilterResponse -> TestMetricFilterResponse -> Bool)
-> (TestMetricFilterResponse -> TestMetricFilterResponse -> Bool)
-> Eq TestMetricFilterResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestMetricFilterResponse -> TestMetricFilterResponse -> Bool
$c/= :: TestMetricFilterResponse -> TestMetricFilterResponse -> Bool
== :: TestMetricFilterResponse -> TestMetricFilterResponse -> Bool
$c== :: TestMetricFilterResponse -> TestMetricFilterResponse -> Bool
Prelude.Eq, ReadPrec [TestMetricFilterResponse]
ReadPrec TestMetricFilterResponse
Int -> ReadS TestMetricFilterResponse
ReadS [TestMetricFilterResponse]
(Int -> ReadS TestMetricFilterResponse)
-> ReadS [TestMetricFilterResponse]
-> ReadPrec TestMetricFilterResponse
-> ReadPrec [TestMetricFilterResponse]
-> Read TestMetricFilterResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TestMetricFilterResponse]
$creadListPrec :: ReadPrec [TestMetricFilterResponse]
readPrec :: ReadPrec TestMetricFilterResponse
$creadPrec :: ReadPrec TestMetricFilterResponse
readList :: ReadS [TestMetricFilterResponse]
$creadList :: ReadS [TestMetricFilterResponse]
readsPrec :: Int -> ReadS TestMetricFilterResponse
$creadsPrec :: Int -> ReadS TestMetricFilterResponse
Prelude.Read, Int -> TestMetricFilterResponse -> ShowS
[TestMetricFilterResponse] -> ShowS
TestMetricFilterResponse -> String
(Int -> TestMetricFilterResponse -> ShowS)
-> (TestMetricFilterResponse -> String)
-> ([TestMetricFilterResponse] -> ShowS)
-> Show TestMetricFilterResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestMetricFilterResponse] -> ShowS
$cshowList :: [TestMetricFilterResponse] -> ShowS
show :: TestMetricFilterResponse -> String
$cshow :: TestMetricFilterResponse -> String
showsPrec :: Int -> TestMetricFilterResponse -> ShowS
$cshowsPrec :: Int -> TestMetricFilterResponse -> ShowS
Prelude.Show, (forall x.
TestMetricFilterResponse -> Rep TestMetricFilterResponse x)
-> (forall x.
Rep TestMetricFilterResponse x -> TestMetricFilterResponse)
-> Generic TestMetricFilterResponse
forall x.
Rep TestMetricFilterResponse x -> TestMetricFilterResponse
forall x.
TestMetricFilterResponse -> Rep TestMetricFilterResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TestMetricFilterResponse x -> TestMetricFilterResponse
$cfrom :: forall x.
TestMetricFilterResponse -> Rep TestMetricFilterResponse x
Prelude.Generic)
newTestMetricFilterResponse ::
Prelude.Int ->
TestMetricFilterResponse
newTestMetricFilterResponse :: Int -> TestMetricFilterResponse
newTestMetricFilterResponse Int
pHttpStatus_ =
TestMetricFilterResponse' :: Maybe [MetricFilterMatchRecord] -> Int -> TestMetricFilterResponse
TestMetricFilterResponse'
{ $sel:matches:TestMetricFilterResponse' :: Maybe [MetricFilterMatchRecord]
matches =
Maybe [MetricFilterMatchRecord]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:TestMetricFilterResponse' :: Int
httpStatus = Int
pHttpStatus_
}
testMetricFilterResponse_matches :: Lens.Lens' TestMetricFilterResponse (Prelude.Maybe [MetricFilterMatchRecord])
testMetricFilterResponse_matches :: (Maybe [MetricFilterMatchRecord]
-> f (Maybe [MetricFilterMatchRecord]))
-> TestMetricFilterResponse -> f TestMetricFilterResponse
testMetricFilterResponse_matches = (TestMetricFilterResponse -> Maybe [MetricFilterMatchRecord])
-> (TestMetricFilterResponse
-> Maybe [MetricFilterMatchRecord] -> TestMetricFilterResponse)
-> Lens
TestMetricFilterResponse
TestMetricFilterResponse
(Maybe [MetricFilterMatchRecord])
(Maybe [MetricFilterMatchRecord])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestMetricFilterResponse' {Maybe [MetricFilterMatchRecord]
matches :: Maybe [MetricFilterMatchRecord]
$sel:matches:TestMetricFilterResponse' :: TestMetricFilterResponse -> Maybe [MetricFilterMatchRecord]
matches} -> Maybe [MetricFilterMatchRecord]
matches) (\s :: TestMetricFilterResponse
s@TestMetricFilterResponse' {} Maybe [MetricFilterMatchRecord]
a -> TestMetricFilterResponse
s {$sel:matches:TestMetricFilterResponse' :: Maybe [MetricFilterMatchRecord]
matches = Maybe [MetricFilterMatchRecord]
a} :: TestMetricFilterResponse) ((Maybe [MetricFilterMatchRecord]
-> f (Maybe [MetricFilterMatchRecord]))
-> TestMetricFilterResponse -> f TestMetricFilterResponse)
-> ((Maybe [MetricFilterMatchRecord]
-> f (Maybe [MetricFilterMatchRecord]))
-> Maybe [MetricFilterMatchRecord]
-> f (Maybe [MetricFilterMatchRecord]))
-> (Maybe [MetricFilterMatchRecord]
-> f (Maybe [MetricFilterMatchRecord]))
-> TestMetricFilterResponse
-> f TestMetricFilterResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[MetricFilterMatchRecord]
[MetricFilterMatchRecord]
[MetricFilterMatchRecord]
[MetricFilterMatchRecord]
-> Iso
(Maybe [MetricFilterMatchRecord])
(Maybe [MetricFilterMatchRecord])
(Maybe [MetricFilterMatchRecord])
(Maybe [MetricFilterMatchRecord])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
[MetricFilterMatchRecord]
[MetricFilterMatchRecord]
[MetricFilterMatchRecord]
[MetricFilterMatchRecord]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
testMetricFilterResponse_httpStatus :: Lens.Lens' TestMetricFilterResponse Prelude.Int
testMetricFilterResponse_httpStatus :: (Int -> f Int)
-> TestMetricFilterResponse -> f TestMetricFilterResponse
testMetricFilterResponse_httpStatus = (TestMetricFilterResponse -> Int)
-> (TestMetricFilterResponse -> Int -> TestMetricFilterResponse)
-> Lens TestMetricFilterResponse TestMetricFilterResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestMetricFilterResponse' {Int
httpStatus :: Int
$sel:httpStatus:TestMetricFilterResponse' :: TestMetricFilterResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: TestMetricFilterResponse
s@TestMetricFilterResponse' {} Int
a -> TestMetricFilterResponse
s {$sel:httpStatus:TestMetricFilterResponse' :: Int
httpStatus = Int
a} :: TestMetricFilterResponse)
instance Prelude.NFData TestMetricFilterResponse