{-# 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.Glue.GetWorkflowRun
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the metadata for a given workflow run.
module Amazonka.Glue.GetWorkflowRun
  ( -- * Creating a Request
    GetWorkflowRun (..),
    newGetWorkflowRun,

    -- * Request Lenses
    getWorkflowRun_includeGraph,
    getWorkflowRun_name,
    getWorkflowRun_runId,

    -- * Destructuring the Response
    GetWorkflowRunResponse (..),
    newGetWorkflowRunResponse,

    -- * Response Lenses
    getWorkflowRunResponse_run,
    getWorkflowRunResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetWorkflowRun' smart constructor.
data GetWorkflowRun = GetWorkflowRun'
  { -- | Specifies whether to include the workflow graph in response or not.
    GetWorkflowRun -> Maybe Bool
includeGraph :: Prelude.Maybe Prelude.Bool,
    -- | Name of the workflow being run.
    GetWorkflowRun -> Text
name :: Prelude.Text,
    -- | The ID of the workflow run.
    GetWorkflowRun -> Text
runId :: Prelude.Text
  }
  deriving (GetWorkflowRun -> GetWorkflowRun -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetWorkflowRun -> GetWorkflowRun -> Bool
$c/= :: GetWorkflowRun -> GetWorkflowRun -> Bool
== :: GetWorkflowRun -> GetWorkflowRun -> Bool
$c== :: GetWorkflowRun -> GetWorkflowRun -> Bool
Prelude.Eq, ReadPrec [GetWorkflowRun]
ReadPrec GetWorkflowRun
Int -> ReadS GetWorkflowRun
ReadS [GetWorkflowRun]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetWorkflowRun]
$creadListPrec :: ReadPrec [GetWorkflowRun]
readPrec :: ReadPrec GetWorkflowRun
$creadPrec :: ReadPrec GetWorkflowRun
readList :: ReadS [GetWorkflowRun]
$creadList :: ReadS [GetWorkflowRun]
readsPrec :: Int -> ReadS GetWorkflowRun
$creadsPrec :: Int -> ReadS GetWorkflowRun
Prelude.Read, Int -> GetWorkflowRun -> ShowS
[GetWorkflowRun] -> ShowS
GetWorkflowRun -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetWorkflowRun] -> ShowS
$cshowList :: [GetWorkflowRun] -> ShowS
show :: GetWorkflowRun -> String
$cshow :: GetWorkflowRun -> String
showsPrec :: Int -> GetWorkflowRun -> ShowS
$cshowsPrec :: Int -> GetWorkflowRun -> ShowS
Prelude.Show, forall x. Rep GetWorkflowRun x -> GetWorkflowRun
forall x. GetWorkflowRun -> Rep GetWorkflowRun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetWorkflowRun x -> GetWorkflowRun
$cfrom :: forall x. GetWorkflowRun -> Rep GetWorkflowRun x
Prelude.Generic)

-- |
-- Create a value of 'GetWorkflowRun' 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:
--
-- 'includeGraph', 'getWorkflowRun_includeGraph' - Specifies whether to include the workflow graph in response or not.
--
-- 'name', 'getWorkflowRun_name' - Name of the workflow being run.
--
-- 'runId', 'getWorkflowRun_runId' - The ID of the workflow run.
newGetWorkflowRun ::
  -- | 'name'
  Prelude.Text ->
  -- | 'runId'
  Prelude.Text ->
  GetWorkflowRun
newGetWorkflowRun :: Text -> Text -> GetWorkflowRun
newGetWorkflowRun Text
pName_ Text
pRunId_ =
  GetWorkflowRun'
    { $sel:includeGraph:GetWorkflowRun' :: Maybe Bool
includeGraph = forall a. Maybe a
Prelude.Nothing,
      $sel:name:GetWorkflowRun' :: Text
name = Text
pName_,
      $sel:runId:GetWorkflowRun' :: Text
runId = Text
pRunId_
    }

-- | Specifies whether to include the workflow graph in response or not.
getWorkflowRun_includeGraph :: Lens.Lens' GetWorkflowRun (Prelude.Maybe Prelude.Bool)
getWorkflowRun_includeGraph :: Lens' GetWorkflowRun (Maybe Bool)
getWorkflowRun_includeGraph = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWorkflowRun' {Maybe Bool
includeGraph :: Maybe Bool
$sel:includeGraph:GetWorkflowRun' :: GetWorkflowRun -> Maybe Bool
includeGraph} -> Maybe Bool
includeGraph) (\s :: GetWorkflowRun
s@GetWorkflowRun' {} Maybe Bool
a -> GetWorkflowRun
s {$sel:includeGraph:GetWorkflowRun' :: Maybe Bool
includeGraph = Maybe Bool
a} :: GetWorkflowRun)

-- | Name of the workflow being run.
getWorkflowRun_name :: Lens.Lens' GetWorkflowRun Prelude.Text
getWorkflowRun_name :: Lens' GetWorkflowRun Text
getWorkflowRun_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWorkflowRun' {Text
name :: Text
$sel:name:GetWorkflowRun' :: GetWorkflowRun -> Text
name} -> Text
name) (\s :: GetWorkflowRun
s@GetWorkflowRun' {} Text
a -> GetWorkflowRun
s {$sel:name:GetWorkflowRun' :: Text
name = Text
a} :: GetWorkflowRun)

-- | The ID of the workflow run.
getWorkflowRun_runId :: Lens.Lens' GetWorkflowRun Prelude.Text
getWorkflowRun_runId :: Lens' GetWorkflowRun Text
getWorkflowRun_runId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWorkflowRun' {Text
runId :: Text
$sel:runId:GetWorkflowRun' :: GetWorkflowRun -> Text
runId} -> Text
runId) (\s :: GetWorkflowRun
s@GetWorkflowRun' {} Text
a -> GetWorkflowRun
s {$sel:runId:GetWorkflowRun' :: Text
runId = Text
a} :: GetWorkflowRun)

instance Core.AWSRequest GetWorkflowRun where
  type
    AWSResponse GetWorkflowRun =
      GetWorkflowRunResponse
  request :: (Service -> Service) -> GetWorkflowRun -> Request GetWorkflowRun
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 GetWorkflowRun
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetWorkflowRun)))
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 WorkflowRun -> Int -> GetWorkflowRunResponse
GetWorkflowRunResponse'
            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
"Run")
            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 GetWorkflowRun where
  hashWithSalt :: Int -> GetWorkflowRun -> Int
hashWithSalt Int
_salt GetWorkflowRun' {Maybe Bool
Text
runId :: Text
name :: Text
includeGraph :: Maybe Bool
$sel:runId:GetWorkflowRun' :: GetWorkflowRun -> Text
$sel:name:GetWorkflowRun' :: GetWorkflowRun -> Text
$sel:includeGraph:GetWorkflowRun' :: GetWorkflowRun -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
includeGraph
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
runId

instance Prelude.NFData GetWorkflowRun where
  rnf :: GetWorkflowRun -> ()
rnf GetWorkflowRun' {Maybe Bool
Text
runId :: Text
name :: Text
includeGraph :: Maybe Bool
$sel:runId:GetWorkflowRun' :: GetWorkflowRun -> Text
$sel:name:GetWorkflowRun' :: GetWorkflowRun -> Text
$sel:includeGraph:GetWorkflowRun' :: GetWorkflowRun -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
includeGraph
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
runId

instance Data.ToHeaders GetWorkflowRun where
  toHeaders :: GetWorkflowRun -> 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
"AWSGlue.GetWorkflowRun" :: 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 GetWorkflowRun where
  toJSON :: GetWorkflowRun -> Value
toJSON GetWorkflowRun' {Maybe Bool
Text
runId :: Text
name :: Text
includeGraph :: Maybe Bool
$sel:runId:GetWorkflowRun' :: GetWorkflowRun -> Text
$sel:name:GetWorkflowRun' :: GetWorkflowRun -> Text
$sel:includeGraph:GetWorkflowRun' :: GetWorkflowRun -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"IncludeGraph" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
includeGraph,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"RunId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
runId)
          ]
      )

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

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

-- | /See:/ 'newGetWorkflowRunResponse' smart constructor.
data GetWorkflowRunResponse = GetWorkflowRunResponse'
  { -- | The requested workflow run metadata.
    GetWorkflowRunResponse -> Maybe WorkflowRun
run :: Prelude.Maybe WorkflowRun,
    -- | The response's http status code.
    GetWorkflowRunResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetWorkflowRunResponse -> GetWorkflowRunResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetWorkflowRunResponse -> GetWorkflowRunResponse -> Bool
$c/= :: GetWorkflowRunResponse -> GetWorkflowRunResponse -> Bool
== :: GetWorkflowRunResponse -> GetWorkflowRunResponse -> Bool
$c== :: GetWorkflowRunResponse -> GetWorkflowRunResponse -> Bool
Prelude.Eq, ReadPrec [GetWorkflowRunResponse]
ReadPrec GetWorkflowRunResponse
Int -> ReadS GetWorkflowRunResponse
ReadS [GetWorkflowRunResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetWorkflowRunResponse]
$creadListPrec :: ReadPrec [GetWorkflowRunResponse]
readPrec :: ReadPrec GetWorkflowRunResponse
$creadPrec :: ReadPrec GetWorkflowRunResponse
readList :: ReadS [GetWorkflowRunResponse]
$creadList :: ReadS [GetWorkflowRunResponse]
readsPrec :: Int -> ReadS GetWorkflowRunResponse
$creadsPrec :: Int -> ReadS GetWorkflowRunResponse
Prelude.Read, Int -> GetWorkflowRunResponse -> ShowS
[GetWorkflowRunResponse] -> ShowS
GetWorkflowRunResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetWorkflowRunResponse] -> ShowS
$cshowList :: [GetWorkflowRunResponse] -> ShowS
show :: GetWorkflowRunResponse -> String
$cshow :: GetWorkflowRunResponse -> String
showsPrec :: Int -> GetWorkflowRunResponse -> ShowS
$cshowsPrec :: Int -> GetWorkflowRunResponse -> ShowS
Prelude.Show, forall x. Rep GetWorkflowRunResponse x -> GetWorkflowRunResponse
forall x. GetWorkflowRunResponse -> Rep GetWorkflowRunResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetWorkflowRunResponse x -> GetWorkflowRunResponse
$cfrom :: forall x. GetWorkflowRunResponse -> Rep GetWorkflowRunResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetWorkflowRunResponse' 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:
--
-- 'run', 'getWorkflowRunResponse_run' - The requested workflow run metadata.
--
-- 'httpStatus', 'getWorkflowRunResponse_httpStatus' - The response's http status code.
newGetWorkflowRunResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetWorkflowRunResponse
newGetWorkflowRunResponse :: Int -> GetWorkflowRunResponse
newGetWorkflowRunResponse Int
pHttpStatus_ =
  GetWorkflowRunResponse'
    { $sel:run:GetWorkflowRunResponse' :: Maybe WorkflowRun
run = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetWorkflowRunResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The requested workflow run metadata.
getWorkflowRunResponse_run :: Lens.Lens' GetWorkflowRunResponse (Prelude.Maybe WorkflowRun)
getWorkflowRunResponse_run :: Lens' GetWorkflowRunResponse (Maybe WorkflowRun)
getWorkflowRunResponse_run = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWorkflowRunResponse' {Maybe WorkflowRun
run :: Maybe WorkflowRun
$sel:run:GetWorkflowRunResponse' :: GetWorkflowRunResponse -> Maybe WorkflowRun
run} -> Maybe WorkflowRun
run) (\s :: GetWorkflowRunResponse
s@GetWorkflowRunResponse' {} Maybe WorkflowRun
a -> GetWorkflowRunResponse
s {$sel:run:GetWorkflowRunResponse' :: Maybe WorkflowRun
run = Maybe WorkflowRun
a} :: GetWorkflowRunResponse)

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

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