{-# 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.IoT.DeleteCustomMetric
-- 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 a Device Defender detect custom metric.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions DeleteCustomMetric>
-- action.
--
-- Before you can delete a custom metric, you must first remove the custom
-- metric from all security profiles it\'s a part of. The security profile
-- associated with the custom metric can be found using the
-- <https://docs.aws.amazon.com/iot/latest/apireference/API_ListSecurityProfiles.html ListSecurityProfiles>
-- API with @metricName@ set to your custom metric name.
module Amazonka.IoT.DeleteCustomMetric
  ( -- * Creating a Request
    DeleteCustomMetric (..),
    newDeleteCustomMetric,

    -- * Request Lenses
    deleteCustomMetric_metricName,

    -- * Destructuring the Response
    DeleteCustomMetricResponse (..),
    newDeleteCustomMetricResponse,

    -- * Response Lenses
    deleteCustomMetricResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types
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:/ 'newDeleteCustomMetric' smart constructor.
data DeleteCustomMetric = DeleteCustomMetric'
  { -- | The name of the custom metric.
    DeleteCustomMetric -> Text
metricName :: Prelude.Text
  }
  deriving (DeleteCustomMetric -> DeleteCustomMetric -> Bool
(DeleteCustomMetric -> DeleteCustomMetric -> Bool)
-> (DeleteCustomMetric -> DeleteCustomMetric -> Bool)
-> Eq DeleteCustomMetric
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteCustomMetric -> DeleteCustomMetric -> Bool
$c/= :: DeleteCustomMetric -> DeleteCustomMetric -> Bool
== :: DeleteCustomMetric -> DeleteCustomMetric -> Bool
$c== :: DeleteCustomMetric -> DeleteCustomMetric -> Bool
Prelude.Eq, ReadPrec [DeleteCustomMetric]
ReadPrec DeleteCustomMetric
Int -> ReadS DeleteCustomMetric
ReadS [DeleteCustomMetric]
(Int -> ReadS DeleteCustomMetric)
-> ReadS [DeleteCustomMetric]
-> ReadPrec DeleteCustomMetric
-> ReadPrec [DeleteCustomMetric]
-> Read DeleteCustomMetric
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteCustomMetric]
$creadListPrec :: ReadPrec [DeleteCustomMetric]
readPrec :: ReadPrec DeleteCustomMetric
$creadPrec :: ReadPrec DeleteCustomMetric
readList :: ReadS [DeleteCustomMetric]
$creadList :: ReadS [DeleteCustomMetric]
readsPrec :: Int -> ReadS DeleteCustomMetric
$creadsPrec :: Int -> ReadS DeleteCustomMetric
Prelude.Read, Int -> DeleteCustomMetric -> ShowS
[DeleteCustomMetric] -> ShowS
DeleteCustomMetric -> String
(Int -> DeleteCustomMetric -> ShowS)
-> (DeleteCustomMetric -> String)
-> ([DeleteCustomMetric] -> ShowS)
-> Show DeleteCustomMetric
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteCustomMetric] -> ShowS
$cshowList :: [DeleteCustomMetric] -> ShowS
show :: DeleteCustomMetric -> String
$cshow :: DeleteCustomMetric -> String
showsPrec :: Int -> DeleteCustomMetric -> ShowS
$cshowsPrec :: Int -> DeleteCustomMetric -> ShowS
Prelude.Show, (forall x. DeleteCustomMetric -> Rep DeleteCustomMetric x)
-> (forall x. Rep DeleteCustomMetric x -> DeleteCustomMetric)
-> Generic DeleteCustomMetric
forall x. Rep DeleteCustomMetric x -> DeleteCustomMetric
forall x. DeleteCustomMetric -> Rep DeleteCustomMetric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteCustomMetric x -> DeleteCustomMetric
$cfrom :: forall x. DeleteCustomMetric -> Rep DeleteCustomMetric x
Prelude.Generic)

-- |
-- Create a value of 'DeleteCustomMetric' 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:
--
-- 'metricName', 'deleteCustomMetric_metricName' - The name of the custom metric.
newDeleteCustomMetric ::
  -- | 'metricName'
  Prelude.Text ->
  DeleteCustomMetric
newDeleteCustomMetric :: Text -> DeleteCustomMetric
newDeleteCustomMetric Text
pMetricName_ =
  DeleteCustomMetric' :: Text -> DeleteCustomMetric
DeleteCustomMetric' {$sel:metricName:DeleteCustomMetric' :: Text
metricName = Text
pMetricName_}

-- | The name of the custom metric.
deleteCustomMetric_metricName :: Lens.Lens' DeleteCustomMetric Prelude.Text
deleteCustomMetric_metricName :: (Text -> f Text) -> DeleteCustomMetric -> f DeleteCustomMetric
deleteCustomMetric_metricName = (DeleteCustomMetric -> Text)
-> (DeleteCustomMetric -> Text -> DeleteCustomMetric)
-> Lens DeleteCustomMetric DeleteCustomMetric Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCustomMetric' {Text
metricName :: Text
$sel:metricName:DeleteCustomMetric' :: DeleteCustomMetric -> Text
metricName} -> Text
metricName) (\s :: DeleteCustomMetric
s@DeleteCustomMetric' {} Text
a -> DeleteCustomMetric
s {$sel:metricName:DeleteCustomMetric' :: Text
metricName = Text
a} :: DeleteCustomMetric)

instance Core.AWSRequest DeleteCustomMetric where
  type
    AWSResponse DeleteCustomMetric =
      DeleteCustomMetricResponse
  request :: DeleteCustomMetric -> Request DeleteCustomMetric
request = Service -> DeleteCustomMetric -> Request DeleteCustomMetric
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteCustomMetric
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteCustomMetric)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteCustomMetric))
-> Logger
-> Service
-> Proxy DeleteCustomMetric
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteCustomMetric)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteCustomMetricResponse
DeleteCustomMetricResponse'
            (Int -> DeleteCustomMetricResponse)
-> Either String Int -> Either String DeleteCustomMetricResponse
forall (f :: * -> *) a b. Functor 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 DeleteCustomMetric

instance Prelude.NFData DeleteCustomMetric

instance Core.ToHeaders DeleteCustomMetric where
  toHeaders :: DeleteCustomMetric -> ResponseHeaders
toHeaders = ResponseHeaders -> DeleteCustomMetric -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath DeleteCustomMetric where
  toPath :: DeleteCustomMetric -> ByteString
toPath DeleteCustomMetric' {Text
metricName :: Text
$sel:metricName:DeleteCustomMetric' :: DeleteCustomMetric -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/custom-metric/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
metricName]

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

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

-- |
-- Create a value of 'DeleteCustomMetricResponse' 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:
--
-- 'httpStatus', 'deleteCustomMetricResponse_httpStatus' - The response's http status code.
newDeleteCustomMetricResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteCustomMetricResponse
newDeleteCustomMetricResponse :: Int -> DeleteCustomMetricResponse
newDeleteCustomMetricResponse Int
pHttpStatus_ =
  DeleteCustomMetricResponse' :: Int -> DeleteCustomMetricResponse
DeleteCustomMetricResponse'
    { $sel:httpStatus:DeleteCustomMetricResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData DeleteCustomMetricResponse