{-# 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.DeleteModelVersion
-- 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 a model version.
--
-- You can delete models and model versions in Amazon Fraud Detector,
-- provided that they are not associated with a detector version.
--
-- When you delete a model version, Amazon Fraud Detector permanently
-- deletes that model version and the data is no longer stored in Amazon
-- Fraud Detector.
module Amazonka.FraudDetector.DeleteModelVersion
  ( -- * Creating a Request
    DeleteModelVersion (..),
    newDeleteModelVersion,

    -- * Request Lenses
    deleteModelVersion_modelId,
    deleteModelVersion_modelType,
    deleteModelVersion_modelVersionNumber,

    -- * Destructuring the Response
    DeleteModelVersionResponse (..),
    newDeleteModelVersionResponse,

    -- * Response Lenses
    deleteModelVersionResponse_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:/ 'newDeleteModelVersion' smart constructor.
data DeleteModelVersion = DeleteModelVersion'
  { -- | The model ID of the model version to delete.
    DeleteModelVersion -> Text
modelId :: Prelude.Text,
    -- | The model type of the model version to delete.
    DeleteModelVersion -> ModelTypeEnum
modelType :: ModelTypeEnum,
    -- | The model version number of the model version to delete.
    DeleteModelVersion -> Text
modelVersionNumber :: Prelude.Text
  }
  deriving (DeleteModelVersion -> DeleteModelVersion -> Bool
(DeleteModelVersion -> DeleteModelVersion -> Bool)
-> (DeleteModelVersion -> DeleteModelVersion -> Bool)
-> Eq DeleteModelVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteModelVersion -> DeleteModelVersion -> Bool
$c/= :: DeleteModelVersion -> DeleteModelVersion -> Bool
== :: DeleteModelVersion -> DeleteModelVersion -> Bool
$c== :: DeleteModelVersion -> DeleteModelVersion -> Bool
Prelude.Eq, ReadPrec [DeleteModelVersion]
ReadPrec DeleteModelVersion
Int -> ReadS DeleteModelVersion
ReadS [DeleteModelVersion]
(Int -> ReadS DeleteModelVersion)
-> ReadS [DeleteModelVersion]
-> ReadPrec DeleteModelVersion
-> ReadPrec [DeleteModelVersion]
-> Read DeleteModelVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteModelVersion]
$creadListPrec :: ReadPrec [DeleteModelVersion]
readPrec :: ReadPrec DeleteModelVersion
$creadPrec :: ReadPrec DeleteModelVersion
readList :: ReadS [DeleteModelVersion]
$creadList :: ReadS [DeleteModelVersion]
readsPrec :: Int -> ReadS DeleteModelVersion
$creadsPrec :: Int -> ReadS DeleteModelVersion
Prelude.Read, Int -> DeleteModelVersion -> ShowS
[DeleteModelVersion] -> ShowS
DeleteModelVersion -> String
(Int -> DeleteModelVersion -> ShowS)
-> (DeleteModelVersion -> String)
-> ([DeleteModelVersion] -> ShowS)
-> Show DeleteModelVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteModelVersion] -> ShowS
$cshowList :: [DeleteModelVersion] -> ShowS
show :: DeleteModelVersion -> String
$cshow :: DeleteModelVersion -> String
showsPrec :: Int -> DeleteModelVersion -> ShowS
$cshowsPrec :: Int -> DeleteModelVersion -> ShowS
Prelude.Show, (forall x. DeleteModelVersion -> Rep DeleteModelVersion x)
-> (forall x. Rep DeleteModelVersion x -> DeleteModelVersion)
-> Generic DeleteModelVersion
forall x. Rep DeleteModelVersion x -> DeleteModelVersion
forall x. DeleteModelVersion -> Rep DeleteModelVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteModelVersion x -> DeleteModelVersion
$cfrom :: forall x. DeleteModelVersion -> Rep DeleteModelVersion x
Prelude.Generic)

