{-# 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.DeleteMetricFilter
-- 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)
--
-- Deletes the specified metric filter.
module Amazonka.CloudWatchLogs.DeleteMetricFilter
  ( -- * Creating a Request
    DeleteMetricFilter (..),
    newDeleteMetricFilter,

    -- * Request Lenses
    deleteMetricFilter_logGroupName,
    deleteMetricFilter_filterName,

    -- * Destructuring the Response
    DeleteMetricFilterResponse (..),
    newDeleteMetricFilterResponse,
  )
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:/ 'newDeleteMetricFilter' smart constructor.
data DeleteMetricFilter = DeleteMetricFilter'
  { -- | The name of the log group.
    DeleteMetricFilter -> Text
logGroupName :: Prelude.Text,
    -- | The name of the metric filter.
    DeleteMetricFilter -> Text
filterName :: Prelude.Text
  }
  deriving (DeleteMetricFilter -> DeleteMetricFilter -> Bool
(DeleteMetricFilter -> DeleteMetricFilter -> Bool)
-> (DeleteMetricFilter -> DeleteMetricFilter -> Bool)
-> Eq DeleteMetricFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteMetricFilter -> DeleteMetricFilter -> Bool
$c/= :: DeleteMetricFilter -> DeleteMetricFilter -> Bool
== :: DeleteMetricFilter -> DeleteMetricFilter -> Bool
$c== :: DeleteMetricFilter -> DeleteMetricFilter -> Bool
Prelude.Eq, ReadPrec [DeleteMetricFilter]
ReadPrec DeleteMetricFilter
Int -> ReadS DeleteMetricFilter
ReadS [DeleteMetricFilter]
(Int -> ReadS DeleteMetricFilter)
-> ReadS [DeleteMetricFilter]
-> ReadPrec DeleteMetricFilter
-> ReadPrec [DeleteMetricFilter]
-> Read DeleteMetricFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteMetricFilter]
$creadListPrec :: ReadPrec [DeleteMetricFilter]
readPrec :: ReadPrec DeleteMetricFilter
$creadPrec :: ReadPrec DeleteMetricFilter
readList :: ReadS [DeleteMetricFilter]
$creadList :: ReadS [DeleteMetricFilter]
readsPrec :: Int -> ReadS DeleteMetricFilter
$creadsPrec :: Int -> ReadS DeleteMetricFilter
Prelude.Read, Int -> DeleteMetricFilter -> ShowS
[DeleteMetricFilter] -> ShowS
DeleteMetricFilter -> String
(Int -> DeleteMetricFilter -> ShowS)
-> (DeleteMetricFilter -> String)
-> ([DeleteMetricFilter] -> ShowS)
-> Show DeleteMetricFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteMetricFilter] -> ShowS
$cshowList :: [DeleteMetricFilter] -> ShowS
show :: DeleteMetricFilter -> String
$cshow :: DeleteMetricFilter -> String
showsPrec :: Int -> DeleteMetricFilter -> ShowS
$cshowsPrec :: Int -> DeleteMetricFilter -> ShowS
Prelude.Show, (forall x. DeleteMetricFilter -> Rep DeleteMetricFilter x)
-> (forall x. Rep DeleteMetricFilter x -> DeleteMetricFilter)
-> Generic DeleteMetricFilter
forall x. Rep DeleteMetricFilter x -> DeleteMetricFilter
forall x. DeleteMetricFilter -> Rep DeleteMetricFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteMetricFilter x -> DeleteMetricFilter
$cfrom :: forall x. DeleteMetricFilter -> Rep DeleteMetricFilter x
Prelude.Generic)

-- |
-- Create a value of 'DeleteMetricFilter' 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:
--
-- 'logGroupName', 'deleteMetricFilter_logGroupName' - The name of the log group.
--
-- 'filterName', 'deleteMetricFilter_filterName' - The name of the metric filter.
newDeleteMetricFilter ::
  -- | 'logGroupName'
  Prelude.Text ->
  -- | 'filterName'
  Prelude.Text ->
  DeleteMetricFilter
newDeleteMetricFilter :: Text -> Text -> DeleteMetricFilter
newDeleteMetricFilter Text
pLogGroupName_ Text
pFilterName_ =
  DeleteMetricFilter' :: Text -> Text -> DeleteMetricFilter
DeleteMetricFilter'
    { $sel:logGroupName:DeleteMetricFilter' :: Text
logGroupName = Text
pLogGroupName_,
      $sel:filterName:DeleteMetricFilter' :: Text
filterName = Text
pFilterName_
    }

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

-- | The name of the metric filter.
deleteMetricFilter_filterName :: Lens.Lens' DeleteMetricFilter Prelude.Text
deleteMetricFilter_filterName :: (Text -> f Text) -> DeleteMetricFilter -> f DeleteMetricFilter
deleteMetricFilter_filterName = (DeleteMetricFilter -> Text)
-> (DeleteMetricFilter -> Text -> DeleteMetricFilter)
-> Lens DeleteMetricFilter DeleteMetricFilter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteMetricFilter' {Text
filterName :: Text
$sel:filterName:DeleteMetricFilter' :: DeleteMetricFilter -> Text
filterName} -> Text
filterName) (\s :: DeleteMetricFilter
s@DeleteMetricFilter' {} Text
a -> DeleteMetricFilter
s {$sel:filterName:DeleteMetricFilter' :: Text
filterName = Text
a} :: DeleteMetricFilter)

