{-# 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.GetWorkflow
-- 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 resource metadata for a workflow.
module Amazonka.Glue.GetWorkflow
  ( -- * Creating a Request
    GetWorkflow (..),
    newGetWorkflow,

    -- * Request Lenses
    getWorkflow_includeGraph,
    getWorkflow_name,

    -- * Destructuring the Response
    GetWorkflowResponse (..),
    newGetWorkflowResponse,

    -- * Response Lenses
    getWorkflowResponse_workflow,
    getWorkflowResponse_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:/ 'newGetWorkflow' smart constructor.
data GetWorkflow = GetWorkflow'
  { -- | Specifies whether to include a graph when returning the workflow
    -- resource metadata.
    GetWorkflow -> Maybe Bool
includeGraph :: Prelude.Maybe Prelude.Bool,
    -- | The name of the workflow to retrieve.
    GetWorkflow -> Text
name :: Prelude.Text
  }
  deriving (GetWorkflow -> GetWorkflow -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetWorkflow -> GetWorkflow -> Bool
$c/= :: GetWorkflow -> GetWorkflow -> Bool
== :: GetWorkflow -> GetWorkflow -> Bool
$c== :: GetWorkflow -> GetWorkflow -> Bool
Prelude.Eq, ReadPrec [GetWorkflow]
ReadPrec GetWorkflow
Int -> ReadS GetWorkflow
ReadS [GetWorkflow]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetWorkflow]
$creadListPrec :: ReadPrec [GetWorkflow]
readPrec :: ReadPrec GetWorkflow
$creadPrec :: ReadPrec GetWorkflow
readList :: ReadS [GetWorkflow]
$creadList :: ReadS [GetWorkflow]
readsPrec :: Int -> ReadS GetWorkflow
$creadsPrec :: Int -> ReadS GetWorkflow
Prelude.Read, Int -> GetWorkflow -> ShowS
[GetWorkflow] -> ShowS
GetWorkflow -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetWorkflow] -> ShowS
$cshowList :: [GetWorkflow] -> ShowS
show :: GetWorkflow -> String
$cshow :: GetWorkflow -> String
showsPrec :: Int -> GetWorkflow -> ShowS
$cshowsPrec :: Int -> GetWorkflow -> ShowS
Prelude.Show, forall x. Rep GetWorkflow x -> GetWorkflow
forall x. GetWorkflow -> Rep GetWorkflow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetWorkflow x -> GetWorkflow
$cfrom :: forall x. GetWorkflow -> Rep GetWorkflow x
Prelude.Generic)

-- |
-- Create a value of 'GetWorkflow' 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', 'getWorkflow_includeGraph' - Specifies whether to include a graph when returning the workflow
-- resource metadata.
--
-- 'name', 'getWorkflow_name' - The name of the workflow to retrieve.
newGetWorkflow ::
  -- | 'name'
  Prelude.Text ->
  GetWorkflow
newGetWorkflow :: Text -> GetWorkflow
newGetWorkflow Text
pName_ =
  GetWorkflow'
    { $sel:includeGraph:GetWorkflow' :: Maybe Bool
includeGraph = forall a. Maybe a
Prelude.Nothing,
      $sel:name:GetWorkflow' :: Text
name = Text
pName_
    }

-- | Specifies whether to include a graph when returning the workflow
-- resource metadata.
getWorkflow_includeGraph :: Lens.Lens' GetWorkflow (Prelude.Maybe Prelude.Bool)
getWorkflow_includeGraph :: Lens' GetWorkflow (Maybe Bool)
getWorkflow_includeGraph = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWorkflow' {Maybe Bool
includeGraph :: Maybe Bool
$sel:includeGraph:GetWorkflow' :: GetWorkflow -> Maybe Bool
includeGraph} -> Maybe Bool
includeGraph) (\s :: GetWorkflow
s@GetWorkflow' {} Maybe Bool
a -> GetWorkflow
s {$sel:includeGraph:GetWorkflow' :: Maybe Bool
includeGraph = Maybe Bool
a} :: GetWorkflow)

-- | The name of the workflow to retrieve.
getWorkflow_name :: Lens.Lens' GetWorkflow Prelude.Text
getWorkflow_name :: Lens' GetWorkflow Text
getWorkflow_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWorkflow' {Text
name :: Text
$sel:name:GetWorkflow' :: GetWorkflow -> Text
name} -> Text
name) (\s :: GetWorkflow
s@GetWorkflow' {} Text
a -> GetWorkflow
s {$sel:name:GetWorkflow' :: Text
name = Text
a} :: GetWorkflow)

instance Core.AWSRequest GetWorkflow where
  type AWSResponse GetWorkflow = GetWorkflowResponse
  request :: (Service -> Service) -> GetWorkflow -> Request GetWorkflow
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 GetWorkflow
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetWorkflow)))
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 Workflow -> Int -> GetWorkflowResponse
GetWorkflowResponse'
            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
"Workflow")
            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 GetWorkflow where
  hashWithSalt :: Int -> GetWorkflow -> Int
hashWithSalt Int
_salt GetWorkflow' {Maybe Bool
Text
name :: Text
includeGraph :: Maybe Bool
$sel:name:GetWorkflow' :: GetWorkflow -> Text
$sel:includeGraph:GetWorkflow' :: GetWorkflow -> 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

instance Prelude.NFData GetWorkflow where
  rnf :: GetWorkflow -> ()
rnf GetWorkflow' {Maybe Bool
Text
name :: Text
includeGraph :: Maybe Bool
$sel:name:GetWorkflow' :: GetWorkflow -> Text
$sel:includeGraph:GetWorkflow' :: GetWorkflow -> 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

instance Data.ToHeaders GetWorkflow where
  toHeaders :: GetWorkflow -> 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.GetWorkflow" :: 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 GetWorkflow where
  toJSON :: GetWorkflow -> Value
toJSON GetWorkflow' {Maybe Bool
Text
name :: Text
includeGraph :: Maybe Bool
$sel:name:GetWorkflow' :: GetWorkflow -> Text
$sel:includeGraph:GetWorkflow' :: GetWorkflow -> 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)
          ]
      )

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

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

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

-- |
-- Create a value of 'GetWorkflowResponse' 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:
--
-- 'workflow', 'getWorkflowResponse_workflow' - The resource metadata for the workflow.
--
-- 'httpStatus', 'getWorkflowResponse_httpStatus' - The response's http status code.
newGetWorkflowResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetWorkflowResponse
newGetWorkflowResponse :: Int -> GetWorkflowResponse
newGetWorkflowResponse Int
pHttpStatus_ =
  GetWorkflowResponse'
    { $sel:workflow:GetWorkflowResponse' :: Maybe Workflow
workflow = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetWorkflowResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The resource metadata for the workflow.
getWorkflowResponse_workflow :: Lens.Lens' GetWorkflowResponse (Prelude.Maybe Workflow)
getWorkflowResponse_workflow :: Lens' GetWorkflowResponse (Maybe Workflow)
getWorkflowResponse_workflow = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWorkflowResponse' {Maybe Workflow
workflow :: Maybe Workflow
$sel:workflow:GetWorkflowResponse' :: GetWorkflowResponse -> Maybe Workflow
workflow} -> Maybe Workflow
workflow) (\s :: GetWorkflowResponse
s@GetWorkflowResponse' {} Maybe Workflow
a -> GetWorkflowResponse
s {$sel:workflow:GetWorkflowResponse' :: Maybe Workflow
workflow = Maybe Workflow
a} :: GetWorkflowResponse)

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

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