{-# 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.Translate.StopTextTranslationJob
-- 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 asynchronous batch translation job that is in progress.
--
-- If the job\'s state is @IN_PROGRESS@, the job will be marked for
-- termination and put into the @STOP_REQUESTED@ state. If the job
-- completes before it can be stopped, it is put into the @COMPLETED@
-- state. Otherwise, the job is put into the @STOPPED@ state.
--
-- Asynchronous batch translation jobs are started with the
-- StartTextTranslationJob operation. You can use the
-- DescribeTextTranslationJob or ListTextTranslationJobs operations to get
-- a batch translation job\'s @JobId@.
module Amazonka.Translate.StopTextTranslationJob
  ( -- * Creating a Request
    StopTextTranslationJob (..),
    newStopTextTranslationJob,

    -- * Request Lenses
    stopTextTranslationJob_jobId,

    -- * Destructuring the Response
    StopTextTranslationJobResponse (..),
    newStopTextTranslationJobResponse,

    -- * Response Lenses
    stopTextTranslationJobResponse_jobId,
    stopTextTranslationJobResponse_jobStatus,
    stopTextTranslationJobResponse_httpStatus,
  )
where

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
import Amazonka.Translate.Types

-- | /See:/ 'newStopTextTranslationJob' smart constructor.
data StopTextTranslationJob = StopTextTranslationJob'
  { -- | The job ID of the job to be stopped.
    StopTextTranslationJob -> Text
jobId :: Prelude.Text
  }
  deriving (StopTextTranslationJob -> StopTextTranslationJob -> Bool
(StopTextTranslationJob -> StopTextTranslationJob -> Bool)
-> (StopTextTranslationJob -> StopTextTranslationJob -> Bool)
-> Eq StopTextTranslationJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopTextTranslationJob -> StopTextTranslationJob -> Bool
$c/= :: StopTextTranslationJob -> StopTextTranslationJob -> Bool
== :: StopTextTranslationJob -> StopTextTranslationJob -> Bool
$c== :: StopTextTranslationJob -> StopTextTranslationJob -> Bool
Prelude.Eq, ReadPrec [StopTextTranslationJob]
ReadPrec StopTextTranslationJob
Int -> ReadS StopTextTranslationJob
ReadS [StopTextTranslationJob]
(Int -> ReadS StopTextTranslationJob)
-> ReadS [StopTextTranslationJob]
-> ReadPrec StopTextTranslationJob
-> ReadPrec [StopTextTranslationJob]
-> Read StopTextTranslationJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopTextTranslationJob]
$creadListPrec :: ReadPrec [StopTextTranslationJob]
readPrec :: ReadPrec StopTextTranslationJob
$creadPrec :: ReadPrec StopTextTranslationJob
readList :: ReadS [StopTextTranslationJob]
$creadList :: ReadS [StopTextTranslationJob]
readsPrec :: Int -> ReadS StopTextTranslationJob
$creadsPrec :: Int -> ReadS StopTextTranslationJob
Prelude.Read, Int -> StopTextTranslationJob -> ShowS
[StopTextTranslationJob] -> ShowS
StopTextTranslationJob -> String
(Int -> StopTextTranslationJob -> ShowS)
-> (StopTextTranslationJob -> String)
-> ([StopTextTranslationJob] -> ShowS)
-> Show StopTextTranslationJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopTextTranslationJob] -> ShowS
$cshowList :: [StopTextTranslationJob] -> ShowS
show :: StopTextTranslationJob -> String
$cshow :: StopTextTranslationJob -> String
showsPrec :: Int -> StopTextTranslationJob -> ShowS
$cshowsPrec :: Int -> StopTextTranslationJob -> ShowS
Prelude.Show, (forall x. StopTextTranslationJob -> Rep StopTextTranslationJob x)
-> (forall x.
    Rep StopTextTranslationJob x -> StopTextTranslationJob)
-> Generic StopTextTranslationJob
forall x. Rep StopTextTranslationJob x -> StopTextTranslationJob
forall x. StopTextTranslationJob -> Rep StopTextTranslationJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopTextTranslationJob x -> StopTextTranslationJob
$cfrom :: forall x. StopTextTranslationJob -> Rep StopTextTranslationJob x
Prelude.Generic)

-- |
-- Create a value of 'StopTextTranslationJob' 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:
--
-- 'jobId', 'stopTextTranslationJob_jobId' - The job ID of the job to be stopped.
newStopTextTranslationJob ::
  -- | 'jobId'
  Prelude.Text ->
  StopTextTranslationJob
newStopTextTranslationJob :: Text -> StopTextTranslationJob
newStopTextTranslationJob Text
pJobId_ =
  StopTextTranslationJob' :: Text -> StopTextTranslationJob
StopTextTranslationJob' {$sel:jobId:StopTextTranslationJob' :: Text
jobId = Text
pJobId_}

