{-# 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.FraudDetector.DeleteDetector
-- 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 detector. Before deleting a detector, you must first delete
-- all detector versions and rule versions associated with the detector.
--
-- When you delete a detector, Amazon Fraud Detector permanently deletes
-- the detector and the data is no longer stored in Amazon Fraud Detector.
module Amazonka.FraudDetector.DeleteDetector
  ( -- * Creating a Request
    DeleteDetector (..),
    newDeleteDetector,

    -- * Request Lenses
    deleteDetector_detectorId,

    -- * Destructuring the Response
    DeleteDetectorResponse (..),
    newDeleteDetectorResponse,

    -- * Response Lenses
    deleteDetectorResponse_httpStatus,
  )
where

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

-- |
-- Create a value of 'DeleteDetector' 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:
--
-- 'detectorId', 'deleteDetector_detectorId' - The ID of the detector to delete.
newDeleteDetector ::
  -- | 'detectorId'
  Prelude.Text ->
  DeleteDetector
newDeleteDetector :: Text -> DeleteDetector
newDeleteDetector Text
pDetectorId_ =
  DeleteDetector' :: Text -> DeleteDetector
DeleteDetector' {$sel:detectorId:DeleteDetector' :: Text
detectorId = Text
pDetectorId_}

-- | The ID of the detector to delete.
deleteDetector_detectorId :: Lens.Lens' DeleteDetector Prelude.Text
deleteDetector_detectorId :: (Text -> f Text) -> DeleteDetector -> f DeleteDetector
deleteDetector_detectorId = (DeleteDetector -> Text)
-> (DeleteDetector -> Text -> DeleteDetector)
-> Lens DeleteDetector DeleteDetector Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDetector' {Text
detectorId :: Text
$sel:detectorId:DeleteDetector' :: DeleteDetector -> Text
detectorId} -> Text
detectorId) (\s :: DeleteDetector
s@DeleteDetector' {} Text
a -> DeleteDetector
s {$sel:detectorId:DeleteDetector' :: Text
detectorId = Text
a} :: DeleteDetector)

instance Core.AWSRequest DeleteDetector where
  type
    AWSResponse DeleteDetector =
      DeleteDetectorResponse
  request :: DeleteDetector -> Request DeleteDetector
request = Service -> DeleteDetector -> Request DeleteDetector
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteDetector
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteDetector)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteDetector))
-> Logger
-> Service
-> Proxy DeleteDetector
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteDetector)))
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 -> DeleteDetectorResponse
DeleteDetectorResponse'
            (Int -> DeleteDetectorResponse)
-> Either String Int -> Either String DeleteDetectorResponse
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 DeleteDetector

instance Prelude.NFData DeleteDetector

instance Core.ToHeaders DeleteDetector where
  toHeaders :: DeleteDetector -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteDetector -> 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
"AWSHawksNestServiceFacade.DeleteDetector" ::
                          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 DeleteDetector where
  toJSON :: DeleteDetector -> Value
toJSON DeleteDetector' {Text
detectorId :: Text
$sel:detectorId:DeleteDetector' :: DeleteDetector -> 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
"detectorId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
detectorId)]
      )

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

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

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

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

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

instance Prelude.NFData DeleteDetectorResponse