{-# 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.CreateBlueprint
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Registers a blueprint with Glue.
module Amazonka.Glue.CreateBlueprint
  ( -- * Creating a Request
    CreateBlueprint (..),
    newCreateBlueprint,

    -- * Request Lenses
    createBlueprint_description,
    createBlueprint_tags,
    createBlueprint_name,
    createBlueprint_blueprintLocation,

    -- * Destructuring the Response
    CreateBlueprintResponse (..),
    newCreateBlueprintResponse,

    -- * Response Lenses
    createBlueprintResponse_name,
    createBlueprintResponse_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:/ 'newCreateBlueprint' smart constructor.
data CreateBlueprint = CreateBlueprint'
  { -- | A description of the blueprint.
    CreateBlueprint -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The tags to be applied to this blueprint.
    CreateBlueprint -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name of the blueprint.
    CreateBlueprint -> Text
name :: Prelude.Text,
    -- | Specifies a path in Amazon S3 where the blueprint is published.
    CreateBlueprint -> Text
blueprintLocation :: Prelude.Text
  }
  deriving (CreateBlueprint -> CreateBlueprint -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateBlueprint -> CreateBlueprint -> Bool
$c/= :: CreateBlueprint -> CreateBlueprint -> Bool
== :: CreateBlueprint -> CreateBlueprint -> Bool
$c== :: CreateBlueprint -> CreateBlueprint -> Bool
Prelude.Eq, ReadPrec [CreateBlueprint]
ReadPrec CreateBlueprint
Int -> ReadS CreateBlueprint
ReadS [CreateBlueprint]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateBlueprint]
$creadListPrec :: ReadPrec [CreateBlueprint]
readPrec :: ReadPrec CreateBlueprint
$creadPrec :: ReadPrec CreateBlueprint
readList :: ReadS [CreateBlueprint]
$creadList :: ReadS [CreateBlueprint]
readsPrec :: Int -> ReadS CreateBlueprint
$creadsPrec :: Int -> ReadS CreateBlueprint
Prelude.Read, Int -> CreateBlueprint -> ShowS
[CreateBlueprint] -> ShowS
CreateBlueprint -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateBlueprint] -> ShowS
$cshowList :: [CreateBlueprint] -> ShowS
show :: CreateBlueprint -> String
$cshow :: CreateBlueprint -> String
showsPrec :: Int -> CreateBlueprint -> ShowS
$cshowsPrec :: Int -> CreateBlueprint -> ShowS
Prelude.Show, forall x. Rep CreateBlueprint x -> CreateBlueprint
forall x. CreateBlueprint -> Rep CreateBlueprint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateBlueprint x -> CreateBlueprint
$cfrom :: forall x. CreateBlueprint -> Rep CreateBlueprint x
Prelude.Generic)

-- |
-- Create a value of 'CreateBlueprint' 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:
--
-- 'description', 'createBlueprint_description' - A description of the blueprint.
--
-- 'tags', 'createBlueprint_tags' - The tags to be applied to this blueprint.
--
-- 'name', 'createBlueprint_name' - The name of the blueprint.
--
-- 'blueprintLocation', 'createBlueprint_blueprintLocation' - Specifies a path in Amazon S3 where the blueprint is published.
newCreateBlueprint ::
  -- | 'name'
  Prelude.Text ->
  -- | 'blueprintLocation'
  Prelude.Text ->
  CreateBlueprint
newCreateBlueprint :: Text -> Text -> CreateBlueprint
newCreateBlueprint Text
pName_ Text
pBlueprintLocation_ =
  CreateBlueprint'
    { $sel:description:CreateBlueprint' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateBlueprint' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateBlueprint' :: Text
name = Text
pName_,
      $sel:blueprintLocation:CreateBlueprint' :: Text
blueprintLocation = Text
pBlueprintLocation_
    }

-- | A description of the blueprint.
createBlueprint_description :: Lens.Lens' CreateBlueprint (Prelude.Maybe Prelude.Text)
createBlueprint_description :: Lens' CreateBlueprint (Maybe Text)
createBlueprint_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBlueprint' {Maybe Text
description :: Maybe Text
$sel:description:CreateBlueprint' :: CreateBlueprint -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateBlueprint
s@CreateBlueprint' {} Maybe Text
a -> CreateBlueprint
s {$sel:description:CreateBlueprint' :: Maybe Text
description = Maybe Text
a} :: CreateBlueprint)

-- | The tags to be applied to this blueprint.
createBlueprint_tags :: Lens.Lens' CreateBlueprint (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createBlueprint_tags :: Lens' CreateBlueprint (Maybe (HashMap Text Text))
createBlueprint_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBlueprint' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateBlueprint' :: CreateBlueprint -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateBlueprint
s@CreateBlueprint' {} Maybe (HashMap Text Text)
a -> CreateBlueprint
s {$sel:tags:CreateBlueprint' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateBlueprint) 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 name of the blueprint.
createBlueprint_name :: Lens.Lens' CreateBlueprint Prelude.Text
createBlueprint_name :: Lens' CreateBlueprint Text
createBlueprint_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBlueprint' {Text
name :: Text
$sel:name:CreateBlueprint' :: CreateBlueprint -> Text
name} -> Text
name) (\s :: CreateBlueprint
s@CreateBlueprint' {} Text
a -> CreateBlueprint
s {$sel:name:CreateBlueprint' :: Text
name = Text
a} :: CreateBlueprint)