-- | The job ID of the job to be stopped.
stopTextTranslationJob_jobId :: Lens.Lens' StopTextTranslationJob Prelude.Text
stopTextTranslationJob_jobId :: (Text -> f Text)
-> StopTextTranslationJob -> f StopTextTranslationJob
stopTextTranslationJob_jobId = (StopTextTranslationJob -> Text)
-> (StopTextTranslationJob -> Text -> StopTextTranslationJob)
-> Lens StopTextTranslationJob StopTextTranslationJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopTextTranslationJob' {Text
jobId :: Text
$sel:jobId:StopTextTranslationJob' :: StopTextTranslationJob -> Text
jobId} -> Text
jobId) (\s :: StopTextTranslationJob
s@StopTextTranslationJob' {} Text
a -> StopTextTranslationJob
s {$sel:jobId:StopTextTranslationJob' :: Text
jobId = Text
a} :: StopTextTranslationJob)

instance Core.AWSRequest StopTextTranslationJob where
  type
    AWSResponse StopTextTranslationJob =
      StopTextTranslationJobResponse
  request :: StopTextTranslationJob -> Request StopTextTranslationJob
request = Service -> StopTextTranslationJob -> Request StopTextTranslationJob
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopTextTranslationJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopTextTranslationJob)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StopTextTranslationJob))
-> Logger
-> Service
-> Proxy StopTextTranslationJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopTextTranslationJob)))
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
-> Maybe JobStatus -> Int -> StopTextTranslationJobResponse
StopTextTranslationJobResponse'
            (Maybe Text
 -> Maybe JobStatus -> Int -> StopTextTranslationJobResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe JobStatus -> Int -> StopTextTranslationJobResponse)
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
"JobId")
            Either
  String (Maybe JobStatus -> Int -> StopTextTranslationJobResponse)
-> Either String (Maybe JobStatus)
-> Either String (Int -> StopTextTranslationJobResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe JobStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"JobStatus")
            Either String (Int -> StopTextTranslationJobResponse)
-> Either String Int
-> Either String StopTextTranslationJobResponse
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 StopTextTranslationJob

instance Prelude.NFData StopTextTranslationJob

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

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

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

-- | /See:/ 'newStopTextTranslationJobResponse' smart constructor.
data StopTextTranslationJobResponse = StopTextTranslationJobResponse'
  { -- | The job ID of the stopped batch translation job.
    StopTextTranslationJobResponse -> Maybe Text
jobId :: Prelude.Maybe Prelude.Text,
    -- | The status of the designated job. Upon successful completion, the job\'s
    -- status will be @STOPPED@.
    StopTextTranslationJobResponse -> Maybe JobStatus
jobStatus :: Prelude.Maybe JobStatus,
    -- | The response's http status code.
    StopTextTranslationJobResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StopTextTranslationJobResponse
-> StopTextTranslationJobResponse -> Bool
(StopTextTranslationJobResponse
 -> StopTextTranslationJobResponse -> Bool)
-> (StopTextTranslationJobResponse
    -> StopTextTranslationJobResponse -> Bool)
-> Eq StopTextTranslationJobResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopTextTranslationJobResponse
-> StopTextTranslationJobResponse -> Bool
$c/= :: StopTextTranslationJobResponse
-> StopTextTranslationJobResponse -> Bool
== :: StopTextTranslationJobResponse
-> StopTextTranslationJobResponse -> Bool
$c== :: StopTextTranslationJobResponse
-> StopTextTranslationJobResponse -> Bool
Prelude.Eq, ReadPrec [StopTextTranslationJobResponse]
ReadPrec StopTextTranslationJobResponse
Int -> ReadS StopTextTranslationJobResponse
ReadS [StopTextTranslationJobResponse]
(Int -> ReadS StopTextTranslationJobResponse)
-> ReadS [StopTextTranslationJobResponse]
-> ReadPrec StopTextTranslationJobResponse
-> ReadPrec [StopTextTranslationJobResponse]
-> Read StopTextTranslationJobResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopTextTranslationJobResponse]
$creadListPrec :: ReadPrec [StopTextTranslationJobResponse]
readPrec :: ReadPrec StopTextTranslationJobResponse
$creadPrec :: ReadPrec StopTextTranslationJobResponse
readList :: ReadS [StopTextTranslationJobResponse]
$creadList :: ReadS [StopTextTranslationJobResponse]
readsPrec :: Int -> ReadS StopTextTranslationJobResponse
$creadsPrec :: Int -> ReadS StopTextTranslationJobResponse
Prelude.Read, Int -> StopTextTranslationJobResponse -> ShowS
[StopTextTranslationJobResponse] -> ShowS
StopTextTranslationJobResponse -> String
(Int -> StopTextTranslationJobResponse -> ShowS)
-> (StopTextTranslationJobResponse -> String)
-> ([StopTextTranslationJobResponse] -> ShowS)
-> Show StopTextTranslationJobResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopTextTranslationJobResponse] -> ShowS
$cshowList :: [StopTextTranslationJobResponse] -> ShowS
show :: StopTextTranslationJobResponse -> String
$cshow :: StopTextTranslationJobResponse -> String
showsPrec :: Int -> StopTextTranslationJobResponse -> ShowS
$cshowsPrec :: Int -> StopTextTranslationJobResponse -> ShowS
Prelude.Show, (forall x.
 StopTextTranslationJobResponse
 -> Rep StopTextTranslationJobResponse x)
-> (forall x.
    Rep StopTextTranslationJobResponse x
    -> StopTextTranslationJobResponse)
-> Generic StopTextTranslationJobResponse
forall x.
Rep StopTextTranslationJobResponse x
-> StopTextTranslationJobResponse
forall x.
StopTextTranslationJobResponse
-> Rep StopTextTranslationJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StopTextTranslationJobResponse x
-> StopTextTranslationJobResponse
$cfrom :: forall x.
StopTextTranslationJobResponse
-> Rep StopTextTranslationJobResponse x
Prelude.Generic)

-- |
-- Create a value of 'StopTextTranslationJobResponse' 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:
--
-- 'jobId', 'stopTextTranslationJobResponse_jobId' - The job ID of the stopped batch translation job.
--
-- 'jobStatus', 'stopTextTranslationJobResponse_jobStatus' - The status of the designated job. Upon successful completion, the job\'s
-- status will be @STOPPED@.
--
-- 'httpStatus', 'stopTextTranslationJobResponse_httpStatus' - The response's http status code.
newStopTextTranslationJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopTextTranslationJobResponse
newStopTextTranslationJobResponse :: Int -> StopTextTranslationJobResponse
newStopTextTranslationJobResponse Int
pHttpStatus_ =
  StopTextTranslationJobResponse' :: Maybe Text
-> Maybe JobStatus -> Int -> StopTextTranslationJobResponse
StopTextTranslationJobResponse'
    { $sel:jobId:StopTextTranslationJobResponse' :: Maybe Text
jobId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:jobStatus:StopTextTranslationJobResponse' :: Maybe JobStatus
jobStatus = Maybe JobStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StopTextTranslationJobResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The job ID of the stopped batch translation job.
stopTextTranslationJobResponse_jobId :: Lens.Lens' StopTextTranslationJobResponse (Prelude.Maybe Prelude.Text)
stopTextTranslationJobResponse_jobId :: (Maybe Text -> f (Maybe Text))
-> StopTextTranslationJobResponse
-> f StopTextTranslationJobResponse
stopTextTranslationJobResponse_jobId = (StopTextTranslationJobResponse -> Maybe Text)
-> (StopTextTranslationJobResponse
    -> Maybe Text -> StopTextTranslationJobResponse)
-> Lens
     StopTextTranslationJobResponse
     StopTextTranslationJobResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopTextTranslationJobResponse' {Maybe Text
jobId :: Maybe Text
$sel:jobId:StopTextTranslationJobResponse' :: StopTextTranslationJobResponse -> Maybe Text
jobId} -> Maybe Text
jobId) (\s :: StopTextTranslationJobResponse
s@StopTextTranslationJobResponse' {} Maybe Text
a -> StopTextTranslationJobResponse
s {$sel:jobId:StopTextTranslationJobResponse' :: Maybe Text
jobId = Maybe Text
a} :: StopTextTranslationJobResponse)

-- | The status of the designated job. Upon successful completion, the job\'s
-- status will be @STOPPED@.
stopTextTranslationJobResponse_jobStatus :: Lens.Lens' StopTextTranslationJobResponse (Prelude.Maybe JobStatus)
stopTextTranslationJobResponse_jobStatus :: (Maybe JobStatus -> f (Maybe JobStatus))
-> StopTextTranslationJobResponse
-> f StopTextTranslationJobResponse
stopTextTranslationJobResponse_jobStatus = (StopTextTranslationJobResponse -> Maybe JobStatus)
-> (StopTextTranslationJobResponse
    -> Maybe JobStatus -> StopTextTranslationJobResponse)
-> Lens
     StopTextTranslationJobResponse
     StopTextTranslationJobResponse
     (Maybe JobStatus)
     (Maybe JobStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopTextTranslationJobResponse' {Maybe JobStatus
jobStatus :: Maybe JobStatus
$sel:jobStatus:StopTextTranslationJobResponse' :: StopTextTranslationJobResponse -> Maybe JobStatus
jobStatus} -> Maybe JobStatus
jobStatus) (\s :: StopTextTranslationJobResponse
s@StopTextTranslationJobResponse' {} Maybe JobStatus
a -> StopTextTranslationJobResponse
s {$sel:jobStatus:StopTextTranslationJobResponse' :: Maybe JobStatus
jobStatus = Maybe JobStatus
a} :: StopTextTranslationJobResponse)

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

instance
  Prelude.NFData
    StopTextTranslationJobResponse