{-# 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-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)
--
-- 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 Amazonka.Glue.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:/ '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
(GetWorkflowRun -> GetWorkflowRun -> Bool)
-> (GetWorkflowRun -> GetWorkflowRun -> Bool) -> Eq GetWorkflowRun
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]
(Int -> ReadS GetWorkflowRun)
-> ReadS [GetWorkflowRun]
-> ReadPrec GetWorkflowRun
-> ReadPrec [GetWorkflowRun]
-> Read 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
(Int -> GetWorkflowRun -> ShowS)
-> (GetWorkflowRun -> String)
-> ([GetWorkflowRun] -> ShowS)
-> Show GetWorkflowRun
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. GetWorkflowRun -> Rep GetWorkflowRun x)
-> (forall x. Rep GetWorkflowRun x -> GetWorkflowRun)
-> Generic GetWorkflowRun
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' :: Maybe Bool -> Text -> Text -> GetWorkflowRun
GetWorkflowRun'
    { $sel:includeGraph:GetWorkflowRun' :: Maybe Bool
includeGraph = Maybe Bool
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 :: (Maybe Bool -> f (Maybe Bool))
-> GetWorkflowRun -> f GetWorkflowRun
getWorkflowRun_includeGraph = (GetWorkflowRun -> Maybe Bool)
-> (GetWorkflowRun -> Maybe Bool -> GetWorkflowRun)
-> Lens GetWorkflowRun GetWorkflowRun (Maybe Bool) (Maybe Bool)
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 :: (Text -> f Text) -> GetWorkflowRun -> f GetWorkflowRun
getWorkflowRun_name = (GetWorkflowRun -> Text)
-> (GetWorkflowRun -> Text -> GetWorkflowRun)
-> Lens GetWorkflowRun GetWorkflowRun Text Text
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 :: (Text -> f Text) -> GetWorkflowRun -> f GetWorkflowRun
getWorkflowRun_runId = (GetWorkflowRun -> Text)
-> (GetWorkflowRun -> Text -> GetWorkflowRun)
-> Lens GetWorkflowRun GetWorkflowRun Text Text
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 :: GetWorkflowRun -> Request GetWorkflowRun
request = Service -> GetWorkflowRun -> Request GetWorkflowRun
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetWorkflowRun
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetWorkflowRun)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetWorkflowRun))
-> Logger
-> Service
-> Proxy GetWorkflowRun
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetWorkflowRun)))
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 WorkflowRun -> Int -> GetWorkflowRunResponse
GetWorkflowRunResponse'
            (Maybe WorkflowRun -> Int -> GetWorkflowRunResponse)
-> Either String (Maybe WorkflowRun)
-> Either String (Int -> GetWorkflowRunResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe WorkflowRun)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Run")
            Either String (Int -> GetWorkflowRunResponse)
-> Either String Int -> Either String GetWorkflowRunResponse
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 GetWorkflowRun

instance Prelude.NFData GetWorkflowRun

instance Core.ToHeaders GetWorkflowRun where
  toHeaders :: GetWorkflowRun -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetWorkflowRun -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"AWSGlue.GetWorkflowRun" :: Prelude.ByteString),
            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.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"IncludeGraph" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
includeGraph,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RunId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
runId)
          ]
      )

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

instance Core.ToQuery GetWorkflowRun where
  toQuery :: GetWorkflowRun -> QueryString
toQuery = QueryString -> GetWorkflowRun -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetWorkflowRunResponse -> GetWorkflowRunResponse -> Bool)
-> (GetWorkflowRunResponse -> GetWorkflowRunResponse -> Bool)
-> Eq GetWorkflowRunResponse
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]
(Int -> ReadS GetWorkflowRunResponse)
-> ReadS [GetWorkflowRunResponse]
-> ReadPrec GetWorkflowRunResponse
-> ReadPrec [GetWorkflowRunResponse]
-> Read 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
(Int -> GetWorkflowRunResponse -> ShowS)
-> (GetWorkflowRunResponse -> String)
-> ([GetWorkflowRunResponse] -> ShowS)
-> Show GetWorkflowRunResponse
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. GetWorkflowRunResponse -> Rep GetWorkflowRunResponse x)
-> (forall x.
    Rep GetWorkflowRunResponse x -> GetWorkflowRunResponse)
-> Generic GetWorkflowRunResponse
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' :: Maybe WorkflowRun -> Int -> GetWorkflowRunResponse
GetWorkflowRunResponse'
    { $sel:run:GetWorkflowRunResponse' :: Maybe WorkflowRun
run = Maybe WorkflowRun
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 :: (Maybe WorkflowRun -> f (Maybe WorkflowRun))
-> GetWorkflowRunResponse -> f GetWorkflowRunResponse
getWorkflowRunResponse_run = (GetWorkflowRunResponse -> Maybe WorkflowRun)
-> (GetWorkflowRunResponse
    -> Maybe WorkflowRun -> GetWorkflowRunResponse)
-> Lens
     GetWorkflowRunResponse
     GetWorkflowRunResponse
     (Maybe WorkflowRun)
     (Maybe WorkflowRun)
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 :: (Int -> f Int)
-> GetWorkflowRunResponse -> f GetWorkflowRunResponse
getWorkflowRunResponse_httpStatus = (GetWorkflowRunResponse -> Int)
-> (GetWorkflowRunResponse -> Int -> GetWorkflowRunResponse)
-> Lens GetWorkflowRunResponse GetWorkflowRunResponse Int Int
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