{-# 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.LookoutMetrics.DeleteAnomalyDetector
-- 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 detector. Deleting an anomaly detector will delete all of its
-- corresponding resources including any configured datasets and alerts.
module Amazonka.LookoutMetrics.DeleteAnomalyDetector
  ( -- * Creating a Request
    DeleteAnomalyDetector (..),
    newDeleteAnomalyDetector,

    -- * Request Lenses
    deleteAnomalyDetector_anomalyDetectorArn,

    -- * Destructuring the Response
    DeleteAnomalyDetectorResponse (..),
    newDeleteAnomalyDetectorResponse,

    -- * Response Lenses
    deleteAnomalyDetectorResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LookoutMetrics.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

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

-- |
-- Create a value of 'DeleteAnomalyDetector' 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:
--
-- 'anomalyDetectorArn', 'deleteAnomalyDetector_anomalyDetectorArn' - The ARN of the detector to delete.
newDeleteAnomalyDetector ::
  -- | 'anomalyDetectorArn'
  Prelude.Text ->
  DeleteAnomalyDetector
newDeleteAnomalyDetector :: Text -> DeleteAnomalyDetector
newDeleteAnomalyDetector Text
pAnomalyDetectorArn_ =
  DeleteAnomalyDetector'
    { $sel:anomalyDetectorArn:DeleteAnomalyDetector' :: Text
anomalyDetectorArn =
        Text
pAnomalyDetectorArn_
    }

-- | The ARN of the detector to delete.
deleteAnomalyDetector_anomalyDetectorArn :: Lens.Lens' DeleteAnomalyDetector Prelude.Text
deleteAnomalyDetector_anomalyDetectorArn :: Lens' DeleteAnomalyDetector Text
deleteAnomalyDetector_anomalyDetectorArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAnomalyDetector' {Text
anomalyDetectorArn :: Text
$sel:anomalyDetectorArn:DeleteAnomalyDetector' :: DeleteAnomalyDetector -> Text
anomalyDetectorArn} -> Text
anomalyDetectorArn) (\s :: DeleteAnomalyDetector
s@DeleteAnomalyDetector' {} Text
a -> DeleteAnomalyDetector
s {$sel:anomalyDetectorArn:DeleteAnomalyDetector' :: Text
anomalyDetectorArn = Text
a} :: DeleteAnomalyDetector)

instance Core.AWSRequest DeleteAnomalyDetector where
  type
    AWSResponse DeleteAnomalyDetector =
      DeleteAnomalyDetectorResponse
  request :: (Service -> Service)
-> DeleteAnomalyDetector -> Request DeleteAnomalyDetector
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteAnomalyDetector
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteAnomalyDetector)))
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 -> DeleteAnomalyDetectorResponse
DeleteAnomalyDetectorResponse'
            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 DeleteAnomalyDetector where
  hashWithSalt :: Int -> DeleteAnomalyDetector -> Int
hashWithSalt Int
_salt DeleteAnomalyDetector' {Text
anomalyDetectorArn :: Text
$sel:anomalyDetectorArn:DeleteAnomalyDetector' :: DeleteAnomalyDetector -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
anomalyDetectorArn

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

instance Data.ToHeaders DeleteAnomalyDetector where
  toHeaders :: DeleteAnomalyDetector -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteAnomalyDetector where
  toJSON :: DeleteAnomalyDetector -> Value
toJSON DeleteAnomalyDetector' {Text
anomalyDetectorArn :: Text
$sel:anomalyDetectorArn:DeleteAnomalyDetector' :: DeleteAnomalyDetector -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"AnomalyDetectorArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
anomalyDetectorArn)
          ]
      )

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

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

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

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

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

instance Prelude.NFData DeleteAnomalyDetectorResponse where
  rnf :: DeleteAnomalyDetectorResponse -> ()
rnf DeleteAnomalyDetectorResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteAnomalyDetectorResponse' :: DeleteAnomalyDetectorResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus