{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types
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
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]
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
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. 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' {$sel:metricName:DeleteCustomMetric' :: Text
metricName = Text
pMetricName_}

-- | The name of the custom metric.
deleteCustomMetric_metricName :: Lens.Lens' DeleteCustomMetric Prelude.Text
deleteCustomMetric_metricName :: Lens' DeleteCustomMetric Text
deleteCustomMetric_metricName = 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 :: (Service -> Service)
-> DeleteCustomMetric -> Request DeleteCustomMetric
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteCustomMetric
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteCustomMetric)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteCustomMetricResponse
DeleteCustomMetricResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteCustomMetric where
  hashWithSalt :: Int -> DeleteCustomMetric -> Int
hashWithSalt Int
_salt DeleteCustomMetric' {Text
metricName :: Text
$sel:metricName:DeleteCustomMetric' :: DeleteCustomMetric -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
metricName

instance Prelude.NFData DeleteCustomMetric where
  rnf :: DeleteCustomMetric -> ()
rnf DeleteCustomMetric' {Text
metricName :: Text
$sel:metricName:DeleteCustomMetric' :: DeleteCustomMetric -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
metricName

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

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

instance Data.ToQuery DeleteCustomMetric where
  toQuery :: DeleteCustomMetric -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:httpStatus:DeleteCustomMetricResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
deleteCustomMetricResponse_httpStatus :: Lens.Lens' DeleteCustomMetricResponse Prelude.Int
deleteCustomMetricResponse_httpStatus :: Lens' DeleteCustomMetricResponse Int
deleteCustomMetricResponse_httpStatus = 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 where
  rnf :: DeleteCustomMetricResponse -> ()
rnf DeleteCustomMetricResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteCustomMetricResponse' :: DeleteCustomMetricResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus