{-# 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.DataBrew.PublishRecipe
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Publishes a new version of a DataBrew recipe.
module Amazonka.DataBrew.PublishRecipe
  ( -- * Creating a Request
    PublishRecipe (..),
    newPublishRecipe,

    -- * Request Lenses
    publishRecipe_description,
    publishRecipe_name,

    -- * Destructuring the Response
    PublishRecipeResponse (..),
    newPublishRecipeResponse,

    -- * Response Lenses
    publishRecipeResponse_httpStatus,
    publishRecipeResponse_name,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DataBrew.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newPublishRecipe' smart constructor.
data PublishRecipe = PublishRecipe'
  { -- | A description of the recipe to be published, for this version of the
    -- recipe.
    PublishRecipe -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The name of the recipe to be published.
    PublishRecipe -> Text
name :: Prelude.Text
  }
  deriving (PublishRecipe -> PublishRecipe -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PublishRecipe -> PublishRecipe -> Bool
$c/= :: PublishRecipe -> PublishRecipe -> Bool
== :: PublishRecipe -> PublishRecipe -> Bool
$c== :: PublishRecipe -> PublishRecipe -> Bool
Prelude.Eq, ReadPrec [PublishRecipe]
ReadPrec PublishRecipe
Int -> ReadS PublishRecipe
ReadS [PublishRecipe]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PublishRecipe]
$creadListPrec :: ReadPrec [PublishRecipe]
readPrec :: ReadPrec PublishRecipe
$creadPrec :: ReadPrec PublishRecipe
readList :: ReadS [PublishRecipe]
$creadList :: ReadS [PublishRecipe]
readsPrec :: Int -> ReadS PublishRecipe
$creadsPrec :: Int -> ReadS PublishRecipe
Prelude.Read, Int -> PublishRecipe -> ShowS
[PublishRecipe] -> ShowS
PublishRecipe -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PublishRecipe] -> ShowS
$cshowList :: [PublishRecipe] -> ShowS
show :: PublishRecipe -> String
$cshow :: PublishRecipe -> String
showsPrec :: Int -> PublishRecipe -> ShowS
$cshowsPrec :: Int -> PublishRecipe -> ShowS
Prelude.Show, forall x. Rep PublishRecipe x -> PublishRecipe
forall x. PublishRecipe -> Rep PublishRecipe x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PublishRecipe x -> PublishRecipe
$cfrom :: forall x. PublishRecipe -> Rep PublishRecipe x
Prelude.Generic)

-- |
-- Create a value of 'PublishRecipe' 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', 'publishRecipe_description' - A description of the recipe to be published, for this version of the
-- recipe.
--
-- 'name', 'publishRecipe_name' - The name of the recipe to be published.
newPublishRecipe ::
  -- | 'name'
  Prelude.Text ->
  PublishRecipe
newPublishRecipe :: Text -> PublishRecipe
newPublishRecipe Text
pName_ =
  PublishRecipe'
    { $sel:description:PublishRecipe' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:name:PublishRecipe' :: Text
name = Text
pName_
    }

-- | A description of the recipe to be published, for this version of the
-- recipe.
publishRecipe_description :: Lens.Lens' PublishRecipe (Prelude.Maybe Prelude.Text)
publishRecipe_description :: Lens' PublishRecipe (Maybe Text)
publishRecipe_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublishRecipe' {Maybe Text
description :: Maybe Text
$sel:description:PublishRecipe' :: PublishRecipe -> Maybe Text
description} -> Maybe Text
description) (\s :: PublishRecipe
s@PublishRecipe' {} Maybe Text
a -> PublishRecipe
s {$sel:description:PublishRecipe' :: Maybe Text
description = Maybe Text
a} :: PublishRecipe)

-- | The name of the recipe to be published.
publishRecipe_name :: Lens.Lens' PublishRecipe Prelude.Text
publishRecipe_name :: Lens' PublishRecipe Text
publishRecipe_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublishRecipe' {Text
name :: Text
$sel:name:PublishRecipe' :: PublishRecipe -> Text
name} -> Text
name) (\s :: PublishRecipe
s@PublishRecipe' {} Text
a -> PublishRecipe
s {$sel:name:PublishRecipe' :: Text
name = Text
a} :: PublishRecipe)

instance Core.AWSRequest PublishRecipe where
  type
    AWSResponse PublishRecipe =
      PublishRecipeResponse
  request :: (Service -> Service) -> PublishRecipe -> Request PublishRecipe
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 PublishRecipe
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PublishRecipe)))
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 ->
          Int -> Text -> PublishRecipeResponse
PublishRecipeResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"Name")
      )

instance Prelude.Hashable PublishRecipe where
  hashWithSalt :: Int -> PublishRecipe -> Int
hashWithSalt Int
_salt PublishRecipe' {Maybe Text
Text
name :: Text
description :: Maybe Text
$sel:name:PublishRecipe' :: PublishRecipe -> Text
$sel:description:PublishRecipe' :: PublishRecipe -> 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

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

instance Data.ToHeaders PublishRecipe where
  toHeaders :: PublishRecipe -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON PublishRecipe where
  toJSON :: PublishRecipe -> Value
toJSON PublishRecipe' {Maybe Text
Text
name :: Text
description :: Maybe Text
$sel:name:PublishRecipe' :: PublishRecipe -> Text
$sel:description:PublishRecipe' :: PublishRecipe -> 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]
      )

instance Data.ToPath PublishRecipe where
  toPath :: PublishRecipe -> ByteString
toPath PublishRecipe' {Maybe Text
Text
name :: Text
description :: Maybe Text
$sel:name:PublishRecipe' :: PublishRecipe -> Text
$sel:description:PublishRecipe' :: PublishRecipe -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/recipes/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
name, ByteString
"/publishRecipe"]

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

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

-- |
-- Create a value of 'PublishRecipeResponse' 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:
--
-- 'httpStatus', 'publishRecipeResponse_httpStatus' - The response's http status code.
--
-- 'name', 'publishRecipeResponse_name' - The name of the recipe that you published.
newPublishRecipeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'name'
  Prelude.Text ->
  PublishRecipeResponse
newPublishRecipeResponse :: Int -> Text -> PublishRecipeResponse
newPublishRecipeResponse Int
pHttpStatus_ Text
pName_ =
  PublishRecipeResponse'
    { $sel:httpStatus:PublishRecipeResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:name:PublishRecipeResponse' :: Text
name = Text
pName_
    }

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

-- | The name of the recipe that you published.
publishRecipeResponse_name :: Lens.Lens' PublishRecipeResponse Prelude.Text
publishRecipeResponse_name :: Lens' PublishRecipeResponse Text
publishRecipeResponse_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublishRecipeResponse' {Text
name :: Text
$sel:name:PublishRecipeResponse' :: PublishRecipeResponse -> Text
name} -> Text
name) (\s :: PublishRecipeResponse
s@PublishRecipeResponse' {} Text
a -> PublishRecipeResponse
s {$sel:name:PublishRecipeResponse' :: Text
name = Text
a} :: PublishRecipeResponse)

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