{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CloudWatchLogs.DescribeMetricFilters
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists the specified metric filters. You can list all of the metric
-- filters or filter the results by log name, prefix, metric name, or
-- metric namespace. The results are ASCII-sorted by filter name.
--
-- This operation returns paginated results.
module Amazonka.CloudWatchLogs.DescribeMetricFilters
  ( -- * Creating a Request
    DescribeMetricFilters (..),
    newDescribeMetricFilters,

    -- * Request Lenses
    describeMetricFilters_filterNamePrefix,
    describeMetricFilters_metricName,
    describeMetricFilters_logGroupName,
    describeMetricFilters_nextToken,
    describeMetricFilters_metricNamespace,
    describeMetricFilters_limit,

    -- * Destructuring the Response
    DescribeMetricFiltersResponse (..),
    newDescribeMetricFiltersResponse,

    -- * Response Lenses
    describeMetricFiltersResponse_nextToken,
    describeMetricFiltersResponse_metricFilters,
    describeMetricFiltersResponse_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

-- | /See:/ 'newDescribeMetricFilters' smart constructor.
data DescribeMetricFilters = DescribeMetricFilters'
  { -- | The prefix to match. CloudWatch Logs uses the value you set here only if
    -- you also include the @logGroupName@ parameter in your request.
    DescribeMetricFilters -> Maybe Text
filterNamePrefix :: Prelude.Maybe Prelude.Text,
    -- | Filters results to include only those with the specified metric name. If
    -- you include this parameter in your request, you must also include the
    -- @metricNamespace@ parameter.
    DescribeMetricFilters -> Maybe Text
metricName :: Prelude.Maybe Prelude.Text,
    -- | The name of the log group.
    DescribeMetricFilters -> Maybe Text
logGroupName :: Prelude.Maybe Prelude.Text,
    -- | The token for the next set of items to return. (You received this token
    -- from a previous call.)
    DescribeMetricFilters -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Filters results to include only those in the specified namespace. If you
    -- include this parameter in your request, you must also include the
    -- @metricName@ parameter.
    DescribeMetricFilters -> Maybe Text
metricNamespace :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items returned. If you don\'t specify a value, the
    -- default is up to 50 items.
    DescribeMetricFilters -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural
  }
  deriving (DescribeMetricFilters -> DescribeMetricFilters -> Bool
(DescribeMetricFilters -> DescribeMetricFilters -> Bool)
-> (DescribeMetricFilters -> DescribeMetricFilters -> Bool)
-> Eq DescribeMetricFilters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeMetricFilters -> DescribeMetricFilters -> Bool
$c/= :: DescribeMetricFilters -> DescribeMetricFilters -> Bool
== :: DescribeMetricFilters -> DescribeMetricFilters -> Bool
$c== :: DescribeMetricFilters -> DescribeMetricFilters -> Bool
Prelude.Eq, ReadPrec [DescribeMetricFilters]
ReadPrec DescribeMetricFilters
Int -> ReadS DescribeMetricFilters
ReadS [DescribeMetricFilters]
(Int -> ReadS DescribeMetricFilters)
-> ReadS [DescribeMetricFilters]
-> ReadPrec DescribeMetricFilters
-> ReadPrec [DescribeMetricFilters]
-> Read DescribeMetricFilters
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeMetricFilters]
$creadListPrec :: ReadPrec [DescribeMetricFilters]
readPrec :: ReadPrec DescribeMetricFilters
$creadPrec :: ReadPrec DescribeMetricFilters
readList :: ReadS [DescribeMetricFilters]
$creadList :: ReadS [DescribeMetricFilters]
readsPrec :: Int -> ReadS DescribeMetricFilters
$creadsPrec :: Int -> ReadS DescribeMetricFilters
Prelude.Read, Int -> DescribeMetricFilters -> ShowS
[DescribeMetricFilters] -> ShowS
DescribeMetricFilters -> String
(Int -> DescribeMetricFilters -> ShowS)
-> (DescribeMetricFilters -> String)
-> ([DescribeMetricFilters] -> ShowS)
-> Show DescribeMetricFilters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeMetricFilters] -> ShowS
$cshowList :: [DescribeMetricFilters] -> ShowS
show :: DescribeMetricFilters -> String
$cshow :: DescribeMetricFilters -> String
showsPrec :: Int -> DescribeMetricFilters -> ShowS
$cshowsPrec :: Int -> DescribeMetricFilters -> ShowS
Prelude.Show, (forall x. DescribeMetricFilters -> Rep DescribeMetricFilters x)
-> (forall x. Rep DescribeMetricFilters x -> DescribeMetricFilters)
-> Generic DescribeMetricFilters
forall x. Rep DescribeMetricFilters x -> DescribeMetricFilters
forall x. DescribeMetricFilters -> Rep DescribeMetricFilters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeMetricFilters x -> DescribeMetricFilters
$cfrom :: forall x. DescribeMetricFilters -> Rep DescribeMetricFilters x
Prelude.Generic)

