{-# 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.DeleteDetectorVersion
-- 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 the detector version. You cannot delete detector versions that
-- are in @ACTIVE@ status.
--
-- When you delete a detector version, Amazon Fraud Detector permanently
-- deletes the detector and the data is no longer stored in Amazon Fraud
-- Detector.
module Amazonka.FraudDetector.DeleteDetectorVersion
  ( -- * Creating a Request
    DeleteDetectorVersion (..),
    newDeleteDetectorVersion,

    -- * Request Lenses
    deleteDetectorVersion_detectorId,
    deleteDetectorVersion_detectorVersionId,

    -- * Destructuring the Response
    DeleteDetectorVersionResponse (..),
    newDeleteDetectorVersionResponse,

    -- * Response Lenses
    deleteDetectorVersionResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'DeleteDetectorVersion' 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', 'deleteDetectorVersion_detectorId' - The ID of the parent detector for the detector version to delete.
--
-- 'detectorVersionId', 'deleteDetectorVersion_detectorVersionId' - The ID of the detector version to delete.
newDeleteDetectorVersion ::
  -- | 'detectorId'
  Prelude.Text ->
  -- | 'detectorVersionId'
  Prelude.Text ->
  DeleteDetectorVersion
newDeleteDetectorVersion :: Text -> Text -> DeleteDetectorVersion
newDeleteDetectorVersion
  Text
pDetectorId_
  Text
pDetectorVersionId_ =
    DeleteDetectorVersion'
      { $sel:detectorId:DeleteDetectorVersion' :: Text
detectorId = Text
pDetectorId_,
        $sel:detectorVersionId:DeleteDetectorVersion' :: Text
detectorVersionId = Text
pDetectorVersionId_
      }

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

-- | The ID of the detector version to delete.
deleteDetectorVersion_detectorVersionId :: Lens.Lens' DeleteDetectorVersion Prelude.Text
deleteDetectorVersion_detectorVersionId :: Lens' DeleteDetectorVersion Text
deleteDetectorVersion_detectorVersionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDetectorVersion' {Text
detectorVersionId :: Text
$sel:detectorVersionId:DeleteDetectorVersion' :: DeleteDetectorVersion -> Text
detectorVersionId} -> Text
detectorVersionId) (\s :: DeleteDetectorVersion
s@DeleteDetectorVersion' {} Text
a -> DeleteDetectorVersion
s {$sel:detectorVersionId:DeleteDetectorVersion' :: Text
detectorVersionId = Text
a} :: DeleteDetectorVersion)

instance Core.AWSRequest DeleteDetectorVersion where
  type
    AWSResponse DeleteDetectorVersion =
      DeleteDetectorVersionResponse
  request :: (Service -> Service)
-> DeleteDetectorVersion -> Request DeleteDetectorVersion
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 DeleteDetectorVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteDetectorVersion)))
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 -> DeleteDetectorVersionResponse
DeleteDetectorVersionResponse'
            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 DeleteDetectorVersion where
  hashWithSalt :: Int -> DeleteDetectorVersion -> Int
hashWithSalt Int
_salt DeleteDetectorVersion' {Text
detectorVersionId :: Text
detectorId :: Text
$sel:detectorVersionId:DeleteDetectorVersion' :: DeleteDetectorVersion -> Text
$sel:detectorId:DeleteDetectorVersion' :: DeleteDetectorVersion -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
detectorId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
detectorVersionId

instance Prelude.NFData DeleteDetectorVersion where
  rnf :: DeleteDetectorVersion -> ()
rnf DeleteDetectorVersion' {Text
detectorVersionId :: Text
detectorId :: Text
$sel:detectorVersionId:DeleteDetectorVersion' :: DeleteDetectorVersion -> Text
$sel:detectorId:DeleteDetectorVersion' :: DeleteDetectorVersion -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
detectorId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
detectorVersionId

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

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

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

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

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

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

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

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