{-# 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.StartEventsDetectionJob
-- 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)
--
-- Starts an asynchronous event detection job for a collection of
-- documents.
module Amazonka.Comprehend.StartEventsDetectionJob
  ( -- * Creating a Request
    StartEventsDetectionJob (..),
    newStartEventsDetectionJob,

    -- * Request Lenses
    startEventsDetectionJob_jobName,
    startEventsDetectionJob_clientRequestToken,
    startEventsDetectionJob_tags,
    startEventsDetectionJob_inputDataConfig,
    startEventsDetectionJob_outputDataConfig,
    startEventsDetectionJob_dataAccessRoleArn,
    startEventsDetectionJob_languageCode,
    startEventsDetectionJob_targetEventTypes,

    -- * Destructuring the Response
    StartEventsDetectionJobResponse (..),
    newStartEventsDetectionJobResponse,

    -- * Response Lenses
    startEventsDetectionJobResponse_jobId,
    startEventsDetectionJobResponse_jobArn,
    startEventsDetectionJobResponse_jobStatus,
    startEventsDetectionJobResponse_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:/ 'newStartEventsDetectionJob' smart constructor.
data StartEventsDetectionJob = StartEventsDetectionJob'
  { -- | The identifier of the events detection job.
    StartEventsDetectionJob -> Maybe Text
jobName :: Prelude.Maybe Prelude.Text,
    -- | An unique identifier for the request. If you don\'t set the client
    -- request token, Amazon Comprehend generates one.
    StartEventsDetectionJob -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | Tags to be associated with the events detection job. A tag is a
    -- key-value pair that adds metadata to a resource used by Amazon
    -- Comprehend. For example, a tag with \"Sales\" as the key might be added
    -- to a resource to indicate its use by the sales department.
    StartEventsDetectionJob -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | Specifies the format and location of the input data for the job.
    StartEventsDetectionJob -> InputDataConfig
inputDataConfig :: InputDataConfig,
    -- | Specifies where to send the output files.
    StartEventsDetectionJob -> OutputDataConfig
outputDataConfig :: OutputDataConfig,
    -- | The Amazon Resource Name (ARN) of the AWS Identity and Access Management
    -- (IAM) role that grants Amazon Comprehend read access to your input data.
    StartEventsDetectionJob -> Text
dataAccessRoleArn :: Prelude.Text,
    -- | The language code of the input documents.
    StartEventsDetectionJob -> LanguageCode
languageCode :: LanguageCode,
    -- | The types of events to detect in the input documents.
    StartEventsDetectionJob -> NonEmpty Text
targetEventTypes :: Prelude.NonEmpty Prelude.Text
  }
  deriving (StartEventsDetectionJob -> StartEventsDetectionJob -> Bool
(StartEventsDetectionJob -> StartEventsDetectionJob -> Bool)
-> (StartEventsDetectionJob -> StartEventsDetectionJob -> Bool)
-> Eq StartEventsDetectionJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartEventsDetectionJob -> StartEventsDetectionJob -> Bool
$c/= :: StartEventsDetectionJob -> StartEventsDetectionJob -> Bool
== :: StartEventsDetectionJob -> StartEventsDetectionJob -> Bool
$c== :: StartEventsDetectionJob -> StartEventsDetectionJob -> Bool
Prelude.Eq, ReadPrec [StartEventsDetectionJob]
ReadPrec StartEventsDetectionJob
Int -> ReadS StartEventsDetectionJob
ReadS [StartEventsDetectionJob]
(Int -> ReadS StartEventsDetectionJob)
-> ReadS [StartEventsDetectionJob]
-> ReadPrec StartEventsDetectionJob
-> ReadPrec [StartEventsDetectionJob]
-> Read StartEventsDetectionJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartEventsDetectionJob]
$creadListPrec :: ReadPrec [StartEventsDetectionJob]
readPrec :: ReadPrec StartEventsDetectionJob
$creadPrec :: ReadPrec StartEventsDetectionJob
readList :: ReadS [StartEventsDetectionJob]
$creadList :: ReadS [StartEventsDetectionJob]
readsPrec :: Int -> ReadS StartEventsDetectionJob
$creadsPrec :: Int -> ReadS StartEventsDetectionJob
Prelude.Read, Int -> StartEventsDetectionJob -> ShowS
[StartEventsDetectionJob] -> ShowS
StartEventsDetectionJob -> String
(Int -> StartEventsDetectionJob -> ShowS)
-> (StartEventsDetectionJob -> String)
-> ([StartEventsDetectionJob] -> ShowS)
-> Show StartEventsDetectionJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartEventsDetectionJob] -> ShowS
$cshowList :: [StartEventsDetectionJob] -> ShowS
show :: StartEventsDetectionJob -> String
$cshow :: StartEventsDetectionJob -> String
showsPrec :: Int -> StartEventsDetectionJob -> ShowS
$cshowsPrec :: Int -> StartEventsDetectionJob -> ShowS
Prelude.Show, (forall x.
 StartEventsDetectionJob -> Rep StartEventsDetectionJob x)
-> (forall x.
    Rep StartEventsDetectionJob x -> StartEventsDetectionJob)
-> Generic StartEventsDetectionJob
forall x. Rep StartEventsDetectionJob x -> StartEventsDetectionJob
forall x. StartEventsDetectionJob -> Rep StartEventsDetectionJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartEventsDetectionJob x -> StartEventsDetectionJob
$cfrom :: forall x. StartEventsDetectionJob -> Rep StartEventsDetectionJob x
Prelude.Generic)

-- |
-- Create a value of 'StartEventsDetectionJob' 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:
--
-- 'jobName', 'startEventsDetectionJob_jobName' - The identifier of the events detection job.
--
-- 'clientRequestToken', 'startEventsDetectionJob_clientRequestToken' - An unique identifier for the request. If you don\'t set the client
-- request token, Amazon Comprehend generates one.
--
-- 'tags', 'startEventsDetectionJob_tags' - Tags to be associated with the events detection job. A tag is a
-- key-value pair that adds metadata to a resource used by Amazon
-- Comprehend. For example, a tag with \"Sales\" as the key might be added
-- to a resource to indicate its use by the sales department.
--
-- 'inputDataConfig', 'startEventsDetectionJob_inputDataConfig' - Specifies the format and location of the input data for the job.
--
-- 'outputDataConfig', 'startEventsDetectionJob_outputDataConfig' - Specifies where to send the output files.
--
-- 'dataAccessRoleArn', 'startEventsDetectionJob_dataAccessRoleArn' - The Amazon Resource Name (ARN) of the AWS Identity and Access Management
-- (IAM) role that grants Amazon Comprehend read access to your input data.
--
-- 'languageCode', 'startEventsDetectionJob_languageCode' - The language code of the input documents.
--
-- 'targetEventTypes', 'startEventsDetectionJob_targetEventTypes' - The types of events to detect in the input documents.
newStartEventsDetectionJob ::
  -- | 'inputDataConfig'
  InputDataConfig ->
  -- | 'outputDataConfig'
  OutputDataConfig ->
  -- | 'dataAccessRoleArn'
  Prelude.Text ->
  -- | 'languageCode'
  LanguageCode ->
  -- | 'targetEventTypes'
  Prelude.NonEmpty Prelude.Text ->
  StartEventsDetectionJob
newStartEventsDetectionJob :: InputDataConfig
-> OutputDataConfig
-> Text
-> LanguageCode
-> NonEmpty Text
-> StartEventsDetectionJob
newStartEventsDetectionJob
  InputDataConfig
pInputDataConfig_
  OutputDataConfig
pOutputDataConfig_
  Text
pDataAccessRoleArn_
  LanguageCode
pLanguageCode_
  NonEmpty Text
pTargetEventTypes_ =
    StartEventsDetectionJob' :: Maybe Text
-> Maybe Text
-> Maybe [Tag]
-> InputDataConfig
-> OutputDataConfig
-> Text
-> LanguageCode
-> NonEmpty Text
-> StartEventsDetectionJob
StartEventsDetectionJob'
      { $sel:jobName:StartEventsDetectionJob' :: Maybe Text
jobName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:clientRequestToken:StartEventsDetectionJob' :: Maybe Text
clientRequestToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:StartEventsDetectionJob' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
        $sel:inputDataConfig:StartEventsDetectionJob' :: InputDataConfig
inputDataConfig = InputDataConfig
pInputDataConfig_,
        $sel:outputDataConfig:StartEventsDetectionJob' :: OutputDataConfig
outputDataConfig = OutputDataConfig
pOutputDataConfig_,
        $sel:dataAccessRoleArn:StartEventsDetectionJob' :: Text
dataAccessRoleArn = Text
pDataAccessRoleArn_,
        $sel:languageCode:StartEventsDetectionJob' :: LanguageCode
languageCode = LanguageCode
pLanguageCode_,
        $sel:targetEventTypes:StartEventsDetectionJob' :: NonEmpty Text
targetEventTypes =
          Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pTargetEventTypes_
      }

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

-- | An unique identifier for the request. If you don\'t set the client
-- request token, Amazon Comprehend generates one.
startEventsDetectionJob_clientRequestToken :: Lens.Lens' StartEventsDetectionJob (Prelude.Maybe Prelude.Text)
startEventsDetectionJob_clientRequestToken :: (Maybe Text -> f (Maybe Text))
-> StartEventsDetectionJob -> f StartEventsDetectionJob
startEventsDetectionJob_clientRequestToken = (StartEventsDetectionJob -> Maybe Text)
-> (StartEventsDetectionJob
    -> Maybe Text -> StartEventsDetectionJob)
-> Lens
     StartEventsDetectionJob
     StartEventsDetectionJob
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartEventsDetectionJob' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:StartEventsDetectionJob' :: StartEventsDetectionJob -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: StartEventsDetectionJob
s@StartEventsDetectionJob' {} Maybe Text
a -> StartEventsDetectionJob
s {$sel:clientRequestToken:StartEventsDetectionJob' :: Maybe Text
clientRequestToken = Maybe Text
a} :: StartEventsDetectionJob)

-- | Tags to be associated with the events detection job. A tag is a
-- key-value pair that adds metadata to a resource used by Amazon
-- Comprehend. For example, a tag with \"Sales\" as the key might be added
-- to a resource to indicate its use by the sales department.
startEventsDetectionJob_tags :: Lens.Lens' StartEventsDetectionJob (Prelude.Maybe [Tag])
startEventsDetectionJob_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> StartEventsDetectionJob -> f StartEventsDetectionJob
startEventsDetectionJob_tags = (StartEventsDetectionJob -> Maybe [Tag])
-> (StartEventsDetectionJob
    -> Maybe [Tag] -> StartEventsDetectionJob)
-> Lens
     StartEventsDetectionJob
     StartEventsDetectionJob
     (Maybe [Tag])
     (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartEventsDetectionJob' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:StartEventsDetectionJob' :: StartEventsDetectionJob -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: StartEventsDetectionJob
s@StartEventsDetectionJob' {} Maybe [Tag]
a -> StartEventsDetectionJob
s {$sel:tags:StartEventsDetectionJob' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: StartEventsDetectionJob) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> StartEventsDetectionJob -> f StartEventsDetectionJob)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> StartEventsDetectionJob
-> f StartEventsDetectionJob
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the format and location of the input data for the job.
startEventsDetectionJob_inputDataConfig :: Lens.Lens' StartEventsDetectionJob InputDataConfig
startEventsDetectionJob_inputDataConfig :: (InputDataConfig -> f InputDataConfig)
-> StartEventsDetectionJob -> f StartEventsDetectionJob
startEventsDetectionJob_inputDataConfig = (StartEventsDetectionJob -> InputDataConfig)
-> (StartEventsDetectionJob
    -> InputDataConfig -> StartEventsDetectionJob)
-> Lens
     StartEventsDetectionJob
     StartEventsDetectionJob
     InputDataConfig
     InputDataConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartEventsDetectionJob' {InputDataConfig
inputDataConfig :: InputDataConfig
$sel:inputDataConfig:StartEventsDetectionJob' :: StartEventsDetectionJob -> InputDataConfig
inputDataConfig} -> InputDataConfig
inputDataConfig) (\s :: StartEventsDetectionJob
s@StartEventsDetectionJob' {} InputDataConfig
a -> StartEventsDetectionJob
s {$sel:inputDataConfig:StartEventsDetectionJob' :: InputDataConfig
inputDataConfig = InputDataConfig
a} :: StartEventsDetectionJob)

-- | Specifies where to send the output files.
startEventsDetectionJob_outputDataConfig :: Lens.Lens' StartEventsDetectionJob OutputDataConfig
startEventsDetectionJob_outputDataConfig :: (OutputDataConfig -> f OutputDataConfig)
-> StartEventsDetectionJob -> f StartEventsDetectionJob
startEventsDetectionJob_outputDataConfig = (StartEventsDetectionJob -> OutputDataConfig)
-> (StartEventsDetectionJob
    -> OutputDataConfig -> StartEventsDetectionJob)
-> Lens
     StartEventsDetectionJob
     StartEventsDetectionJob
     OutputDataConfig
     OutputDataConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartEventsDetectionJob' {OutputDataConfig
outputDataConfig :: OutputDataConfig
$sel:outputDataConfig:StartEventsDetectionJob' :: StartEventsDetectionJob -> OutputDataConfig
outputDataConfig} -> OutputDataConfig
outputDataConfig) (\s :: StartEventsDetectionJob
s@StartEventsDetectionJob' {} OutputDataConfig
a -> StartEventsDetectionJob
s {$sel:outputDataConfig:StartEventsDetectionJob' :: OutputDataConfig
outputDataConfig = OutputDataConfig
a} :: StartEventsDetectionJob)

-- | The Amazon Resource Name (ARN) of the AWS Identity and Access Management
-- (IAM) role that grants Amazon Comprehend read access to your input data.
startEventsDetectionJob_dataAccessRoleArn :: Lens.Lens' StartEventsDetectionJob Prelude.Text
startEventsDetectionJob_dataAccessRoleArn :: (Text -> f Text)
-> StartEventsDetectionJob -> f StartEventsDetectionJob
startEventsDetectionJob_dataAccessRoleArn = (StartEventsDetectionJob -> Text)
-> (StartEventsDetectionJob -> Text -> StartEventsDetectionJob)
-> Lens StartEventsDetectionJob StartEventsDetectionJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartEventsDetectionJob' {Text
dataAccessRoleArn :: Text
$sel:dataAccessRoleArn:StartEventsDetectionJob' :: StartEventsDetectionJob -> Text
dataAccessRoleArn} -> Text
dataAccessRoleArn) (\s :: StartEventsDetectionJob
s@StartEventsDetectionJob' {} Text
a -> StartEventsDetectionJob
s {$sel:dataAccessRoleArn:StartEventsDetectionJob' :: Text
dataAccessRoleArn = Text
a} :: StartEventsDetectionJob)

-- | The language code of the input documents.
startEventsDetectionJob_languageCode :: Lens.Lens' StartEventsDetectionJob LanguageCode
startEventsDetectionJob_languageCode :: (LanguageCode -> f LanguageCode)
-> StartEventsDetectionJob -> f StartEventsDetectionJob
startEventsDetectionJob_languageCode = (StartEventsDetectionJob -> LanguageCode)
-> (StartEventsDetectionJob
    -> LanguageCode -> StartEventsDetectionJob)
-> Lens
     StartEventsDetectionJob
     StartEventsDetectionJob
     LanguageCode
     LanguageCode
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartEventsDetectionJob' {LanguageCode
languageCode :: LanguageCode
$sel:languageCode:StartEventsDetectionJob' :: StartEventsDetectionJob -> LanguageCode
languageCode} -> LanguageCode
languageCode) (\s :: StartEventsDetectionJob
s@StartEventsDetectionJob' {} LanguageCode
a -> StartEventsDetectionJob
s {$sel:languageCode:StartEventsDetectionJob' :: LanguageCode
languageCode = LanguageCode
a} :: StartEventsDetectionJob)

-- | The types of events to detect in the input documents.
startEventsDetectionJob_targetEventTypes :: Lens.Lens' StartEventsDetectionJob (Prelude.NonEmpty Prelude.Text)
startEventsDetectionJob_targetEventTypes :: (NonEmpty Text -> f (NonEmpty Text))
-> StartEventsDetectionJob -> f StartEventsDetectionJob
startEventsDetectionJob_targetEventTypes = (StartEventsDetectionJob -> NonEmpty Text)
-> (StartEventsDetectionJob
    -> NonEmpty Text -> StartEventsDetectionJob)
-> Lens
     StartEventsDetectionJob
     StartEventsDetectionJob
     (NonEmpty Text)
     (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartEventsDetectionJob' {NonEmpty Text
targetEventTypes :: NonEmpty Text
$sel:targetEventTypes:StartEventsDetectionJob' :: StartEventsDetectionJob -> NonEmpty Text
targetEventTypes} -> NonEmpty Text
targetEventTypes) (\s :: StartEventsDetectionJob
s@StartEventsDetectionJob' {} NonEmpty Text
a -> StartEventsDetectionJob
s {$sel:targetEventTypes:StartEventsDetectionJob' :: NonEmpty Text
targetEventTypes = NonEmpty Text
a} :: StartEventsDetectionJob) ((NonEmpty Text -> f (NonEmpty Text))
 -> StartEventsDetectionJob -> f StartEventsDetectionJob)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> StartEventsDetectionJob
-> f StartEventsDetectionJob
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData StartEventsDetectionJob

instance Core.ToHeaders StartEventsDetectionJob where
  toHeaders :: StartEventsDetectionJob -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartEventsDetectionJob -> 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.StartEventsDetectionJob" ::
                          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 StartEventsDetectionJob where
  toJSON :: StartEventsDetectionJob -> Value
toJSON StartEventsDetectionJob' {Maybe [Tag]
Maybe Text
NonEmpty Text
Text
InputDataConfig
LanguageCode
OutputDataConfig
targetEventTypes :: NonEmpty Text
languageCode :: LanguageCode
dataAccessRoleArn :: Text
outputDataConfig :: OutputDataConfig
inputDataConfig :: InputDataConfig
tags :: Maybe [Tag]
clientRequestToken :: Maybe Text
jobName :: Maybe Text
$sel:targetEventTypes:StartEventsDetectionJob' :: StartEventsDetectionJob -> NonEmpty Text
$sel:languageCode:StartEventsDetectionJob' :: StartEventsDetectionJob -> LanguageCode
$sel:dataAccessRoleArn:StartEventsDetectionJob' :: StartEventsDetectionJob -> Text
$sel:outputDataConfig:StartEventsDetectionJob' :: StartEventsDetectionJob -> OutputDataConfig
$sel:inputDataConfig:StartEventsDetectionJob' :: StartEventsDetectionJob -> InputDataConfig
$sel:tags:StartEventsDetectionJob' :: StartEventsDetectionJob -> Maybe [Tag]
$sel:clientRequestToken:StartEventsDetectionJob' :: StartEventsDetectionJob -> Maybe Text
$sel:jobName:StartEventsDetectionJob' :: StartEventsDetectionJob -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"JobName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
jobName,
            (Text
"ClientRequestToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientRequestToken,
            (Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"InputDataConfig" Text -> InputDataConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= InputDataConfig
inputDataConfig),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"OutputDataConfig" Text -> OutputDataConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= OutputDataConfig
outputDataConfig),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"DataAccessRoleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
dataAccessRoleArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"LanguageCode" Text -> LanguageCode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LanguageCode
languageCode),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TargetEventTypes" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
targetEventTypes)
          ]
      )

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

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

-- | /See:/ 'newStartEventsDetectionJobResponse' smart constructor.
data StartEventsDetectionJobResponse = StartEventsDetectionJobResponse'
  { -- | An unique identifier for the request. If you don\'t set the client
    -- request token, Amazon Comprehend generates one.
    StartEventsDetectionJobResponse -> Maybe Text
jobId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the events detection job. It is a
    -- unique, fully qualified identifier for the job. It includes the AWS
    -- account, Region, and the job ID. The format of the ARN is as follows:
    --
    -- @arn:\<partition>:comprehend:\<region>:\<account-id>:events-detection-job\/\<job-id>@
    --
    -- The following is an example job ARN:
    --
    -- @arn:aws:comprehend:us-west-2:111122223333:events-detection-job\/1234abcd12ab34cd56ef1234567890ab@
    StartEventsDetectionJobResponse -> Maybe Text
jobArn :: Prelude.Maybe Prelude.Text,
    -- | The status of the events detection job.
    StartEventsDetectionJobResponse -> Maybe JobStatus
jobStatus :: Prelude.Maybe JobStatus,
    -- | The response's http status code.
    StartEventsDetectionJobResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartEventsDetectionJobResponse
-> StartEventsDetectionJobResponse -> Bool
(StartEventsDetectionJobResponse
 -> StartEventsDetectionJobResponse -> Bool)
-> (StartEventsDetectionJobResponse
    -> StartEventsDetectionJobResponse -> Bool)
-> Eq StartEventsDetectionJobResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartEventsDetectionJobResponse
-> StartEventsDetectionJobResponse -> Bool
$c/= :: StartEventsDetectionJobResponse
-> StartEventsDetectionJobResponse -> Bool
== :: StartEventsDetectionJobResponse
-> StartEventsDetectionJobResponse -> Bool
$c== :: StartEventsDetectionJobResponse
-> StartEventsDetectionJobResponse -> Bool
Prelude.Eq, ReadPrec [StartEventsDetectionJobResponse]
ReadPrec StartEventsDetectionJobResponse
Int -> ReadS StartEventsDetectionJobResponse
ReadS [StartEventsDetectionJobResponse]
(Int -> ReadS StartEventsDetectionJobResponse)
-> ReadS [StartEventsDetectionJobResponse]
-> ReadPrec StartEventsDetectionJobResponse
-> ReadPrec [StartEventsDetectionJobResponse]
-> Read StartEventsDetectionJobResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartEventsDetectionJobResponse]
$creadListPrec :: ReadPrec [StartEventsDetectionJobResponse]
readPrec :: ReadPrec StartEventsDetectionJobResponse
$creadPrec :: ReadPrec StartEventsDetectionJobResponse
readList :: ReadS [StartEventsDetectionJobResponse]
$creadList :: ReadS [StartEventsDetectionJobResponse]
readsPrec :: Int -> ReadS StartEventsDetectionJobResponse
$creadsPrec :: Int -> ReadS StartEventsDetectionJobResponse
Prelude.Read, Int -> StartEventsDetectionJobResponse -> ShowS
[StartEventsDetectionJobResponse] -> ShowS
StartEventsDetectionJobResponse -> String
(Int -> StartEventsDetectionJobResponse -> ShowS)
-> (StartEventsDetectionJobResponse -> String)
-> ([StartEventsDetectionJobResponse] -> ShowS)
-> Show StartEventsDetectionJobResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartEventsDetectionJobResponse] -> ShowS
$cshowList :: [StartEventsDetectionJobResponse] -> ShowS
show :: StartEventsDetectionJobResponse -> String
$cshow :: StartEventsDetectionJobResponse -> String
showsPrec :: Int -> StartEventsDetectionJobResponse -> ShowS
$cshowsPrec :: Int -> StartEventsDetectionJobResponse -> ShowS
Prelude.Show, (forall x.
 StartEventsDetectionJobResponse
 -> Rep StartEventsDetectionJobResponse x)
-> (forall x.
    Rep StartEventsDetectionJobResponse x
    -> StartEventsDetectionJobResponse)
-> Generic StartEventsDetectionJobResponse
forall x.
Rep StartEventsDetectionJobResponse x
-> StartEventsDetectionJobResponse
forall x.
StartEventsDetectionJobResponse
-> Rep StartEventsDetectionJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartEventsDetectionJobResponse x
-> StartEventsDetectionJobResponse
$cfrom :: forall x.
StartEventsDetectionJobResponse
-> Rep StartEventsDetectionJobResponse x
Prelude.Generic)

-- |
-- Create a value of 'StartEventsDetectionJobResponse' 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', 'startEventsDetectionJobResponse_jobId' - An unique identifier for the request. If you don\'t set the client
-- request token, Amazon Comprehend generates one.
--
-- 'jobArn', 'startEventsDetectionJobResponse_jobArn' - The Amazon Resource Name (ARN) of the events detection job. It is a
-- unique, fully qualified identifier for the job. It includes the AWS
-- account, Region, and the job ID. The format of the ARN is as follows:
--
-- @arn:\<partition>:comprehend:\<region>:\<account-id>:events-detection-job\/\<job-id>@
--
-- The following is an example job ARN:
--
-- @arn:aws:comprehend:us-west-2:111122223333:events-detection-job\/1234abcd12ab34cd56ef1234567890ab@
--
-- 'jobStatus', 'startEventsDetectionJobResponse_jobStatus' - The status of the events detection job.
--
-- 'httpStatus', 'startEventsDetectionJobResponse_httpStatus' - The response's http status code.
newStartEventsDetectionJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartEventsDetectionJobResponse
newStartEventsDetectionJobResponse :: Int -> StartEventsDetectionJobResponse
newStartEventsDetectionJobResponse Int
pHttpStatus_ =
  StartEventsDetectionJobResponse' :: Maybe Text