-- |
-- Create a value of 'DescribeMetricFilters' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'filterNamePrefix', 'describeMetricFilters_filterNamePrefix' - The prefix to match. CloudWatch Logs uses the value you set here only if
-- you also include the @logGroupName@ parameter in your request.
--
-- 'metricName', 'describeMetricFilters_metricName' - Filters results to include only those with the specified metric name. If
-- you include this parameter in your request, you must also include the
-- @metricNamespace@ parameter.
--
-- 'logGroupName', 'describeMetricFilters_logGroupName' - The name of the log group.
--
-- 'nextToken', 'describeMetricFilters_nextToken' - The token for the next set of items to return. (You received this token
-- from a previous call.)
--
-- 'metricNamespace', 'describeMetricFilters_metricNamespace' - Filters results to include only those in the specified namespace. If you
-- include this parameter in your request, you must also include the
-- @metricName@ parameter.
--
-- 'limit', 'describeMetricFilters_limit' - The maximum number of items returned. If you don\'t specify a value, the
-- default is up to 50 items.
newDescribeMetricFilters ::
  DescribeMetricFilters
newDescribeMetricFilters :: DescribeMetricFilters
newDescribeMetricFilters =
  DescribeMetricFilters' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> DescribeMetricFilters
DescribeMetricFilters'
    { $sel:filterNamePrefix:DescribeMetricFilters' :: Maybe Text
filterNamePrefix =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:metricName:DescribeMetricFilters' :: Maybe Text
metricName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:logGroupName:DescribeMetricFilters' :: Maybe Text
logGroupName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeMetricFilters' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:metricNamespace:DescribeMetricFilters' :: Maybe Text
metricNamespace = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:DescribeMetricFilters' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The prefix to match. CloudWatch Logs uses the value you set here only if
-- you also include the @logGroupName@ parameter in your request.
describeMetricFilters_filterNamePrefix :: Lens.Lens' DescribeMetricFilters (Prelude.Maybe Prelude.Text)
describeMetricFilters_filterNamePrefix :: (Maybe Text -> f (Maybe Text))
-> DescribeMetricFilters -> f DescribeMetricFilters
describeMetricFilters_filterNamePrefix = (DescribeMetricFilters -> Maybe Text)
-> (DescribeMetricFilters -> Maybe Text -> DescribeMetricFilters)
-> Lens
     DescribeMetricFilters
     DescribeMetricFilters
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMetricFilters' {Maybe Text
filterNamePrefix :: Maybe Text
$sel:filterNamePrefix:DescribeMetricFilters' :: DescribeMetricFilters -> Maybe Text
filterNamePrefix} -> Maybe Text
filterNamePrefix) (\s :: DescribeMetricFilters
s@DescribeMetricFilters' {} Maybe Text
a -> DescribeMetricFilters
s {$sel:filterNamePrefix:DescribeMetricFilters' :: Maybe Text
filterNamePrefix = Maybe Text
a} :: DescribeMetricFilters)

