{-# 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.GetBlueprintRun
-- 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 details of a blueprint run.
module Amazonka.Glue.GetBlueprintRun
  ( -- * Creating a Request
    GetBlueprintRun (..),
    newGetBlueprintRun,

    -- * Request Lenses
    getBlueprintRun_blueprintName,
    getBlueprintRun_runId,

    -- * Destructuring the Response
    GetBlueprintRunResponse (..),
    newGetBlueprintRunResponse,

    -- * Response Lenses
    getBlueprintRunResponse_blueprintRun,
    getBlueprintRunResponse_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:/ 'newGetBlueprintRun' smart constructor.
data GetBlueprintRun = GetBlueprintRun'
  { -- | The name of the blueprint.
    GetBlueprintRun -> Text
blueprintName :: Prelude.Text,
    -- | The run ID for the blueprint run you want to retrieve.
    GetBlueprintRun -> Text
runId :: Prelude.Text
  }
  deriving (GetBlueprintRun -> GetBlueprintRun -> Bool
(GetBlueprintRun -> GetBlueprintRun -> Bool)
-> (GetBlueprintRun -> GetBlueprintRun -> Bool)
-> Eq GetBlueprintRun
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetBlueprintRun -> GetBlueprintRun -> Bool
$c/= :: GetBlueprintRun -> GetBlueprintRun -> Bool
== :: GetBlueprintRun -> GetBlueprintRun -> Bool
$c== :: GetBlueprintRun -> GetBlueprintRun -> Bool
Prelude.Eq, ReadPrec [GetBlueprintRun]
ReadPrec GetBlueprintRun
Int -> ReadS GetBlueprintRun
ReadS [GetBlueprintRun]
(Int -> ReadS GetBlueprintRun)
-> ReadS [GetBlueprintRun]
-> ReadPrec GetBlueprintRun
-> ReadPrec [GetBlueprintRun]
-> Read GetBlueprintRun
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetBlueprintRun]
$creadListPrec :: ReadPrec [GetBlueprintRun]
readPrec :: ReadPrec GetBlueprintRun
$creadPrec :: ReadPrec GetBlueprintRun
readList :: ReadS [GetBlueprintRun]
$creadList :: ReadS [GetBlueprintRun]
readsPrec :: Int -> ReadS GetBlueprintRun
$creadsPrec :: Int -> ReadS GetBlueprintRun
Prelude.Read, Int -> GetBlueprintRun -> ShowS
[GetBlueprintRun] -> ShowS
GetBlueprintRun -> String
(Int -> GetBlueprintRun -> ShowS)
-> (GetBlueprintRun -> String)
-> ([GetBlueprintRun] -> ShowS)
-> Show GetBlueprintRun
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetBlueprintRun] -> ShowS
$cshowList :: [GetBlueprintRun] -> ShowS
show :: GetBlueprintRun -> String
$cshow :: GetBlueprintRun -> String
showsPrec :: Int -> GetBlueprintRun -> ShowS
$cshowsPrec :: Int -> GetBlueprintRun -> ShowS
Prelude.Show, (forall x. GetBlueprintRun -> Rep GetBlueprintRun x)
-> (forall x. Rep GetBlueprintRun x -> GetBlueprintRun)
-> Generic GetBlueprintRun
forall x. Rep GetBlueprintRun x -> GetBlueprintRun
forall x. GetBlueprintRun -> Rep GetBlueprintRun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetBlueprintRun x -> GetBlueprintRun
$cfrom :: forall x. GetBlueprintRun -> Rep GetBlueprintRun x
Prelude.Generic)

-- |
-- Create a value of 'GetBlueprintRun' 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:
--
-- 'blueprintName', 'getBlueprintRun_blueprintName' - The name of the blueprint.
--
-- 'runId', 'getBlueprintRun_runId' - The run ID for the blueprint run you want to retrieve.
newGetBlueprintRun ::
  -- | 'blueprintName'
  Prelude.Text ->
  -- | 'runId'
  Prelude.Text ->
  GetBlueprintRun
newGetBlueprintRun :: Text -> Text -> GetBlueprintRun
newGetBlueprintRun Text
pBlueprintName_ Text
pRunId_ =
  GetBlueprintRun' :: Text -> Text -> GetBlueprintRun
GetBlueprintRun'
    { $sel:blueprintName:GetBlueprintRun' :: Text
blueprintName = Text
pBlueprintName_,
      $sel:runId:GetBlueprintRun' :: Text
runId = Text
pRunId_
    }

-- | The name of the blueprint.
getBlueprintRun_blueprintName :: Lens.Lens' GetBlueprintRun Prelude.Text
getBlueprintRun_blueprintName :: (Text -> f Text) -> GetBlueprintRun -> f GetBlueprintRun
getBlueprintRun_blueprintName = (GetBlueprintRun -> Text)
-> (GetBlueprintRun -> Text -> GetBlueprintRun)
-> Lens GetBlueprintRun GetBlueprintRun Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBlueprintRun' {Text
blueprintName :: Text
$sel:blueprintName:GetBlueprintRun' :: GetBlueprintRun -> Text
blueprintName} -> Text
blueprintName) (\s :: GetBlueprintRun
s@GetBlueprintRun' {} Text
a -> GetBlueprintRun
s {$sel:blueprintName:GetBlueprintRun' :: Text
blueprintName = Text
a} :: GetBlueprintRun)

-- | The run ID for the blueprint run you want to retrieve.
getBlueprintRun_runId :: Lens.Lens' GetBlueprintRun Prelude.Text
getBlueprintRun_runId :: (Text -> f Text) -> GetBlueprintRun -> f GetBlueprintRun
getBlueprintRun_runId = (GetBlueprintRun -> Text)
-> (GetBlueprintRun -> Text -> GetBlueprintRun)
-> Lens GetBlueprintRun GetBlueprintRun Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBlueprintRun' {Text
runId :: Text
$sel:runId:GetBlueprintRun' :: GetBlueprintRun -> Text
runId} -> Text
runId) (\s :: GetBlueprintRun
s@GetBlueprintRun' {} Text
a -> GetBlueprintRun
s {$sel:runId:GetBlueprintRun' :: Text
runId = Text
a} :: GetBlueprintRun)

instance Core.AWSRequest GetBlueprintRun where
  type
    AWSResponse GetBlueprintRun =
      GetBlueprintRunResponse
  request :: GetBlueprintRun -> Request GetBlueprintRun
request = Service -> GetBlueprintRun -> Request GetBlueprintRun
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetBlueprintRun
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetBlueprintRun)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetBlueprintRun))
-> Logger
-> Service
-> Proxy GetBlueprintRun
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetBlueprintRun)))
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 BlueprintRun -> Int -> GetBlueprintRunResponse
GetBlueprintRunResponse'
            (Maybe BlueprintRun -> Int -> GetBlueprintRunResponse)
-> Either String (Maybe BlueprintRun)
-> Either String (Int -> GetBlueprintRunResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe BlueprintRun)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"BlueprintRun")
            Either String (Int -> GetBlueprintRunResponse)
-> Either String Int -> Either String GetBlueprintRunResponse
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 GetBlueprintRun

instance Prelude.NFData GetBlueprintRun

instance Core.ToHeaders GetBlueprintRun where
  toHeaders :: GetBlueprintRun -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetBlueprintRun -> 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.GetBlueprintRun" :: 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 GetBlueprintRun where
  toJSON :: GetBlueprintRun -> Value
toJSON GetBlueprintRun' {Text
runId :: Text
blueprintName :: Text
$sel:runId:GetBlueprintRun' :: GetBlueprintRun -> Text
$sel:blueprintName:GetBlueprintRun' :: GetBlueprintRun -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"BlueprintName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
blueprintName),
            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 GetBlueprintRun where
  toPath :: GetBlueprintRun -> ByteString
toPath = ByteString -> GetBlueprintRun -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'GetBlueprintRunResponse' 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:
--
-- 'blueprintRun', 'getBlueprintRunResponse_blueprintRun' - Returns a @BlueprintRun@ object.
--
-- 'httpStatus', 'getBlueprintRunResponse_httpStatus' - The response's http status code.
newGetBlueprintRunResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetBlueprintRunResponse
newGetBlueprintRunResponse :: Int -> GetBlueprintRunResponse
newGetBlueprintRunResponse Int
pHttpStatus_ =
  GetBlueprintRunResponse' :: Maybe BlueprintRun -> Int -> GetBlueprintRunResponse
GetBlueprintRunResponse'
    { $sel:blueprintRun:GetBlueprintRunResponse' :: Maybe BlueprintRun
blueprintRun =
        Maybe BlueprintRun
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetBlueprintRunResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Returns a @BlueprintRun@ object.
getBlueprintRunResponse_blueprintRun :: Lens.Lens' GetBlueprintRunResponse (Prelude.Maybe BlueprintRun)
getBlueprintRunResponse_blueprintRun :: (Maybe BlueprintRun -> f (Maybe BlueprintRun))
-> GetBlueprintRunResponse -> f GetBlueprintRunResponse
getBlueprintRunResponse_blueprintRun = (GetBlueprintRunResponse -> Maybe BlueprintRun)
-> (GetBlueprintRunResponse
    -> Maybe BlueprintRun -> GetBlueprintRunResponse)
-> Lens
     GetBlueprintRunResponse
     GetBlueprintRunResponse
     (Maybe BlueprintRun)
     (Maybe BlueprintRun)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBlueprintRunResponse' {Maybe BlueprintRun
blueprintRun :: Maybe BlueprintRun
$sel:blueprintRun:GetBlueprintRunResponse' :: GetBlueprintRunResponse -> Maybe BlueprintRun
blueprintRun} -> Maybe BlueprintRun
blueprintRun) (\s :: GetBlueprintRunResponse
s@GetBlueprintRunResponse' {} Maybe BlueprintRun
a -> GetBlueprintRunResponse
s {$sel:blueprintRun:GetBlueprintRunResponse' :: Maybe BlueprintRun
blueprintRun = Maybe BlueprintRun
a} :: GetBlueprintRunResponse)

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

instance Prelude.NFData GetBlueprintRunResponse