{-# 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.PutMetricFilter
(
PutMetricFilter (..),
newPutMetricFilter,
putMetricFilter_logGroupName,
putMetricFilter_filterName,
putMetricFilter_filterPattern,
putMetricFilter_metricTransformations,
PutMetricFilterResponse (..),
newPutMetricFilterResponse,
)
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 PutMetricFilter = PutMetricFilter'
{
PutMetricFilter -> Text
logGroupName :: Prelude.Text,
PutMetricFilter -> Text
filterName :: Prelude.Text,
PutMetricFilter -> Text
filterPattern :: Prelude.Text,
PutMetricFilter -> NonEmpty MetricTransformation
metricTransformations :: Prelude.NonEmpty MetricTransformation
}
deriving (PutMetricFilter -> PutMetricFilter -> Bool
(PutMetricFilter -> PutMetricFilter -> Bool)
-> (PutMetricFilter -> PutMetricFilter -> Bool)
-> Eq PutMetricFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutMetricFilter -> PutMetricFilter -> Bool
$c/= :: PutMetricFilter -> PutMetricFilter -> Bool
== :: PutMetricFilter -> PutMetricFilter -> Bool
$c== :: PutMetricFilter -> PutMetricFilter -> Bool
Prelude.Eq, ReadPrec [PutMetricFilter]
ReadPrec PutMetricFilter
Int -> ReadS PutMetricFilter
ReadS [PutMetricFilter]
(Int -> ReadS PutMetricFilter)
-> ReadS [PutMetricFilter]
-> ReadPrec PutMetricFilter
-> ReadPrec [PutMetricFilter]
-> Read PutMetricFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutMetricFilter]
$creadListPrec :: ReadPrec [PutMetricFilter]
readPrec :: ReadPrec PutMetricFilter
$creadPrec :: ReadPrec PutMetricFilter
readList :: ReadS [PutMetricFilter]
$creadList :: ReadS [PutMetricFilter]
readsPrec :: Int -> ReadS PutMetricFilter
$creadsPrec :: Int -> ReadS PutMetricFilter
Prelude.Read, Int -> PutMetricFilter -> ShowS
[PutMetricFilter] -> ShowS
PutMetricFilter -> String
(Int -> PutMetricFilter -> ShowS)
-> (PutMetricFilter -> String)
-> ([PutMetricFilter] -> ShowS)
-> Show PutMetricFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutMetricFilter] -> ShowS
$cshowList :: [PutMetricFilter] -> ShowS
show :: PutMetricFilter -> String
$cshow :: PutMetricFilter -> String
showsPrec :: Int -> PutMetricFilter -> ShowS
$cshowsPrec :: Int -> PutMetricFilter -> ShowS
Prelude.Show, (forall x. PutMetricFilter -> Rep PutMetricFilter x)
-> (forall x. Rep PutMetricFilter x -> PutMetricFilter)
-> Generic PutMetricFilter
forall x. Rep PutMetricFilter x -> PutMetricFilter
forall x. PutMetricFilter -> Rep PutMetricFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutMetricFilter x -> PutMetricFilter
$cfrom :: forall x. PutMetricFilter -> Rep PutMetricFilter x
Prelude.Generic)
newPutMetricFilter ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
Prelude.NonEmpty MetricTransformation ->
PutMetricFilter
newPutMetricFilter :: Text
-> Text -> Text -> NonEmpty MetricTransformation -> PutMetricFilter
newPutMetricFilter
Text
pLogGroupName_
Text
pFilterName_
Text
pFilterPattern_
NonEmpty MetricTransformation
pMetricTransformations_ =
PutMetricFilter' :: Text
-> Text -> Text -> NonEmpty MetricTransformation -> PutMetricFilter
PutMetricFilter'
{ $sel:logGroupName:PutMetricFilter' :: Text
logGroupName = Text
pLogGroupName_,
$sel:filterName:PutMetricFilter' :: Text
filterName = Text
pFilterName_,
$sel:filterPattern:PutMetricFilter' :: Text
filterPattern = Text
pFilterPattern_,
$sel:metricTransformations:PutMetricFilter' :: NonEmpty MetricTransformation
metricTransformations =
Tagged
(NonEmpty MetricTransformation)
(Identity (NonEmpty MetricTransformation))
-> Tagged
(NonEmpty MetricTransformation)
(Identity (NonEmpty MetricTransformation))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
(NonEmpty MetricTransformation)
(Identity (NonEmpty MetricTransformation))
-> Tagged
(NonEmpty MetricTransformation)
(Identity (NonEmpty MetricTransformation)))
-> NonEmpty MetricTransformation -> NonEmpty MetricTransformation
forall t b. AReview t b -> b -> t
Lens.# NonEmpty MetricTransformation
pMetricTransformations_
}
putMetricFilter_logGroupName :: Lens.Lens' PutMetricFilter Prelude.Text
putMetricFilter_logGroupName :: (Text -> f Text) -> PutMetricFilter -> f PutMetricFilter
putMetricFilter_logGroupName = (PutMetricFilter -> Text)
-> (PutMetricFilter -> Text -> PutMetricFilter)
-> Lens PutMetricFilter PutMetricFilter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetricFilter' {Text
logGroupName :: Text
$sel:logGroupName:PutMetricFilter' :: PutMetricFilter -> Text
logGroupName} -> Text
logGroupName) (\s :: PutMetricFilter
s@PutMetricFilter' {} Text
a -> PutMetricFilter
s {$sel:logGroupName:PutMetricFilter' :: Text
logGroupName = Text
a} :: PutMetricFilter)
putMetricFilter_filterName :: Lens.Lens' PutMetricFilter Prelude.Text
putMetricFilter_filterName :: (Text -> f Text) -> PutMetricFilter -> f PutMetricFilter
putMetricFilter_filterName = (PutMetricFilter -> Text)
-> (PutMetricFilter -> Text -> PutMetricFilter)
-> Lens PutMetricFilter PutMetricFilter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetricFilter' {Text
filterName :: Text
$sel:filterName:PutMetricFilter' :: PutMetricFilter -> Text
filterName} -> Text
filterName) (\s :: PutMetricFilter
s@PutMetricFilter' {} Text
a -> PutMetricFilter
s {$sel:filterName:PutMetricFilter' :: Text
filterName = Text
a} :: PutMetricFilter)
putMetricFilter_filterPattern :: Lens.Lens' PutMetricFilter Prelude.Text
putMetricFilter_filterPattern :: (Text -> f Text) -> PutMetricFilter -> f PutMetricFilter
putMetricFilter_filterPattern = (PutMetricFilter -> Text)
-> (PutMetricFilter -> Text -> PutMetricFilter)
-> Lens PutMetricFilter PutMetricFilter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetricFilter' {Text
filterPattern :: Text
$sel:filterPattern:PutMetricFilter' :: PutMetricFilter -> Text
filterPattern} -> Text
filterPattern) (\s :: PutMetricFilter
s@PutMetricFilter' {} Text
a -> PutMetricFilter
s {$sel:filterPattern:PutMetricFilter' :: Text
filterPattern = Text
a} :: PutMetricFilter)
putMetricFilter_metricTransformations :: Lens.Lens' PutMetricFilter (Prelude.NonEmpty MetricTransformation)
putMetricFilter_metricTransformations :: (NonEmpty MetricTransformation
-> f (NonEmpty MetricTransformation))
-> PutMetricFilter -> f PutMetricFilter
putMetricFilter_metricTransformations = (PutMetricFilter -> NonEmpty MetricTransformation)
-> (PutMetricFilter
-> NonEmpty MetricTransformation -> PutMetricFilter)
-> Lens
PutMetricFilter
PutMetricFilter
(NonEmpty MetricTransformation)
(NonEmpty MetricTransformation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetricFilter' {NonEmpty MetricTransformation
metricTransformations :: NonEmpty MetricTransformation
$sel:metricTransformations:PutMetricFilter' :: PutMetricFilter -> NonEmpty MetricTransformation
metricTransformations} -> NonEmpty MetricTransformation
metricTransformations) (\s :: PutMetricFilter
s@PutMetricFilter' {} NonEmpty MetricTransformation
a -> PutMetricFilter
s {$sel:metricTransformations:PutMetricFilter' :: NonEmpty MetricTransformation
metricTransformations = NonEmpty MetricTransformation
a} :: PutMetricFilter) ((NonEmpty MetricTransformation
-> f (NonEmpty MetricTransformation))
-> PutMetricFilter -> f PutMetricFilter)
-> ((NonEmpty MetricTransformation
-> f (NonEmpty MetricTransformation))
-> NonEmpty MetricTransformation
-> f (NonEmpty MetricTransformation))
-> (NonEmpty MetricTransformation
-> f (NonEmpty MetricTransformation))
-> PutMetricFilter
-> f PutMetricFilter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty MetricTransformation
-> f (NonEmpty MetricTransformation))
-> NonEmpty MetricTransformation
-> f (NonEmpty MetricTransformation)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest PutMetricFilter where
type
AWSResponse PutMetricFilter =
PutMetricFilterResponse
request :: PutMetricFilter -> Request PutMetricFilter
request = Service -> PutMetricFilter -> Request PutMetricFilter
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy PutMetricFilter
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutMetricFilter)))
response =
AWSResponse PutMetricFilter
-> Logger
-> Service
-> Proxy PutMetricFilter
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutMetricFilter)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse PutMetricFilter
PutMetricFilterResponse
PutMetricFilterResponse'
instance Prelude.Hashable PutMetricFilter
instance Prelude.NFData PutMetricFilter
instance Core.ToHeaders PutMetricFilter where
toHeaders :: PutMetricFilter -> [Header]
toHeaders =
[Header] -> PutMetricFilter -> [Header]
forall a b. a -> b -> a
Prelude.const
( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"Logs_20140328.PutMetricFilter" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON PutMetricFilter where
toJSON :: PutMetricFilter -> Value
toJSON PutMetricFilter' {NonEmpty MetricTransformation
Text
metricTransformations :: NonEmpty MetricTransformation
filterPattern :: Text
filterName :: Text
logGroupName :: Text
$sel:metricTransformations:PutMetricFilter' :: PutMetricFilter -> NonEmpty MetricTransformation
$sel:filterPattern:PutMetricFilter' :: PutMetricFilter -> Text
$sel:filterName:PutMetricFilter' :: PutMetricFilter -> Text
$sel:logGroupName:PutMetricFilter' :: PutMetricFilter -> 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
"logGroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
logGroupName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"filterName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
filterName),
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
"metricTransformations"
Text -> NonEmpty MetricTransformation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty MetricTransformation
metricTransformations
)
]
)
instance Core.ToPath PutMetricFilter where
toPath :: PutMetricFilter -> ByteString
toPath = ByteString -> PutMetricFilter -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery PutMetricFilter where
toQuery :: PutMetricFilter -> QueryString
toQuery = QueryString -> PutMetricFilter -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data PutMetricFilterResponse = PutMetricFilterResponse'
{
}
deriving (PutMetricFilterResponse -> PutMetricFilterResponse -> Bool
(PutMetricFilterResponse -> PutMetricFilterResponse -> Bool)
-> (PutMetricFilterResponse -> PutMetricFilterResponse -> Bool)
-> Eq PutMetricFilterResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutMetricFilterResponse -> PutMetricFilterResponse -> Bool
$c/= :: PutMetricFilterResponse -> PutMetricFilterResponse -> Bool
== :: PutMetricFilterResponse -> PutMetricFilterResponse -> Bool
$c== :: PutMetricFilterResponse -> PutMetricFilterResponse -> Bool
Prelude.Eq, ReadPrec [PutMetricFilterResponse]
ReadPrec PutMetricFilterResponse
Int -> ReadS PutMetricFilterResponse
ReadS [PutMetricFilterResponse]
(Int -> ReadS PutMetricFilterResponse)
-> ReadS [PutMetricFilterResponse]
-> ReadPrec PutMetricFilterResponse
-> ReadPrec [PutMetricFilterResponse]
-> Read PutMetricFilterResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutMetricFilterResponse]
$creadListPrec :: ReadPrec [PutMetricFilterResponse]
readPrec :: ReadPrec PutMetricFilterResponse
$creadPrec :: ReadPrec PutMetricFilterResponse
readList :: ReadS [PutMetricFilterResponse]
$creadList :: ReadS [PutMetricFilterResponse]
readsPrec :: Int -> ReadS PutMetricFilterResponse
$creadsPrec :: Int -> ReadS PutMetricFilterResponse
Prelude.Read, Int -> PutMetricFilterResponse -> ShowS
[PutMetricFilterResponse] -> ShowS
PutMetricFilterResponse -> String
(Int -> PutMetricFilterResponse -> ShowS)
-> (PutMetricFilterResponse -> String)
-> ([PutMetricFilterResponse] -> ShowS)
-> Show PutMetricFilterResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutMetricFilterResponse] -> ShowS
$cshowList :: [PutMetricFilterResponse] -> ShowS
show :: PutMetricFilterResponse -> String
$cshow :: PutMetricFilterResponse -> String
showsPrec :: Int -> PutMetricFilterResponse -> ShowS
$cshowsPrec :: Int -> PutMetricFilterResponse -> ShowS
Prelude.Show, (forall x.
PutMetricFilterResponse -> Rep PutMetricFilterResponse x)
-> (forall x.
Rep PutMetricFilterResponse x -> PutMetricFilterResponse)
-> Generic PutMetricFilterResponse
forall x. Rep PutMetricFilterResponse x -> PutMetricFilterResponse
forall x. PutMetricFilterResponse -> Rep PutMetricFilterResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutMetricFilterResponse x -> PutMetricFilterResponse
$cfrom :: forall x. PutMetricFilterResponse -> Rep PutMetricFilterResponse x
Prelude.Generic)
newPutMetricFilterResponse ::
PutMetricFilterResponse
newPutMetricFilterResponse :: PutMetricFilterResponse
newPutMetricFilterResponse = PutMetricFilterResponse
PutMetricFilterResponse'
instance Prelude.NFData PutMetricFilterResponse