amazonka-athena-2.0: gen/Amazonka/Athena/ListNotebookSessions.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.ListNotebookSessions
-- 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, in descending order, the sessions that have been created in a
-- notebook 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.ListNotebookSessions
( -- * Creating a Request
ListNotebookSessions (..),
newListNotebookSessions,
-- * Request Lenses
listNotebookSessions_maxResults,
listNotebookSessions_nextToken,
listNotebookSessions_notebookId,
-- * Destructuring the Response
ListNotebookSessionsResponse (..),
newListNotebookSessionsResponse,
-- * Response Lenses
listNotebookSessionsResponse_nextToken,
listNotebookSessionsResponse_httpStatus,
listNotebookSessionsResponse_notebookSessionsList,
)
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:/ 'newListNotebookSessions' smart constructor.
data ListNotebookSessions = ListNotebookSessions'
{ -- | The maximum number of notebook 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,
-- | The ID of the notebook to list sessions for.
notebookId :: Prelude.Text
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'ListNotebookSessions' 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', 'listNotebookSessions_maxResults' - The maximum number of notebook sessions to return.
--
-- 'nextToken', 'listNotebookSessions_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.
--
-- 'notebookId', 'listNotebookSessions_notebookId' - The ID of the notebook to list sessions for.
newListNotebookSessions ::
-- | 'notebookId'
Prelude.Text ->
ListNotebookSessions
newListNotebookSessions pNotebookId_ =
ListNotebookSessions'
{ maxResults = Prelude.Nothing,
nextToken = Prelude.Nothing,
notebookId = pNotebookId_
}
-- | The maximum number of notebook sessions to return.
listNotebookSessions_maxResults :: Lens.Lens' ListNotebookSessions (Prelude.Maybe Prelude.Natural)
listNotebookSessions_maxResults = Lens.lens (\ListNotebookSessions' {maxResults} -> maxResults) (\s@ListNotebookSessions' {} a -> s {maxResults = a} :: ListNotebookSessions)
-- | 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.
listNotebookSessions_nextToken :: Lens.Lens' ListNotebookSessions (Prelude.Maybe Prelude.Text)
listNotebookSessions_nextToken = Lens.lens (\ListNotebookSessions' {nextToken} -> nextToken) (\s@ListNotebookSessions' {} a -> s {nextToken = a} :: ListNotebookSessions)
-- | The ID of the notebook to list sessions for.
listNotebookSessions_notebookId :: Lens.Lens' ListNotebookSessions Prelude.Text
listNotebookSessions_notebookId = Lens.lens (\ListNotebookSessions' {notebookId} -> notebookId) (\s@ListNotebookSessions' {} a -> s {notebookId = a} :: ListNotebookSessions)
instance Core.AWSRequest ListNotebookSessions where
type
AWSResponse ListNotebookSessions =
ListNotebookSessionsResponse
request overrides =
Request.postJSON (overrides defaultService)
response =
Response.receiveJSON
( \s h x ->
ListNotebookSessionsResponse'
Prelude.<$> (x Data..?> "NextToken")
Prelude.<*> (Prelude.pure (Prelude.fromEnum s))
Prelude.<*> ( x
Data..?> "NotebookSessionsList"
Core..!@ Prelude.mempty
)
)
instance Prelude.Hashable ListNotebookSessions where
hashWithSalt _salt ListNotebookSessions' {..} =
_salt
`Prelude.hashWithSalt` maxResults
`Prelude.hashWithSalt` nextToken
`Prelude.hashWithSalt` notebookId
instance Prelude.NFData ListNotebookSessions where
rnf ListNotebookSessions' {..} =
Prelude.rnf maxResults
`Prelude.seq` Prelude.rnf nextToken
`Prelude.seq` Prelude.rnf notebookId
instance Data.ToHeaders ListNotebookSessions where
toHeaders =
Prelude.const
( Prelude.mconcat
[ "X-Amz-Target"
Data.=# ( "AmazonAthena.ListNotebookSessions" ::
Prelude.ByteString
),
"Content-Type"
Data.=# ( "application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON ListNotebookSessions where
toJSON ListNotebookSessions' {..} =
Data.object
( Prelude.catMaybes
[ ("MaxResults" Data..=) Prelude.<$> maxResults,
("NextToken" Data..=) Prelude.<$> nextToken,
Prelude.Just ("NotebookId" Data..= notebookId)
]
)
instance Data.ToPath ListNotebookSessions where
toPath = Prelude.const "/"
instance Data.ToQuery ListNotebookSessions where
toQuery = Prelude.const Prelude.mempty
-- | /See:/ 'newListNotebookSessionsResponse' smart constructor.
data ListNotebookSessionsResponse = ListNotebookSessionsResponse'
{ -- | 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,
-- | A list of the sessions belonging to the notebook.
notebookSessionsList :: [NotebookSessionSummary]
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'ListNotebookSessionsResponse' 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:
--
-- 'nextToken', 'listNotebookSessionsResponse_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', 'listNotebookSessionsResponse_httpStatus' - The response's http status code.
--
-- 'notebookSessionsList', 'listNotebookSessionsResponse_notebookSessionsList' - A list of the sessions belonging to the notebook.
newListNotebookSessionsResponse ::
-- | 'httpStatus'
Prelude.Int ->
ListNotebookSessionsResponse
newListNotebookSessionsResponse pHttpStatus_ =
ListNotebookSessionsResponse'
{ nextToken =
Prelude.Nothing,
httpStatus = pHttpStatus_,
notebookSessionsList = Prelude.mempty
}
-- | 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.
listNotebookSessionsResponse_nextToken :: Lens.Lens' ListNotebookSessionsResponse (Prelude.Maybe Prelude.Text)
listNotebookSessionsResponse_nextToken = Lens.lens (\ListNotebookSessionsResponse' {nextToken} -> nextToken) (\s@ListNotebookSessionsResponse' {} a -> s {nextToken = a} :: ListNotebookSessionsResponse)
-- | The response's http status code.
listNotebookSessionsResponse_httpStatus :: Lens.Lens' ListNotebookSessionsResponse Prelude.Int
listNotebookSessionsResponse_httpStatus = Lens.lens (\ListNotebookSessionsResponse' {httpStatus} -> httpStatus) (\s@ListNotebookSessionsResponse' {} a -> s {httpStatus = a} :: ListNotebookSessionsResponse)
-- | A list of the sessions belonging to the notebook.
listNotebookSessionsResponse_notebookSessionsList :: Lens.Lens' ListNotebookSessionsResponse [NotebookSessionSummary]
listNotebookSessionsResponse_notebookSessionsList = Lens.lens (\ListNotebookSessionsResponse' {notebookSessionsList} -> notebookSessionsList) (\s@ListNotebookSessionsResponse' {} a -> s {notebookSessionsList = a} :: ListNotebookSessionsResponse) Prelude.. Lens.coerced
instance Prelude.NFData ListNotebookSessionsResponse where
rnf ListNotebookSessionsResponse' {..} =
Prelude.rnf nextToken
`Prelude.seq` Prelude.rnf httpStatus
`Prelude.seq` Prelude.rnf notebookSessionsList