{-# 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-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)
--
-- 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.Lens as Lens
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
(DeleteMLModel -> DeleteMLModel -> Bool)
-> (DeleteMLModel -> DeleteMLModel -> Bool) -> Eq DeleteMLModel
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]
(Int -> ReadS DeleteMLModel)
-> ReadS [DeleteMLModel]
-> ReadPrec DeleteMLModel
-> ReadPrec [DeleteMLModel]
-> Read 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
(Int -> DeleteMLModel -> ShowS)
-> (DeleteMLModel -> String)
-> ([DeleteMLModel] -> ShowS)
-> Show DeleteMLModel
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. DeleteMLModel -> Rep DeleteMLModel x)
-> (forall x. Rep DeleteMLModel x -> DeleteMLModel)
-> Generic DeleteMLModel
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' :: Text -> DeleteMLModel
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 :: (Text -> f Text) -> DeleteMLModel -> f DeleteMLModel
deleteMLModel_mLModelId = (DeleteMLModel -> Text)
-> (DeleteMLModel -> Text -> DeleteMLModel)
-> Lens DeleteMLModel DeleteMLModel Text Text
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 :: DeleteMLModel -> Request DeleteMLModel
request = Service -> DeleteMLModel -> Request DeleteMLModel
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteMLModel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteMLModel)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteMLModel))
-> Logger
-> Service
-> Proxy DeleteMLModel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteMLModel)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> DeleteMLModelResponse
DeleteMLModelResponse'
            (Maybe Text -> Int -> DeleteMLModelResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DeleteMLModelResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"MLModelId")
            Either String (Int -> DeleteMLModelResponse)
-> Either String Int -> Either String DeleteMLModelResponse
forall (f :: * -> *) a b. Applicative f => 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 DeleteMLModel

instance Prelude.NFData DeleteMLModel

instance Core.ToHeaders DeleteMLModel where
  toHeaders :: DeleteMLModel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteMLModel -> 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
"AmazonML_20141212.DeleteMLModel" ::
                          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 DeleteMLModel where
  toJSON :: DeleteMLModel -> Value
toJSON DeleteMLModel' {Text
mLModelId :: Text
$sel:mLModelId:DeleteMLModel' :: DeleteMLModel -> 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
"MLModelId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
mLModelId)]
      )

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

instance Core.ToQuery DeleteMLModel where
  toQuery :: DeleteMLModel -> QueryString
toQuery = QueryString -> DeleteMLModel -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteMLModelResponse -> DeleteMLModelResponse -> Bool)
-> (DeleteMLModelResponse -> DeleteMLModelResponse -> Bool)
-> Eq DeleteMLModelResponse
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]
(Int -> ReadS DeleteMLModelResponse)
-> ReadS [DeleteMLModelResponse]
-> ReadPrec DeleteMLModelResponse
-> ReadPrec [DeleteMLModelResponse]
-> Read 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
(Int -> DeleteMLModelResponse -> ShowS)
-> (DeleteMLModelResponse -> String)
-> ([DeleteMLModelResponse] -> ShowS)
-> Show DeleteMLModelResponse
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. DeleteMLModelResponse -> Rep DeleteMLModelResponse x)
-> (forall x. Rep DeleteMLModelResponse x -> DeleteMLModelResponse)
-> Generic DeleteMLModelResponse
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' :: Maybe Text -> Int -> DeleteMLModelResponse
DeleteMLModelResponse'
    { $sel:mLModelId:DeleteMLModelResponse' :: Maybe Text
mLModelId = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DeleteMLModelResponse -> f DeleteMLModelResponse
deleteMLModelResponse_mLModelId = (DeleteMLModelResponse -> Maybe Text)
-> (DeleteMLModelResponse -> Maybe Text -> DeleteMLModelResponse)
-> Lens
     DeleteMLModelResponse
     DeleteMLModelResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int) -> DeleteMLModelResponse -> f DeleteMLModelResponse
deleteMLModelResponse_httpStatus = (DeleteMLModelResponse -> Int)
-> (DeleteMLModelResponse -> Int -> DeleteMLModelResponse)
-> Lens DeleteMLModelResponse DeleteMLModelResponse Int Int
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