instance Core.AWSRequest DeleteMetricFilter where
  type
    AWSResponse DeleteMetricFilter =
      DeleteMetricFilterResponse
  request :: DeleteMetricFilter -> Request DeleteMetricFilter
request = Service -> DeleteMetricFilter -> Request DeleteMetricFilter
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteMetricFilter
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteMetricFilter)))
response =
    AWSResponse DeleteMetricFilter
-> Logger
-> Service
-> Proxy DeleteMetricFilter
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteMetricFilter)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DeleteMetricFilter
DeleteMetricFilterResponse
DeleteMetricFilterResponse'

instance Prelude.Hashable DeleteMetricFilter

instance Prelude.NFData DeleteMetricFilter

instance Core.ToHeaders DeleteMetricFilter where
  toHeaders :: DeleteMetricFilter -> [Header]
toHeaders =
    [Header] -> DeleteMetricFilter -> [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.DeleteMetricFilter" ::
                          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 DeleteMetricFilter where
  toJSON :: DeleteMetricFilter -> Value
toJSON DeleteMetricFilter' {Text
filterName :: Text
logGroupName :: Text
$sel:filterName:DeleteMetricFilter' :: DeleteMetricFilter -> Text
$sel:logGroupName:DeleteMetricFilter' :: DeleteMetricFilter -> 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)
          ]
      )

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

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

-- | /See:/ 'newDeleteMetricFilterResponse' smart constructor.
data DeleteMetricFilterResponse = DeleteMetricFilterResponse'
  {
  }
  deriving (DeleteMetricFilterResponse -> DeleteMetricFilterResponse -> Bool
(DeleteMetricFilterResponse -> DeleteMetricFilterResponse -> Bool)
-> (DeleteMetricFilterResponse
    -> DeleteMetricFilterResponse -> Bool)
-> Eq DeleteMetricFilterResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteMetricFilterResponse -> DeleteMetricFilterResponse -> Bool
$c/= :: DeleteMetricFilterResponse -> DeleteMetricFilterResponse -> Bool
== :: DeleteMetricFilterResponse -> DeleteMetricFilterResponse -> Bool
$c== :: DeleteMetricFilterResponse -> DeleteMetricFilterResponse -> Bool
Prelude.Eq, ReadPrec [DeleteMetricFilterResponse]
ReadPrec DeleteMetricFilterResponse
Int -> ReadS DeleteMetricFilterResponse
ReadS [DeleteMetricFilterResponse]
(Int -> ReadS DeleteMetricFilterResponse)
-> ReadS [DeleteMetricFilterResponse]
-> ReadPrec DeleteMetricFilterResponse
-> ReadPrec [DeleteMetricFilterResponse]
-> Read DeleteMetricFilterResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteMetricFilterResponse]
$creadListPrec :: ReadPrec [DeleteMetricFilterResponse]
readPrec :: ReadPrec DeleteMetricFilterResponse
$creadPrec :: ReadPrec DeleteMetricFilterResponse
readList :: ReadS [DeleteMetricFilterResponse]
$creadList :: ReadS [DeleteMetricFilterResponse]
readsPrec :: Int -> ReadS DeleteMetricFilterResponse
$creadsPrec :: Int -> ReadS DeleteMetricFilterResponse
Prelude.Read, Int -> DeleteMetricFilterResponse -> ShowS
[DeleteMetricFilterResponse] -> ShowS
DeleteMetricFilterResponse -> String
(Int -> DeleteMetricFilterResponse -> ShowS)
-> (DeleteMetricFilterResponse -> String)
-> ([DeleteMetricFilterResponse] -> ShowS)
-> Show DeleteMetricFilterResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteMetricFilterResponse] -> ShowS
$cshowList :: [DeleteMetricFilterResponse] -> ShowS
show :: DeleteMetricFilterResponse -> String
$cshow :: DeleteMetricFilterResponse -> String
showsPrec :: Int -> DeleteMetricFilterResponse -> ShowS
$cshowsPrec :: Int -> DeleteMetricFilterResponse -> ShowS
Prelude.Show, (forall x.
 DeleteMetricFilterResponse -> Rep DeleteMetricFilterResponse x)
-> (forall x.
    Rep DeleteMetricFilterResponse x -> DeleteMetricFilterResponse)
-> Generic DeleteMetricFilterResponse
forall x.
Rep DeleteMetricFilterResponse x -> DeleteMetricFilterResponse
forall x.
DeleteMetricFilterResponse -> Rep DeleteMetricFilterResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteMetricFilterResponse x -> DeleteMetricFilterResponse
$cfrom :: forall x.
DeleteMetricFilterResponse -> Rep DeleteMetricFilterResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteMetricFilterResponse' 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.
newDeleteMetricFilterResponse ::
  DeleteMetricFilterResponse
newDeleteMetricFilterResponse :: DeleteMetricFilterResponse
newDeleteMetricFilterResponse =
  DeleteMetricFilterResponse
DeleteMetricFilterResponse'

instance Prelude.NFData DeleteMetricFilterResponse