{-# 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.StopTargetedSentimentDetectionJob
-- 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 targeted sentiment detection job in progress.
--
-- If the job state is @IN_PROGRESS@, the job is 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
-- be stopped and put into the @STOPPED@ state.
--
-- If the job is in the @COMPLETED@ or @FAILED@ state when you call the
-- @StopDominantLanguageDetectionJob@ operation, the operation returns a
-- 400 Internal Request Exception.
--
-- When a job is stopped, any documents already processed are written to
-- the output location.
module Amazonka.Comprehend.StopTargetedSentimentDetectionJob
  ( -- * Creating a Request
    StopTargetedSentimentDetectionJob (..),
    newStopTargetedSentimentDetectionJob,

    -- * Request Lenses
    stopTargetedSentimentDetectionJob_jobId,

    -- * Destructuring the Response
    StopTargetedSentimentDetectionJobResponse (..),
    newStopTargetedSentimentDetectionJobResponse,

    -- * Response Lenses
    stopTargetedSentimentDetectionJobResponse_jobId,
    stopTargetedSentimentDetectionJobResponse_jobStatus,
    stopTargetedSentimentDetectionJobResponse_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:/ 'newStopTargetedSentimentDetectionJob' smart constructor.
data StopTargetedSentimentDetectionJob = StopTargetedSentimentDetectionJob'
  { -- | The identifier of the targeted sentiment detection job to stop.
    StopTargetedSentimentDetectionJob -> Text
jobId :: Prelude.Text
  }
  deriving (StopTargetedSentimentDetectionJob
-> StopTargetedSentimentDetectionJob -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopTargetedSentimentDetectionJob
-> StopTargetedSentimentDetectionJob -> Bool
$c/= :: StopTargetedSentimentDetectionJob
-> StopTargetedSentimentDetectionJob -> Bool
== :: StopTargetedSentimentDetectionJob
-> StopTargetedSentimentDetectionJob -> Bool
$c== :: StopTargetedSentimentDetectionJob
-> StopTargetedSentimentDetectionJob -> Bool
Prelude.Eq, ReadPrec [StopTargetedSentimentDetectionJob]
ReadPrec StopTargetedSentimentDetectionJob
Int -> ReadS StopTargetedSentimentDetectionJob
ReadS [StopTargetedSentimentDetectionJob]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopTargetedSentimentDetectionJob]
$creadListPrec :: ReadPrec [StopTargetedSentimentDetectionJob]
readPrec :: ReadPrec StopTargetedSentimentDetectionJob
$creadPrec :: ReadPrec StopTargetedSentimentDetectionJob
readList :: ReadS [StopTargetedSentimentDetectionJob]
$creadList :: ReadS [StopTargetedSentimentDetectionJob]
readsPrec :: Int -> ReadS StopTargetedSentimentDetectionJob
$creadsPrec :: Int -> ReadS StopTargetedSentimentDetectionJob
Prelude.Read, Int -> StopTargetedSentimentDetectionJob -> ShowS
[StopTargetedSentimentDetectionJob] -> ShowS
StopTargetedSentimentDetectionJob -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopTargetedSentimentDetectionJob] -> ShowS
$cshowList :: [StopTargetedSentimentDetectionJob] -> ShowS
show :: StopTargetedSentimentDetectionJob -> String
$cshow :: StopTargetedSentimentDetectionJob -> String
showsPrec :: Int -> StopTargetedSentimentDetectionJob -> ShowS
$cshowsPrec :: Int -> StopTargetedSentimentDetectionJob -> ShowS
Prelude.Show, forall x.
Rep StopTargetedSentimentDetectionJob x
-> StopTargetedSentimentDetectionJob
forall x.
StopTargetedSentimentDetectionJob
-> Rep StopTargetedSentimentDetectionJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StopTargetedSentimentDetectionJob x
-> StopTargetedSentimentDetectionJob
$cfrom :: forall x.
StopTargetedSentimentDetectionJob
-> Rep StopTargetedSentimentDetectionJob x
Prelude.Generic)

-- |
-- Create a value of 'StopTargetedSentimentDetectionJob' 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', 'stopTargetedSentimentDetectionJob_jobId' - The identifier of the targeted sentiment detection job to stop.
newStopTargetedSentimentDetectionJob ::
  -- | 'jobId'
  Prelude.Text ->
  StopTargetedSentimentDetectionJob
newStopTargetedSentimentDetectionJob :: Text -> StopTargetedSentimentDetectionJob
newStopTargetedSentimentDetectionJob Text
pJobId_ =
  StopTargetedSentimentDetectionJob' {$sel:jobId:StopTargetedSentimentDetectionJob' :: Text
jobId = Text
pJobId_}

-- | The identifier of the targeted sentiment detection job to stop.
stopTargetedSentimentDetectionJob_jobId :: Lens.Lens' StopTargetedSentimentDetectionJob Prelude.Text
stopTargetedSentimentDetectionJob_jobId :: Lens' StopTargetedSentimentDetectionJob Text
stopTargetedSentimentDetectionJob_jobId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopTargetedSentimentDetectionJob' {Text
jobId :: Text
$sel:jobId:StopTargetedSentimentDetectionJob' :: StopTargetedSentimentDetectionJob -> Text
jobId} -> Text
jobId) (\s :: StopTargetedSentimentDetectionJob
s@StopTargetedSentimentDetectionJob' {} Text
a -> StopTargetedSentimentDetectionJob
s {$sel:jobId:StopTargetedSentimentDetectionJob' :: Text
jobId = Text
a} :: StopTargetedSentimentDetectionJob)

instance
  Core.AWSRequest
    StopTargetedSentimentDetectionJob
  where
  type
    AWSResponse StopTargetedSentimentDetectionJob =
      StopTargetedSentimentDetectionJobResponse
  request :: (Service -> Service)
-> StopTargetedSentimentDetectionJob
-> Request StopTargetedSentimentDetectionJob
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 StopTargetedSentimentDetectionJob
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse StopTargetedSentimentDetectionJob)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe JobStatus
-> Int
-> StopTargetedSentimentDetectionJobResponse
StopTargetedSentimentDetectionJobResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"JobId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"JobStatus")
            forall (f :: * -> *) a b. Applicative f => 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
    StopTargetedSentimentDetectionJob
  where
  hashWithSalt :: Int -> StopTargetedSentimentDetectionJob -> Int
hashWithSalt
    Int
_salt
    StopTargetedSentimentDetectionJob' {Text
jobId :: Text
$sel:jobId:StopTargetedSentimentDetectionJob' :: StopTargetedSentimentDetectionJob -> Text
..} =
      Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
jobId

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

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

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

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

-- | /See:/ 'newStopTargetedSentimentDetectionJobResponse' smart constructor.
data StopTargetedSentimentDetectionJobResponse = StopTargetedSentimentDetectionJobResponse'
  { -- | The identifier of the targeted sentiment detection job to stop.
    StopTargetedSentimentDetectionJobResponse -> Maybe Text
jobId :: Prelude.Maybe Prelude.Text,
    -- | Either @STOP_REQUESTED@ if the job is currently running, or @STOPPED@ if
    -- the job was previously stopped with the @StopSentimentDetectionJob@
    -- operation.
    StopTargetedSentimentDetectionJobResponse -> Maybe JobStatus
jobStatus :: Prelude.Maybe JobStatus,
    -- | The response's http status code.
    StopTargetedSentimentDetectionJobResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StopTargetedSentimentDetectionJobResponse
-> StopTargetedSentimentDetectionJobResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopTargetedSentimentDetectionJobResponse
-> StopTargetedSentimentDetectionJobResponse -> Bool
$c/= :: StopTargetedSentimentDetectionJobResponse
-> StopTargetedSentimentDetectionJobResponse -> Bool
== :: StopTargetedSentimentDetectionJobResponse
-> StopTargetedSentimentDetectionJobResponse -> Bool
$c== :: StopTargetedSentimentDetectionJobResponse
-> StopTargetedSentimentDetectionJobResponse -> Bool
Prelude.Eq, ReadPrec [StopTargetedSentimentDetectionJobResponse]
ReadPrec StopTargetedSentimentDetectionJobResponse
Int -> ReadS StopTargetedSentimentDetectionJobResponse
ReadS [StopTargetedSentimentDetectionJobResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopTargetedSentimentDetectionJobResponse]
$creadListPrec :: ReadPrec [StopTargetedSentimentDetectionJobResponse]
readPrec :: ReadPrec StopTargetedSentimentDetectionJobResponse
$creadPrec :: ReadPrec StopTargetedSentimentDetectionJobResponse
readList :: ReadS [StopTargetedSentimentDetectionJobResponse]
$creadList :: ReadS [StopTargetedSentimentDetectionJobResponse]
readsPrec :: Int -> ReadS StopTargetedSentimentDetectionJobResponse
$creadsPrec :: Int -> ReadS StopTargetedSentimentDetectionJobResponse
Prelude.Read, Int -> StopTargetedSentimentDetectionJobResponse -> ShowS
[StopTargetedSentimentDetectionJobResponse] -> ShowS
StopTargetedSentimentDetectionJobResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopTargetedSentimentDetectionJobResponse] -> ShowS
$cshowList :: [StopTargetedSentimentDetectionJobResponse] -> ShowS
show :: StopTargetedSentimentDetectionJobResponse -> String
$cshow :: StopTargetedSentimentDetectionJobResponse -> String
showsPrec :: Int -> StopTargetedSentimentDetectionJobResponse -> ShowS
$cshowsPrec :: Int -> StopTargetedSentimentDetectionJobResponse -> ShowS
Prelude.Show, forall x.
Rep StopTargetedSentimentDetectionJobResponse x
-> StopTargetedSentimentDetectionJobResponse
forall x.
StopTargetedSentimentDetectionJobResponse
-> Rep StopTargetedSentimentDetectionJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StopTargetedSentimentDetectionJobResponse x
-> StopTargetedSentimentDetectionJobResponse
$cfrom :: forall x.
StopTargetedSentimentDetectionJobResponse
-> Rep StopTargetedSentimentDetectionJobResponse x
Prelude.Generic)