-- | Filters results to include only those with the specified metric name. If
-- you include this parameter in your request, you must also include the
-- @metricNamespace@ parameter.
describeMetricFilters_metricName :: Lens.Lens' DescribeMetricFilters (Prelude.Maybe Prelude.Text)
describeMetricFilters_metricName :: (Maybe Text -> f (Maybe Text))
-> DescribeMetricFilters -> f DescribeMetricFilters
describeMetricFilters_metricName = (DescribeMetricFilters -> Maybe Text)
-> (DescribeMetricFilters -> Maybe Text -> DescribeMetricFilters)
-> Lens
     DescribeMetricFilters
     DescribeMetricFilters
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMetricFilters' {Maybe Text
metricName :: Maybe Text
$sel:metricName:DescribeMetricFilters' :: DescribeMetricFilters -> Maybe Text
metricName} -> Maybe Text
metricName) (\s :: DescribeMetricFilters
s@DescribeMetricFilters' {} Maybe Text
a -> DescribeMetricFilters
s {$sel:metricName:DescribeMetricFilters' :: Maybe Text
metricName = Maybe Text
a} :: DescribeMetricFilters)

-- | The name of the log group.
describeMetricFilters_logGroupName :: Lens.Lens' DescribeMetricFilters (Prelude.Maybe Prelude.Text)
describeMetricFilters_logGroupName :: (Maybe Text -> f (Maybe Text))
-> DescribeMetricFilters -> f DescribeMetricFilters
describeMetricFilters_logGroupName = (DescribeMetricFilters -> Maybe Text)
-> (DescribeMetricFilters -> Maybe Text -> DescribeMetricFilters)
-> Lens
     DescribeMetricFilters
     DescribeMetricFilters
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMetricFilters' {Maybe Text
logGroupName :: Maybe Text
$sel:logGroupName:DescribeMetricFilters' :: DescribeMetricFilters -> Maybe Text
logGroupName} -> Maybe Text
logGroupName) (\s :: DescribeMetricFilters
s@DescribeMetricFilters' {} Maybe Text
a -> DescribeMetricFilters
s {$sel:logGroupName:DescribeMetricFilters' :: Maybe Text
logGroupName = Maybe Text
a} :: DescribeMetricFilters)

-- | The token for the next set of items to return. (You received this token
-- from a previous call.)
describeMetricFilters_nextToken :: Lens.Lens' DescribeMetricFilters (Prelude.Maybe Prelude.Text)
describeMetricFilters_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeMetricFilters -> f DescribeMetricFilters
describeMetricFilters_nextToken = (DescribeMetricFilters -> Maybe Text)
-> (DescribeMetricFilters -> Maybe Text -> DescribeMetricFilters)
-> Lens
     DescribeMetricFilters
     DescribeMetricFilters
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMetricFilters' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeMetricFilters' :: DescribeMetricFilters -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeMetricFilters
s@DescribeMetricFilters' {} Maybe Text
a -> DescribeMetricFilters
s {$sel:nextToken:DescribeMetricFilters' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeMetricFilters)

-- | Filters results to include only those in the specified namespace. If you
-- include this parameter in your request, you must also include the
-- @metricName@ parameter.
describeMetricFilters_metricNamespace :: Lens.Lens' DescribeMetricFilters (Prelude.Maybe Prelude.Text)
describeMetricFilters_metricNamespace :: (Maybe Text -> f (Maybe Text))
-> DescribeMetricFilters -> f DescribeMetricFilters
describeMetricFilters_metricNamespace = (DescribeMetricFilters -> Maybe Text)
-> (DescribeMetricFilters -> Maybe Text -> DescribeMetricFilters)
-> Lens
     DescribeMetricFilters
     DescribeMetricFilters
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMetricFilters' {Maybe Text
metricNamespace :: Maybe Text
$sel:metricNamespace:DescribeMetricFilters' :: DescribeMetricFilters -> Maybe Text
metricNamespace} -> Maybe Text
metricNamespace) (\s :: DescribeMetricFilters
s@DescribeMetricFilters' {} Maybe Text
a -> DescribeMetricFilters
s {$sel:metricNamespace:DescribeMetricFilters' :: Maybe Text
metricNamespace = Maybe Text
a} :: DescribeMetricFilters)

-- | The maximum number of items returned. If you don\'t specify a value, the
-- default is up to 50 items.
describeMetricFilters_limit :: Lens.Lens' DescribeMetricFilters (Prelude.Maybe Prelude.Natural)
describeMetricFilters_limit :: (Maybe Natural -> f (Maybe Natural))
-> DescribeMetricFilters -> f DescribeMetricFilters
describeMetricFilters_limit = (DescribeMetricFilters -> Maybe Natural)
-> (DescribeMetricFilters
    -> Maybe Natural -> DescribeMetricFilters)
-> Lens
     DescribeMetricFilters
     DescribeMetricFilters
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMetricFilters' {Maybe Natural
limit :: Maybe Natural
$sel:limit:DescribeMetricFilters' :: DescribeMetricFilters -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: DescribeMetricFilters
s@DescribeMetricFilters' {} Maybe Natural
a -> DescribeMetricFilters
s {$sel:limit:DescribeMetricFilters' :: Maybe Natural
limit = Maybe Natural
a} :: DescribeMetricFilters)

instance Core.AWSPager DescribeMetricFilters where
  page :: DescribeMetricFilters
-> AWSResponse DescribeMetricFilters -> Maybe DescribeMetricFilters
page DescribeMetricFilters
rq AWSResponse DescribeMetricFilters
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeMetricFilters
DescribeMetricFiltersResponse
rs
            DescribeMetricFiltersResponse
-> Getting (First Text) DescribeMetricFiltersResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeMetricFiltersResponse
-> Const (First Text) DescribeMetricFiltersResponse
Lens' DescribeMetricFiltersResponse (Maybe Text)
describeMetricFiltersResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeMetricFiltersResponse
 -> Const (First Text) DescribeMetricFiltersResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeMetricFiltersResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeMetricFilters
forall a. Maybe a
Prelude.Nothing
    | Maybe [MetricFilter] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeMetricFilters
DescribeMetricFiltersResponse
rs
            DescribeMetricFiltersResponse
-> Getting
     (First [MetricFilter]) DescribeMetricFiltersResponse [MetricFilter]
-> Maybe [MetricFilter]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [MetricFilter]
 -> Const (First [MetricFilter]) (Maybe [MetricFilter]))
-> DescribeMetricFiltersResponse
-> Const (First [MetricFilter]) DescribeMetricFiltersResponse
Lens' DescribeMetricFiltersResponse (Maybe [MetricFilter])
describeMetricFiltersResponse_metricFilters
              ((Maybe [MetricFilter]
  -> Const (First [MetricFilter]) (Maybe [MetricFilter]))
 -> DescribeMetricFiltersResponse
 -> Const (First [MetricFilter]) DescribeMetricFiltersResponse)
-> (([MetricFilter] -> Const (First [MetricFilter]) [MetricFilter])
    -> Maybe [MetricFilter]
    -> Const (First [MetricFilter]) (Maybe [MetricFilter]))
-> Getting
     (First [MetricFilter]) DescribeMetricFiltersResponse [MetricFilter]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([MetricFilter] -> Const (First [MetricFilter]) [MetricFilter])
-> Maybe [MetricFilter]
-> Const (First [MetricFilter]) (Maybe [MetricFilter])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeMetricFilters
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeMetricFilters -> Maybe DescribeMetricFilters
forall a. a -> Maybe a
Prelude.Just (DescribeMetricFilters -> Maybe DescribeMetricFilters)
-> DescribeMetricFilters -> Maybe DescribeMetricFilters
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeMetricFilters
rq
          DescribeMetricFilters
-> (DescribeMetricFilters -> DescribeMetricFilters)
-> DescribeMetricFilters
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeMetricFilters -> Identity DescribeMetricFilters
Lens
  DescribeMetricFilters
  DescribeMetricFilters
  (Maybe Text)
  (Maybe Text)
describeMetricFilters_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeMetricFilters -> Identity DescribeMetricFilters)
-> Maybe Text -> DescribeMetricFilters -> DescribeMetricFilters
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeMetricFilters
DescribeMetricFiltersResponse
rs
          DescribeMetricFiltersResponse
