{-# 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.DescribeKeyPhrasesDetectionJob
-- 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 key phrases detection job. Use
-- this operation to get the status of a detection job.
module Amazonka.Comprehend.DescribeKeyPhrasesDetectionJob
  ( -- * Creating a Request
    DescribeKeyPhrasesDetectionJob (..),
    newDescribeKeyPhrasesDetectionJob,

    -- * Request Lenses
    describeKeyPhrasesDetectionJob_jobId,

    -- * Destructuring the Response
    DescribeKeyPhrasesDetectionJobResponse (..),
    newDescribeKeyPhrasesDetectionJobResponse,

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

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

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

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

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

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

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

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

-- |
-- Create a value of 'DescribeKeyPhrasesDetectionJobResponse' 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:
--
-- 'keyPhrasesDetectionJobProperties', 'describeKeyPhrasesDetectionJobResponse_keyPhrasesDetectionJobProperties' - An object that contains the properties associated with a key phrases
-- detection job.
--
-- 'httpStatus', 'describeKeyPhrasesDetectionJobResponse_httpStatus' - The response's http status code.
newDescribeKeyPhrasesDetectionJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeKeyPhrasesDetectionJobResponse
newDescribeKeyPhrasesDetectionJobResponse :: Int -> DescribeKeyPhrasesDetectionJobResponse
newDescribeKeyPhrasesDetectionJobResponse
  Int
pHttpStatus_ =
    DescribeKeyPhrasesDetectionJobResponse'
      { $sel:keyPhrasesDetectionJobProperties:DescribeKeyPhrasesDetectionJobResponse' :: Maybe KeyPhrasesDetectionJobProperties
keyPhrasesDetectionJobProperties =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DescribeKeyPhrasesDetectionJobResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | An object that contains the properties associated with a key phrases
-- detection job.
describeKeyPhrasesDetectionJobResponse_keyPhrasesDetectionJobProperties :: Lens.Lens' DescribeKeyPhrasesDetectionJobResponse (Prelude.Maybe KeyPhrasesDetectionJobProperties)
describeKeyPhrasesDetectionJobResponse_keyPhrasesDetectionJobProperties :: Lens'
  DescribeKeyPhrasesDetectionJobResponse
  (Maybe KeyPhrasesDetectionJobProperties)
describeKeyPhrasesDetectionJobResponse_keyPhrasesDetectionJobProperties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeKeyPhrasesDetectionJobResponse' {Maybe KeyPhrasesDetectionJobProperties
keyPhrasesDetectionJobProperties :: Maybe KeyPhrasesDetectionJobProperties
$sel:keyPhrasesDetectionJobProperties:DescribeKeyPhrasesDetectionJobResponse' :: DescribeKeyPhrasesDetectionJobResponse
-> Maybe KeyPhrasesDetectionJobProperties
keyPhrasesDetectionJobProperties} -> Maybe KeyPhrasesDetectionJobProperties
keyPhrasesDetectionJobProperties) (\s :: DescribeKeyPhrasesDetectionJobResponse
s@DescribeKeyPhrasesDetectionJobResponse' {} Maybe KeyPhrasesDetectionJobProperties
a -> DescribeKeyPhrasesDetectionJobResponse
s {$sel:keyPhrasesDetectionJobProperties:DescribeKeyPhrasesDetectionJobResponse' :: Maybe KeyPhrasesDetectionJobProperties
keyPhrasesDetectionJobProperties = Maybe KeyPhrasesDetectionJobProperties
a} :: DescribeKeyPhrasesDetectionJobResponse)

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

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