{-# 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.StopSentimentDetectionJob
-- 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 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.StopSentimentDetectionJob
  ( -- * Creating a Request
    StopSentimentDetectionJob (..),
    newStopSentimentDetectionJob,

    -- * Request Lenses
    stopSentimentDetectionJob_jobId,

    -- * Destructuring the Response
    StopSentimentDetectionJobResponse (..),
    newStopSentimentDetectionJobResponse,

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

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

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

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

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

instance Data.ToHeaders StopSentimentDetectionJob where
  toHeaders :: StopSentimentDetectionJob -> 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.StopSentimentDetectionJob" ::
                          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 StopSentimentDetectionJob where
  toJSON :: StopSentimentDetectionJob -> Value
toJSON StopSentimentDetectionJob' {Text
jobId :: Text
$sel:jobId:StopSentimentDetectionJob' :: StopSentimentDetectionJob -> 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 StopSentimentDetectionJob where
  toPath :: StopSentimentDetectionJob -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newStopSentimentDetectionJobResponse' smart constructor.
data StopSentimentDetectionJobResponse = StopSentimentDetectionJobResponse'
  { -- | The identifier of the sentiment detection job to stop.
    StopSentimentDetectionJobResponse -> 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.
    StopSentimentDetectionJobResponse -> Maybe JobStatus
jobStatus :: Prelude.Maybe JobStatus,
    -- | The response's http status code.
    StopSentimentDetectionJobResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StopSentimentDetectionJobResponse
-> StopSentimentDetectionJobResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopSentimentDetectionJobResponse
-> StopSentimentDetectionJobResponse -> Bool
$c/= :: StopSentimentDetectionJobResponse
-> StopSentimentDetectionJobResponse -> Bool
== :: StopSentimentDetectionJobResponse
-> StopSentimentDetectionJobResponse -> Bool
$c== :: StopSentimentDetectionJobResponse
-> StopSentimentDetectionJobResponse -> Bool
Prelude.Eq, ReadPrec [StopSentimentDetectionJobResponse]
ReadPrec StopSentimentDetectionJobResponse
Int -> ReadS StopSentimentDetectionJobResponse
ReadS [StopSentimentDetectionJobResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopSentimentDetectionJobResponse]
$creadListPrec :: ReadPrec [StopSentimentDetectionJobResponse]
readPrec :: ReadPrec StopSentimentDetectionJobResponse
$creadPrec :: ReadPrec StopSentimentDetectionJobResponse
readList :: ReadS [StopSentimentDetectionJobResponse]
$creadList :: ReadS [StopSentimentDetectionJobResponse]
readsPrec :: Int -> ReadS StopSentimentDetectionJobResponse
$creadsPrec :: Int -> ReadS StopSentimentDetectionJobResponse
Prelude.Read, Int -> StopSentimentDetectionJobResponse -> ShowS
[StopSentimentDetectionJobResponse] -> ShowS
StopSentimentDetectionJobResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopSentimentDetectionJobResponse] -> ShowS
$cshowList :: [StopSentimentDetectionJobResponse] -> ShowS
show :: StopSentimentDetectionJobResponse -> String
$cshow :: StopSentimentDetectionJobResponse -> String
showsPrec :: Int -> StopSentimentDetectionJobResponse -> ShowS
$cshowsPrec :: Int -> StopSentimentDetectionJobResponse -> ShowS
Prelude.Show, forall x.
Rep StopSentimentDetectionJobResponse x
-> StopSentimentDetectionJobResponse
forall x.
StopSentimentDetectionJobResponse
-> Rep StopSentimentDetectionJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StopSentimentDetectionJobResponse x
-> StopSentimentDetectionJobResponse
$cfrom :: forall x.
StopSentimentDetectionJobResponse
-> Rep StopSentimentDetectionJobResponse x
Prelude.Generic)

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

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

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

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

instance
  Prelude.NFData
    StopSentimentDetectionJobResponse
  where
  rnf :: StopSentimentDetectionJobResponse -> ()
rnf StopSentimentDetectionJobResponse' {Int
Maybe Text
Maybe JobStatus
httpStatus :: Int
jobStatus :: Maybe JobStatus
jobId :: Maybe Text
$sel:httpStatus:StopSentimentDetectionJobResponse' :: StopSentimentDetectionJobResponse -> Int
$sel:jobStatus:StopSentimentDetectionJobResponse' :: StopSentimentDetectionJobResponse -> Maybe JobStatus
$sel:jobId:StopSentimentDetectionJobResponse' :: StopSentimentDetectionJobResponse -> 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