{-# 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.GetDataflowGraph
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Transforms a Python script into a directed acyclic graph (DAG).
module Amazonka.Glue.GetDataflowGraph
  ( -- * Creating a Request
    GetDataflowGraph (..),
    newGetDataflowGraph,

    -- * Request Lenses
    getDataflowGraph_pythonScript,

    -- * Destructuring the Response
    GetDataflowGraphResponse (..),
    newGetDataflowGraphResponse,

    -- * Response Lenses
    getDataflowGraphResponse_dagEdges,
    getDataflowGraphResponse_dagNodes,
    getDataflowGraphResponse_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:/ 'newGetDataflowGraph' smart constructor.
data GetDataflowGraph = GetDataflowGraph'
  { -- | The Python script to transform.
    GetDataflowGraph -> Maybe Text
pythonScript :: Prelude.Maybe Prelude.Text
  }
  deriving (GetDataflowGraph -> GetDataflowGraph -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDataflowGraph -> GetDataflowGraph -> Bool
$c/= :: GetDataflowGraph -> GetDataflowGraph -> Bool
== :: GetDataflowGraph -> GetDataflowGraph -> Bool
$c== :: GetDataflowGraph -> GetDataflowGraph -> Bool
Prelude.Eq, ReadPrec [GetDataflowGraph]
ReadPrec GetDataflowGraph
Int -> ReadS GetDataflowGraph
ReadS [GetDataflowGraph]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDataflowGraph]
$creadListPrec :: ReadPrec [GetDataflowGraph]
readPrec :: ReadPrec GetDataflowGraph
$creadPrec :: ReadPrec GetDataflowGraph
readList :: ReadS [GetDataflowGraph]
$creadList :: ReadS [GetDataflowGraph]
readsPrec :: Int -> ReadS GetDataflowGraph
$creadsPrec :: Int -> ReadS GetDataflowGraph
Prelude.Read, Int -> GetDataflowGraph -> ShowS
[GetDataflowGraph] -> ShowS
GetDataflowGraph -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDataflowGraph] -> ShowS
$cshowList :: [GetDataflowGraph] -> ShowS
show :: GetDataflowGraph -> String
$cshow :: GetDataflowGraph -> String
showsPrec :: Int -> GetDataflowGraph -> ShowS
$cshowsPrec :: Int -> GetDataflowGraph -> ShowS
Prelude.Show, forall x. Rep GetDataflowGraph x -> GetDataflowGraph
forall x. GetDataflowGraph -> Rep GetDataflowGraph x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDataflowGraph x -> GetDataflowGraph
$cfrom :: forall x. GetDataflowGraph -> Rep GetDataflowGraph x
Prelude.Generic)

-- |
-- Create a value of 'GetDataflowGraph' 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:
--
-- 'pythonScript', 'getDataflowGraph_pythonScript' - The Python script to transform.
newGetDataflowGraph ::
  GetDataflowGraph
newGetDataflowGraph :: GetDataflowGraph
newGetDataflowGraph =
  GetDataflowGraph' {$sel:pythonScript:GetDataflowGraph' :: Maybe Text
pythonScript = forall a. Maybe a
Prelude.Nothing}

-- | The Python script to transform.
getDataflowGraph_pythonScript :: Lens.Lens' GetDataflowGraph (Prelude.Maybe Prelude.Text)
getDataflowGraph_pythonScript :: Lens' GetDataflowGraph (Maybe Text)
getDataflowGraph_pythonScript = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDataflowGraph' {Maybe Text
pythonScript :: Maybe Text
$sel:pythonScript:GetDataflowGraph' :: GetDataflowGraph -> Maybe Text
pythonScript} -> Maybe Text
pythonScript) (\s :: GetDataflowGraph
s@GetDataflowGraph' {} Maybe Text
a -> GetDataflowGraph
s {$sel:pythonScript:GetDataflowGraph' :: Maybe Text
pythonScript = Maybe Text
a} :: GetDataflowGraph)

