{-# 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.StopEventsDetectionJob
-- 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 events detection job in progress.
module Amazonka.Comprehend.StopEventsDetectionJob
  ( -- * Creating a Request
    StopEventsDetectionJob (..),
    newStopEventsDetectionJob,

    -- * Request Lenses
    stopEventsDetectionJob_jobId,

    -- * Destructuring the Response
    StopEventsDetectionJobResponse (..),
    newStopEventsDetectionJobResponse,

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

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

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

instance Core.AWSRequest StopEventsDetectionJob where
  type
    AWSResponse StopEventsDetectionJob =
      StopEventsDetectionJobResponse
  request :: StopEventsDetectionJob -> Request StopEventsDetectionJob
request = Service -> StopEventsDetectionJob -> Request StopEventsDetectionJob
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopEventsDetectionJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopEventsDetectionJob)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StopEventsDetectionJob))
-> Logger
-> Service
-> Proxy StopEventsDetectionJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopEventsDetectionJob)))
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 -> StopEventsDetectionJobResponse
StopEventsDetectionJobResponse'
            (Maybe Text
 -> Maybe JobStatus -> Int -> StopEventsDetectionJobResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe JobStatus -> Int -> StopEventsDetectionJobResponse)
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 -> StopEventsDetectionJobResponse)
-> Either String (Maybe JobStatus)
-> Either String (Int -> StopEventsDetectionJobResponse)
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 -> StopEventsDetectionJobResponse)
-> Either String Int
-> Either String StopEventsDetectionJobResponse
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 StopEventsDetectionJob

instance Prelude.NFData StopEventsDetectionJob

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

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

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

-- |
-- Create a value of 'StopEventsDetectionJobResponse' 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', 'stopEventsDetectionJobResponse_jobId' - The identifier of the events detection job to stop.
--
-- 'jobStatus', 'stopEventsDetectionJobResponse_jobStatus' - The status of the events detection job.
--
-- 'httpStatus', 'stopEventsDetectionJobResponse_httpStatus' - The response's http status code.
newStopEventsDetectionJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopEventsDetectionJobResponse
newStopEventsDetectionJobResponse :: Int -> StopEventsDetectionJobResponse
newStopEventsDetectionJobResponse Int
pHttpStatus_ =
  StopEventsDetectionJobResponse' :: Maybe Text
-> Maybe JobStatus -> Int -> StopEventsDetectionJobResponse
StopEventsDetectionJobResponse'
    { $sel:jobId:StopEventsDetectionJobResponse' :: Maybe Text
jobId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:jobStatus:StopEventsDetectionJobResponse' :: Maybe JobStatus
jobStatus = Maybe JobStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StopEventsDetectionJobResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

-- | The status of the events detection job.
stopEventsDetectionJobResponse_jobStatus :: Lens.Lens' StopEventsDetectionJobResponse (Prelude.Maybe JobStatus)
stopEventsDetectionJobResponse_jobStatus :: (Maybe JobStatus -> f (Maybe JobStatus))
-> StopEventsDetectionJobResponse
-> f StopEventsDetectionJobResponse
stopEventsDetectionJobResponse_jobStatus = (StopEventsDetectionJobResponse -> Maybe JobStatus)
-> (StopEventsDetectionJobResponse
    -> Maybe JobStatus -> StopEventsDetectionJobResponse)
-> Lens
     StopEventsDetectionJobResponse
     StopEventsDetectionJobResponse
     (Maybe JobStatus)
     (Maybe JobStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopEventsDetectionJobResponse' {Maybe JobStatus
jobStatus :: Maybe JobStatus
$sel:jobStatus:StopEventsDetectionJobResponse' :: StopEventsDetectionJobResponse -> Maybe JobStatus
jobStatus} -> Maybe JobStatus
jobStatus) (\s :: StopEventsDetectionJobResponse
s@StopEventsDetectionJobResponse' {} Maybe JobStatus
a -> StopEventsDetectionJobResponse
s {$sel:jobStatus:StopEventsDetectionJobResponse' :: Maybe JobStatus
jobStatus = Maybe JobStatus
a} :: StopEventsDetectionJobResponse)

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

instance
  Prelude.NFData
    StopEventsDetectionJobResponse