{-# 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.ListRecipeVersions
-- 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 the versions of a particular DataBrew recipe, except for
-- @LATEST_WORKING@.
--
-- This operation returns paginated results.
module Amazonka.DataBrew.ListRecipeVersions
  ( -- * Creating a Request
    ListRecipeVersions (..),
    newListRecipeVersions,

    -- * Request Lenses
    listRecipeVersions_maxResults,
    listRecipeVersions_nextToken,
    listRecipeVersions_name,

    -- * Destructuring the Response
    ListRecipeVersionsResponse (..),
    newListRecipeVersionsResponse,

    -- * Response Lenses
    listRecipeVersionsResponse_nextToken,
    listRecipeVersionsResponse_httpStatus,
    listRecipeVersionsResponse_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:/ 'newListRecipeVersions' smart constructor.
data ListRecipeVersions = ListRecipeVersions'
  { -- | The maximum number of results to return in this request.
    ListRecipeVersions -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token returned by a previous call to retrieve the next set of
    -- results.
    ListRecipeVersions -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the recipe for which to return version information.
    ListRecipeVersions -> Text
name :: Prelude.Text
  }
  deriving (ListRecipeVersions -> ListRecipeVersions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListRecipeVersions -> ListRecipeVersions -> Bool
$c/= :: ListRecipeVersions -> ListRecipeVersions -> Bool
== :: ListRecipeVersions -> ListRecipeVersions -> Bool
$c== :: ListRecipeVersions -> ListRecipeVersions -> Bool
Prelude.Eq, ReadPrec [ListRecipeVersions]
ReadPrec ListRecipeVersions
Int -> ReadS ListRecipeVersions
ReadS [ListRecipeVersions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListRecipeVersions]
$creadListPrec :: ReadPrec [ListRecipeVersions]
readPrec :: ReadPrec ListRecipeVersions
$creadPrec :: ReadPrec ListRecipeVersions
readList :: ReadS [ListRecipeVersions]
$creadList :: ReadS [ListRecipeVersions]
readsPrec :: Int -> ReadS ListRecipeVersions
$creadsPrec :: Int -> ReadS ListRecipeVersions
Prelude.Read, Int -> ListRecipeVersions -> ShowS
[ListRecipeVersions] -> ShowS
ListRecipeVersions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListRecipeVersions] -> ShowS
$cshowList :: [ListRecipeVersions] -> ShowS
show :: ListRecipeVersions -> String
$cshow :: ListRecipeVersions -> String
showsPrec :: Int -> ListRecipeVersions -> ShowS
$cshowsPrec :: Int -> ListRecipeVersions -> ShowS
Prelude.Show, forall x. Rep ListRecipeVersions x -> ListRecipeVersions
forall x. ListRecipeVersions -> Rep ListRecipeVersions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListRecipeVersions x -> ListRecipeVersions
$cfrom :: forall x. ListRecipeVersions -> Rep ListRecipeVersions x
Prelude.Generic)

-- |
-- Create a value of 'ListRecipeVersions' 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', 'listRecipeVersions_maxResults' - The maximum number of results to return in this request.
--
-- 'nextToken', 'listRecipeVersions_nextToken' - The token returned by a previous call to retrieve the next set of
-- results.
--
-- 'name', 'listRecipeVersions_name' - The name of the recipe for which to return version information.
newListRecipeVersions ::
  -- | 'name'
  Prelude.Text ->
  ListRecipeVersions
newListRecipeVersions :: Text -> ListRecipeVersions
newListRecipeVersions Text
pName_ =
  ListRecipeVersions'
    { $sel:maxResults:ListRecipeVersions' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListRecipeVersions' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ListRecipeVersions' :: Text
name = Text
pName_
    }

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

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

-- | The name of the recipe for which to return version information.
listRecipeVersions_name :: Lens.Lens' ListRecipeVersions Prelude.Text
listRecipeVersions_name :: Lens' ListRecipeVersions Text
listRecipeVersions_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRecipeVersions' {Text
name :: Text
$sel:name:ListRecipeVersions' :: ListRecipeVersions -> Text
name} -> Text
name) (\s :: ListRecipeVersions
s@ListRecipeVersions' {} Text
a -> ListRecipeVersions
s {$sel:name:ListRecipeVersions' :: Text
name = Text
a} :: ListRecipeVersions)

instance Core.AWSPager ListRecipeVersions where
  page :: ListRecipeVersions
-> AWSResponse ListRecipeVersions -> Maybe ListRecipeVersions
page ListRecipeVersions
rq AWSResponse ListRecipeVersions
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListRecipeVersions
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRecipeVersionsResponse (Maybe Text)
listRecipeVersionsResponse_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 ListRecipeVersions
rs forall s a. s -> Getting a s a -> a
Lens.^. Lens' ListRecipeVersionsResponse [Recipe]
listRecipeVersionsResponse_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.$ ListRecipeVersions
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListRecipeVersions (Maybe Text)
listRecipeVersions_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListRecipeVersions
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRecipeVersionsResponse (Maybe Text)
listRecipeVersionsResponse_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 ListRecipeVersions where
  type
    AWSResponse ListRecipeVersions =
      ListRecipeVersionsResponse
  request :: (Service -> Service)
-> ListRecipeVersions -> Request ListRecipeVersions
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 ListRecipeVersions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListRecipeVersions)))
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] -> ListRecipeVersionsResponse
ListRecipeVersionsResponse'
            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 ListRecipeVersions where
  hashWithSalt :: Int -> ListRecipeVersions -> Int
hashWithSalt Int
_salt ListRecipeVersions' {Maybe Natural
Maybe Text
Text
name :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:name:ListRecipeVersions' :: ListRecipeVersions -> Text
$sel:nextToken:ListRecipeVersions' :: ListRecipeVersions -> Maybe Text
$sel:maxResults:ListRecipeVersions' :: ListRecipeVersions -> 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` Text
name

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

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

instance Data.ToQuery ListRecipeVersions where
  toQuery :: ListRecipeVersions -> QueryString
toQuery ListRecipeVersions' {Maybe Natural
Maybe Text
Text
name :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:name:ListRecipeVersions' :: ListRecipeVersions -> Text
$sel:nextToken:ListRecipeVersions' :: ListRecipeVersions -> Maybe Text
$sel:maxResults:ListRecipeVersions' :: ListRecipeVersions -> 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
"name" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
name
      ]

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

-- |
-- Create a value of 'ListRecipeVersionsResponse' 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', 'listRecipeVersionsResponse_nextToken' - A token that you can use in a subsequent call to retrieve the next set
-- of results.
--
-- 'httpStatus', 'listRecipeVersionsResponse_httpStatus' - The response's http status code.
--
-- 'recipes', 'listRecipeVersionsResponse_recipes' - A list of versions for the specified recipe.
newListRecipeVersionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListRecipeVersionsResponse
newListRecipeVersionsResponse :: Int -> ListRecipeVersionsResponse
newListRecipeVersionsResponse Int
pHttpStatus_ =
  ListRecipeVersionsResponse'
    { $sel:nextToken:ListRecipeVersionsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListRecipeVersionsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:recipes:ListRecipeVersionsResponse' :: [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.
listRecipeVersionsResponse_nextToken :: Lens.Lens' ListRecipeVersionsResponse (Prelude.Maybe Prelude.Text)
listRecipeVersionsResponse_nextToken :: Lens' ListRecipeVersionsResponse (Maybe Text)
listRecipeVersionsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRecipeVersionsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListRecipeVersionsResponse' :: ListRecipeVersionsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListRecipeVersionsResponse
s@ListRecipeVersionsResponse' {} Maybe Text
a -> ListRecipeVersionsResponse
s {$sel:nextToken:ListRecipeVersionsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListRecipeVersionsResponse)

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

-- | A list of versions for the specified recipe.
listRecipeVersionsResponse_recipes :: Lens.Lens' ListRecipeVersionsResponse [Recipe]
listRecipeVersionsResponse_recipes :: Lens' ListRecipeVersionsResponse [Recipe]
listRecipeVersionsResponse_recipes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRecipeVersionsResponse' {[Recipe]
recipes :: [Recipe]
$sel:recipes:ListRecipeVersionsResponse' :: ListRecipeVersionsResponse -> [Recipe]
recipes} -> [Recipe]
recipes) (\s :: ListRecipeVersionsResponse
s@ListRecipeVersionsResponse' {} [Recipe]
a -> ListRecipeVersionsResponse
s {$sel:recipes:ListRecipeVersionsResponse' :: [Recipe]
recipes = [Recipe]
a} :: ListRecipeVersionsResponse) 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 ListRecipeVersionsResponse where
  rnf :: ListRecipeVersionsResponse -> ()
rnf ListRecipeVersionsResponse' {Int
[Recipe]
Maybe Text
recipes :: [Recipe]
httpStatus :: Int
nextToken :: Maybe Text
$sel:recipes:ListRecipeVersionsResponse' :: ListRecipeVersionsResponse -> [Recipe]
$sel:httpStatus:ListRecipeVersionsResponse' :: ListRecipeVersionsResponse -> Int
$sel:nextToken:ListRecipeVersionsResponse' :: ListRecipeVersionsResponse -> 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