{-# 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.EMRContainers.DescribeJobRun
-- 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)
--
-- Displays detailed information about a job run. A job run is a unit of
-- work, such as a Spark jar, PySpark script, or SparkSQL query, that you
-- submit to Amazon EMR on EKS.
module Amazonka.EMRContainers.DescribeJobRun
  ( -- * Creating a Request
    DescribeJobRun (..),
    newDescribeJobRun,

    -- * Request Lenses
    describeJobRun_id,
    describeJobRun_virtualClusterId,

    -- * Destructuring the Response
    DescribeJobRunResponse (..),
    newDescribeJobRunResponse,

    -- * Response Lenses
    describeJobRunResponse_jobRun,
    describeJobRunResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.EMRContainers.Types
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:/ 'newDescribeJobRun' smart constructor.
data DescribeJobRun = DescribeJobRun'
  { -- | The ID of the job run request.
    DescribeJobRun -> Text
id :: Prelude.Text,
    -- | The ID of the virtual cluster for which the job run is submitted.
    DescribeJobRun -> Text
virtualClusterId :: Prelude.Text
  }
  deriving (DescribeJobRun -> DescribeJobRun -> Bool
(DescribeJobRun -> DescribeJobRun -> Bool)
-> (DescribeJobRun -> DescribeJobRun -> Bool) -> Eq DescribeJobRun
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeJobRun -> DescribeJobRun -> Bool
$c/= :: DescribeJobRun -> DescribeJobRun -> Bool
== :: DescribeJobRun -> DescribeJobRun -> Bool
$c== :: DescribeJobRun -> DescribeJobRun -> Bool
Prelude.Eq, ReadPrec [DescribeJobRun]
ReadPrec DescribeJobRun
Int -> ReadS DescribeJobRun
ReadS [DescribeJobRun]
(Int -> ReadS DescribeJobRun)
-> ReadS [DescribeJobRun]
-> ReadPrec DescribeJobRun
-> ReadPrec [DescribeJobRun]
-> Read DescribeJobRun
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeJobRun]
$creadListPrec :: ReadPrec [DescribeJobRun]
readPrec :: ReadPrec DescribeJobRun
$creadPrec :: ReadPrec DescribeJobRun
readList :: ReadS [DescribeJobRun]
$creadList :: ReadS [DescribeJobRun]
readsPrec :: Int -> ReadS DescribeJobRun
$creadsPrec :: Int -> ReadS DescribeJobRun
Prelude.Read, Int -> DescribeJobRun -> ShowS
[DescribeJobRun] -> ShowS
DescribeJobRun -> String
(Int -> DescribeJobRun -> ShowS)
-> (DescribeJobRun -> String)
-> ([DescribeJobRun] -> ShowS)
-> Show DescribeJobRun
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeJobRun] -> ShowS
$cshowList :: [DescribeJobRun] -> ShowS
show :: DescribeJobRun -> String
$cshow :: DescribeJobRun -> String
showsPrec :: Int -> DescribeJobRun -> ShowS
$cshowsPrec :: Int -> DescribeJobRun -> ShowS
Prelude.Show, (forall x. DescribeJobRun -> Rep DescribeJobRun x)
-> (forall x. Rep DescribeJobRun x -> DescribeJobRun)
-> Generic DescribeJobRun
forall x. Rep DescribeJobRun x -> DescribeJobRun
forall x. DescribeJobRun -> Rep DescribeJobRun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeJobRun x -> DescribeJobRun
$cfrom :: forall x. DescribeJobRun -> Rep DescribeJobRun x
Prelude.Generic)

-- |
-- Create a value of 'DescribeJobRun' 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:
--
-- 'id', 'describeJobRun_id' - The ID of the job run request.
--
-- 'virtualClusterId', 'describeJobRun_virtualClusterId' - The ID of the virtual cluster for which the job run is submitted.
newDescribeJobRun ::
  -- | 'id'
  Prelude.Text ->
  -- | 'virtualClusterId'
  Prelude.Text ->
  DescribeJobRun
newDescribeJobRun :: Text -> Text -> DescribeJobRun
newDescribeJobRun Text
pId_ Text
pVirtualClusterId_ =
  DescribeJobRun' :: Text -> Text -> DescribeJobRun
DescribeJobRun'
    { $sel:id:DescribeJobRun' :: Text
id = Text
pId_,
      $sel:virtualClusterId:DescribeJobRun' :: Text
virtualClusterId = Text
pVirtualClusterId_
    }

-- | The ID of the job run request.
describeJobRun_id :: Lens.Lens' DescribeJobRun Prelude.Text
describeJobRun_id :: (Text -> f Text) -> DescribeJobRun -> f DescribeJobRun
describeJobRun_id = (DescribeJobRun -> Text)
-> (DescribeJobRun -> Text -> DescribeJobRun)
-> Lens DescribeJobRun DescribeJobRun Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeJobRun' {Text
id :: Text
$sel:id:DescribeJobRun' :: DescribeJobRun -> Text
id} -> Text
id) (\s :: DescribeJobRun
s@DescribeJobRun' {} Text
a -> DescribeJobRun
s {$sel:id:DescribeJobRun' :: Text
id = Text
a} :: DescribeJobRun)

-- | The ID of the virtual cluster for which the job run is submitted.
describeJobRun_virtualClusterId :: Lens.Lens' DescribeJobRun Prelude.Text
describeJobRun_virtualClusterId :: (Text -> f Text) -> DescribeJobRun -> f DescribeJobRun
describeJobRun_virtualClusterId = (DescribeJobRun -> Text)
-> (DescribeJobRun -> Text -> DescribeJobRun)
-> Lens DescribeJobRun DescribeJobRun Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeJobRun' {Text
virtualClusterId :: Text
$sel:virtualClusterId:DescribeJobRun' :: DescribeJobRun -> Text
virtualClusterId} -> Text
virtualClusterId) (\s :: DescribeJobRun
s@DescribeJobRun' {} Text
a -> DescribeJobRun
s {$sel:virtualClusterId:DescribeJobRun' :: Text
virtualClusterId = Text
a} :: DescribeJobRun)

instance Core.AWSRequest DescribeJobRun where
  type
    AWSResponse DescribeJobRun =
      DescribeJobRunResponse
  request :: DescribeJobRun -> Request DescribeJobRun
request = Service -> DescribeJobRun -> Request DescribeJobRun
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeJobRun
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeJobRun)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeJobRun))
-> Logger
-> Service
-> Proxy DescribeJobRun
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeJobRun)))
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 JobRun -> Int -> DescribeJobRunResponse
DescribeJobRunResponse'
            (Maybe JobRun -> Int -> DescribeJobRunResponse)
-> Either String (Maybe JobRun)
-> Either String (Int -> DescribeJobRunResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe JobRun)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"jobRun")
            Either String (Int -> DescribeJobRunResponse)
-> Either String Int -> Either String DescribeJobRunResponse
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 DescribeJobRun

instance Prelude.NFData DescribeJobRun

instance Core.ToHeaders DescribeJobRun where
  toHeaders :: DescribeJobRun -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeJobRun -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath DescribeJobRun where
  toPath :: DescribeJobRun -> ByteString
toPath DescribeJobRun' {Text
virtualClusterId :: Text
id :: Text
$sel:virtualClusterId:DescribeJobRun' :: DescribeJobRun -> Text
$sel:id:DescribeJobRun' :: DescribeJobRun -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/virtualclusters/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
virtualClusterId,
        ByteString
"/jobruns/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
id
      ]

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

-- | /See:/ 'newDescribeJobRunResponse' smart constructor.
data DescribeJobRunResponse = DescribeJobRunResponse'
  { -- | The output displays information about a job run.
    DescribeJobRunResponse -> Maybe JobRun
jobRun :: Prelude.Maybe JobRun,
    -- | The response's http status code.
    DescribeJobRunResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeJobRunResponse -> DescribeJobRunResponse -> Bool
(DescribeJobRunResponse -> DescribeJobRunResponse -> Bool)
-> (DescribeJobRunResponse -> DescribeJobRunResponse -> Bool)
-> Eq DescribeJobRunResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeJobRunResponse -> DescribeJobRunResponse -> Bool
$c/= :: DescribeJobRunResponse -> DescribeJobRunResponse -> Bool
== :: DescribeJobRunResponse -> DescribeJobRunResponse -> Bool
$c== :: DescribeJobRunResponse -> DescribeJobRunResponse -> Bool
Prelude.Eq, Int -> DescribeJobRunResponse -> ShowS
[DescribeJobRunResponse] -> ShowS
DescribeJobRunResponse -> String
(Int -> DescribeJobRunResponse -> ShowS)
-> (DescribeJobRunResponse -> String)
-> ([DescribeJobRunResponse] -> ShowS)
-> Show DescribeJobRunResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeJobRunResponse] -> ShowS
$cshowList :: [DescribeJobRunResponse] -> ShowS
show :: DescribeJobRunResponse -> String
$cshow :: DescribeJobRunResponse -> String
showsPrec :: Int -> DescribeJobRunResponse -> ShowS
$cshowsPrec :: Int -> DescribeJobRunResponse -> ShowS
Prelude.Show, (forall x. DescribeJobRunResponse -> Rep DescribeJobRunResponse x)
-> (forall x.
    Rep DescribeJobRunResponse x -> DescribeJobRunResponse)
-> Generic DescribeJobRunResponse
forall x. Rep DescribeJobRunResponse x -> DescribeJobRunResponse
forall x. DescribeJobRunResponse -> Rep DescribeJobRunResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeJobRunResponse x -> DescribeJobRunResponse
$cfrom :: forall x. DescribeJobRunResponse -> Rep DescribeJobRunResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeJobRunResponse' 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:
--
-- 'jobRun', 'describeJobRunResponse_jobRun' - The output displays information about a job run.
--
-- 'httpStatus', 'describeJobRunResponse_httpStatus' - The response's http status code.
newDescribeJobRunResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeJobRunResponse
newDescribeJobRunResponse :: Int -> DescribeJobRunResponse
newDescribeJobRunResponse Int
pHttpStatus_ =
  DescribeJobRunResponse' :: Maybe JobRun -> Int -> DescribeJobRunResponse
DescribeJobRunResponse'
    { $sel:jobRun:DescribeJobRunResponse' :: Maybe JobRun
jobRun = Maybe JobRun
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeJobRunResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The output displays information about a job run.
describeJobRunResponse_jobRun :: Lens.Lens' DescribeJobRunResponse (Prelude.Maybe JobRun)
describeJobRunResponse_jobRun :: (Maybe JobRun -> f (Maybe JobRun))
-> DescribeJobRunResponse -> f DescribeJobRunResponse
describeJobRunResponse_jobRun = (DescribeJobRunResponse -> Maybe JobRun)
-> (DescribeJobRunResponse
    -> Maybe JobRun -> DescribeJobRunResponse)
-> Lens
     DescribeJobRunResponse
     DescribeJobRunResponse
     (Maybe JobRun)
     (Maybe JobRun)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeJobRunResponse' {Maybe JobRun
jobRun :: Maybe JobRun
$sel:jobRun:DescribeJobRunResponse' :: DescribeJobRunResponse -> Maybe JobRun
jobRun} -> Maybe JobRun
jobRun) (\s :: DescribeJobRunResponse
s@DescribeJobRunResponse' {} Maybe JobRun
a -> DescribeJobRunResponse
s {$sel:jobRun:DescribeJobRunResponse' :: Maybe JobRun
jobRun = Maybe JobRun
a} :: DescribeJobRunResponse)

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

instance Prelude.NFData DescribeJobRunResponse