{-# 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-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)
--
-- 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 Amazonka.DataBrew.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:/ '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
(PublishRecipe -> PublishRecipe -> Bool)
-> (PublishRecipe -> PublishRecipe -> Bool) -> Eq PublishRecipe
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]
(Int -> ReadS PublishRecipe)
-> ReadS [PublishRecipe]
-> ReadPrec PublishRecipe
-> ReadPrec [PublishRecipe]
-> Read 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
(Int -> PublishRecipe -> ShowS)
-> (PublishRecipe -> String)
-> ([PublishRecipe] -> ShowS)
-> Show PublishRecipe
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. PublishRecipe -> Rep PublishRecipe x)
-> (forall x. Rep PublishRecipe x -> PublishRecipe)
-> Generic PublishRecipe
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' :: Maybe Text -> Text -> PublishRecipe
PublishRecipe'
    { $sel:description:PublishRecipe' :: Maybe Text
description = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> PublishRecipe -> f PublishRecipe
publishRecipe_description = (PublishRecipe -> Maybe Text)
-> (PublishRecipe -> Maybe Text -> PublishRecipe)
-> Lens PublishRecipe PublishRecipe (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> PublishRecipe -> f PublishRecipe
publishRecipe_name = (PublishRecipe -> Text)
-> (PublishRecipe -> Text -> PublishRecipe)
-> Lens PublishRecipe PublishRecipe Text Text
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 :: PublishRecipe -> Request PublishRecipe
request = Service -> PublishRecipe -> Request PublishRecipe
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PublishRecipe
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PublishRecipe)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse PublishRecipe))
-> Logger
-> Service
-> Proxy PublishRecipe
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PublishRecipe)))
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 ->
          Int -> Text -> PublishRecipeResponse
PublishRecipeResponse'
            (Int -> Text -> PublishRecipeResponse)
-> Either String Int
-> Either String (Text -> PublishRecipeResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (Text -> PublishRecipeResponse)
-> Either String Text -> Either String PublishRecipeResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"Name")
      )

instance Prelude.Hashable PublishRecipe

instance Prelude.NFData PublishRecipe

instance Core.ToHeaders PublishRecipe where
  toHeaders :: PublishRecipe -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PublishRecipe -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description]
      )

instance Core.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
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/recipes/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
name, ByteString
"/publishRecipe"]

instance Core.ToQuery PublishRecipe where
  toQuery :: PublishRecipe -> QueryString
toQuery = QueryString -> PublishRecipe -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(PublishRecipeResponse -> PublishRecipeResponse -> Bool)
-> (PublishRecipeResponse -> PublishRecipeResponse -> Bool)
-> Eq PublishRecipeResponse
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]
(Int -> ReadS PublishRecipeResponse)
-> ReadS [PublishRecipeResponse]
-> ReadPrec PublishRecipeResponse
-> ReadPrec [PublishRecipeResponse]
-> Read 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
(Int -> PublishRecipeResponse -> ShowS)
-> (PublishRecipeResponse -> String)
-> ([PublishRecipeResponse] -> ShowS)
-> Show PublishRecipeResponse
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. PublishRecipeResponse -> Rep PublishRecipeResponse x)
-> (forall x. Rep PublishRecipeResponse x -> PublishRecipeResponse)
-> Generic PublishRecipeResponse
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' :: Int -> Text -> PublishRecipeResponse
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 :: (Int -> f Int) -> PublishRecipeResponse -> f PublishRecipeResponse
publishRecipeResponse_httpStatus = (PublishRecipeResponse -> Int)
-> (PublishRecipeResponse -> Int -> PublishRecipeResponse)
-> Lens PublishRecipeResponse PublishRecipeResponse Int Int
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 :: (Text -> f Text)
-> PublishRecipeResponse -> f PublishRecipeResponse
publishRecipeResponse_name = (PublishRecipeResponse -> Text)
-> (PublishRecipeResponse -> Text -> PublishRecipeResponse)
-> Lens PublishRecipeResponse PublishRecipeResponse Text Text
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