{-# 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-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 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 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:/ '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
(DeleteDetectorVersion -> DeleteDetectorVersion -> Bool)
-> (DeleteDetectorVersion -> DeleteDetectorVersion -> Bool)
-> Eq DeleteDetectorVersion
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]
(Int -> ReadS DeleteDetectorVersion)
-> ReadS [DeleteDetectorVersion]
-> ReadPrec DeleteDetectorVersion
-> ReadPrec [DeleteDetectorVersion]
-> Read 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
(Int -> DeleteDetectorVersion -> ShowS)
-> (DeleteDetectorVersion -> String)
-> ([DeleteDetectorVersion] -> ShowS)
-> Show DeleteDetectorVersion
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. DeleteDetectorVersion -> Rep DeleteDetectorVersion x)
-> (forall x. Rep DeleteDetectorVersion x -> DeleteDetectorVersion)
-> Generic DeleteDetectorVersion
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' :: Text -> Text -> DeleteDetectorVersion
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 :: (Text -> f Text)
-> DeleteDetectorVersion -> f DeleteDetectorVersion
deleteDetectorVersion_detectorId = (DeleteDetectorVersion -> Text)
-> (DeleteDetectorVersion -> Text -> DeleteDetectorVersion)
-> Lens DeleteDetectorVersion DeleteDetectorVersion Text Text
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 :: (Text -> f Text)
-> DeleteDetectorVersion -> f DeleteDetectorVersion
deleteDetectorVersion_detectorVersionId = (DeleteDetectorVersion -> Text)
-> (DeleteDetectorVersion -> Text -> DeleteDetectorVersion)
-> Lens DeleteDetectorVersion DeleteDetectorVersion Text Text
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 :: DeleteDetectorVersion -> Request DeleteDetectorVersion
request = Service -> DeleteDetectorVersion -> Request DeleteDetectorVersion
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteDetectorVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteDetectorVersion)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteDetectorVersion))
-> Logger
-> Service
-> Proxy DeleteDetectorVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteDetectorVersion)))
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 -> DeleteDetectorVersionResponse
DeleteDetectorVersionResponse'
            (Int -> DeleteDetectorVersionResponse)
-> Either String Int -> Either String DeleteDetectorVersionResponse
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 DeleteDetectorVersion

instance Prelude.NFData DeleteDetectorVersion

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

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

instance Core.ToQuery DeleteDetectorVersion where
  toQuery :: DeleteDetectorVersion -> QueryString
toQuery = QueryString -> DeleteDetectorVersion -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteDetectorVersionResponse
 -> DeleteDetectorVersionResponse -> Bool)
-> (DeleteDetectorVersionResponse
    -> DeleteDetectorVersionResponse -> Bool)
-> Eq DeleteDetectorVersionResponse
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]
(Int -> ReadS DeleteDetectorVersionResponse)
-> ReadS [DeleteDetectorVersionResponse]
-> ReadPrec DeleteDetectorVersionResponse
-> ReadPrec [DeleteDetectorVersionResponse]
-> Read 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
(Int -> DeleteDetectorVersionResponse -> ShowS)
-> (DeleteDetectorVersionResponse -> String)
-> ([DeleteDetectorVersionResponse] -> ShowS)
-> Show DeleteDetectorVersionResponse
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.
 DeleteDetectorVersionResponse
 -> Rep DeleteDetectorVersionResponse x)
-> (forall x.
    Rep DeleteDetectorVersionResponse x
    -> DeleteDetectorVersionResponse)
-> Generic DeleteDetectorVersionResponse
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' :: Int -> DeleteDetectorVersionResponse
DeleteDetectorVersionResponse'
    { $sel:httpStatus:DeleteDetectorVersionResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
deleteDetectorVersionResponse_httpStatus :: Lens.Lens' DeleteDetectorVersionResponse Prelude.Int
deleteDetectorVersionResponse_httpStatus :: (Int -> f Int)
-> DeleteDetectorVersionResponse -> f DeleteDetectorVersionResponse
deleteDetectorVersionResponse_httpStatus = (DeleteDetectorVersionResponse -> Int)
-> (DeleteDetectorVersionResponse
    -> Int -> DeleteDetectorVersionResponse)
-> Lens
     DeleteDetectorVersionResponse DeleteDetectorVersionResponse Int Int
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