amazonka-iotsitewise-2.0: gen/Amazonka/IoTSiteWise/ListProjects.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.IoTSiteWise.ListProjects
-- 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 a paginated list of projects for an IoT SiteWise Monitor
-- portal.
--
-- This operation returns paginated results.
module Amazonka.IoTSiteWise.ListProjects
( -- * Creating a Request
ListProjects (..),
newListProjects,
-- * Request Lenses
listProjects_maxResults,
listProjects_nextToken,
listProjects_portalId,
-- * Destructuring the Response
ListProjectsResponse (..),
newListProjectsResponse,
-- * Response Lenses
listProjectsResponse_nextToken,
listProjectsResponse_httpStatus,
listProjectsResponse_projectSummaries,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTSiteWise.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
-- | /See:/ 'newListProjects' smart constructor.
data ListProjects = ListProjects'
{ -- | The maximum number of results to return for each paginated request.
--
-- Default: 50
maxResults :: Prelude.Maybe Prelude.Natural,
-- | The token to be used for the next set of paginated results.
nextToken :: Prelude.Maybe Prelude.Text,
-- | The ID of the portal.
portalId :: Prelude.Text
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'ListProjects' 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', 'listProjects_maxResults' - The maximum number of results to return for each paginated request.
--
-- Default: 50
--
-- 'nextToken', 'listProjects_nextToken' - The token to be used for the next set of paginated results.
--
-- 'portalId', 'listProjects_portalId' - The ID of the portal.
newListProjects ::
-- | 'portalId'
Prelude.Text ->
ListProjects
newListProjects pPortalId_ =
ListProjects'
{ maxResults = Prelude.Nothing,
nextToken = Prelude.Nothing,
portalId = pPortalId_
}
-- | The maximum number of results to return for each paginated request.
--
-- Default: 50
listProjects_maxResults :: Lens.Lens' ListProjects (Prelude.Maybe Prelude.Natural)
listProjects_maxResults = Lens.lens (\ListProjects' {maxResults} -> maxResults) (\s@ListProjects' {} a -> s {maxResults = a} :: ListProjects)
-- | The token to be used for the next set of paginated results.
listProjects_nextToken :: Lens.Lens' ListProjects (Prelude.Maybe Prelude.Text)
listProjects_nextToken = Lens.lens (\ListProjects' {nextToken} -> nextToken) (\s@ListProjects' {} a -> s {nextToken = a} :: ListProjects)
-- | The ID of the portal.
listProjects_portalId :: Lens.Lens' ListProjects Prelude.Text
listProjects_portalId = Lens.lens (\ListProjects' {portalId} -> portalId) (\s@ListProjects' {} a -> s {portalId = a} :: ListProjects)
instance Core.AWSPager ListProjects where
page rq rs
| Core.stop
( rs
Lens.^? listProjectsResponse_nextToken
Prelude.. Lens._Just
) =
Prelude.Nothing
| Core.stop
(rs Lens.^. listProjectsResponse_projectSummaries) =
Prelude.Nothing
| Prelude.otherwise =
Prelude.Just
Prelude.$ rq
Prelude.& listProjects_nextToken
Lens..~ rs
Lens.^? listProjectsResponse_nextToken
Prelude.. Lens._Just
instance Core.AWSRequest ListProjects where
type AWSResponse ListProjects = ListProjectsResponse
request overrides =
Request.get (overrides defaultService)
response =
Response.receiveJSON
( \s h x ->
ListProjectsResponse'
Prelude.<$> (x Data..?> "nextToken")
Prelude.<*> (Prelude.pure (Prelude.fromEnum s))
Prelude.<*> ( x
Data..?> "projectSummaries"
Core..!@ Prelude.mempty
)
)
instance Prelude.Hashable ListProjects where
hashWithSalt _salt ListProjects' {..} =
_salt
`Prelude.hashWithSalt` maxResults
`Prelude.hashWithSalt` nextToken
`Prelude.hashWithSalt` portalId
instance Prelude.NFData ListProjects where
rnf ListProjects' {..} =
Prelude.rnf maxResults
`Prelude.seq` Prelude.rnf nextToken
`Prelude.seq` Prelude.rnf portalId
instance Data.ToHeaders ListProjects where
toHeaders =
Prelude.const
( Prelude.mconcat
[ "Content-Type"
Data.=# ( "application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToPath ListProjects where
toPath = Prelude.const "/projects"
instance Data.ToQuery ListProjects where
toQuery ListProjects' {..} =
Prelude.mconcat
[ "maxResults" Data.=: maxResults,
"nextToken" Data.=: nextToken,
"portalId" Data.=: portalId
]
-- | /See:/ 'newListProjectsResponse' smart constructor.
data ListProjectsResponse = ListProjectsResponse'
{ -- | The token for the next set of results, or null if there are no
-- additional results.
nextToken :: Prelude.Maybe Prelude.Text,
-- | The response's http status code.
httpStatus :: Prelude.Int,
-- | A list that summarizes each project in the portal.
projectSummaries :: [ProjectSummary]
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'ListProjectsResponse' 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', 'listProjectsResponse_nextToken' - The token for the next set of results, or null if there are no
-- additional results.
--
-- 'httpStatus', 'listProjectsResponse_httpStatus' - The response's http status code.
--
-- 'projectSummaries', 'listProjectsResponse_projectSummaries' - A list that summarizes each project in the portal.
newListProjectsResponse ::
-- | 'httpStatus'
Prelude.Int ->
ListProjectsResponse
newListProjectsResponse pHttpStatus_ =
ListProjectsResponse'
{ nextToken = Prelude.Nothing,
httpStatus = pHttpStatus_,
projectSummaries = Prelude.mempty
}
-- | The token for the next set of results, or null if there are no
-- additional results.
listProjectsResponse_nextToken :: Lens.Lens' ListProjectsResponse (Prelude.Maybe Prelude.Text)
listProjectsResponse_nextToken = Lens.lens (\ListProjectsResponse' {nextToken} -> nextToken) (\s@ListProjectsResponse' {} a -> s {nextToken = a} :: ListProjectsResponse)
-- | The response's http status code.
listProjectsResponse_httpStatus :: Lens.Lens' ListProjectsResponse Prelude.Int
listProjectsResponse_httpStatus = Lens.lens (\ListProjectsResponse' {httpStatus} -> httpStatus) (\s@ListProjectsResponse' {} a -> s {httpStatus = a} :: ListProjectsResponse)
-- | A list that summarizes each project in the portal.
listProjectsResponse_projectSummaries :: Lens.Lens' ListProjectsResponse [ProjectSummary]
listProjectsResponse_projectSummaries = Lens.lens (\ListProjectsResponse' {projectSummaries} -> projectSummaries) (\s@ListProjectsResponse' {} a -> s {projectSummaries = a} :: ListProjectsResponse) Prelude.. Lens.coerced
instance Prelude.NFData ListProjectsResponse where
rnf ListProjectsResponse' {..} =
Prelude.rnf nextToken
`Prelude.seq` Prelude.rnf httpStatus
`Prelude.seq` Prelude.rnf projectSummaries