{-# 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.EMRServerless.GetDashboardForJobRun
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns a URL to access the job run dashboard.
module Amazonka.EMRServerless.GetDashboardForJobRun
  ( -- * Creating a Request
    GetDashboardForJobRun (..),
    newGetDashboardForJobRun,

    -- * Request Lenses
    getDashboardForJobRun_applicationId,
    getDashboardForJobRun_jobRunId,

    -- * Destructuring the Response
    GetDashboardForJobRunResponse (..),
    newGetDashboardForJobRunResponse,

    -- * Response Lenses
    getDashboardForJobRunResponse_url,
    getDashboardForJobRunResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EMRServerless.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetDashboardForJobRun' smart constructor.
data GetDashboardForJobRun = GetDashboardForJobRun'
  { -- | The ID of the application.
    GetDashboardForJobRun -> Text
applicationId :: Prelude.Text,
    -- | The ID of the job run.
    GetDashboardForJobRun -> Text
jobRunId :: Prelude.Text
  }
  deriving (GetDashboardForJobRun -> GetDashboardForJobRun -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDashboardForJobRun -> GetDashboardForJobRun -> Bool
$c/= :: GetDashboardForJobRun -> GetDashboardForJobRun -> Bool
== :: GetDashboardForJobRun -> GetDashboardForJobRun -> Bool
$c== :: GetDashboardForJobRun -> GetDashboardForJobRun -> Bool
Prelude.Eq, ReadPrec [GetDashboardForJobRun]
ReadPrec GetDashboardForJobRun
Int -> ReadS GetDashboardForJobRun
ReadS [GetDashboardForJobRun]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDashboardForJobRun]
$creadListPrec :: ReadPrec [GetDashboardForJobRun]
readPrec :: ReadPrec GetDashboardForJobRun
$creadPrec :: ReadPrec GetDashboardForJobRun
readList :: ReadS [GetDashboardForJobRun]
$creadList :: ReadS [GetDashboardForJobRun]
readsPrec :: Int -> ReadS GetDashboardForJobRun
$creadsPrec :: Int -> ReadS GetDashboardForJobRun
Prelude.Read, Int -> GetDashboardForJobRun -> ShowS
[GetDashboardForJobRun] -> ShowS
GetDashboardForJobRun -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDashboardForJobRun] -> ShowS
$cshowList :: [GetDashboardForJobRun] -> ShowS
show :: GetDashboardForJobRun -> String
$cshow :: GetDashboardForJobRun -> String
showsPrec :: Int -> GetDashboardForJobRun -> ShowS
$cshowsPrec :: Int -> GetDashboardForJobRun -> ShowS
Prelude.Show, forall x. Rep GetDashboardForJobRun x -> GetDashboardForJobRun
forall x. GetDashboardForJobRun -> Rep GetDashboardForJobRun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDashboardForJobRun x -> GetDashboardForJobRun
$cfrom :: forall x. GetDashboardForJobRun -> Rep GetDashboardForJobRun x
Prelude.Generic)

-- |
-- Create a value of 'GetDashboardForJobRun' 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:
--
-- 'applicationId', 'getDashboardForJobRun_applicationId' - The ID of the application.
--
-- 'jobRunId', 'getDashboardForJobRun_jobRunId' - The ID of the job run.
newGetDashboardForJobRun ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'jobRunId'
  Prelude.Text ->
  GetDashboardForJobRun
newGetDashboardForJobRun :: Text -> Text -> GetDashboardForJobRun
newGetDashboardForJobRun Text
pApplicationId_ Text
pJobRunId_ =
  GetDashboardForJobRun'
    { $sel:applicationId:GetDashboardForJobRun' :: Text
applicationId =
        Text
pApplicationId_,
      $sel:jobRunId:GetDashboardForJobRun' :: Text
jobRunId = Text
pJobRunId_
    }

-- | The ID of the application.
getDashboardForJobRun_applicationId :: Lens.Lens' GetDashboardForJobRun Prelude.Text
getDashboardForJobRun_applicationId :: Lens' GetDashboardForJobRun Text
getDashboardForJobRun_applicationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDashboardForJobRun' {Text
applicationId :: Text
$sel:applicationId:GetDashboardForJobRun' :: GetDashboardForJobRun -> Text
applicationId} -> Text
applicationId) (\s :: GetDashboardForJobRun
s@GetDashboardForJobRun' {} Text
a -> GetDashboardForJobRun
s {$sel:applicationId:GetDashboardForJobRun' :: Text
applicationId = Text
a} :: GetDashboardForJobRun)

-- | The ID of the job run.
getDashboardForJobRun_jobRunId :: Lens.Lens' GetDashboardForJobRun Prelude.Text
getDashboardForJobRun_jobRunId :: Lens' GetDashboardForJobRun Text
getDashboardForJobRun_jobRunId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDashboardForJobRun' {Text
jobRunId :: Text
$sel:jobRunId:GetDashboardForJobRun' :: GetDashboardForJobRun -> Text
jobRunId} -> Text
jobRunId) (\s :: GetDashboardForJobRun
s@GetDashboardForJobRun' {} Text
a -> GetDashboardForJobRun
s {$sel:jobRunId:GetDashboardForJobRun' :: Text
jobRunId = Text
a} :: GetDashboardForJobRun)

instance Core.AWSRequest GetDashboardForJobRun where
  type
    AWSResponse GetDashboardForJobRun =
      GetDashboardForJobRunResponse
  request :: (Service -> Service)
-> GetDashboardForJobRun -> Request GetDashboardForJobRun
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetDashboardForJobRun
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDashboardForJobRun)))
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 -> Int -> GetDashboardForJobRunResponse
GetDashboardForJobRunResponse'
            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
"url")
            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 GetDashboardForJobRun where
  hashWithSalt :: Int -> GetDashboardForJobRun -> Int
hashWithSalt Int
_salt GetDashboardForJobRun' {Text
jobRunId :: Text
applicationId :: Text
$sel:jobRunId:GetDashboardForJobRun' :: GetDashboardForJobRun -> Text
$sel:applicationId:GetDashboardForJobRun' :: GetDashboardForJobRun -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
applicationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
jobRunId

instance Prelude.NFData GetDashboardForJobRun where
  rnf :: GetDashboardForJobRun -> ()
rnf GetDashboardForJobRun' {Text
jobRunId :: Text
applicationId :: Text
$sel:jobRunId:GetDashboardForJobRun' :: GetDashboardForJobRun -> Text
$sel:applicationId:GetDashboardForJobRun' :: GetDashboardForJobRun -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
applicationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
jobRunId

instance Data.ToHeaders GetDashboardForJobRun where
  toHeaders :: GetDashboardForJobRun -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath GetDashboardForJobRun where
  toPath :: GetDashboardForJobRun -> ByteString
toPath GetDashboardForJobRun' {Text
jobRunId :: Text
applicationId :: Text
$sel:jobRunId:GetDashboardForJobRun' :: GetDashboardForJobRun -> Text
$sel:applicationId:GetDashboardForJobRun' :: GetDashboardForJobRun -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/applications/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
applicationId,
        ByteString
"/jobruns/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
jobRunId,
        ByteString
"/dashboard"
      ]

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

-- | /See:/ 'newGetDashboardForJobRunResponse' smart constructor.
data GetDashboardForJobRunResponse = GetDashboardForJobRunResponse'
  { -- | The URL to view job run\'s dashboard.
    GetDashboardForJobRunResponse -> Maybe Text
url :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetDashboardForJobRunResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDashboardForJobRunResponse
-> GetDashboardForJobRunResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDashboardForJobRunResponse
-> GetDashboardForJobRunResponse -> Bool
$c/= :: GetDashboardForJobRunResponse
-> GetDashboardForJobRunResponse -> Bool
== :: GetDashboardForJobRunResponse
-> GetDashboardForJobRunResponse -> Bool
$c== :: GetDashboardForJobRunResponse
-> GetDashboardForJobRunResponse -> Bool
Prelude.Eq, ReadPrec [GetDashboardForJobRunResponse]
ReadPrec GetDashboardForJobRunResponse
Int -> ReadS GetDashboardForJobRunResponse
ReadS [GetDashboardForJobRunResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDashboardForJobRunResponse]
$creadListPrec :: ReadPrec [GetDashboardForJobRunResponse]
readPrec :: ReadPrec GetDashboardForJobRunResponse
$creadPrec :: ReadPrec GetDashboardForJobRunResponse
readList :: ReadS [GetDashboardForJobRunResponse]
$creadList :: ReadS [GetDashboardForJobRunResponse]
readsPrec :: Int -> ReadS GetDashboardForJobRunResponse
$creadsPrec :: Int -> ReadS GetDashboardForJobRunResponse
Prelude.Read, Int -> GetDashboardForJobRunResponse -> ShowS
[GetDashboardForJobRunResponse] -> ShowS
GetDashboardForJobRunResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDashboardForJobRunResponse] -> ShowS
$cshowList :: [GetDashboardForJobRunResponse] -> ShowS
show :: GetDashboardForJobRunResponse -> String
$cshow :: GetDashboardForJobRunResponse -> String
showsPrec :: Int -> GetDashboardForJobRunResponse -> ShowS
$cshowsPrec :: Int -> GetDashboardForJobRunResponse -> ShowS
Prelude.Show, forall x.
Rep GetDashboardForJobRunResponse x
-> GetDashboardForJobRunResponse
forall x.
GetDashboardForJobRunResponse
-> Rep GetDashboardForJobRunResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetDashboardForJobRunResponse x
-> GetDashboardForJobRunResponse
$cfrom :: forall x.
GetDashboardForJobRunResponse
-> Rep GetDashboardForJobRunResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDashboardForJobRunResponse' 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:
--
-- 'url', 'getDashboardForJobRunResponse_url' - The URL to view job run\'s dashboard.
--
-- 'httpStatus', 'getDashboardForJobRunResponse_httpStatus' - The response's http status code.
newGetDashboardForJobRunResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDashboardForJobRunResponse
newGetDashboardForJobRunResponse :: Int -> GetDashboardForJobRunResponse
newGetDashboardForJobRunResponse Int
pHttpStatus_ =
  GetDashboardForJobRunResponse'
    { $sel:url:GetDashboardForJobRunResponse' :: Maybe Text
url =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDashboardForJobRunResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The URL to view job run\'s dashboard.
getDashboardForJobRunResponse_url :: Lens.Lens' GetDashboardForJobRunResponse (Prelude.Maybe Prelude.Text)
getDashboardForJobRunResponse_url :: Lens' GetDashboardForJobRunResponse (Maybe Text)
getDashboardForJobRunResponse_url = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDashboardForJobRunResponse' {Maybe Text
url :: Maybe Text
$sel:url:GetDashboardForJobRunResponse' :: GetDashboardForJobRunResponse -> Maybe Text
url} -> Maybe Text
url) (\s :: GetDashboardForJobRunResponse
s@GetDashboardForJobRunResponse' {} Maybe Text
a -> GetDashboardForJobRunResponse
s {$sel:url:GetDashboardForJobRunResponse' :: Maybe Text
url = Maybe Text
a} :: GetDashboardForJobRunResponse)

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

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