-> Getting (First Text) DescribeMetricFiltersResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeMetricFiltersResponse
-> Const (First Text) DescribeMetricFiltersResponse
Lens' DescribeMetricFiltersResponse (Maybe Text)
describeMetricFiltersResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeMetricFiltersResponse
 -> Const (First Text) DescribeMetricFiltersResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeMetricFiltersResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest DescribeMetricFilters where
  type
    AWSResponse DescribeMetricFilters =
      DescribeMetricFiltersResponse
  request :: DescribeMetricFilters -> Request DescribeMetricFilters
request = Service -> DescribeMetricFilters -> Request DescribeMetricFilters
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeMetricFilters
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeMetricFilters)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeMetricFilters))
-> Logger
-> Service
-> Proxy DescribeMetricFilters
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeMetricFilters)))
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 Text
-> Maybe [MetricFilter] -> Int -> DescribeMetricFiltersResponse
DescribeMetricFiltersResponse'
            (Maybe Text
 -> Maybe [MetricFilter] -> Int -> DescribeMetricFiltersResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [MetricFilter] -> Int -> DescribeMetricFiltersResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextToken")
            Either
  String
  (Maybe [MetricFilter] -> Int -> DescribeMetricFiltersResponse)
-> Either String (Maybe [MetricFilter])
-> Either String (Int -> DescribeMetricFiltersResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [MetricFilter]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"metricFilters" Either String (Maybe (Maybe [MetricFilter]))
-> Maybe [MetricFilter] -> Either String (Maybe [MetricFilter])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [MetricFilter]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> DescribeMetricFiltersResponse)
-> Either String Int -> Either String DescribeMetricFiltersResponse
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 DescribeMetricFilters

instance Prelude.NFData DescribeMetricFilters

instance Core.ToHeaders DescribeMetricFilters where
  toHeaders :: DescribeMetricFilters -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeMetricFilters -> 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.DescribeMetricFilters" ::
                          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 DescribeMetricFilters where
  toJSON :: DescribeMetricFilters -> Value
toJSON DescribeMetricFilters' {Maybe Natural
Maybe Text
limit :: Maybe Natural
metricNamespace :: Maybe Text
nextToken :: Maybe Text
logGroupName :: Maybe Text
metricName :: Maybe Text
filterNamePrefix :: Maybe Text
$sel:limit:DescribeMetricFilters' :: DescribeMetricFilters -> Maybe Natural
$sel:metricNamespace:DescribeMetricFilters' :: DescribeMetricFilters -> Maybe Text
$sel:nextToken:DescribeMetricFilters' :: DescribeMetricFilters -> Maybe Text
$sel:logGroupName:DescribeMetricFilters' :: DescribeMetricFilters -> Maybe Text
$sel:metricName:DescribeMetricFilters' :: DescribeMetricFilters -> Maybe Text
$sel:filterNamePrefix:DescribeMetricFilters' :: DescribeMetricFilters -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"filterNamePrefix" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
filterNamePrefix,
            (Text
"metricName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
metricName,
            (Text
"logGroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
logGroupName,
            (Text
"nextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"metricNamespace" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
metricNamespace,
            (Text
"limit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
limit
          ]
      )

instance Core.ToPath DescribeMetricFilters where
  toPath :: DescribeMetricFilters -> ByteString
toPath = ByteString -> DescribeMetricFilters -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DescribeMetricFilters where
  toQuery :: DescribeMetricFilters -> QueryString
toQuery = QueryString -> DescribeMetricFilters -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newDescribeMetricFiltersResponse' smart constructor.
data DescribeMetricFiltersResponse = DescribeMetricFiltersResponse'
  { DescribeMetricFiltersResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The metric filters.
    DescribeMetricFiltersResponse -> Maybe [MetricFilter]
metricFilters :: Prelude.Maybe [MetricFilter],
    -- | The response's http status code.
    DescribeMetricFiltersResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeMetricFiltersResponse
-> DescribeMetricFiltersResponse -> Bool
(DescribeMetricFiltersResponse
 -> DescribeMetricFiltersResponse -> Bool)
-> (DescribeMetricFiltersResponse
    -> DescribeMetricFiltersResponse -> Bool)
-> Eq DescribeMetricFiltersResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeMetricFiltersResponse
-> DescribeMetricFiltersResponse -> Bool
$c/= :: DescribeMetricFiltersResponse
-> DescribeMetricFiltersResponse -> Bool
== :: DescribeMetricFiltersResponse
-> DescribeMetricFiltersResponse -> Bool
$c== :: DescribeMetricFiltersResponse
-> DescribeMetricFiltersResponse -> Bool
Prelude.Eq, ReadPrec [DescribeMetricFiltersResponse]
ReadPrec DescribeMetricFiltersResponse
Int -> ReadS DescribeMetricFiltersResponse
ReadS [DescribeMetricFiltersResponse]
(Int -> ReadS DescribeMetricFiltersResponse)
-> ReadS [DescribeMetricFiltersResponse]
-> ReadPrec DescribeMetricFiltersResponse
-> ReadPrec [DescribeMetricFiltersResponse]
-> Read DescribeMetricFiltersResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeMetricFiltersResponse]
$creadListPrec :: ReadPrec [DescribeMetricFiltersResponse]
readPrec :: ReadPrec DescribeMetricFiltersResponse
$creadPrec :: ReadPrec DescribeMetricFiltersResponse
readList :: ReadS [DescribeMetricFiltersResponse]
$creadList :: ReadS [DescribeMetricFiltersResponse]
readsPrec :: Int -> ReadS DescribeMetricFiltersResponse
$creadsPrec :: Int -> ReadS DescribeMetricFiltersResponse
Prelude.Read, Int -> DescribeMetricFiltersResponse -> ShowS
[DescribeMetricFiltersResponse] -> ShowS
DescribeMetricFiltersResponse -> String
(Int -> DescribeMetricFiltersResponse -> ShowS)
-> (DescribeMetricFiltersResponse -> String)
-> ([DescribeMetricFiltersResponse] -> ShowS)
-> Show DescribeMetricFiltersResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeMetricFiltersResponse] -> ShowS
$cshowList :: [DescribeMetricFiltersResponse] -> ShowS
show :: DescribeMetricFiltersResponse -> String
$cshow :: DescribeMetricFiltersResponse -> String
showsPrec :: Int -> DescribeMetricFiltersResponse -> ShowS
$cshowsPrec :: Int -> DescribeMetricFiltersResponse -> ShowS
Prelude.Show, (forall x.
 DescribeMetricFiltersResponse
 -> Rep DescribeMetricFiltersResponse x)
-> (forall x.
    Rep DescribeMetricFiltersResponse x
    -> DescribeMetricFiltersResponse)
-> Generic DescribeMetricFiltersResponse
forall x.
Rep DescribeMetricFiltersResponse x
-> DescribeMetricFiltersResponse
forall x.
DescribeMetricFiltersResponse
-> Rep DescribeMetricFiltersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeMetricFiltersResponse x
-> DescribeMetricFiltersResponse
$cfrom :: forall x.
DescribeMetricFiltersResponse
-> Rep DescribeMetricFiltersResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeMetricFiltersResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'nextToken', 'describeMetricFiltersResponse_nextToken' - Undocumented member.
--
-- 'metricFilters', 'describeMetricFiltersResponse_metricFilters' - The metric filters.
--
-- 'httpStatus', 'describeMetricFiltersResponse_httpStatus' - The response's http status code.
newDescribeMetricFiltersResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeMetricFiltersResponse
newDescribeMetricFiltersResponse :: Int -> DescribeMetricFiltersResponse
newDescribeMetricFiltersResponse Int
pHttpStatus_ =
  DescribeMetricFiltersResponse' :: Maybe Text
-> Maybe [MetricFilter] -> Int -> DescribeMetricFiltersResponse
DescribeMetricFiltersResponse'
    { $sel:nextToken:DescribeMetricFiltersResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:metricFilters:DescribeMetricFiltersResponse' :: Maybe [MetricFilter]
metricFilters = Maybe [MetricFilter]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeMetricFiltersResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
describeMetricFiltersResponse_nextToken :: Lens.Lens' DescribeMetricFiltersResponse (Prelude.Maybe Prelude.Text)
describeMetricFiltersResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeMetricFiltersResponse -> f DescribeMetricFiltersResponse
describeMetricFiltersResponse_nextToken = (DescribeMetricFiltersResponse -> Maybe Text)
-> (DescribeMetricFiltersResponse
    -> Maybe Text -> DescribeMetricFiltersResponse)
-> Lens' DescribeMetricFiltersResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMetricFiltersResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeMetricFiltersResponse' :: DescribeMetricFiltersResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeMetricFiltersResponse
s@DescribeMetricFiltersResponse' {} Maybe Text
a -> DescribeMetricFiltersResponse
s {$sel:nextToken:DescribeMetricFiltersResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeMetricFiltersResponse)

-- | The metric filters.
describeMetricFiltersResponse_metricFilters :: Lens.Lens' DescribeMetricFiltersResponse (Prelude.Maybe [MetricFilter])
describeMetricFiltersResponse_metricFilters :: (Maybe [MetricFilter] -> f (Maybe [MetricFilter]))
-> DescribeMetricFiltersResponse -> f DescribeMetricFiltersResponse
describeMetricFiltersResponse_metricFilters = (DescribeMetricFiltersResponse -> Maybe [MetricFilter])
-> (DescribeMetricFiltersResponse
    -> Maybe [MetricFilter] -> DescribeMetricFiltersResponse)
-> Lens' DescribeMetricFiltersResponse (Maybe [MetricFilter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMetricFiltersResponse' {Maybe [MetricFilter]
metricFilters :: Maybe [MetricFilter]
$sel:metricFilters:DescribeMetricFiltersResponse' :: DescribeMetricFiltersResponse -> Maybe [MetricFilter]
metricFilters} -> Maybe [MetricFilter]
metricFilters) (\s :: DescribeMetricFiltersResponse
s@DescribeMetricFiltersResponse' {} Maybe [MetricFilter]
a -> DescribeMetricFiltersResponse
s {$sel:metricFilters:DescribeMetricFiltersResponse' :: Maybe [MetricFilter]
metricFilters = Maybe [MetricFilter]
a} :: DescribeMetricFiltersResponse) ((Maybe [MetricFilter] -> f (Maybe [MetricFilter]))
 -> DescribeMetricFiltersResponse
 -> f DescribeMetricFiltersResponse)
-> ((Maybe [MetricFilter] -> f (Maybe [MetricFilter]))
    -> Maybe [MetricFilter] -> f (Maybe [MetricFilter]))
-> (Maybe [MetricFilter] -> f (Maybe [MetricFilter]))
-> DescribeMetricFiltersResponse
-> f DescribeMetricFiltersResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [MetricFilter] [MetricFilter] [MetricFilter] [MetricFilter]
-> Iso
     (Maybe [MetricFilter])
     (Maybe [MetricFilter])
     (Maybe [MetricFilter])
     (Maybe [MetricFilter])
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 [MetricFilter] [MetricFilter] [MetricFilter] [MetricFilter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
describeMetricFiltersResponse_httpStatus :: Lens.Lens' DescribeMetricFiltersResponse Prelude.Int
describeMetricFiltersResponse_httpStatus :: (Int -> f Int)
-> DescribeMetricFiltersResponse -> f DescribeMetricFiltersResponse
describeMetricFiltersResponse_httpStatus = (DescribeMetricFiltersResponse -> Int)
-> (DescribeMetricFiltersResponse
    -> Int -> DescribeMetricFiltersResponse)
-> Lens
     DescribeMetricFiltersResponse DescribeMetricFiltersResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMetricFiltersResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeMetricFiltersResponse' :: DescribeMetricFiltersResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeMetricFiltersResponse
s@DescribeMetricFiltersResponse' {} Int
a -> DescribeMetricFiltersResponse
s {$sel:httpStatus:DescribeMetricFiltersResponse' :: Int
httpStatus = Int
a} :: DescribeMetricFiltersResponse)

instance Prelude.NFData DescribeMetricFiltersResponse