instance Core.AWSRequest GetDataflowGraph where
  type
    AWSResponse GetDataflowGraph =
      GetDataflowGraphResponse
  request :: (Service -> Service)
-> GetDataflowGraph -> Request GetDataflowGraph
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 GetDataflowGraph
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDataflowGraph)))
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 [CodeGenEdge]
-> Maybe [CodeGenNode] -> Int -> GetDataflowGraphResponse
GetDataflowGraphResponse'
            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
"DagEdges" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"DagNodes" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 GetDataflowGraph where
  hashWithSalt :: Int -> GetDataflowGraph -> Int
hashWithSalt Int
_salt GetDataflowGraph' {Maybe Text
pythonScript :: Maybe Text
$sel:pythonScript:GetDataflowGraph' :: GetDataflowGraph -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
pythonScript

instance Prelude.NFData GetDataflowGraph where
  rnf :: GetDataflowGraph -> ()
rnf GetDataflowGraph' {Maybe Text
pythonScript :: Maybe Text
$sel:pythonScript:GetDataflowGraph' :: GetDataflowGraph -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
pythonScript

instance Data.ToHeaders GetDataflowGraph where
  toHeaders :: GetDataflowGraph -> 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.GetDataflowGraph" :: 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 GetDataflowGraph where
  toJSON :: GetDataflowGraph -> Value
toJSON GetDataflowGraph' {Maybe Text
pythonScript :: Maybe Text
$sel:pythonScript:GetDataflowGraph' :: GetDataflowGraph -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"PythonScript" 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 Text
pythonScript]
      )

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

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

