{-# 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.DeleteModel
-- 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.
--
-- 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, Amazon Fraud Detector permanently deletes that
-- model and the data is no longer stored in Amazon Fraud Detector.
module Amazonka.FraudDetector.DeleteModel
  ( -- * Creating a Request
    DeleteModel (..),
    newDeleteModel,

    -- * Request Lenses
    deleteModel_modelId,
    deleteModel_modelType,

    -- * Destructuring the Response
    DeleteModelResponse (..),
    newDeleteModelResponse,

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

-- |
-- Create a value of 'DeleteModel' 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', 'deleteModel_modelId' - The model ID of the model to delete.
--
-- 'modelType', 'deleteModel_modelType' - The model type of the model to delete.
newDeleteModel ::
  -- | 'modelId'
  Prelude.Text ->
  -- | 'modelType'
  ModelTypeEnum ->
  DeleteModel
newDeleteModel :: Text -> ModelTypeEnum -> DeleteModel
newDeleteModel Text
pModelId_ ModelTypeEnum
pModelType_ =
  DeleteModel' :: Text -> ModelTypeEnum -> DeleteModel
DeleteModel'
    { $sel:modelId:DeleteModel' :: Text
modelId = Text
pModelId_,
      $sel:modelType:DeleteModel' :: ModelTypeEnum
modelType = ModelTypeEnum
pModelType_
    }

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

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

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

instance Prelude.NFData DeleteModel

instance Core.ToHeaders DeleteModel where
  toHeaders :: DeleteModel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteModel -> 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.DeleteModel" ::
                          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 DeleteModel where
  toJSON :: DeleteModel -> Value
toJSON DeleteModel' {Text
ModelTypeEnum
modelType :: ModelTypeEnum
modelId :: Text
$sel:modelType:DeleteModel' :: DeleteModel -> ModelTypeEnum
$sel:modelId:DeleteModel' :: DeleteModel -> 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)
          ]
      )

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

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

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

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

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

instance Prelude.NFData DeleteModelResponse