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

instance Prelude.NFData StopSentimentDetectionJob

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

instance Core.ToQuery StopSentimentDetectionJob where
  toQuery :: StopSentimentDetectionJob -> QueryString
toQuery = QueryString -> StopSentimentDetectionJob -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(StopSentimentDetectionJobResponse
 -> StopSentimentDetectionJobResponse -> Bool)
-> (StopSentimentDetectionJobResponse
    -> StopSentimentDetectionJobResponse -> Bool)
-> Eq StopSentimentDetectionJobResponse
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]
(Int -> ReadS StopSentimentDetectionJobResponse)
-> ReadS [StopSentimentDetectionJobResponse]
-> ReadPrec StopSentimentDetectionJobResponse
-> ReadPrec [StopSentimentDetectionJobResponse]
-> Read 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
(Int -> StopSentimentDetectionJobResponse -> ShowS)
-> (StopSentimentDetectionJobResponse -> String)
-> ([StopSentimentDetectionJobResponse] -> ShowS)
-> Show StopSentimentDetectionJobResponse
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.
 StopSentimentDetectionJobResponse
 -> Rep StopSentimentDetectionJobResponse x)
-> (forall x.
    Rep StopSentimentDetectionJobResponse x
    -> StopSentimentDetectionJobResponse)
-> Generic StopSentimentDetectionJobResponse
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' :: Maybe Text
-> Maybe JobStatus -> Int -> StopSentimentDetectionJobResponse
StopSentimentDetectionJobResponse'
    { $sel:jobId:StopSentimentDetectionJobResponse' :: Maybe Text
jobId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:jobStatus:StopSentimentDetectionJobResponse' :: Maybe JobStatus
jobStatus = Maybe 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 :: (Maybe Text -> f (Maybe Text))
-> StopSentimentDetectionJobResponse
-> f StopSentimentDetectionJobResponse
stopSentimentDetectionJobResponse_jobId = (StopSentimentDetectionJobResponse -> Maybe Text)
-> (StopSentimentDetectionJobResponse
    -> Maybe Text -> StopSentimentDetectionJobResponse)
-> Lens
     StopSentimentDetectionJobResponse
     StopSentimentDetectionJobResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe JobStatus -> f (Maybe JobStatus))
-> StopSentimentDetectionJobResponse
-> f StopSentimentDetectionJobResponse
stopSentimentDetectionJobResponse_jobStatus = (StopSentimentDetectionJobResponse -> Maybe JobStatus)
-> (StopSentimentDetectionJobResponse
    -> Maybe JobStatus -> StopSentimentDetectionJobResponse)
-> Lens
     StopSentimentDetectionJobResponse
     StopSentimentDetectionJobResponse
     (Maybe JobStatus)
     (Maybe 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 :: (Int -> f Int)
-> StopSentimentDetectionJobResponse
-> f StopSentimentDetectionJobResponse
stopSentimentDetectionJobResponse_httpStatus = (StopSentimentDetectionJobResponse -> Int)
-> (StopSentimentDetectionJobResponse
    -> Int -> StopSentimentDetectionJobResponse)
-> Lens
     StopSentimentDetectionJobResponse
     StopSentimentDetectionJobResponse
     Int
     Int
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