-- | /See:/ 'newGetDataflowGraphResponse' smart constructor.
data GetDataflowGraphResponse = GetDataflowGraphResponse'
  { -- | A list of the edges in the resulting DAG.
    GetDataflowGraphResponse -> Maybe [CodeGenEdge]
dagEdges :: Prelude.Maybe [CodeGenEdge],
    -- | A list of the nodes in the resulting DAG.
    GetDataflowGraphResponse -> Maybe [CodeGenNode]
dagNodes :: Prelude.Maybe [CodeGenNode],
    -- | The response's http status code.
    GetDataflowGraphResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDataflowGraphResponse -> GetDataflowGraphResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDataflowGraphResponse -> GetDataflowGraphResponse -> Bool
$c/= :: GetDataflowGraphResponse -> GetDataflowGraphResponse -> Bool
== :: GetDataflowGraphResponse -> GetDataflowGraphResponse -> Bool
$c== :: GetDataflowGraphResponse -> GetDataflowGraphResponse -> Bool
Prelude.Eq, ReadPrec [GetDataflowGraphResponse]
ReadPrec GetDataflowGraphResponse
Int -> ReadS GetDataflowGraphResponse
ReadS [GetDataflowGraphResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDataflowGraphResponse]
$creadListPrec :: ReadPrec [GetDataflowGraphResponse]
readPrec :: ReadPrec GetDataflowGraphResponse
$creadPrec :: ReadPrec GetDataflowGraphResponse
readList :: ReadS [GetDataflowGraphResponse]
$creadList :: ReadS [GetDataflowGraphResponse]
readsPrec :: Int -> ReadS GetDataflowGraphResponse
$creadsPrec :: Int -> ReadS GetDataflowGraphResponse
Prelude.Read, Int -> GetDataflowGraphResponse -> ShowS
[GetDataflowGraphResponse] -> ShowS
GetDataflowGraphResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDataflowGraphResponse] -> ShowS
$cshowList :: [GetDataflowGraphResponse] -> ShowS
show :: GetDataflowGraphResponse -> String
$cshow :: GetDataflowGraphResponse -> String
showsPrec :: Int -> GetDataflowGraphResponse -> ShowS
$cshowsPrec :: Int -> GetDataflowGraphResponse -> ShowS
Prelude.Show, forall x.
Rep GetDataflowGraphResponse x -> GetDataflowGraphResponse
forall x.
GetDataflowGraphResponse -> Rep GetDataflowGraphResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetDataflowGraphResponse x -> GetDataflowGraphResponse
$cfrom :: forall x.
GetDataflowGraphResponse -> Rep GetDataflowGraphResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDataflowGraphResponse' 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:
--
-- 'dagEdges', 'getDataflowGraphResponse_dagEdges' - A list of the edges in the resulting DAG.
--
-- 'dagNodes', 'getDataflowGraphResponse_dagNodes' - A list of the nodes in the resulting DAG.
--
-- 'httpStatus', 'getDataflowGraphResponse_httpStatus' - The response's http status code.
newGetDataflowGraphResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDataflowGraphResponse
newGetDataflowGraphResponse :: Int -> GetDataflowGraphResponse
newGetDataflowGraphResponse Int
pHttpStatus_ =
  GetDataflowGraphResponse'
    { $sel:dagEdges:GetDataflowGraphResponse' :: Maybe [CodeGenEdge]
dagEdges =
        forall a. Maybe a
Prelude.Nothing,
      $sel:dagNodes:GetDataflowGraphResponse' :: Maybe [CodeGenNode]
dagNodes = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDataflowGraphResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of the edges in the resulting DAG.
getDataflowGraphResponse_dagEdges :: Lens.Lens' GetDataflowGraphResponse (Prelude.Maybe [CodeGenEdge])
getDataflowGraphResponse_dagEdges :: Lens' GetDataflowGraphResponse (Maybe [CodeGenEdge])
getDataflowGraphResponse_dagEdges = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDataflowGraphResponse' {Maybe [CodeGenEdge]
dagEdges :: Maybe [CodeGenEdge]
$sel:dagEdges:GetDataflowGraphResponse' :: GetDataflowGraphResponse -> Maybe [CodeGenEdge]
dagEdges} -> Maybe [CodeGenEdge]
dagEdges) (\s :: GetDataflowGraphResponse
s@GetDataflowGraphResponse' {} Maybe [CodeGenEdge]
a -> GetDataflowGraphResponse
s {$sel:dagEdges:GetDataflowGraphResponse' :: Maybe [CodeGenEdge]
dagEdges = Maybe [CodeGenEdge]
a} :: GetDataflowGraphResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of the nodes in the resulting DAG.
getDataflowGraphResponse_dagNodes :: Lens.Lens' GetDataflowGraphResponse (Prelude.Maybe [CodeGenNode])
getDataflowGraphResponse_dagNodes :: Lens' GetDataflowGraphResponse (Maybe [CodeGenNode])
getDataflowGraphResponse_dagNodes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDataflowGraphResponse' {Maybe [CodeGenNode]
dagNodes :: Maybe [CodeGenNode]
$sel:dagNodes:GetDataflowGraphResponse' :: GetDataflowGraphResponse -> Maybe [CodeGenNode]
dagNodes} -> Maybe [CodeGenNode]
dagNodes) (\s :: GetDataflowGraphResponse
s@GetDataflowGraphResponse' {} Maybe [CodeGenNode]
a -> GetDataflowGraphResponse
s {$sel:dagNodes:GetDataflowGraphResponse' :: Maybe [CodeGenNode]
dagNodes = Maybe [CodeGenNode]
a} :: GetDataflowGraphResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData GetDataflowGraphResponse where
  rnf :: GetDataflowGraphResponse -> ()
rnf GetDataflowGraphResponse' {Int
Maybe [CodeGenEdge]
Maybe [CodeGenNode]
httpStatus :: Int
dagNodes :: Maybe [CodeGenNode]
dagEdges :: Maybe [CodeGenEdge]
$sel:httpStatus:GetDataflowGraphResponse' :: GetDataflowGraphResponse -> Int
$sel:dagNodes:GetDataflowGraphResponse' :: GetDataflowGraphResponse -> Maybe [CodeGenNode]
$sel:dagEdges:GetDataflowGraphResponse' :: GetDataflowGraphResponse -> Maybe [CodeGenEdge]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [CodeGenEdge]
dagEdges
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [CodeGenNode]
dagNodes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus