amazonka-athena-2.0: gen/Amazonka/Athena/ListDataCatalogs.hs
{-# 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.Athena.ListDataCatalogs
-- 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 data catalogs in the current Amazon Web Services account.
--
-- This operation returns paginated results.
module Amazonka.Athena.ListDataCatalogs
( -- * Creating a Request
ListDataCatalogs (..),
newListDataCatalogs,
-- * Request Lenses
listDataCatalogs_maxResults,
listDataCatalogs_nextToken,
-- * Destructuring the Response
ListDataCatalogsResponse (..),
newListDataCatalogsResponse,
-- * Response Lenses
listDataCatalogsResponse_dataCatalogsSummary,
listDataCatalogsResponse_nextToken,
listDataCatalogsResponse_httpStatus,
)
where
import Amazonka.Athena.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
-- | /See:/ 'newListDataCatalogs' smart constructor.
data ListDataCatalogs = ListDataCatalogs'
{ -- | Specifies the maximum number of data catalogs to return.
maxResults :: Prelude.Maybe Prelude.Natural,
-- | A token generated by the Athena service that specifies where to continue
-- pagination if a previous request was truncated. To obtain the next set
-- of pages, pass in the NextToken from the response object of the previous
-- page call.
nextToken :: Prelude.Maybe Prelude.Text
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'ListDataCatalogs' 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', 'listDataCatalogs_maxResults' - Specifies the maximum number of data catalogs to return.
--
-- 'nextToken', 'listDataCatalogs_nextToken' - A token generated by the Athena service that specifies where to continue
-- pagination if a previous request was truncated. To obtain the next set
-- of pages, pass in the NextToken from the response object of the previous
-- page call.
newListDataCatalogs ::
ListDataCatalogs
newListDataCatalogs =
ListDataCatalogs'
{ maxResults = Prelude.Nothing,
nextToken = Prelude.Nothing
}
-- | Specifies the maximum number of data catalogs to return.
listDataCatalogs_maxResults :: Lens.Lens' ListDataCatalogs (Prelude.Maybe Prelude.Natural)
listDataCatalogs_maxResults = Lens.lens (\ListDataCatalogs' {maxResults} -> maxResults) (\s@ListDataCatalogs' {} a -> s {maxResults = a} :: ListDataCatalogs)
-- | A token generated by the Athena service that specifies where to continue
-- pagination if a previous request was truncated. To obtain the next set
-- of pages, pass in the NextToken from the response object of the previous
-- page call.
listDataCatalogs_nextToken :: Lens.Lens' ListDataCatalogs (Prelude.Maybe Prelude.Text)
listDataCatalogs_nextToken = Lens.lens (\ListDataCatalogs' {nextToken} -> nextToken) (\s@ListDataCatalogs' {} a -> s {nextToken = a} :: ListDataCatalogs)
instance Core.AWSPager ListDataCatalogs where
page rq rs
| Core.stop
( rs
Lens.^? listDataCatalogsResponse_nextToken
Prelude.. Lens._Just
) =
Prelude.Nothing
| Core.stop
( rs
Lens.^? listDataCatalogsResponse_dataCatalogsSummary
Prelude.. Lens._Just
) =
Prelude.Nothing
| Prelude.otherwise =
Prelude.Just
Prelude.$ rq
Prelude.& listDataCatalogs_nextToken
Lens..~ rs
Lens.^? listDataCatalogsResponse_nextToken
Prelude.. Lens._Just
instance Core.AWSRequest ListDataCatalogs where
type
AWSResponse ListDataCatalogs =
ListDataCatalogsResponse
request overrides =
Request.postJSON (overrides defaultService)
response =
Response.receiveJSON
( \s h x ->
ListDataCatalogsResponse'
Prelude.<$> ( x
Data..?> "DataCatalogsSummary"
Core..!@ Prelude.mempty
)
Prelude.<*> (x Data..?> "NextToken")
Prelude.<*> (Prelude.pure (Prelude.fromEnum s))
)
instance Prelude.Hashable ListDataCatalogs where
hashWithSalt _salt ListDataCatalogs' {..} =
_salt
`Prelude.hashWithSalt` maxResults
`Prelude.hashWithSalt` nextToken
instance Prelude.NFData ListDataCatalogs where
rnf ListDataCatalogs' {..} =
Prelude.rnf maxResults
`Prelude.seq` Prelude.rnf nextToken
instance Data.ToHeaders ListDataCatalogs where
toHeaders =
Prelude.const
( Prelude.mconcat
[ "X-Amz-Target"
Data.=# ( "AmazonAthena.ListDataCatalogs" ::
Prelude.ByteString
),
"Content-Type"
Data.=# ( "application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON ListDataCatalogs where
toJSON ListDataCatalogs' {..} =
Data.object
( Prelude.catMaybes
[ ("MaxResults" Data..=) Prelude.<$> maxResults,
("NextToken" Data..=) Prelude.<$> nextToken
]
)
instance Data.ToPath ListDataCatalogs where
toPath = Prelude.const "/"
instance Data.ToQuery ListDataCatalogs where
toQuery = Prelude.const Prelude.mempty
-- | /See:/ 'newListDataCatalogsResponse' smart constructor.
data ListDataCatalogsResponse = ListDataCatalogsResponse'
{ -- | A summary list of data catalogs.
dataCatalogsSummary :: Prelude.Maybe [DataCatalogSummary],
-- | A token generated by the Athena service that specifies where to continue
-- pagination if a previous request was truncated. To obtain the next set
-- of pages, pass in the NextToken from the response object of the previous
-- page call.
nextToken :: Prelude.Maybe Prelude.Text,
-- | The response's http status code.
httpStatus :: Prelude.Int
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'ListDataCatalogsResponse' 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:
--
-- 'dataCatalogsSummary', 'listDataCatalogsResponse_dataCatalogsSummary' - A summary list of data catalogs.
--
-- 'nextToken', 'listDataCatalogsResponse_nextToken' - A token generated by the Athena service that specifies where to continue
-- pagination if a previous request was truncated. To obtain the next set
-- of pages, pass in the NextToken from the response object of the previous
-- page call.
--
-- 'httpStatus', 'listDataCatalogsResponse_httpStatus' - The response's http status code.
newListDataCatalogsResponse ::
-- | 'httpStatus'
Prelude.Int ->
ListDataCatalogsResponse
newListDataCatalogsResponse pHttpStatus_ =
ListDataCatalogsResponse'
{ dataCatalogsSummary =
Prelude.Nothing,
nextToken = Prelude.Nothing,
httpStatus = pHttpStatus_
}
-- | A summary list of data catalogs.
listDataCatalogsResponse_dataCatalogsSummary :: Lens.Lens' ListDataCatalogsResponse (Prelude.Maybe [DataCatalogSummary])
listDataCatalogsResponse_dataCatalogsSummary = Lens.lens (\ListDataCatalogsResponse' {dataCatalogsSummary} -> dataCatalogsSummary) (\s@ListDataCatalogsResponse' {} a -> s {dataCatalogsSummary = a} :: ListDataCatalogsResponse) Prelude.. Lens.mapping Lens.coerced
-- | A token generated by the Athena service that specifies where to continue
-- pagination if a previous request was truncated. To obtain the next set
-- of pages, pass in the NextToken from the response object of the previous
-- page call.
listDataCatalogsResponse_nextToken :: Lens.Lens' ListDataCatalogsResponse (Prelude.Maybe Prelude.Text)
listDataCatalogsResponse_nextToken = Lens.lens (\ListDataCatalogsResponse' {nextToken} -> nextToken) (\s@ListDataCatalogsResponse' {} a -> s {nextToken = a} :: ListDataCatalogsResponse)
-- | The response's http status code.
listDataCatalogsResponse_httpStatus :: Lens.Lens' ListDataCatalogsResponse Prelude.Int
listDataCatalogsResponse_httpStatus = Lens.lens (\ListDataCatalogsResponse' {httpStatus} -> httpStatus) (\s@ListDataCatalogsResponse' {} a -> s {httpStatus = a} :: ListDataCatalogsResponse)
instance Prelude.NFData ListDataCatalogsResponse where
rnf ListDataCatalogsResponse' {..} =
Prelude.rnf dataCatalogsSummary
`Prelude.seq` Prelude.rnf nextToken
`Prelude.seq` Prelude.rnf httpStatus