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

    -- * Request Lenses
    updateBlueprint_description,
    updateBlueprint_name,
    updateBlueprint_blueprintLocation,

    -- * Destructuring the Response
    UpdateBlueprintResponse (..),
    newUpdateBlueprintResponse,

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

-- |
-- Create a value of 'UpdateBlueprint' 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', 'updateBlueprint_description' - A description of the blueprint.
--
-- 'name', 'updateBlueprint_name' - The name of the blueprint.
--
-- 'blueprintLocation', 'updateBlueprint_blueprintLocation' - Specifies a path in Amazon S3 where the blueprint is published.
newUpdateBlueprint ::
  -- | 'name'
  Prelude.Text ->
  -- | 'blueprintLocation'
  Prelude.Text ->
  UpdateBlueprint
newUpdateBlueprint :: Text -> Text -> UpdateBlueprint
newUpdateBlueprint Text
pName_ Text
pBlueprintLocation_ =
  UpdateBlueprint'
    { $sel:description:UpdateBlueprint' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateBlueprint' :: Text
name = Text
pName_,
      $sel:blueprintLocation:UpdateBlueprint' :: Text
blueprintLocation = Text
pBlueprintLocation_
    }

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

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

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

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

instance Prelude.NFData UpdateBlueprint where
  rnf :: UpdateBlueprint -> ()
rnf UpdateBlueprint' {Maybe Text
Text
blueprintLocation :: Text
name :: Text
description :: Maybe Text
$sel:blueprintLocation:UpdateBlueprint' :: UpdateBlueprint -> Text
$sel:name:UpdateBlueprint' :: UpdateBlueprint -> Text
$sel:description:UpdateBlueprint' :: UpdateBlueprint -> 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 Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
blueprintLocation

instance Data.ToHeaders UpdateBlueprint where
  toHeaders :: UpdateBlueprint -> 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.UpdateBlueprint" :: 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 UpdateBlueprint where
  toJSON :: UpdateBlueprint -> Value
toJSON UpdateBlueprint' {Maybe Text
Text
blueprintLocation :: Text
name :: Text
description :: Maybe Text
$sel:blueprintLocation:UpdateBlueprint' :: UpdateBlueprint -> Text
$sel:name:UpdateBlueprint' :: UpdateBlueprint -> Text
$sel:description:UpdateBlueprint' :: UpdateBlueprint -> 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,
            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 UpdateBlueprint where
  toPath :: UpdateBlueprint -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

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

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