{-# 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.ListRecipes
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists all of the DataBrew recipes that are defined.
--
-- This operation returns paginated results.
module Amazonka.DataBrew.ListRecipes
  ( -- * Creating a Request
    ListRecipes (..),
    newListRecipes,

    -- * Request Lenses
    listRecipes_maxResults,
    listRecipes_nextToken,
    listRecipes_recipeVersion,

    -- * Destructuring the Response
    ListRecipesResponse (..),
    newListRecipesResponse,

    -- * Response Lenses
    listRecipesResponse_nextToken,
    listRecipesResponse_httpStatus,
    listRecipesResponse_recipes,
  )
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:/ 'newListRecipes' smart constructor.
data ListRecipes = ListRecipes'
  { -- | The maximum number of results to return in this request.
    ListRecipes -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token returned by a previous call to retrieve the next set of
    -- results.
    ListRecipes -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Return only those recipes with a version identifier of @LATEST_WORKING@
    -- or @LATEST_PUBLISHED@. If @RecipeVersion@ is omitted, @ListRecipes@
    -- returns all of the @LATEST_PUBLISHED@ recipe versions.
    --
    -- Valid values: @LATEST_WORKING@ | @LATEST_PUBLISHED@
    ListRecipes -> Maybe Text
recipeVersion :: Prelude.Maybe Prelude.Text
  }
  deriving (ListRecipes -> ListRecipes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListRecipes -> ListRecipes -> Bool
$c/= :: ListRecipes -> ListRecipes -> Bool
== :: ListRecipes -> ListRecipes -> Bool
$c== :: ListRecipes -> ListRecipes -> Bool
Prelude.Eq, ReadPrec [ListRecipes]
ReadPrec ListRecipes
Int -> ReadS ListRecipes
ReadS [ListRecipes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListRecipes]
$creadListPrec :: ReadPrec [ListRecipes]
readPrec :: ReadPrec ListRecipes
$creadPrec :: ReadPrec ListRecipes
readList :: ReadS [ListRecipes]
$creadList :: ReadS [ListRecipes]
readsPrec :: Int -> ReadS ListRecipes
$creadsPrec :: Int -> ReadS ListRecipes
Prelude.Read, Int -> ListRecipes -> ShowS
[ListRecipes] -> ShowS
ListRecipes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListRecipes] -> ShowS
$cshowList :: [ListRecipes] -> ShowS
show :: ListRecipes -> String
$cshow :: ListRecipes -> String
showsPrec :: Int -> ListRecipes -> ShowS
$cshowsPrec :: Int -> ListRecipes -> ShowS
Prelude.Show, forall x. Rep ListRecipes x -> ListRecipes
forall x. ListRecipes -> Rep ListRecipes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListRecipes x -> ListRecipes
$cfrom :: forall x. ListRecipes -> Rep ListRecipes x
Prelude.Generic)

-- |
-- Create a value of 'ListRecipes' 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:
--
-- 'maxResults', 'listRecipes_maxResults' - The maximum number of results to return in this request.
--
-- 'nextToken', 'listRecipes_nextToken' - The token returned by a previous call to retrieve the next set of
-- results.
--
-- 'recipeVersion', 'listRecipes_recipeVersion' - Return only those recipes with a version identifier of @LATEST_WORKING@
-- or @LATEST_PUBLISHED@. If @RecipeVersion@ is omitted, @ListRecipes@
-- returns all of the @LATEST_PUBLISHED@ recipe versions.
--
-- Valid values: @LATEST_WORKING@ | @LATEST_PUBLISHED@
newListRecipes ::
  ListRecipes
newListRecipes :: ListRecipes
newListRecipes =
  ListRecipes'
    { $sel:maxResults:ListRecipes' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListRecipes' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:recipeVersion:ListRecipes' :: Maybe Text
recipeVersion = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of results to return in this request.
listRecipes_maxResults :: Lens.Lens' ListRecipes (Prelude.Maybe Prelude.Natural)
listRecipes_maxResults :: Lens' ListRecipes (Maybe Natural)
listRecipes_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRecipes' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListRecipes' :: ListRecipes -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListRecipes
s@ListRecipes' {} Maybe Natural
a -> ListRecipes
s {$sel:maxResults:ListRecipes' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListRecipes)

-- | The token returned by a previous call to retrieve the next set of
-- results.
listRecipes_nextToken :: Lens.Lens' ListRecipes (Prelude.Maybe Prelude.Text)
listRecipes_nextToken :: Lens' ListRecipes (Maybe Text)
listRecipes_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRecipes' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListRecipes' :: ListRecipes -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListRecipes
s@ListRecipes' {} Maybe Text
a -> ListRecipes
s {$sel:nextToken:ListRecipes' :: Maybe Text
nextToken = Maybe Text
a} :: ListRecipes)

-- | Return only those recipes with a version identifier of @LATEST_WORKING@
-- or @LATEST_PUBLISHED@. If @RecipeVersion@ is omitted, @ListRecipes@
-- returns all of the @LATEST_PUBLISHED@ recipe versions.
--
-- Valid values: @LATEST_WORKING@ | @LATEST_PUBLISHED@
listRecipes_recipeVersion :: Lens.Lens' ListRecipes (Prelude.Maybe Prelude.Text)
listRecipes_recipeVersion :: Lens' ListRecipes (Maybe Text)
listRecipes_recipeVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRecipes' {Maybe Text
recipeVersion :: Maybe Text
$sel:recipeVersion:ListRecipes' :: ListRecipes -> Maybe Text
recipeVersion} -> Maybe Text
recipeVersion) (\s :: ListRecipes
s@ListRecipes' {} Maybe Text
a -> ListRecipes
s {$sel:recipeVersion:ListRecipes' :: Maybe Text
recipeVersion = Maybe Text
a} :: ListRecipes)

instance Core.AWSPager ListRecipes where
  page :: ListRecipes -> AWSResponse ListRecipes -> Maybe ListRecipes
page ListRecipes
rq AWSResponse ListRecipes
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListRecipes
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRecipesResponse (Maybe Text)
listRecipesResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop (AWSResponse ListRecipes
rs forall s a. s -> Getting a s a -> a
Lens.^. Lens' ListRecipesResponse [Recipe]
listRecipesResponse_recipes) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListRecipes
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListRecipes (Maybe Text)
listRecipes_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListRecipes
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRecipesResponse (Maybe Text)
listRecipesResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListRecipes where
  type AWSResponse ListRecipes = ListRecipesResponse
  request :: (Service -> Service) -> ListRecipes -> Request ListRecipes
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListRecipes
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListRecipes)))
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 -> [Recipe] -> ListRecipesResponse
ListRecipesResponse'
            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
"NextToken")
            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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Recipes" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ListRecipes where
  hashWithSalt :: Int -> ListRecipes -> Int
hashWithSalt Int
_salt ListRecipes' {Maybe Natural
Maybe Text
recipeVersion :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:recipeVersion:ListRecipes' :: ListRecipes -> Maybe Text
$sel:nextToken:ListRecipes' :: ListRecipes -> Maybe Text
$sel:maxResults:ListRecipes' :: ListRecipes -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
recipeVersion

instance Prelude.NFData ListRecipes where
  rnf :: ListRecipes -> ()
rnf ListRecipes' {Maybe Natural
Maybe Text
recipeVersion :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:recipeVersion:ListRecipes' :: ListRecipes -> Maybe Text
$sel:nextToken:ListRecipes' :: ListRecipes -> Maybe Text
$sel:maxResults:ListRecipes' :: ListRecipes -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
recipeVersion

instance Data.ToHeaders ListRecipes where
  toHeaders :: ListRecipes -> 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.ToPath ListRecipes where
  toPath :: ListRecipes -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/recipes"

instance Data.ToQuery ListRecipes where
  toQuery :: ListRecipes -> QueryString
toQuery ListRecipes' {Maybe Natural
Maybe Text
recipeVersion :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:recipeVersion:ListRecipes' :: ListRecipes -> Maybe Text
$sel:nextToken:ListRecipes' :: ListRecipes -> Maybe Text
$sel:maxResults:ListRecipes' :: ListRecipes -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken,
        ByteString
"recipeVersion" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
recipeVersion
      ]

-- | /See:/ 'newListRecipesResponse' smart constructor.
data ListRecipesResponse = ListRecipesResponse'
  { -- | A token that you can use in a subsequent call to retrieve the next set
    -- of results.
    ListRecipesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListRecipesResponse -> Int
httpStatus :: Prelude.Int,
    -- | A list of recipes that are defined.
    ListRecipesResponse -> [Recipe]
recipes :: [Recipe]
  }
  deriving (ListRecipesResponse -> ListRecipesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListRecipesResponse -> ListRecipesResponse -> Bool
$c/= :: ListRecipesResponse -> ListRecipesResponse -> Bool
== :: ListRecipesResponse -> ListRecipesResponse -> Bool
$c== :: ListRecipesResponse -> ListRecipesResponse -> Bool
Prelude.Eq, ReadPrec [ListRecipesResponse]
ReadPrec ListRecipesResponse
Int -> ReadS ListRecipesResponse
ReadS [ListRecipesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListRecipesResponse]
$creadListPrec :: ReadPrec [ListRecipesResponse]
readPrec :: ReadPrec ListRecipesResponse
$creadPrec :: ReadPrec ListRecipesResponse
readList :: ReadS [ListRecipesResponse]
$creadList :: ReadS [ListRecipesResponse]
readsPrec :: Int -> ReadS ListRecipesResponse
$creadsPrec :: Int -> ReadS ListRecipesResponse
Prelude.Read, Int -> ListRecipesResponse -> ShowS
[ListRecipesResponse] -> ShowS
ListRecipesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListRecipesResponse] -> ShowS
$cshowList :: [ListRecipesResponse] -> ShowS
show :: ListRecipesResponse -> String
$cshow :: ListRecipesResponse -> String
showsPrec :: Int -> ListRecipesResponse -> ShowS
$cshowsPrec :: Int -> ListRecipesResponse -> ShowS
Prelude.Show, forall x. Rep ListRecipesResponse x -> ListRecipesResponse
forall x. ListRecipesResponse -> Rep ListRecipesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListRecipesResponse x -> ListRecipesResponse
$cfrom :: forall x. ListRecipesResponse -> Rep ListRecipesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListRecipesResponse' 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:
--
-- 'nextToken', 'listRecipesResponse_nextToken' - A token that you can use in a subsequent call to retrieve the next set
-- of results.
--
-- 'httpStatus', 'listRecipesResponse_httpStatus' - The response's http status code.
--
-- 'recipes', 'listRecipesResponse_recipes' - A list of recipes that are defined.
newListRecipesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListRecipesResponse
newListRecipesResponse :: Int -> ListRecipesResponse
newListRecipesResponse Int
pHttpStatus_ =
  ListRecipesResponse'
    { $sel:nextToken:ListRecipesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListRecipesResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:recipes:ListRecipesResponse' :: [Recipe]
recipes = forall a. Monoid a => a
Prelude.mempty
    }

-- | A token that you can use in a subsequent call to retrieve the next set
-- of results.
listRecipesResponse_nextToken :: Lens.Lens' ListRecipesResponse (Prelude.Maybe Prelude.Text)
listRecipesResponse_nextToken :: Lens' ListRecipesResponse (Maybe Text)
listRecipesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRecipesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListRecipesResponse' :: ListRecipesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListRecipesResponse
s@ListRecipesResponse' {} Maybe Text
a -> ListRecipesResponse
s {$sel:nextToken:ListRecipesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListRecipesResponse)

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

-- | A list of recipes that are defined.
listRecipesResponse_recipes :: Lens.Lens' ListRecipesResponse [Recipe]
listRecipesResponse_recipes :: Lens' ListRecipesResponse [Recipe]
listRecipesResponse_recipes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRecipesResponse' {[Recipe]
recipes :: [Recipe]
$sel:recipes:ListRecipesResponse' :: ListRecipesResponse -> [Recipe]
recipes} -> [Recipe]
recipes) (\s :: ListRecipesResponse
s@ListRecipesResponse' {} [Recipe]
a -> ListRecipesResponse
s {$sel:recipes:ListRecipesResponse' :: [Recipe]
recipes = [Recipe]
a} :: ListRecipesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ListRecipesResponse where
  rnf :: ListRecipesResponse -> ()
rnf ListRecipesResponse' {Int
[Recipe]
Maybe Text
recipes :: [Recipe]
httpStatus :: Int
nextToken :: Maybe Text
$sel:recipes:ListRecipesResponse' :: ListRecipesResponse -> [Recipe]
$sel:httpStatus:ListRecipesResponse' :: ListRecipesResponse -> Int
$sel:nextToken:ListRecipesResponse' :: ListRecipesResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 [Recipe]
recipes