-- |
-- Create a value of 'DeleteModelVersion' 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:
--
-- 'modelId', 'deleteModelVersion_modelId' - The model ID of the model version to delete.
--
-- 'modelType', 'deleteModelVersion_modelType' - The model type of the model version to delete.
--
-- 'modelVersionNumber', 'deleteModelVersion_modelVersionNumber' - The model version number of the model version to delete.
newDeleteModelVersion ::
  -- | 'modelId'
  Prelude.Text ->
  -- | 'modelType'
  ModelTypeEnum ->
  -- | 'modelVersionNumber'
  Prelude.Text ->
  DeleteModelVersion
newDeleteModelVersion :: Text -> ModelTypeEnum -> Text -> DeleteModelVersion
newDeleteModelVersion
  Text
pModelId_
  ModelTypeEnum
pModelType_
  Text
pModelVersionNumber_ =
    DeleteModelVersion' :: Text -> ModelTypeEnum -> Text -> DeleteModelVersion
DeleteModelVersion'
      { $sel:modelId:DeleteModelVersion' :: Text
modelId = Text
pModelId_,
        $sel:modelType:DeleteModelVersion' :: ModelTypeEnum
modelType = ModelTypeEnum
pModelType_,
        $sel:modelVersionNumber:DeleteModelVersion' :: Text
modelVersionNumber = Text
pModelVersionNumber_
      }

-- | The model ID of the model version to delete.
deleteModelVersion_modelId :: Lens.Lens' DeleteModelVersion Prelude.Text
deleteModelVersion_modelId :: (Text -> f Text) -> DeleteModelVersion -> f DeleteModelVersion
deleteModelVersion_modelId = (DeleteModelVersion -> Text)
-> (DeleteModelVersion -> Text -> DeleteModelVersion)
-> Lens DeleteModelVersion DeleteModelVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteModelVersion' {Text
modelId :: Text
$sel:modelId:DeleteModelVersion' :: DeleteModelVersion -> Text
modelId} -> Text
modelId) (\s :: DeleteModelVersion
s@DeleteModelVersion' {} Text
a -> DeleteModelVersion
s {$sel:modelId:DeleteModelVersion' :: Text
modelId = Text
a} :: DeleteModelVersion)

-- | The model type of the model version to delete.
deleteModelVersion_modelType :: Lens.Lens' DeleteModelVersion ModelTypeEnum
deleteModelVersion_modelType :: (ModelTypeEnum -> f ModelTypeEnum)
-> DeleteModelVersion -> f DeleteModelVersion
deleteModelVersion_modelType = (DeleteModelVersion -> ModelTypeEnum)
-> (DeleteModelVersion -> ModelTypeEnum -> DeleteModelVersion)
-> Lens
     DeleteModelVersion DeleteModelVersion ModelTypeEnum ModelTypeEnum
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteModelVersion' {ModelTypeEnum
modelType :: ModelTypeEnum
$sel:modelType:DeleteModelVersion' :: DeleteModelVersion -> ModelTypeEnum
modelType} -> ModelTypeEnum
modelType) (\s :: DeleteModelVersion
s@DeleteModelVersion' {} ModelTypeEnum
a -> DeleteModelVersion
s {$sel:modelType:DeleteModelVersion' :: ModelTypeEnum
modelType = ModelTypeEnum
a} :: DeleteModelVersion)

-- | The model version number of the model version to delete.
deleteModelVersion_modelVersionNumber :: Lens.Lens' DeleteModelVersion Prelude.Text
deleteModelVersion_modelVersionNumber :: (Text -> f Text) -> DeleteModelVersion -> f DeleteModelVersion
deleteModelVersion_modelVersionNumber = (DeleteModelVersion -> Text)
-> (DeleteModelVersion -> Text -> DeleteModelVersion)
-> Lens DeleteModelVersion DeleteModelVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteModelVersion' {Text
modelVersionNumber :: Text
$sel:modelVersionNumber:DeleteModelVersion' :: DeleteModelVersion -> Text
modelVersionNumber} -> Text
modelVersionNumber) (\s :: DeleteModelVersion
s@DeleteModelVersion' {} Text
a -> DeleteModelVersion
s {$sel:modelVersionNumber:DeleteModelVersion' :: Text
modelVersionNumber = Text
a} :: DeleteModelVersion)

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

instance Prelude.NFData DeleteModelVersion

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

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

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

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

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

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

instance Prelude.NFData DeleteModelVersionResponse