-- | Specifies a path in Amazon S3 where the blueprint is published.
createBlueprint_blueprintLocation :: Lens.Lens' CreateBlueprint Prelude.Text
createBlueprint_blueprintLocation :: Lens' CreateBlueprint Text
createBlueprint_blueprintLocation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBlueprint' {Text
blueprintLocation :: Text
$sel:blueprintLocation:CreateBlueprint' :: CreateBlueprint -> Text
blueprintLocation} -> Text
blueprintLocation) (\s :: CreateBlueprint
s@CreateBlueprint' {} Text
a -> CreateBlueprint
s {$sel:blueprintLocation:CreateBlueprint' :: Text
blueprintLocation = Text
a} :: CreateBlueprint)

instance Core.AWSRequest CreateBlueprint where
  type
    AWSResponse CreateBlueprint =
      CreateBlueprintResponse
  request :: (Service -> Service) -> CreateBlueprint -> Request CreateBlueprint
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 CreateBlueprint
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateBlueprint)))
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 Text -> Int -> CreateBlueprintResponse
CreateBlueprintResponse'
            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
"Name")
            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 CreateBlueprint where
  hashWithSalt :: Int -> CreateBlueprint -> Int
hashWithSalt Int
_salt CreateBlueprint' {Maybe Text
Maybe (HashMap Text Text)
Text
blueprintLocation :: Text
name :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
$sel:blueprintLocation:CreateBlueprint' :: CreateBlueprint -> Text
$sel:name:CreateBlueprint' :: CreateBlueprint -> Text
$sel:tags:CreateBlueprint' :: CreateBlueprint -> Maybe (HashMap Text Text)
$sel:description:CreateBlueprint' :: CreateBlueprint -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
blueprintLocation

instance Prelude.NFData CreateBlueprint where
  rnf :: CreateBlueprint -> ()
rnf CreateBlueprint' {Maybe Text
Maybe (HashMap Text Text)
Text
blueprintLocation :: Text
name :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
$sel:blueprintLocation:CreateBlueprint' :: CreateBlueprint -> Text
$sel:name:CreateBlueprint' :: CreateBlueprint -> Text
$sel:tags:CreateBlueprint' :: CreateBlueprint -> Maybe (HashMap Text Text)
$sel:description:CreateBlueprint' :: CreateBlueprint -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
blueprintLocation

instance Data.ToHeaders CreateBlueprint where
  toHeaders :: CreateBlueprint -> 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.CreateBlueprint" :: 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 CreateBlueprint where
  toJSON :: CreateBlueprint -> Value
toJSON CreateBlueprint' {Maybe Text
Maybe (HashMap Text Text)
Text
blueprintLocation :: Text
name :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
$sel:blueprintLocation:CreateBlueprint' :: CreateBlueprint -> Text
$sel:name:CreateBlueprint' :: CreateBlueprint -> Text
$sel:tags:CreateBlueprint' :: CreateBlueprint -> Maybe (HashMap Text Text)
$sel:description:CreateBlueprint' :: CreateBlueprint -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Description" 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
description,
            (Key
"Tags" 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 (HashMap Text Text)
tags,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"BlueprintLocation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
blueprintLocation)
          ]
      )

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

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

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

-- |
-- Create a value of 'CreateBlueprintResponse' 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:
--
-- 'name', 'createBlueprintResponse_name' - Returns the name of the blueprint that was registered.
--
-- 'httpStatus', 'createBlueprintResponse_httpStatus' - The response's http status code.
newCreateBlueprintResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateBlueprintResponse
newCreateBlueprintResponse :: Int -> CreateBlueprintResponse
newCreateBlueprintResponse Int
pHttpStatus_ =
  CreateBlueprintResponse'
    { $sel:name:CreateBlueprintResponse' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateBlueprintResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Returns the name of the blueprint that was registered.
createBlueprintResponse_name :: Lens.Lens' CreateBlueprintResponse (Prelude.Maybe Prelude.Text)
createBlueprintResponse_name :: Lens' CreateBlueprintResponse (Maybe Text)
createBlueprintResponse_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBlueprintResponse' {Maybe Text
name :: Maybe Text
$sel:name:CreateBlueprintResponse' :: CreateBlueprintResponse -> Maybe Text
name} -> Maybe Text
name) (\s :: CreateBlueprintResponse
s@CreateBlueprintResponse' {} Maybe Text
a -> CreateBlueprintResponse
s {$sel:name:CreateBlueprintResponse' :: Maybe Text
name = Maybe Text
a} :: CreateBlueprintResponse)

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

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