-- |
-- Create a value of 'StopTargetedSentimentDetectionJobResponse' 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', 'stopTargetedSentimentDetectionJobResponse_jobId' - The identifier of the targeted sentiment detection job to stop.
--
-- 'jobStatus', 'stopTargetedSentimentDetectionJobResponse_jobStatus' - Either @STOP_REQUESTED@ if the job is currently running, or @STOPPED@ if
-- the job was previously stopped with the @StopSentimentDetectionJob@
-- operation.
--
-- 'httpStatus', 'stopTargetedSentimentDetectionJobResponse_httpStatus' - The response's http status code.
newStopTargetedSentimentDetectionJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopTargetedSentimentDetectionJobResponse
newStopTargetedSentimentDetectionJobResponse :: Int -> StopTargetedSentimentDetectionJobResponse
newStopTargetedSentimentDetectionJobResponse
  Int
pHttpStatus_ =
    StopTargetedSentimentDetectionJobResponse'
      { $sel:jobId:StopTargetedSentimentDetectionJobResponse' :: Maybe Text
jobId =
          forall a. Maybe a
Prelude.Nothing,
        $sel:jobStatus:StopTargetedSentimentDetectionJobResponse' :: Maybe JobStatus
jobStatus = forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:StopTargetedSentimentDetectionJobResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The identifier of the targeted sentiment detection job to stop.
stopTargetedSentimentDetectionJobResponse_jobId :: Lens.Lens' StopTargetedSentimentDetectionJobResponse (Prelude.Maybe Prelude.Text)
stopTargetedSentimentDetectionJobResponse_jobId :: Lens' StopTargetedSentimentDetectionJobResponse (Maybe Text)
stopTargetedSentimentDetectionJobResponse_jobId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopTargetedSentimentDetectionJobResponse' {Maybe Text
jobId :: Maybe Text
$sel:jobId:StopTargetedSentimentDetectionJobResponse' :: StopTargetedSentimentDetectionJobResponse -> Maybe Text
jobId} -> Maybe Text
jobId) (\s :: StopTargetedSentimentDetectionJobResponse
s@StopTargetedSentimentDetectionJobResponse' {} Maybe Text
a -> StopTargetedSentimentDetectionJobResponse
s {$sel:jobId:StopTargetedSentimentDetectionJobResponse' :: Maybe Text
jobId = Maybe Text
a} :: StopTargetedSentimentDetectionJobResponse)

-- | Either @STOP_REQUESTED@ if the job is currently running, or @STOPPED@ if
-- the job was previously stopped with the @StopSentimentDetectionJob@
-- operation.
stopTargetedSentimentDetectionJobResponse_jobStatus :: Lens.Lens' StopTargetedSentimentDetectionJobResponse (Prelude.Maybe JobStatus)
stopTargetedSentimentDetectionJobResponse_jobStatus :: Lens' StopTargetedSentimentDetectionJobResponse (Maybe JobStatus)
stopTargetedSentimentDetectionJobResponse_jobStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopTargetedSentimentDetectionJobResponse' {Maybe JobStatus
jobStatus :: Maybe JobStatus
$sel:jobStatus:StopTargetedSentimentDetectionJobResponse' :: StopTargetedSentimentDetectionJobResponse -> Maybe JobStatus
jobStatus} -> Maybe JobStatus
jobStatus) (\s :: StopTargetedSentimentDetectionJobResponse
s@StopTargetedSentimentDetectionJobResponse' {} Maybe JobStatus
a -> StopTargetedSentimentDetectionJobResponse
s {$sel:jobStatus:StopTargetedSentimentDetectionJobResponse' :: Maybe JobStatus
jobStatus = Maybe JobStatus
a} :: StopTargetedSentimentDetectionJobResponse)

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

instance
  Prelude.NFData
    StopTargetedSentimentDetectionJobResponse
  where
  rnf :: StopTargetedSentimentDetectionJobResponse -> ()
rnf StopTargetedSentimentDetectionJobResponse' {Int
Maybe Text
Maybe JobStatus
httpStatus :: Int
jobStatus :: Maybe JobStatus
jobId :: Maybe Text
$sel:httpStatus:StopTargetedSentimentDetectionJobResponse' :: StopTargetedSentimentDetectionJobResponse -> Int
$sel:jobStatus:StopTargetedSentimentDetectionJobResponse' :: StopTargetedSentimentDetectionJobResponse -> Maybe JobStatus
$sel:jobId:StopTargetedSentimentDetectionJobResponse' :: StopTargetedSentimentDetectionJobResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
jobId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe JobStatus
jobStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus