{-# 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.ListSessions -- 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 sessions in a workgroup that are in an active state like -- @CREATING@, @CREATED@, @IDLE@, or @BUSY@. Newer sessions are listed -- first; older sessions are listed later. module Amazonka.Athena.ListSessions ( -- * Creating a Request ListSessions (..), newListSessions, -- * Request Lenses listSessions_maxResults, listSessions_nextToken, listSessions_stateFilter, listSessions_workGroup, -- * Destructuring the Response ListSessionsResponse (..), newListSessionsResponse, -- * Response Lenses listSessionsResponse_nextToken, listSessionsResponse_sessions, listSessionsResponse_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:/ 'newListSessions' smart constructor. data ListSessions = ListSessions' { -- | The maximum number of sessions 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, -- | A filter for a specific session state. A description of each state -- follows. -- -- @CREATING@ - The session is being started, including acquiring -- resources. -- -- @CREATED@ - The session has been started. -- -- @IDLE@ - The session is able to accept a calculation. -- -- @BUSY@ - The session is processing another task and is unable to accept -- a calculation. -- -- @TERMINATING@ - The session is in the process of shutting down. -- -- @TERMINATED@ - The session and its resources are no longer running. -- -- @DEGRADED@ - The session has no healthy coordinators. -- -- @FAILED@ - Due to a failure, the session and its resources are no longer -- running. stateFilter :: Prelude.Maybe SessionState, -- | The workgroup to which the session belongs. workGroup :: Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListSessions' 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', 'listSessions_maxResults' - The maximum number of sessions to return. -- -- 'nextToken', 'listSessions_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. -- -- 'stateFilter', 'listSessions_stateFilter' - A filter for a specific session state. A description of each state -- follows. -- -- @CREATING@ - The session is being started, including acquiring -- resources. -- -- @CREATED@ - The session has been started. -- -- @IDLE@ - The session is able to accept a calculation. -- -- @BUSY@ - The session is processing another task and is unable to accept -- a calculation. -- -- @TERMINATING@ - The session is in the process of shutting down. -- -- @TERMINATED@ - The session and its resources are no longer running. -- -- @DEGRADED@ - The session has no healthy coordinators. -- -- @FAILED@ - Due to a failure, the session and its resources are no longer -- running. -- -- 'workGroup', 'listSessions_workGroup' - The workgroup to which the session belongs. newListSessions :: -- | 'workGroup' Prelude.Text -> ListSessions newListSessions pWorkGroup_ = ListSessions' { maxResults = Prelude.Nothing, nextToken = Prelude.Nothing, stateFilter = Prelude.Nothing, workGroup = pWorkGroup_ } -- | The maximum number of sessions to return. listSessions_maxResults :: Lens.Lens' ListSessions (Prelude.Maybe Prelude.Natural) listSessions_maxResults = Lens.lens (\ListSessions' {maxResults} -> maxResults) (\s@ListSessions' {} a -> s {maxResults = a} :: ListSessions) -- | 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. listSessions_nextToken :: Lens.Lens' ListSessions (Prelude.Maybe Prelude.Text) listSessions_nextToken = Lens.lens (\ListSessions' {nextToken} -> nextToken) (\s@ListSessions' {} a -> s {nextToken = a} :: ListSessions) -- | A filter for a specific session state. A description of each state -- follows. -- -- @CREATING@ - The session is being started, including acquiring -- resources. -- -- @CREATED@ - The session has been started. -- -- @IDLE@ - The session is able to accept a calculation. -- -- @BUSY@ - The session is processing another task and is unable to accept -- a calculation. -- -- @TERMINATING@ - The session is in the process of shutting down. -- -- @TERMINATED@ - The session and its resources are no longer running. -- -- @DEGRADED@ - The session has no healthy coordinators. -- -- @FAILED@ - Due to a failure, the session and its resources are no longer -- running. listSessions_stateFilter :: Lens.Lens' ListSessions (Prelude.Maybe SessionState) listSessions_stateFilter = Lens.lens (\ListSessions' {stateFilter} -> stateFilter) (\s@ListSessions' {} a -> s {stateFilter = a} :: ListSessions) -- | The workgroup to which the session belongs. listSessions_workGroup :: Lens.Lens' ListSessions Prelude.Text listSessions_workGroup = Lens.lens (\ListSessions' {workGroup} -> workGroup) (\s@ListSessions' {} a -> s {workGroup = a} :: ListSessions) instance Core.AWSRequest ListSessions where type AWSResponse ListSessions = ListSessionsResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> ListSessionsResponse' Prelude.<$> (x Data..?> "NextToken") Prelude.<*> (x Data..?> "Sessions" Core..!@ Prelude.mempty) Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable ListSessions where hashWithSalt _salt ListSessions' {..} = _salt `Prelude.hashWithSalt` maxResults `Prelude.hashWithSalt` nextToken `Prelude.hashWithSalt` stateFilter `Prelude.hashWithSalt` workGroup instance Prelude.NFData ListSessions where rnf ListSessions' {..} = Prelude.rnf maxResults `Prelude.seq` Prelude.rnf nextToken `Prelude.seq` Prelude.rnf stateFilter `Prelude.seq` Prelude.rnf workGroup instance Data.ToHeaders ListSessions where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ("AmazonAthena.ListSessions" :: Prelude.ByteString), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON ListSessions where toJSON ListSessions' {..} = Data.object ( Prelude.catMaybes [ ("MaxResults" Data..=) Prelude.<$> maxResults, ("NextToken" Data..=) Prelude.<$> nextToken, ("StateFilter" Data..=) Prelude.<$> stateFilter, Prelude.Just ("WorkGroup" Data..= workGroup) ] ) instance Data.ToPath ListSessions where toPath = Prelude.const "/" instance Data.ToQuery ListSessions where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newListSessionsResponse' smart constructor. data ListSessionsResponse = ListSessionsResponse' { -- | 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 sessions. sessions :: Prelude.Maybe [SessionSummary], -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListSessionsResponse' 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', 'listSessionsResponse_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. -- -- 'sessions', 'listSessionsResponse_sessions' - A list of sessions. -- -- 'httpStatus', 'listSessionsResponse_httpStatus' - The response's http status code. newListSessionsResponse :: -- | 'httpStatus' Prelude.Int -> ListSessionsResponse newListSessionsResponse pHttpStatus_ = ListSessionsResponse' { nextToken = Prelude.Nothing, sessions = 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. listSessionsResponse_nextToken :: Lens.Lens' ListSessionsResponse (Prelude.Maybe Prelude.Text) listSessionsResponse_nextToken = Lens.lens (\ListSessionsResponse' {nextToken} -> nextToken) (\s@ListSessionsResponse' {} a -> s {nextToken = a} :: ListSessionsResponse) -- | A list of sessions. listSessionsResponse_sessions :: Lens.Lens' ListSessionsResponse (Prelude.Maybe [SessionSummary]) listSessionsResponse_sessions = Lens.lens (\ListSessionsResponse' {sessions} -> sessions) (\s@ListSessionsResponse' {} a -> s {sessions = a} :: ListSessionsResponse) Prelude.. Lens.mapping Lens.coerced -- | The response's http status code. listSessionsResponse_httpStatus :: Lens.Lens' ListSessionsResponse Prelude.Int listSessionsResponse_httpStatus = Lens.lens (\ListSessionsResponse' {httpStatus} -> httpStatus) (\s@ListSessionsResponse' {} a -> s {httpStatus = a} :: ListSessionsResponse) instance Prelude.NFData ListSessionsResponse where rnf ListSessionsResponse' {..} = Prelude.rnf nextToken `Prelude.seq` Prelude.rnf sessions `Prelude.seq` Prelude.rnf httpStatus