{-# 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-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)
--
-- 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.Lens as Lens
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
(StopTrainingEntityRecognizer
 -> StopTrainingEntityRecognizer -> Bool)
-> (StopTrainingEntityRecognizer
    -> StopTrainingEntityRecognizer -> Bool)
-> Eq StopTrainingEntityRecognizer
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]
(Int -> ReadS StopTrainingEntityRecognizer)
-> ReadS [StopTrainingEntityRecognizer]
-> ReadPrec StopTrainingEntityRecognizer
-> ReadPrec [StopTrainingEntityRecognizer]
-> Read 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
(Int -> StopTrainingEntityRecognizer -> ShowS)
-> (StopTrainingEntityRecognizer -> String)
-> ([StopTrainingEntityRecognizer] -> ShowS)
-> Show StopTrainingEntityRecognizer
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.
 StopTrainingEntityRecognizer -> Rep StopTrainingEntityRecognizer x)
-> (forall x.
    Rep StopTrainingEntityRecognizer x -> StopTrainingEntityRecognizer)
-> Generic StopTrainingEntityRecognizer
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' :: Text -> StopTrainingEntityRecognizer
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 :: (Text -> f Text)
-> StopTrainingEntityRecognizer -> f StopTrainingEntityRecognizer
stopTrainingEntityRecognizer_entityRecognizerArn = (StopTrainingEntityRecognizer -> Text)
-> (StopTrainingEntityRecognizer
    -> Text -> StopTrainingEntityRecognizer)
-> Lens
     StopTrainingEntityRecognizer StopTrainingEntityRecognizer Text Text
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 :: StopTrainingEntityRecognizer
-> Request StopTrainingEntityRecognizer
request = Service
-> StopTrainingEntityRecognizer
-> Request StopTrainingEntityRecognizer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopTrainingEntityRecognizer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopTrainingEntityRecognizer)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse StopTrainingEntityRecognizer))
-> Logger
-> Service
-> Proxy StopTrainingEntityRecognizer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopTrainingEntityRecognizer)))
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 -> StopTrainingEntityRecognizerResponse
StopTrainingEntityRecognizerResponse'
            (Int -> StopTrainingEntityRecognizerResponse)
-> Either String Int
-> Either String StopTrainingEntityRecognizerResponse
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
    StopTrainingEntityRecognizer

instance Prelude.NFData StopTrainingEntityRecognizer

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

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

instance Core.ToQuery StopTrainingEntityRecognizer where
  toQuery :: StopTrainingEntityRecognizer -> QueryString
toQuery = QueryString -> StopTrainingEntityRecognizer -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(StopTrainingEntityRecognizerResponse
 -> StopTrainingEntityRecognizerResponse -> Bool)
-> (StopTrainingEntityRecognizerResponse
    -> StopTrainingEntityRecognizerResponse -> Bool)
-> Eq StopTrainingEntityRecognizerResponse
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]
(Int -> ReadS StopTrainingEntityRecognizerResponse)
-> ReadS [StopTrainingEntityRecognizerResponse]
-> ReadPrec StopTrainingEntityRecognizerResponse
-> ReadPrec [StopTrainingEntityRecognizerResponse]
-> Read 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
(Int -> StopTrainingEntityRecognizerResponse -> ShowS)
-> (StopTrainingEntityRecognizerResponse -> String)
-> ([StopTrainingEntityRecognizerResponse] -> ShowS)
-> Show StopTrainingEntityRecognizerResponse
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.
 StopTrainingEntityRecognizerResponse
 -> Rep StopTrainingEntityRecognizerResponse x)
-> (forall x.
    Rep StopTrainingEntityRecognizerResponse x
    -> StopTrainingEntityRecognizerResponse)
-> Generic StopTrainingEntityRecognizerResponse
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' :: Int -> StopTrainingEntityRecognizerResponse
StopTrainingEntityRecognizerResponse'
    { $sel:httpStatus:StopTrainingEntityRecognizerResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
stopTrainingEntityRecognizerResponse_httpStatus :: Lens.Lens' StopTrainingEntityRecognizerResponse Prelude.Int
stopTrainingEntityRecognizerResponse_httpStatus :: (Int -> f Int)
-> StopTrainingEntityRecognizerResponse
-> f StopTrainingEntityRecognizerResponse
stopTrainingEntityRecognizerResponse_httpStatus = (StopTrainingEntityRecognizerResponse -> Int)
-> (StopTrainingEntityRecognizerResponse
    -> Int -> StopTrainingEntityRecognizerResponse)
-> Lens
     StopTrainingEntityRecognizerResponse
     StopTrainingEntityRecognizerResponse
     Int
     Int
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