{-# 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.StopTrainingEntityRecognizer
-- 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 an entity recognizer 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 putted into the @STOPPED@
-- state and the service sends back an HTTP 200 response with an empty HTTP
-- body.
module Amazonka.Comprehend.StopTrainingEntityRecognizer
  ( -- * Creating a Request
    StopTrainingEntityRecognizer (..),
    newStopTrainingEntityRecognizer,

    -- * Request Lenses
    stopTrainingEntityRecognizer_entityRecognizerArn,

    -- * Destructuring the Response
    StopTrainingEntityRecognizerResponse (..),
    newStopTrainingEntityRecognizerResponse,

    -- * Response Lenses
    stopTrainingEntityRecognizerResponse_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:/ 'newStopTrainingEntityRecognizer' smart constructor.
data StopTrainingEntityRecognizer = StopTrainingEntityRecognizer'
  { -- | The Amazon Resource Name (ARN) that identifies the entity recognizer
    -- currently being trained.
    StopTrainingEntityRecognizer -> Text
entityRecognizerArn :: Prelude.Text
  }
  deriving (StopTrainingEntityRecognizer
-> StopTrainingEntityRecognizer -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopTrainingEntityRecognizer
-> StopTrainingEntityRecognizer -> Bool
$c/= :: StopTrainingEntityRecognizer
-> StopTrainingEntityRecognizer -> Bool
== :: StopTrainingEntityRecognizer
-> StopTrainingEntityRecognizer -> Bool
$c== :: StopTrainingEntityRecognizer
-> StopTrainingEntityRecognizer -> Bool
Prelude.Eq, ReadPrec [StopTrainingEntityRecognizer]
ReadPrec StopTrainingEntityRecognizer
Int -> ReadS StopTrainingEntityRecognizer
ReadS [StopTrainingEntityRecognizer]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopTrainingEntityRecognizer]
$creadListPrec :: ReadPrec [StopTrainingEntityRecognizer]
readPrec :: ReadPrec StopTrainingEntityRecognizer
$creadPrec :: ReadPrec StopTrainingEntityRecognizer
readList :: ReadS [StopTrainingEntityRecognizer]
$creadList :: ReadS [StopTrainingEntityRecognizer]
readsPrec :: Int -> ReadS StopTrainingEntityRecognizer
$creadsPrec :: Int -> ReadS StopTrainingEntityRecognizer
Prelude.Read, Int -> StopTrainingEntityRecognizer -> ShowS
[StopTrainingEntityRecognizer] -> ShowS
StopTrainingEntityRecognizer -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopTrainingEntityRecognizer] -> ShowS
$cshowList :: [StopTrainingEntityRecognizer] -> ShowS
show :: StopTrainingEntityRecognizer -> String
$cshow :: StopTrainingEntityRecognizer -> String
showsPrec :: Int -> StopTrainingEntityRecognizer -> ShowS
$cshowsPrec :: Int -> StopTrainingEntityRecognizer -> ShowS
Prelude.Show, forall x.
Rep StopTrainingEntityRecognizer x -> StopTrainingEntityRecognizer
forall x.
StopTrainingEntityRecognizer -> Rep StopTrainingEntityRecognizer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StopTrainingEntityRecognizer x -> StopTrainingEntityRecognizer
$cfrom :: forall x.
StopTrainingEntityRecognizer -> Rep StopTrainingEntityRecognizer x
Prelude.Generic)

-- |
-- Create a value of 'StopTrainingEntityRecognizer' 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:
--
-- 'entityRecognizerArn', 'stopTrainingEntityRecognizer_entityRecognizerArn' - The Amazon Resource Name (ARN) that identifies the entity recognizer
-- currently being trained.
newStopTrainingEntityRecognizer ::
  -- | 'entityRecognizerArn'
  Prelude.Text ->
  StopTrainingEntityRecognizer
newStopTrainingEntityRecognizer :: Text -> StopTrainingEntityRecognizer
newStopTrainingEntityRecognizer Text
pEntityRecognizerArn_ =
  StopTrainingEntityRecognizer'
    { $sel:entityRecognizerArn:StopTrainingEntityRecognizer' :: Text
entityRecognizerArn =
        Text
pEntityRecognizerArn_
    }

-- | The Amazon Resource Name (ARN) that identifies the entity recognizer
-- currently being trained.
stopTrainingEntityRecognizer_entityRecognizerArn :: Lens.Lens' StopTrainingEntityRecognizer Prelude.Text
stopTrainingEntityRecognizer_entityRecognizerArn :: Lens' StopTrainingEntityRecognizer Text
stopTrainingEntityRecognizer_entityRecognizerArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopTrainingEntityRecognizer' {Text
entityRecognizerArn :: Text
$sel:entityRecognizerArn:StopTrainingEntityRecognizer' :: StopTrainingEntityRecognizer -> Text
entityRecognizerArn} -> Text
entityRecognizerArn) (\s :: StopTrainingEntityRecognizer
s@StopTrainingEntityRecognizer' {} Text
a -> StopTrainingEntityRecognizer
s {$sel:entityRecognizerArn:StopTrainingEntityRecognizer' :: Text
entityRecognizerArn = Text
a} :: StopTrainingEntityRecognizer)

instance Core.AWSRequest StopTrainingEntityRecognizer where
  type
    AWSResponse StopTrainingEntityRecognizer =
      StopTrainingEntityRecognizerResponse
  request :: (Service -> Service)
-> StopTrainingEntityRecognizer
-> Request StopTrainingEntityRecognizer
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 StopTrainingEntityRecognizer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopTrainingEntityRecognizer)))
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 -> StopTrainingEntityRecognizerResponse
StopTrainingEntityRecognizerResponse'
            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
    StopTrainingEntityRecognizer
  where
  hashWithSalt :: Int -> StopTrainingEntityRecognizer -> Int
hashWithSalt Int
_salt StopTrainingEntityRecognizer' {Text
entityRecognizerArn :: Text
$sel:entityRecognizerArn:StopTrainingEntityRecognizer' :: StopTrainingEntityRecognizer -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
entityRecognizerArn

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

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

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

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

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

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

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

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