{-# 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.ListCrawlers
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the names of all crawler resources in this Amazon Web Services
-- account, or the resources with the specified tag. This operation allows
-- you to see which resources are available in your account, and their
-- names.
--
-- This operation takes the optional @Tags@ field, which you can use as a
-- filter on the response so that tagged resources can be retrieved as a
-- group. If you choose to use tags filtering, only resources with the tag
-- are retrieved.
module Amazonka.Glue.ListCrawlers
  ( -- * Creating a Request
    ListCrawlers (..),
    newListCrawlers,

    -- * Request Lenses
    listCrawlers_maxResults,
    listCrawlers_nextToken,
    listCrawlers_tags,

    -- * Destructuring the Response
    ListCrawlersResponse (..),
    newListCrawlersResponse,

    -- * Response Lenses
    listCrawlersResponse_crawlerNames,
    listCrawlersResponse_nextToken,
    listCrawlersResponse_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:/ 'newListCrawlers' smart constructor.
data ListCrawlers = ListCrawlers'
  { -- | The maximum size of a list to return.
    ListCrawlers -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A continuation token, if this is a continuation request.
    ListCrawlers -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Specifies to return only these tagged resources.
    ListCrawlers -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (ListCrawlers -> ListCrawlers -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListCrawlers -> ListCrawlers -> Bool
$c/= :: ListCrawlers -> ListCrawlers -> Bool
== :: ListCrawlers -> ListCrawlers -> Bool
$c== :: ListCrawlers -> ListCrawlers -> Bool
Prelude.Eq, ReadPrec [ListCrawlers]
ReadPrec ListCrawlers
Int -> ReadS ListCrawlers
ReadS [ListCrawlers]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListCrawlers]
$creadListPrec :: ReadPrec [ListCrawlers]
readPrec :: ReadPrec ListCrawlers
$creadPrec :: ReadPrec ListCrawlers
readList :: ReadS [ListCrawlers]
$creadList :: ReadS [ListCrawlers]
readsPrec :: Int -> ReadS ListCrawlers
$creadsPrec :: Int -> ReadS ListCrawlers
Prelude.Read, Int -> ListCrawlers -> ShowS
[ListCrawlers] -> ShowS
ListCrawlers -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListCrawlers] -> ShowS
$cshowList :: [ListCrawlers] -> ShowS
show :: ListCrawlers -> String
$cshow :: ListCrawlers -> String
showsPrec :: Int -> ListCrawlers -> ShowS
$cshowsPrec :: Int -> ListCrawlers -> ShowS
Prelude.Show, forall x. Rep ListCrawlers x -> ListCrawlers
forall x. ListCrawlers -> Rep ListCrawlers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListCrawlers x -> ListCrawlers
$cfrom :: forall x. ListCrawlers -> Rep ListCrawlers x
Prelude.Generic)

-- |
-- Create a value of 'ListCrawlers' 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', 'listCrawlers_maxResults' - The maximum size of a list to return.
--
-- 'nextToken', 'listCrawlers_nextToken' - A continuation token, if this is a continuation request.
--
-- 'tags', 'listCrawlers_tags' - Specifies to return only these tagged resources.
newListCrawlers ::
  ListCrawlers
newListCrawlers :: ListCrawlers
newListCrawlers =
  ListCrawlers'
    { $sel:maxResults:ListCrawlers' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListCrawlers' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:ListCrawlers' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing
    }

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

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

-- | Specifies to return only these tagged resources.
listCrawlers_tags :: Lens.Lens' ListCrawlers (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
listCrawlers_tags :: Lens' ListCrawlers (Maybe (HashMap Text Text))
listCrawlers_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCrawlers' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:ListCrawlers' :: ListCrawlers -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: ListCrawlers
s@ListCrawlers' {} Maybe (HashMap Text Text)
a -> ListCrawlers
s {$sel:tags:ListCrawlers' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: ListCrawlers) 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 ListCrawlers where
  type AWSResponse ListCrawlers = ListCrawlersResponse
  request :: (Service -> Service) -> ListCrawlers -> Request ListCrawlers
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 ListCrawlers
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListCrawlers)))
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 -> ListCrawlersResponse
ListCrawlersResponse'
            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
"CrawlerNames" 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 ListCrawlers where
  hashWithSalt :: Int -> ListCrawlers -> Int
hashWithSalt Int
_salt ListCrawlers' {Maybe Natural
Maybe Text
Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:tags:ListCrawlers' :: ListCrawlers -> Maybe (HashMap Text Text)
$sel:nextToken:ListCrawlers' :: ListCrawlers -> Maybe Text
$sel:maxResults:ListCrawlers' :: ListCrawlers -> 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 ListCrawlers where
  rnf :: ListCrawlers -> ()
rnf ListCrawlers' {Maybe Natural
Maybe Text
Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:tags:ListCrawlers' :: ListCrawlers -> Maybe (HashMap Text Text)
$sel:nextToken:ListCrawlers' :: ListCrawlers -> Maybe Text
$sel:maxResults:ListCrawlers' :: ListCrawlers -> 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 ListCrawlers where
  toHeaders :: ListCrawlers -> 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.ListCrawlers" :: 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 ListCrawlers where
  toJSON :: ListCrawlers -> Value
toJSON ListCrawlers' {Maybe Natural
Maybe Text
Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:tags:ListCrawlers' :: ListCrawlers -> Maybe (HashMap Text Text)
$sel:nextToken:ListCrawlers' :: ListCrawlers -> Maybe Text
$sel:maxResults:ListCrawlers' :: ListCrawlers -> 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 ListCrawlers where
  toPath :: ListCrawlers -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newListCrawlersResponse' smart constructor.
data ListCrawlersResponse = ListCrawlersResponse'
  { -- | The names of all crawlers in the account, or the crawlers with the
    -- specified tags.
    ListCrawlersResponse -> Maybe [Text]
crawlerNames :: Prelude.Maybe [Prelude.Text],
    -- | A continuation token, if the returned list does not contain the last
    -- metric available.
    ListCrawlersResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListCrawlersResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListCrawlersResponse -> ListCrawlersResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListCrawlersResponse -> ListCrawlersResponse -> Bool
$c/= :: ListCrawlersResponse -> ListCrawlersResponse -> Bool
== :: ListCrawlersResponse -> ListCrawlersResponse -> Bool
$c== :: ListCrawlersResponse -> ListCrawlersResponse -> Bool
Prelude.Eq, ReadPrec [ListCrawlersResponse]
ReadPrec ListCrawlersResponse
Int -> ReadS ListCrawlersResponse
ReadS [ListCrawlersResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListCrawlersResponse]
$creadListPrec :: ReadPrec [ListCrawlersResponse]
readPrec :: ReadPrec ListCrawlersResponse
$creadPrec :: ReadPrec ListCrawlersResponse
readList :: ReadS [ListCrawlersResponse]
$creadList :: ReadS [ListCrawlersResponse]
readsPrec :: Int -> ReadS ListCrawlersResponse
$creadsPrec :: Int -> ReadS ListCrawlersResponse
Prelude.Read, Int -> ListCrawlersResponse -> ShowS
[ListCrawlersResponse] -> ShowS
ListCrawlersResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListCrawlersResponse] -> ShowS
$cshowList :: [ListCrawlersResponse] -> ShowS
show :: ListCrawlersResponse -> String
$cshow :: ListCrawlersResponse -> String
showsPrec :: Int -> ListCrawlersResponse -> ShowS
$cshowsPrec :: Int -> ListCrawlersResponse -> ShowS
Prelude.Show, forall x. Rep ListCrawlersResponse x -> ListCrawlersResponse
forall x. ListCrawlersResponse -> Rep ListCrawlersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListCrawlersResponse x -> ListCrawlersResponse
$cfrom :: forall x. ListCrawlersResponse -> Rep ListCrawlersResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListCrawlersResponse' 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:
--
-- 'crawlerNames', 'listCrawlersResponse_crawlerNames' - The names of all crawlers in the account, or the crawlers with the
-- specified tags.
--
-- 'nextToken', 'listCrawlersResponse_nextToken' - A continuation token, if the returned list does not contain the last
-- metric available.
--
-- 'httpStatus', 'listCrawlersResponse_httpStatus' - The response's http status code.
newListCrawlersResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListCrawlersResponse
newListCrawlersResponse :: Int -> ListCrawlersResponse
newListCrawlersResponse Int
pHttpStatus_ =
  ListCrawlersResponse'
    { $sel:crawlerNames:ListCrawlersResponse' :: Maybe [Text]
crawlerNames =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListCrawlersResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListCrawlersResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The names of all crawlers in the account, or the crawlers with the
-- specified tags.
listCrawlersResponse_crawlerNames :: Lens.Lens' ListCrawlersResponse (Prelude.Maybe [Prelude.Text])
listCrawlersResponse_crawlerNames :: Lens' ListCrawlersResponse (Maybe [Text])
listCrawlersResponse_crawlerNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCrawlersResponse' {Maybe [Text]
crawlerNames :: Maybe [Text]
$sel:crawlerNames:ListCrawlersResponse' :: ListCrawlersResponse -> Maybe [Text]
crawlerNames} -> Maybe [Text]
crawlerNames) (\s :: ListCrawlersResponse
s@ListCrawlersResponse' {} Maybe [Text]
a -> ListCrawlersResponse
s {$sel:crawlerNames:ListCrawlersResponse' :: Maybe [Text]
crawlerNames = Maybe [Text]
a} :: ListCrawlersResponse) 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 the returned list does not contain the last
-- metric available.
listCrawlersResponse_nextToken :: Lens.Lens' ListCrawlersResponse (Prelude.Maybe Prelude.Text)
listCrawlersResponse_nextToken :: Lens' ListCrawlersResponse (Maybe Text)
listCrawlersResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCrawlersResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListCrawlersResponse' :: ListCrawlersResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListCrawlersResponse
s@ListCrawlersResponse' {} Maybe Text
a -> ListCrawlersResponse
s {$sel:nextToken:ListCrawlersResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListCrawlersResponse)

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

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