{-# 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.DescribeSentimentDetectionJob
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets the properties associated with a sentiment detection job. Use this
-- operation to get the status of a detection job.
module Amazonka.Comprehend.DescribeSentimentDetectionJob
  ( -- * Creating a Request
    DescribeSentimentDetectionJob (..),
    newDescribeSentimentDetectionJob,

    -- * Request Lenses
    describeSentimentDetectionJob_jobId,

    -- * Destructuring the Response
    DescribeSentimentDetectionJobResponse (..),
    newDescribeSentimentDetectionJobResponse,

    -- * Response Lenses
    describeSentimentDetectionJobResponse_sentimentDetectionJobProperties,
    describeSentimentDetectionJobResponse_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:/ 'newDescribeSentimentDetectionJob' smart constructor.
data DescribeSentimentDetectionJob = DescribeSentimentDetectionJob'
  { -- | The identifier that Amazon Comprehend generated for the job. The
    -- operation returns this identifier in its response.
    DescribeSentimentDetectionJob -> Text
jobId :: Prelude.Text
  }
  deriving (DescribeSentimentDetectionJob
-> DescribeSentimentDetectionJob -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeSentimentDetectionJob
-> DescribeSentimentDetectionJob -> Bool
$c/= :: DescribeSentimentDetectionJob
-> DescribeSentimentDetectionJob -> Bool
== :: DescribeSentimentDetectionJob
-> DescribeSentimentDetectionJob -> Bool
$c== :: DescribeSentimentDetectionJob
-> DescribeSentimentDetectionJob -> Bool
Prelude.Eq, ReadPrec [DescribeSentimentDetectionJob]
ReadPrec DescribeSentimentDetectionJob
Int -> ReadS DescribeSentimentDetectionJob
ReadS [DescribeSentimentDetectionJob]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeSentimentDetectionJob]
$creadListPrec :: ReadPrec [DescribeSentimentDetectionJob]
readPrec :: ReadPrec DescribeSentimentDetectionJob
$creadPrec :: ReadPrec DescribeSentimentDetectionJob
readList :: ReadS [DescribeSentimentDetectionJob]
$creadList :: ReadS [DescribeSentimentDetectionJob]
readsPrec :: Int -> ReadS DescribeSentimentDetectionJob
$creadsPrec :: Int -> ReadS DescribeSentimentDetectionJob
Prelude.Read, Int -> DescribeSentimentDetectionJob -> ShowS
[DescribeSentimentDetectionJob] -> ShowS
DescribeSentimentDetectionJob -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeSentimentDetectionJob] -> ShowS
$cshowList :: [DescribeSentimentDetectionJob] -> ShowS
show :: DescribeSentimentDetectionJob -> String
$cshow :: DescribeSentimentDetectionJob -> String
showsPrec :: Int -> DescribeSentimentDetectionJob -> ShowS
$cshowsPrec :: Int -> DescribeSentimentDetectionJob -> ShowS
Prelude.Show, forall x.
Rep DescribeSentimentDetectionJob x
-> DescribeSentimentDetectionJob
forall x.
DescribeSentimentDetectionJob
-> Rep DescribeSentimentDetectionJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeSentimentDetectionJob x
-> DescribeSentimentDetectionJob
$cfrom :: forall x.
DescribeSentimentDetectionJob
-> Rep DescribeSentimentDetectionJob x
Prelude.Generic)

-- |
-- Create a value of 'DescribeSentimentDetectionJob' 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', 'describeSentimentDetectionJob_jobId' - The identifier that Amazon Comprehend generated for the job. The
-- operation returns this identifier in its response.
newDescribeSentimentDetectionJob ::
  -- | 'jobId'
  Prelude.Text ->
  DescribeSentimentDetectionJob
newDescribeSentimentDetectionJob :: Text -> DescribeSentimentDetectionJob
newDescribeSentimentDetectionJob Text
pJobId_ =
  DescribeSentimentDetectionJob' {$sel:jobId:DescribeSentimentDetectionJob' :: Text
jobId = Text
pJobId_}

-- | The identifier that Amazon Comprehend generated for the job. The
-- operation returns this identifier in its response.
describeSentimentDetectionJob_jobId :: Lens.Lens' DescribeSentimentDetectionJob Prelude.Text
describeSentimentDetectionJob_jobId :: Lens' DescribeSentimentDetectionJob Text
describeSentimentDetectionJob_jobId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSentimentDetectionJob' {Text
jobId :: Text
$sel:jobId:DescribeSentimentDetectionJob' :: DescribeSentimentDetectionJob -> Text
jobId} -> Text
jobId) (\s :: DescribeSentimentDetectionJob
s@DescribeSentimentDetectionJob' {} Text
a -> DescribeSentimentDetectionJob
s {$sel:jobId:DescribeSentimentDetectionJob' :: Text
jobId = Text
a} :: DescribeSentimentDetectionJob)

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

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

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

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

-- | /See:/ 'newDescribeSentimentDetectionJobResponse' smart constructor.
data DescribeSentimentDetectionJobResponse = DescribeSentimentDetectionJobResponse'
  { -- | An object that contains the properties associated with a sentiment
    -- detection job.
    DescribeSentimentDetectionJobResponse
-> Maybe SentimentDetectionJobProperties
sentimentDetectionJobProperties :: Prelude.Maybe SentimentDetectionJobProperties,
    -- | The response's http status code.
    DescribeSentimentDetectionJobResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeSentimentDetectionJobResponse
-> DescribeSentimentDetectionJobResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeSentimentDetectionJobResponse
-> DescribeSentimentDetectionJobResponse -> Bool
$c/= :: DescribeSentimentDetectionJobResponse
-> DescribeSentimentDetectionJobResponse -> Bool
== :: DescribeSentimentDetectionJobResponse
-> DescribeSentimentDetectionJobResponse -> Bool
$c== :: DescribeSentimentDetectionJobResponse
-> DescribeSentimentDetectionJobResponse -> Bool
Prelude.Eq, ReadPrec [DescribeSentimentDetectionJobResponse]
ReadPrec DescribeSentimentDetectionJobResponse
Int -> ReadS DescribeSentimentDetectionJobResponse
ReadS [DescribeSentimentDetectionJobResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeSentimentDetectionJobResponse]
$creadListPrec :: ReadPrec [DescribeSentimentDetectionJobResponse]
readPrec :: ReadPrec DescribeSentimentDetectionJobResponse
$creadPrec :: ReadPrec DescribeSentimentDetectionJobResponse
readList :: ReadS [DescribeSentimentDetectionJobResponse]
$creadList :: ReadS [DescribeSentimentDetectionJobResponse]
readsPrec :: Int -> ReadS DescribeSentimentDetectionJobResponse
$creadsPrec :: Int -> ReadS DescribeSentimentDetectionJobResponse
Prelude.Read, Int -> DescribeSentimentDetectionJobResponse -> ShowS
[DescribeSentimentDetectionJobResponse] -> ShowS
DescribeSentimentDetectionJobResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeSentimentDetectionJobResponse] -> ShowS
$cshowList :: [DescribeSentimentDetectionJobResponse] -> ShowS
show :: DescribeSentimentDetectionJobResponse -> String
$cshow :: DescribeSentimentDetectionJobResponse -> String
showsPrec :: Int -> DescribeSentimentDetectionJobResponse -> ShowS
$cshowsPrec :: Int -> DescribeSentimentDetectionJobResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeSentimentDetectionJobResponse x
-> DescribeSentimentDetectionJobResponse
forall x.
DescribeSentimentDetectionJobResponse
-> Rep DescribeSentimentDetectionJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeSentimentDetectionJobResponse x
-> DescribeSentimentDetectionJobResponse
$cfrom :: forall x.
DescribeSentimentDetectionJobResponse
-> Rep DescribeSentimentDetectionJobResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeSentimentDetectionJobResponse' 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:
--
-- 'sentimentDetectionJobProperties', 'describeSentimentDetectionJobResponse_sentimentDetectionJobProperties' - An object that contains the properties associated with a sentiment
-- detection job.
--
-- 'httpStatus', 'describeSentimentDetectionJobResponse_httpStatus' - The response's http status code.
newDescribeSentimentDetectionJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeSentimentDetectionJobResponse
newDescribeSentimentDetectionJobResponse :: Int -> DescribeSentimentDetectionJobResponse
newDescribeSentimentDetectionJobResponse Int
pHttpStatus_ =
  DescribeSentimentDetectionJobResponse'
    { $sel:sentimentDetectionJobProperties:DescribeSentimentDetectionJobResponse' :: Maybe SentimentDetectionJobProperties
sentimentDetectionJobProperties =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeSentimentDetectionJobResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object that contains the properties associated with a sentiment
-- detection job.
describeSentimentDetectionJobResponse_sentimentDetectionJobProperties :: Lens.Lens' DescribeSentimentDetectionJobResponse (Prelude.Maybe SentimentDetectionJobProperties)
describeSentimentDetectionJobResponse_sentimentDetectionJobProperties :: Lens'
  DescribeSentimentDetectionJobResponse
  (Maybe SentimentDetectionJobProperties)
describeSentimentDetectionJobResponse_sentimentDetectionJobProperties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSentimentDetectionJobResponse' {Maybe SentimentDetectionJobProperties
sentimentDetectionJobProperties :: Maybe SentimentDetectionJobProperties
$sel:sentimentDetectionJobProperties:DescribeSentimentDetectionJobResponse' :: DescribeSentimentDetectionJobResponse
-> Maybe SentimentDetectionJobProperties
sentimentDetectionJobProperties} -> Maybe SentimentDetectionJobProperties
sentimentDetectionJobProperties) (\s :: DescribeSentimentDetectionJobResponse
s@DescribeSentimentDetectionJobResponse' {} Maybe SentimentDetectionJobProperties
a -> DescribeSentimentDetectionJobResponse
s {$sel:sentimentDetectionJobProperties:DescribeSentimentDetectionJobResponse' :: Maybe SentimentDetectionJobProperties
sentimentDetectionJobProperties = Maybe SentimentDetectionJobProperties
a} :: DescribeSentimentDetectionJobResponse)

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

instance
  Prelude.NFData
    DescribeSentimentDetectionJobResponse
  where
  rnf :: DescribeSentimentDetectionJobResponse -> ()
rnf DescribeSentimentDetectionJobResponse' {Int
Maybe SentimentDetectionJobProperties
httpStatus :: Int
sentimentDetectionJobProperties :: Maybe SentimentDetectionJobProperties
$sel:httpStatus:DescribeSentimentDetectionJobResponse' :: DescribeSentimentDetectionJobResponse -> Int
$sel:sentimentDetectionJobProperties:DescribeSentimentDetectionJobResponse' :: DescribeSentimentDetectionJobResponse
-> Maybe SentimentDetectionJobProperties
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SentimentDetectionJobProperties
sentimentDetectionJobProperties
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus