{-# 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.GetBlueprint
-- 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.
module Amazonka.Glue.GetBlueprint
  ( -- * Creating a Request
    GetBlueprint (..),
    newGetBlueprint,

    -- * Request Lenses
    getBlueprint_includeParameterSpec,
    getBlueprint_includeBlueprint,
    getBlueprint_name,

    -- * Destructuring the Response
    GetBlueprintResponse (..),
    newGetBlueprintResponse,

    -- * Response Lenses
    getBlueprintResponse_blueprint,
    getBlueprintResponse_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:/ 'newGetBlueprint' smart constructor.
data GetBlueprint = GetBlueprint'
  { -- | Specifies whether or not to include the parameter specification.
    GetBlueprint -> Maybe Bool
includeParameterSpec :: Prelude.Maybe Prelude.Bool,
    -- | Specifies whether or not to include the blueprint in the response.
    GetBlueprint -> Maybe Bool
includeBlueprint :: Prelude.Maybe Prelude.Bool,
    -- | The name of the blueprint.
    GetBlueprint -> Text
name :: Prelude.Text
  }
  deriving (GetBlueprint -> GetBlueprint -> Bool
(GetBlueprint -> GetBlueprint -> Bool)
-> (GetBlueprint -> GetBlueprint -> Bool) -> Eq GetBlueprint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetBlueprint -> GetBlueprint -> Bool
$c/= :: GetBlueprint -> GetBlueprint -> Bool
== :: GetBlueprint -> GetBlueprint -> Bool
$c== :: GetBlueprint -> GetBlueprint -> Bool
Prelude.Eq, ReadPrec [GetBlueprint]
ReadPrec GetBlueprint
Int -> ReadS GetBlueprint
ReadS [GetBlueprint]
(Int -> ReadS GetBlueprint)
-> ReadS [GetBlueprint]
-> ReadPrec GetBlueprint
-> ReadPrec [GetBlueprint]
-> Read GetBlueprint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetBlueprint]
$creadListPrec :: ReadPrec [GetBlueprint]
readPrec :: ReadPrec GetBlueprint
$creadPrec :: ReadPrec GetBlueprint
readList :: ReadS [GetBlueprint]
$creadList :: ReadS [GetBlueprint]
readsPrec :: Int -> ReadS GetBlueprint
$creadsPrec :: Int -> ReadS GetBlueprint
Prelude.Read, Int -> GetBlueprint -> ShowS
[GetBlueprint] -> ShowS
GetBlueprint -> String
(Int -> GetBlueprint -> ShowS)
-> (GetBlueprint -> String)
-> ([GetBlueprint] -> ShowS)
-> Show GetBlueprint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetBlueprint] -> ShowS
$cshowList :: [GetBlueprint] -> ShowS
show :: GetBlueprint -> String
$cshow :: GetBlueprint -> String
showsPrec :: Int -> GetBlueprint -> ShowS
$cshowsPrec :: Int -> GetBlueprint -> ShowS
Prelude.Show, (forall x. GetBlueprint -> Rep GetBlueprint x)
-> (forall x. Rep GetBlueprint x -> GetBlueprint)
-> Generic GetBlueprint
forall x. Rep GetBlueprint x -> GetBlueprint
forall x. GetBlueprint -> Rep GetBlueprint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetBlueprint x -> GetBlueprint
$cfrom :: forall x. GetBlueprint -> Rep GetBlueprint x
Prelude.Generic)

-- |
-- Create a value of 'GetBlueprint' 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:
--
-- 'includeParameterSpec', 'getBlueprint_includeParameterSpec' - Specifies whether or not to include the parameter specification.
--
-- 'includeBlueprint', 'getBlueprint_includeBlueprint' - Specifies whether or not to include the blueprint in the response.
--
-- 'name', 'getBlueprint_name' - The name of the blueprint.
newGetBlueprint ::
  -- | 'name'
  Prelude.Text ->
  GetBlueprint
newGetBlueprint :: Text -> GetBlueprint
newGetBlueprint Text
pName_ =
  GetBlueprint' :: Maybe Bool -> Maybe Bool -> Text -> GetBlueprint
GetBlueprint'
    { $sel:includeParameterSpec:GetBlueprint' :: Maybe Bool
includeParameterSpec =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:includeBlueprint:GetBlueprint' :: Maybe Bool
includeBlueprint = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:name:GetBlueprint' :: Text
name = Text
pName_
    }

-- | Specifies whether or not to include the parameter specification.
getBlueprint_includeParameterSpec :: Lens.Lens' GetBlueprint (Prelude.Maybe Prelude.Bool)
getBlueprint_includeParameterSpec :: (Maybe Bool -> f (Maybe Bool)) -> GetBlueprint -> f GetBlueprint
getBlueprint_includeParameterSpec = (GetBlueprint -> Maybe Bool)
-> (GetBlueprint -> Maybe Bool -> GetBlueprint)
-> Lens GetBlueprint GetBlueprint (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBlueprint' {Maybe Bool
includeParameterSpec :: Maybe Bool
$sel:includeParameterSpec:GetBlueprint' :: GetBlueprint -> Maybe Bool
includeParameterSpec} -> Maybe Bool
includeParameterSpec) (\s :: GetBlueprint
s@GetBlueprint' {} Maybe Bool
a -> GetBlueprint
s {$sel:includeParameterSpec:GetBlueprint' :: Maybe Bool
includeParameterSpec = Maybe Bool
a} :: GetBlueprint)

-- | Specifies whether or not to include the blueprint in the response.
getBlueprint_includeBlueprint :: Lens.Lens' GetBlueprint (Prelude.Maybe Prelude.Bool)
getBlueprint_includeBlueprint :: (Maybe Bool -> f (Maybe Bool)) -> GetBlueprint -> f GetBlueprint
getBlueprint_includeBlueprint = (GetBlueprint -> Maybe Bool)
-> (GetBlueprint -> Maybe Bool -> GetBlueprint)
-> Lens GetBlueprint GetBlueprint (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBlueprint' {Maybe Bool
includeBlueprint :: Maybe Bool
$sel:includeBlueprint:GetBlueprint' :: GetBlueprint -> Maybe Bool
includeBlueprint} -> Maybe Bool
includeBlueprint) (\s :: GetBlueprint
s@GetBlueprint' {} Maybe Bool
a -> GetBlueprint
s {$sel:includeBlueprint:GetBlueprint' :: Maybe Bool
includeBlueprint = Maybe Bool
a} :: GetBlueprint)

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

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

instance Prelude.NFData GetBlueprint

instance Core.ToHeaders GetBlueprint where
  toHeaders :: GetBlueprint -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetBlueprint -> 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.GetBlueprint" :: 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 GetBlueprint where
  toJSON :: GetBlueprint -> Value
toJSON GetBlueprint' {Maybe Bool
Text
name :: Text
includeBlueprint :: Maybe Bool
includeParameterSpec :: Maybe Bool
$sel:name:GetBlueprint' :: GetBlueprint -> Text
$sel:includeBlueprint:GetBlueprint' :: GetBlueprint -> Maybe Bool
$sel:includeParameterSpec:GetBlueprint' :: GetBlueprint -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"IncludeParameterSpec" 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
includeParameterSpec,
            (Text
"IncludeBlueprint" 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
includeBlueprint,
            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)
          ]
      )

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

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

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

-- |
-- Create a value of 'GetBlueprintResponse' 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:
--
-- 'blueprint', 'getBlueprintResponse_blueprint' - Returns a @Blueprint@ object.
--
-- 'httpStatus', 'getBlueprintResponse_httpStatus' - The response's http status code.
newGetBlueprintResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetBlueprintResponse
newGetBlueprintResponse :: Int -> GetBlueprintResponse
newGetBlueprintResponse Int
pHttpStatus_ =
  GetBlueprintResponse' :: Maybe Blueprint -> Int -> GetBlueprintResponse
GetBlueprintResponse'
    { $sel:blueprint:GetBlueprintResponse' :: Maybe Blueprint
blueprint = Maybe Blueprint
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetBlueprintResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Returns a @Blueprint@ object.
getBlueprintResponse_blueprint :: Lens.Lens' GetBlueprintResponse (Prelude.Maybe Blueprint)
getBlueprintResponse_blueprint :: (Maybe Blueprint -> f (Maybe Blueprint))
-> GetBlueprintResponse -> f GetBlueprintResponse
getBlueprintResponse_blueprint = (GetBlueprintResponse -> Maybe Blueprint)
-> (GetBlueprintResponse
    -> Maybe Blueprint -> GetBlueprintResponse)
-> Lens
     GetBlueprintResponse
     GetBlueprintResponse
     (Maybe Blueprint)
     (Maybe Blueprint)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBlueprintResponse' {Maybe Blueprint
blueprint :: Maybe Blueprint
$sel:blueprint:GetBlueprintResponse' :: GetBlueprintResponse -> Maybe Blueprint
blueprint} -> Maybe Blueprint
blueprint) (\s :: GetBlueprintResponse
s@GetBlueprintResponse' {} Maybe Blueprint
a -> GetBlueprintResponse
s {$sel:blueprint:GetBlueprintResponse' :: Maybe Blueprint
blueprint = Maybe Blueprint
a} :: GetBlueprintResponse)

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

instance Prelude.NFData GetBlueprintResponse