{-# 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.ListBlueprints
-- 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 the blueprint names in an account.
module Amazonka.Glue.ListBlueprints
  ( -- * Creating a Request
    ListBlueprints (..),
    newListBlueprints,

    -- * Request Lenses
    listBlueprints_maxResults,
    listBlueprints_nextToken,
    listBlueprints_tags,

    -- * Destructuring the Response
    ListBlueprintsResponse (..),
    newListBlueprintsResponse,

    -- * Response Lenses
    listBlueprintsResponse_blueprints,
    listBlueprintsResponse_nextToken,
    listBlueprintsResponse_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:/ 'newListBlueprints' smart constructor.
data ListBlueprints = ListBlueprints'
  { -- | The maximum size of a list to return.
    ListBlueprints -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A continuation token, if this is a continuation request.
    ListBlueprints -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Filters the list by an Amazon Web Services resource tag.
    ListBlueprints -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (ListBlueprints -> ListBlueprints -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListBlueprints -> ListBlueprints -> Bool
$c/= :: ListBlueprints -> ListBlueprints -> Bool
== :: ListBlueprints -> ListBlueprints -> Bool
$c== :: ListBlueprints -> ListBlueprints -> Bool
Prelude.Eq, ReadPrec [ListBlueprints]
ReadPrec ListBlueprints
Int -> ReadS ListBlueprints
ReadS [ListBlueprints]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListBlueprints]
$creadListPrec :: ReadPrec [ListBlueprints]
readPrec :: ReadPrec ListBlueprints
$creadPrec :: ReadPrec ListBlueprints
readList :: ReadS [ListBlueprints]
$creadList :: ReadS [ListBlueprints]
readsPrec :: Int -> ReadS ListBlueprints
$creadsPrec :: Int -> ReadS ListBlueprints
Prelude.Read, Int -> ListBlueprints -> ShowS
[ListBlueprints] -> ShowS
ListBlueprints -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListBlueprints] -> ShowS
$cshowList :: [ListBlueprints] -> ShowS
show :: ListBlueprints -> String
$cshow :: ListBlueprints -> String
showsPrec :: Int -> ListBlueprints -> ShowS
$cshowsPrec :: Int -> ListBlueprints -> ShowS
Prelude.Show, forall x. Rep ListBlueprints x -> ListBlueprints
forall x. ListBlueprints -> Rep ListBlueprints x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListBlueprints x -> ListBlueprints
$cfrom :: forall x. ListBlueprints -> Rep ListBlueprints x
Prelude.Generic)

-- |
-- Create a value of 'ListBlueprints' 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', 'listBlueprints_maxResults' - The maximum size of a list to return.
--
-- 'nextToken', 'listBlueprints_nextToken' - A continuation token, if this is a continuation request.
--
-- 'tags', 'listBlueprints_tags' - Filters the list by an Amazon Web Services resource tag.
newListBlueprints ::
  ListBlueprints
newListBlueprints :: ListBlueprints
newListBlueprints =
  ListBlueprints'
    { $sel:maxResults:ListBlueprints' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListBlueprints' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:ListBlueprints' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum size of a list to return.
listBlueprints_maxResults :: Lens.Lens' ListBlueprints (Prelude.Maybe Prelude.Natural)
listBlueprints_maxResults :: Lens' ListBlueprints (Maybe Natural)
listBlueprints_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBlueprints' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListBlueprints' :: ListBlueprints -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListBlueprints
s@ListBlueprints' {} Maybe Natural
a -> ListBlueprints
s {$sel:maxResults:ListBlueprints' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListBlueprints)

-- | A continuation token, if this is a continuation request.
listBlueprints_nextToken :: Lens.Lens' ListBlueprints (Prelude.Maybe Prelude.Text)
listBlueprints_nextToken :: Lens' ListBlueprints (Maybe Text)
listBlueprints_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBlueprints' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListBlueprints' :: ListBlueprints -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListBlueprints
s@ListBlueprints' {} Maybe Text
a -> ListBlueprints
s {$sel:nextToken:ListBlueprints' :: Maybe Text
nextToken = Maybe Text
a} :: ListBlueprints)

-- | Filters the list by an Amazon Web Services resource tag.
listBlueprints_tags :: Lens.Lens' ListBlueprints (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
listBlueprints_tags :: Lens' ListBlueprints (Maybe (HashMap Text Text))
listBlueprints_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBlueprints' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:ListBlueprints' :: ListBlueprints -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: ListBlueprints
s@ListBlueprints' {} Maybe (HashMap Text Text)
a -> ListBlueprints
s {$sel:tags:ListBlueprints' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: ListBlueprints) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest ListBlueprints where
  type
    AWSResponse ListBlueprints =
      ListBlueprintsResponse
  request :: (Service -> Service) -> ListBlueprints -> Request ListBlueprints
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 ListBlueprints
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListBlueprints)))
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] -> Maybe Text -> Int -> ListBlueprintsResponse
ListBlueprintsResponse'
            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
"Blueprints" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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
"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))
      )

instance Prelude.Hashable ListBlueprints where
  hashWithSalt :: Int -> ListBlueprints -> Int
hashWithSalt Int
_salt ListBlueprints' {Maybe Natural
Maybe Text
Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:tags:ListBlueprints' :: ListBlueprints -> Maybe (HashMap Text Text)
$sel:nextToken:ListBlueprints' :: ListBlueprints -> Maybe Text
$sel:maxResults:ListBlueprints' :: ListBlueprints -> 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 (HashMap Text Text)
tags

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

instance Data.ToHeaders ListBlueprints where
  toHeaders :: ListBlueprints -> 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.ListBlueprints" :: 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 ListBlueprints where
  toJSON :: ListBlueprints -> Value
toJSON ListBlueprints' {Maybe Natural
Maybe Text
Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:tags:ListBlueprints' :: ListBlueprints -> Maybe (HashMap Text Text)
$sel:nextToken:ListBlueprints' :: ListBlueprints -> Maybe Text
$sel:maxResults:ListBlueprints' :: ListBlueprints -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MaxResults" 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 Natural
maxResults,
            (Key
"NextToken" 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
nextToken,
            (Key
"Tags" 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 (HashMap Text Text)
tags
          ]
      )

instance Data.ToPath ListBlueprints where
  toPath :: ListBlueprints -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newListBlueprintsResponse' smart constructor.
data ListBlueprintsResponse = ListBlueprintsResponse'
  { -- | List of names of blueprints in the account.
    ListBlueprintsResponse -> Maybe [Text]
blueprints :: Prelude.Maybe [Prelude.Text],
    -- | A continuation token, if not all blueprint names have been returned.
    ListBlueprintsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListBlueprintsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListBlueprintsResponse -> ListBlueprintsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListBlueprintsResponse -> ListBlueprintsResponse -> Bool
$c/= :: ListBlueprintsResponse -> ListBlueprintsResponse -> Bool
== :: ListBlueprintsResponse -> ListBlueprintsResponse -> Bool
$c== :: ListBlueprintsResponse -> ListBlueprintsResponse -> Bool
Prelude.Eq, ReadPrec [ListBlueprintsResponse]
ReadPrec ListBlueprintsResponse
Int -> ReadS ListBlueprintsResponse
ReadS [ListBlueprintsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListBlueprintsResponse]
$creadListPrec :: ReadPrec [ListBlueprintsResponse]
readPrec :: ReadPrec ListBlueprintsResponse
$creadPrec :: ReadPrec ListBlueprintsResponse
readList :: ReadS [ListBlueprintsResponse]
$creadList :: ReadS [ListBlueprintsResponse]
readsPrec :: Int -> ReadS ListBlueprintsResponse
$creadsPrec :: Int -> ReadS ListBlueprintsResponse
Prelude.Read, Int -> ListBlueprintsResponse -> ShowS
[ListBlueprintsResponse] -> ShowS
ListBlueprintsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListBlueprintsResponse] -> ShowS
$cshowList :: [ListBlueprintsResponse] -> ShowS
show :: ListBlueprintsResponse -> String
$cshow :: ListBlueprintsResponse -> String
showsPrec :: Int -> ListBlueprintsResponse -> ShowS
$cshowsPrec :: Int -> ListBlueprintsResponse -> ShowS
Prelude.Show, forall x. Rep ListBlueprintsResponse x -> ListBlueprintsResponse
forall x. ListBlueprintsResponse -> Rep ListBlueprintsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListBlueprintsResponse x -> ListBlueprintsResponse
$cfrom :: forall x. ListBlueprintsResponse -> Rep ListBlueprintsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListBlueprintsResponse' 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:
--
-- 'blueprints', 'listBlueprintsResponse_blueprints' - List of names of blueprints in the account.
--
-- 'nextToken', 'listBlueprintsResponse_nextToken' - A continuation token, if not all blueprint names have been returned.
--
-- 'httpStatus', 'listBlueprintsResponse_httpStatus' - The response's http status code.
newListBlueprintsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListBlueprintsResponse
newListBlueprintsResponse :: Int -> ListBlueprintsResponse
newListBlueprintsResponse Int
pHttpStatus_ =
  ListBlueprintsResponse'
    { $sel:blueprints:ListBlueprintsResponse' :: Maybe [Text]
blueprints =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListBlueprintsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListBlueprintsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | List of names of blueprints in the account.
listBlueprintsResponse_blueprints :: Lens.Lens' ListBlueprintsResponse (Prelude.Maybe [Prelude.Text])
listBlueprintsResponse_blueprints :: Lens' ListBlueprintsResponse (Maybe [Text])
listBlueprintsResponse_blueprints = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBlueprintsResponse' {Maybe [Text]
blueprints :: Maybe [Text]
$sel:blueprints:ListBlueprintsResponse' :: ListBlueprintsResponse -> Maybe [Text]
blueprints} -> Maybe [Text]
blueprints) (\s :: ListBlueprintsResponse
s@ListBlueprintsResponse' {} Maybe [Text]
a -> ListBlueprintsResponse
s {$sel:blueprints:ListBlueprintsResponse' :: Maybe [Text]
blueprints = Maybe [Text]
a} :: ListBlueprintsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A continuation token, if not all blueprint names have been returned.
listBlueprintsResponse_nextToken :: Lens.Lens' ListBlueprintsResponse (Prelude.Maybe Prelude.Text)
listBlueprintsResponse_nextToken :: Lens' ListBlueprintsResponse (Maybe Text)
listBlueprintsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBlueprintsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListBlueprintsResponse' :: ListBlueprintsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListBlueprintsResponse
s@ListBlueprintsResponse' {} Maybe Text
a -> ListBlueprintsResponse
s {$sel:nextToken:ListBlueprintsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListBlueprintsResponse)

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

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