{-# 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.Comprehend.StopTrainingDocumentClassifier
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Stops a document classifier training job while in progress.
--
-- If the training job state is @TRAINING@, the job is marked for
-- termination and put into the @STOP_REQUESTED@ state. If the training job
-- completes before it can be stopped, it is put into the @TRAINED@;
-- otherwise the training job is stopped and put into the @STOPPED@ state
-- and the service sends back an HTTP 200 response with an empty HTTP body.
module Amazonka.Comprehend.StopTrainingDocumentClassifier
  ( -- * Creating a Request
    StopTrainingDocumentClassifier (..),
    newStopTrainingDocumentClassifier,

    -- * Request Lenses
    stopTrainingDocumentClassifier_documentClassifierArn,

    -- * Destructuring the Response
    StopTrainingDocumentClassifierResponse (..),
    newStopTrainingDocumentClassifierResponse,

    -- * Response Lenses
    stopTrainingDocumentClassifierResponse_httpStatus,
  )
where

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

-- | /See:/ 'newStopTrainingDocumentClassifier' smart constructor.
data StopTrainingDocumentClassifier = StopTrainingDocumentClassifier'
  { -- | The Amazon Resource Name (ARN) that identifies the document classifier
    -- currently being trained.
    StopTrainingDocumentClassifier -> Text
documentClassifierArn :: Prelude.Text
  }
  deriving (StopTrainingDocumentClassifier
-> StopTrainingDocumentClassifier -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopTrainingDocumentClassifier
-> StopTrainingDocumentClassifier -> Bool
$c/= :: StopTrainingDocumentClassifier
-> StopTrainingDocumentClassifier -> Bool
== :: StopTrainingDocumentClassifier
-> StopTrainingDocumentClassifier -> Bool
$c== :: StopTrainingDocumentClassifier
-> StopTrainingDocumentClassifier -> Bool
Prelude.Eq, ReadPrec [StopTrainingDocumentClassifier]
ReadPrec StopTrainingDocumentClassifier
Int -> ReadS StopTrainingDocumentClassifier
ReadS [StopTrainingDocumentClassifier]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopTrainingDocumentClassifier]
$creadListPrec :: ReadPrec [StopTrainingDocumentClassifier]
readPrec :: ReadPrec StopTrainingDocumentClassifier
$creadPrec :: ReadPrec StopTrainingDocumentClassifier
readList :: ReadS [StopTrainingDocumentClassifier]
$creadList :: ReadS [StopTrainingDocumentClassifier]
readsPrec :: Int -> ReadS StopTrainingDocumentClassifier
$creadsPrec :: Int -> ReadS StopTrainingDocumentClassifier
Prelude.Read, Int -> StopTrainingDocumentClassifier -> ShowS
[StopTrainingDocumentClassifier] -> ShowS
StopTrainingDocumentClassifier -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopTrainingDocumentClassifier] -> ShowS
$cshowList :: [StopTrainingDocumentClassifier] -> ShowS
show :: StopTrainingDocumentClassifier -> String
$cshow :: StopTrainingDocumentClassifier -> String
showsPrec :: Int -> StopTrainingDocumentClassifier -> ShowS
$cshowsPrec :: Int -> StopTrainingDocumentClassifier -> ShowS
Prelude.Show, forall x.
Rep StopTrainingDocumentClassifier x
-> StopTrainingDocumentClassifier
forall x.
StopTrainingDocumentClassifier
-> Rep StopTrainingDocumentClassifier x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StopTrainingDocumentClassifier x
-> StopTrainingDocumentClassifier
$cfrom :: forall x.
StopTrainingDocumentClassifier
-> Rep StopTrainingDocumentClassifier x
Prelude.Generic)

-- |
-- Create a value of 'StopTrainingDocumentClassifier' 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:
--
-- 'documentClassifierArn', 'stopTrainingDocumentClassifier_documentClassifierArn' - The Amazon Resource Name (ARN) that identifies the document classifier
-- currently being trained.
newStopTrainingDocumentClassifier ::
  -- | 'documentClassifierArn'
  Prelude.Text ->
  StopTrainingDocumentClassifier
newStopTrainingDocumentClassifier :: Text -> StopTrainingDocumentClassifier
newStopTrainingDocumentClassifier
  Text
pDocumentClassifierArn_ =
    StopTrainingDocumentClassifier'
      { $sel:documentClassifierArn:StopTrainingDocumentClassifier' :: Text
documentClassifierArn =
          Text
pDocumentClassifierArn_
      }

-- | The Amazon Resource Name (ARN) that identifies the document classifier
-- currently being trained.
stopTrainingDocumentClassifier_documentClassifierArn :: Lens.Lens' StopTrainingDocumentClassifier Prelude.Text
stopTrainingDocumentClassifier_documentClassifierArn :: Lens' StopTrainingDocumentClassifier Text
stopTrainingDocumentClassifier_documentClassifierArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopTrainingDocumentClassifier' {Text
documentClassifierArn :: Text
$sel:documentClassifierArn:StopTrainingDocumentClassifier' :: StopTrainingDocumentClassifier -> Text
documentClassifierArn} -> Text
documentClassifierArn) (\s :: StopTrainingDocumentClassifier
s@StopTrainingDocumentClassifier' {} Text
a -> StopTrainingDocumentClassifier
s {$sel:documentClassifierArn:StopTrainingDocumentClassifier' :: Text
documentClassifierArn = Text
a} :: StopTrainingDocumentClassifier)

instance
  Core.AWSRequest
    StopTrainingDocumentClassifier
  where
  type
    AWSResponse StopTrainingDocumentClassifier =
      StopTrainingDocumentClassifierResponse
  request :: (Service -> Service)
-> StopTrainingDocumentClassifier
-> Request StopTrainingDocumentClassifier
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 StopTrainingDocumentClassifier
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse StopTrainingDocumentClassifier)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StopTrainingDocumentClassifierResponse
StopTrainingDocumentClassifierResponse'
            forall (f :: * -> *) a b. Functor 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
    StopTrainingDocumentClassifier
  where
  hashWithSalt :: Int -> StopTrainingDocumentClassifier -> Int
hashWithSalt
    Int
_salt
    StopTrainingDocumentClassifier' {Text
documentClassifierArn :: Text
$sel:documentClassifierArn:StopTrainingDocumentClassifier' :: StopTrainingDocumentClassifier -> Text
..} =
      Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
documentClassifierArn

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

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

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

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

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

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

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

instance
  Prelude.NFData
    StopTrainingDocumentClassifierResponse
  where
  rnf :: StopTrainingDocumentClassifierResponse -> ()
rnf StopTrainingDocumentClassifierResponse' {Int
httpStatus :: Int
$sel:httpStatus:StopTrainingDocumentClassifierResponse' :: StopTrainingDocumentClassifierResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus