{-# 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.ListWorkGroups -- 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 available workgroups for the account. module Amazonka.Athena.ListWorkGroups ( -- * Creating a Request ListWorkGroups (..), newListWorkGroups, -- * Request Lenses listWorkGroups_maxResults, listWorkGroups_nextToken, -- * Destructuring the Response ListWorkGroupsResponse (..), newListWorkGroupsResponse, -- * Response Lenses listWorkGroupsResponse_nextToken, listWorkGroupsResponse_workGroups, listWorkGroupsResponse_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:/ 'newListWorkGroups' smart constructor. data ListWorkGroups = ListWorkGroups' { -- | The maximum number of workgroups to return in this request. 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 'ListWorkGroups' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'maxResults', 'listWorkGroups_maxResults' - The maximum number of workgroups to return in this request. -- -- 'nextToken', 'listWorkGroups_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. newListWorkGroups :: ListWorkGroups newListWorkGroups = ListWorkGroups' { maxResults = Prelude.Nothing, nextToken = Prelude.Nothing } -- | The maximum number of workgroups to return in this request. listWorkGroups_maxResults :: Lens.Lens' ListWorkGroups (Prelude.Maybe Prelude.Natural) listWorkGroups_maxResults = Lens.lens (\ListWorkGroups' {maxResults} -> maxResults) (\s@ListWorkGroups' {} a -> s {maxResults = a} :: ListWorkGroups) -- | 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. listWorkGroups_nextToken :: Lens.Lens' ListWorkGroups (Prelude.Maybe Prelude.Text) listWorkGroups_nextToken = Lens.lens (\ListWorkGroups' {nextToken} -> nextToken) (\s@ListWorkGroups' {} a -> s {nextToken = a} :: ListWorkGroups) instance Core.AWSRequest ListWorkGroups where type AWSResponse ListWorkGroups = ListWorkGroupsResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> ListWorkGroupsResponse' Prelude.<$> (x Data..?> "NextToken") Prelude.<*> (x Data..?> "WorkGroups" Core..!@ Prelude.mempty) Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable ListWorkGroups where hashWithSalt _salt ListWorkGroups' {..} = _salt `Prelude.hashWithSalt` maxResults `Prelude.hashWithSalt` nextToken instance Prelude.NFData ListWorkGroups where rnf ListWorkGroups' {..} = Prelude.rnf maxResults `Prelude.seq` Prelude.rnf nextToken instance Data.ToHeaders ListWorkGroups where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ( "AmazonAthena.ListWorkGroups" :: Prelude.ByteString ), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON ListWorkGroups where toJSON ListWorkGroups' {..} = Data.object ( Prelude.catMaybes [ ("MaxResults" Data..=) Prelude.<$> maxResults, ("NextToken" Data..=) Prelude.<$> nextToken ] ) instance Data.ToPath ListWorkGroups where toPath = Prelude.const "/" instance Data.ToQuery ListWorkGroups where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newListWorkGroupsResponse' smart constructor. data ListWorkGroupsResponse = ListWorkGroupsResponse' { -- | 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, -- | A list of WorkGroupSummary objects that include the names, descriptions, -- creation times, and states for each workgroup. workGroups :: Prelude.Maybe [WorkGroupSummary], -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListWorkGroupsResponse' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'nextToken', 'listWorkGroupsResponse_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. -- -- 'workGroups', 'listWorkGroupsResponse_workGroups' - A list of WorkGroupSummary objects that include the names, descriptions, -- creation times, and states for each workgroup. -- -- 'httpStatus', 'listWorkGroupsResponse_httpStatus' - The response's http status code. newListWorkGroupsResponse :: -- | 'httpStatus' Prelude.Int -> ListWorkGroupsResponse newListWorkGroupsResponse pHttpStatus_ = ListWorkGroupsResponse' { nextToken = Prelude.Nothing, workGroups = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | 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. listWorkGroupsResponse_nextToken :: Lens.Lens' ListWorkGroupsResponse (Prelude.Maybe Prelude.Text) listWorkGroupsResponse_nextToken = Lens.lens (\ListWorkGroupsResponse' {nextToken} -> nextToken) (\s@ListWorkGroupsResponse' {} a -> s {nextToken = a} :: ListWorkGroupsResponse) -- | A list of WorkGroupSummary objects that include the names, descriptions, -- creation times, and states for each workgroup. listWorkGroupsResponse_workGroups :: Lens.Lens' ListWorkGroupsResponse (Prelude.Maybe [WorkGroupSummary]) listWorkGroupsResponse_workGroups = Lens.lens (\ListWorkGroupsResponse' {workGroups} -> workGroups) (\s@ListWorkGroupsResponse' {} a -> s {workGroups = a} :: ListWorkGroupsResponse) Prelude.. Lens.mapping Lens.coerced -- | The response's http status code. listWorkGroupsResponse_httpStatus :: Lens.Lens' ListWorkGroupsResponse Prelude.Int listWorkGroupsResponse_httpStatus = Lens.lens (\ListWorkGroupsResponse' {httpStatus} -> httpStatus) (\s@ListWorkGroupsResponse' {} a -> s {httpStatus = a} :: ListWorkGroupsResponse) instance Prelude.NFData ListWorkGroupsResponse where rnf ListWorkGroupsResponse' {..} = Prelude.rnf nextToken `Prelude.seq` Prelude.rnf workGroups `Prelude.seq` Prelude.rnf httpStatus