{-# 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.MachineLearning.DeleteMLModel
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Assigns the @DELETED@ status to an @MLModel@, rendering it unusable.
--
-- After using the @DeleteMLModel@ operation, you can use the @GetMLModel@
-- operation to verify that the status of the @MLModel@ changed to DELETED.
--
-- __Caution:__ The result of the @DeleteMLModel@ operation is
-- irreversible.
module Amazonka.MachineLearning.DeleteMLModel
  ( -- * Creating a Request
    DeleteMLModel (..),
    newDeleteMLModel,

    -- * Request Lenses
    deleteMLModel_mLModelId,

    -- * Destructuring the Response
    DeleteMLModelResponse (..),
    newDeleteMLModelResponse,

    -- * Response Lenses
    deleteMLModelResponse_mLModelId,
    deleteMLModelResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteMLModel' smart constructor.
data DeleteMLModel = DeleteMLModel'
  { -- | A user-supplied ID that uniquely identifies the @MLModel@.
    DeleteMLModel -> Text
mLModelId :: Prelude.Text
  }
  deriving (DeleteMLModel -> DeleteMLModel -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteMLModel -> DeleteMLModel -> Bool
$c/= :: DeleteMLModel -> DeleteMLModel -> Bool
== :: DeleteMLModel -> DeleteMLModel -> Bool
$c== :: DeleteMLModel -> DeleteMLModel -> Bool
Prelude.Eq, ReadPrec [DeleteMLModel]
ReadPrec DeleteMLModel
Int -> ReadS DeleteMLModel
ReadS [DeleteMLModel]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteMLModel]
$creadListPrec :: ReadPrec [DeleteMLModel]
readPrec :: ReadPrec DeleteMLModel
$creadPrec :: ReadPrec DeleteMLModel
readList :: ReadS [DeleteMLModel]
$creadList :: ReadS [DeleteMLModel]
readsPrec :: Int -> ReadS DeleteMLModel
$creadsPrec :: Int -> ReadS DeleteMLModel
Prelude.Read, Int -> DeleteMLModel -> ShowS
[DeleteMLModel] -> ShowS
DeleteMLModel -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteMLModel] -> ShowS
$cshowList :: [DeleteMLModel] -> ShowS
show :: DeleteMLModel -> String
$cshow :: DeleteMLModel -> String
showsPrec :: Int -> DeleteMLModel -> ShowS
$cshowsPrec :: Int -> DeleteMLModel -> ShowS
Prelude.Show, forall x. Rep DeleteMLModel x -> DeleteMLModel
forall x. DeleteMLModel -> Rep DeleteMLModel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteMLModel x -> DeleteMLModel
$cfrom :: forall x. DeleteMLModel -> Rep DeleteMLModel x
Prelude.Generic)

-- |
-- Create a value of 'DeleteMLModel' 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:
--
-- 'mLModelId', 'deleteMLModel_mLModelId' - A user-supplied ID that uniquely identifies the @MLModel@.
newDeleteMLModel ::
  -- | 'mLModelId'
  Prelude.Text ->
  DeleteMLModel
newDeleteMLModel :: Text -> DeleteMLModel
newDeleteMLModel Text
pMLModelId_ =
  DeleteMLModel' {$sel:mLModelId:DeleteMLModel' :: Text
mLModelId = Text
pMLModelId_}

-- | A user-supplied ID that uniquely identifies the @MLModel@.
deleteMLModel_mLModelId :: Lens.Lens' DeleteMLModel Prelude.Text
deleteMLModel_mLModelId :: Lens' DeleteMLModel Text
deleteMLModel_mLModelId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteMLModel' {Text
mLModelId :: Text
$sel:mLModelId:DeleteMLModel' :: DeleteMLModel -> Text
mLModelId} -> Text
mLModelId) (\s :: DeleteMLModel
s@DeleteMLModel' {} Text
a -> DeleteMLModel
s {$sel:mLModelId:DeleteMLModel' :: Text
mLModelId = Text
a} :: DeleteMLModel)

instance Core.AWSRequest DeleteMLModel where
  type
    AWSResponse DeleteMLModel =
      DeleteMLModelResponse
  request :: (Service -> Service) -> DeleteMLModel -> Request DeleteMLModel
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 DeleteMLModel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteMLModel)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> DeleteMLModelResponse
DeleteMLModelResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"MLModelId")
            forall (f :: * -> *) a b. Applicative f => 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 DeleteMLModel where
  hashWithSalt :: Int -> DeleteMLModel -> Int
hashWithSalt Int
_salt DeleteMLModel' {Text
mLModelId :: Text
$sel:mLModelId:DeleteMLModel' :: DeleteMLModel -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
mLModelId

instance Prelude.NFData DeleteMLModel where
  rnf :: DeleteMLModel -> ()
rnf DeleteMLModel' {Text
mLModelId :: Text
$sel:mLModelId:DeleteMLModel' :: DeleteMLModel -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
mLModelId

instance Data.ToHeaders DeleteMLModel where
  toHeaders :: DeleteMLModel -> 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
"AmazonML_20141212.DeleteMLModel" ::
                          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 DeleteMLModel where
  toJSON :: DeleteMLModel -> Value
toJSON DeleteMLModel' {Text
mLModelId :: Text
$sel:mLModelId:DeleteMLModel' :: DeleteMLModel -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"MLModelId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
mLModelId)]
      )

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

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

-- | Represents the output of a @DeleteMLModel@ operation.
--
-- You can use the @GetMLModel@ operation and check the value of the
-- @Status@ parameter to see whether an @MLModel@ is marked as @DELETED@.
--
-- /See:/ 'newDeleteMLModelResponse' smart constructor.
data DeleteMLModelResponse = DeleteMLModelResponse'
  { -- | A user-supplied ID that uniquely identifies the @MLModel@. This value
    -- should be identical to the value of the @MLModelID@ in the request.
    DeleteMLModelResponse -> Maybe Text
mLModelId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteMLModelResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteMLModelResponse -> DeleteMLModelResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteMLModelResponse -> DeleteMLModelResponse -> Bool
$c/= :: DeleteMLModelResponse -> DeleteMLModelResponse -> Bool
== :: DeleteMLModelResponse -> DeleteMLModelResponse -> Bool
$c== :: DeleteMLModelResponse -> DeleteMLModelResponse -> Bool
Prelude.Eq, ReadPrec [DeleteMLModelResponse]
ReadPrec DeleteMLModelResponse
Int -> ReadS DeleteMLModelResponse
ReadS [DeleteMLModelResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteMLModelResponse]
$creadListPrec :: ReadPrec [DeleteMLModelResponse]
readPrec :: ReadPrec DeleteMLModelResponse
$creadPrec :: ReadPrec DeleteMLModelResponse
readList :: ReadS [DeleteMLModelResponse]
$creadList :: ReadS [DeleteMLModelResponse]
readsPrec :: Int -> ReadS DeleteMLModelResponse
$creadsPrec :: Int -> ReadS DeleteMLModelResponse
Prelude.Read, Int -> DeleteMLModelResponse -> ShowS
[DeleteMLModelResponse] -> ShowS
DeleteMLModelResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteMLModelResponse] -> ShowS
$cshowList :: [DeleteMLModelResponse] -> ShowS
show :: DeleteMLModelResponse -> String
$cshow :: DeleteMLModelResponse -> String
showsPrec :: Int -> DeleteMLModelResponse -> ShowS
$cshowsPrec :: Int -> DeleteMLModelResponse -> ShowS
Prelude.Show, forall x. Rep DeleteMLModelResponse x -> DeleteMLModelResponse
forall x. DeleteMLModelResponse -> Rep DeleteMLModelResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteMLModelResponse x -> DeleteMLModelResponse
$cfrom :: forall x. DeleteMLModelResponse -> Rep DeleteMLModelResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteMLModelResponse' 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:
--
-- 'mLModelId', 'deleteMLModelResponse_mLModelId' - A user-supplied ID that uniquely identifies the @MLModel@. This value
-- should be identical to the value of the @MLModelID@ in the request.
--
-- 'httpStatus', 'deleteMLModelResponse_httpStatus' - The response's http status code.
newDeleteMLModelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteMLModelResponse
newDeleteMLModelResponse :: Int -> DeleteMLModelResponse
newDeleteMLModelResponse Int
pHttpStatus_ =
  DeleteMLModelResponse'
    { $sel:mLModelId:DeleteMLModelResponse' :: Maybe Text
mLModelId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteMLModelResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A user-supplied ID that uniquely identifies the @MLModel@. This value
-- should be identical to the value of the @MLModelID@ in the request.
deleteMLModelResponse_mLModelId :: Lens.Lens' DeleteMLModelResponse (Prelude.Maybe Prelude.Text)
deleteMLModelResponse_mLModelId :: Lens' DeleteMLModelResponse (Maybe Text)
deleteMLModelResponse_mLModelId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteMLModelResponse' {Maybe Text
mLModelId :: Maybe Text
$sel:mLModelId:DeleteMLModelResponse' :: DeleteMLModelResponse -> Maybe Text
mLModelId} -> Maybe Text
mLModelId) (\s :: DeleteMLModelResponse
s@DeleteMLModelResponse' {} Maybe Text
a -> DeleteMLModelResponse
s {$sel:mLModelId:DeleteMLModelResponse' :: Maybe Text
mLModelId = Maybe Text
a} :: DeleteMLModelResponse)

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

instance Prelude.NFData DeleteMLModelResponse where
  rnf :: DeleteMLModelResponse -> ()
rnf DeleteMLModelResponse' {Int
Maybe Text
httpStatus :: Int
mLModelId :: Maybe Text
$sel:httpStatus:DeleteMLModelResponse' :: DeleteMLModelResponse -> Int
$sel:mLModelId:DeleteMLModelResponse' :: DeleteMLModelResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
mLModelId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus