{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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:/ 'newStopEventsDetectionJob' smart constructor.
data StopEventsDetectionJob = StopEventsDetectionJob'
  { -- | The identifier of the events detection job to stop.
    StopEventsDetectionJob -> Text
jobId :: Prelude.Text
  }
  deriving (StopEventsDetectionJob -> StopEventsDetectionJob -> Bool
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]
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
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. 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' {$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 :: Lens' StopEventsDetectionJob Text
stopEventsDetectionJob_jobId = 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 :: (Service -> Service)
-> StopEventsDetectionJob -> Request StopEventsDetectionJob
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 StopEventsDetectionJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopEventsDetectionJob)))
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 -> StopEventsDetectionJobResponse
StopEventsDetectionJobResponse'
            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 StopEventsDetectionJob where
  hashWithSalt :: Int -> StopEventsDetectionJob -> Int
hashWithSalt Int
_salt StopEventsDetectionJob' {Text
jobId :: Text
$sel:jobId:StopEventsDetectionJob' :: StopEventsDetectionJob -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
jobId

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

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

instance Data.ToQuery StopEventsDetectionJob where
  toQuery :: StopEventsDetectionJob -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:jobId:StopEventsDetectionJobResponse' :: Maybe Text
jobId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:jobStatus:StopEventsDetectionJobResponse' :: Maybe JobStatus
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 :: Lens' StopEventsDetectionJobResponse (Maybe Text)
stopEventsDetectionJobResponse_jobId = 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 :: Lens' StopEventsDetectionJobResponse (Maybe JobStatus)
stopEventsDetectionJobResponse_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 :: Lens' StopEventsDetectionJobResponse Int
stopEventsDetectionJobResponse_httpStatus = 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
  where
  rnf :: StopEventsDetectionJobResponse -> ()
rnf StopEventsDetectionJobResponse' {Int
Maybe Text
Maybe JobStatus
httpStatus :: Int
jobStatus :: Maybe JobStatus
jobId :: Maybe Text
$sel:httpStatus:StopEventsDetectionJobResponse' :: StopEventsDetectionJobResponse -> Int
$sel:jobStatus:StopEventsDetectionJobResponse' :: StopEventsDetectionJobResponse -> Maybe JobStatus
$sel:jobId:StopEventsDetectionJobResponse' :: StopEventsDetectionJobResponse -> 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