-> Maybe Text
-> Maybe JobStatus
-> Int
-> StartEventsDetectionJobResponse
StartEventsDetectionJobResponse'
    { $sel:jobId:StartEventsDetectionJobResponse' :: Maybe Text
jobId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:jobArn:StartEventsDetectionJobResponse' :: Maybe Text
jobArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:jobStatus:StartEventsDetectionJobResponse' :: Maybe JobStatus
jobStatus = Maybe JobStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartEventsDetectionJobResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An unique identifier for the request. If you don\'t set the client
-- request token, Amazon Comprehend generates one.
startEventsDetectionJobResponse_jobId :: Lens.Lens' StartEventsDetectionJobResponse (Prelude.Maybe Prelude.Text)
startEventsDetectionJobResponse_jobId :: (Maybe Text -> f (Maybe Text))
-> StartEventsDetectionJobResponse
-> f StartEventsDetectionJobResponse
startEventsDetectionJobResponse_jobId = (StartEventsDetectionJobResponse -> Maybe Text)
-> (StartEventsDetectionJobResponse
    -> Maybe Text -> StartEventsDetectionJobResponse)
-> Lens
     StartEventsDetectionJobResponse
     StartEventsDetectionJobResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartEventsDetectionJobResponse' {Maybe Text
jobId :: Maybe Text
$sel:jobId:StartEventsDetectionJobResponse' :: StartEventsDetectionJobResponse -> Maybe Text
jobId} -> Maybe Text
jobId) (\s :: StartEventsDetectionJobResponse
s@StartEventsDetectionJobResponse' {} Maybe Text
a -> StartEventsDetectionJobResponse
s {$sel:jobId:StartEventsDetectionJobResponse' :: Maybe Text
jobId = Maybe Text
a} :: StartEventsDetectionJobResponse)

-- | The Amazon Resource Name (ARN) of the events detection job. It is a
-- unique, fully qualified identifier for the job. It includes the AWS
-- account, Region, and the job ID. The format of the ARN is as follows:
--
-- @arn:\<partition>:comprehend:\<region>:\<account-id>:events-detection-job\/\<job-id>@
--
-- The following is an example job ARN:
--
-- @arn:aws:comprehend:us-west-2:111122223333:events-detection-job\/1234abcd12ab34cd56ef1234567890ab@
startEventsDetectionJobResponse_jobArn :: Lens.Lens' StartEventsDetectionJobResponse (Prelude.Maybe Prelude.Text)
startEventsDetectionJobResponse_jobArn :: (Maybe Text -> f (Maybe Text))
-> StartEventsDetectionJobResponse
-> f StartEventsDetectionJobResponse
startEventsDetectionJobResponse_jobArn = (StartEventsDetectionJobResponse -> Maybe Text)
-> (StartEventsDetectionJobResponse
    -> Maybe Text -> StartEventsDetectionJobResponse)
-> Lens
     StartEventsDetectionJobResponse
     StartEventsDetectionJobResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartEventsDetectionJobResponse' {Maybe Text
jobArn :: Maybe Text
$sel:jobArn:StartEventsDetectionJobResponse' :: StartEventsDetectionJobResponse -> Maybe Text
jobArn} -> Maybe Text
jobArn) (\s :: StartEventsDetectionJobResponse
s@StartEventsDetectionJobResponse' {} Maybe Text
a -> StartEventsDetectionJobResponse
s {$sel:jobArn:StartEventsDetectionJobResponse' :: Maybe Text
jobArn = Maybe Text
a} :: StartEventsDetectionJobResponse)

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

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

instance
  Prelude.NFData
    StartEventsDetectionJobResponse