{-# 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.Cloud9.ListEnvironments -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Gets a list of Cloud9 development environment identifiers. -- -- This operation returns paginated results. module Amazonka.Cloud9.ListEnvironments ( -- * Creating a Request ListEnvironments (..), newListEnvironments, -- * Request Lenses listEnvironments_maxResults, listEnvironments_nextToken, -- * Destructuring the Response ListEnvironmentsResponse (..), newListEnvironmentsResponse, -- * Response Lenses listEnvironmentsResponse_environmentIds, listEnvironmentsResponse_nextToken, listEnvironmentsResponse_httpStatus, ) where import Amazonka.Cloud9.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:/ 'newListEnvironments' smart constructor. data ListEnvironments = ListEnvironments' { -- | The maximum number of environments to get identifiers for. maxResults :: Prelude.Maybe Prelude.Natural, -- | During a previous call, if there are more than 25 items in the list, -- only the first 25 items are returned, along with a unique string called -- a /next token/. To get the next batch of items in the list, call this -- operation again, adding the next token to the call. To get all of the -- items in the list, keep calling this operation with each subsequent next -- token that is returned, until no more next tokens are returned. nextToken :: Prelude.Maybe Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListEnvironments' 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', 'listEnvironments_maxResults' - The maximum number of environments to get identifiers for. -- -- 'nextToken', 'listEnvironments_nextToken' - During a previous call, if there are more than 25 items in the list, -- only the first 25 items are returned, along with a unique string called -- a /next token/. To get the next batch of items in the list, call this -- operation again, adding the next token to the call. To get all of the -- items in the list, keep calling this operation with each subsequent next -- token that is returned, until no more next tokens are returned. newListEnvironments :: ListEnvironments newListEnvironments = ListEnvironments' { maxResults = Prelude.Nothing, nextToken = Prelude.Nothing } -- | The maximum number of environments to get identifiers for. listEnvironments_maxResults :: Lens.Lens' ListEnvironments (Prelude.Maybe Prelude.Natural) listEnvironments_maxResults = Lens.lens (\ListEnvironments' {maxResults} -> maxResults) (\s@ListEnvironments' {} a -> s {maxResults = a} :: ListEnvironments) -- | During a previous call, if there are more than 25 items in the list, -- only the first 25 items are returned, along with a unique string called -- a /next token/. To get the next batch of items in the list, call this -- operation again, adding the next token to the call. To get all of the -- items in the list, keep calling this operation with each subsequent next -- token that is returned, until no more next tokens are returned. listEnvironments_nextToken :: Lens.Lens' ListEnvironments (Prelude.Maybe Prelude.Text) listEnvironments_nextToken = Lens.lens (\ListEnvironments' {nextToken} -> nextToken) (\s@ListEnvironments' {} a -> s {nextToken = a} :: ListEnvironments) instance Core.AWSPager ListEnvironments where page rq rs | Core.stop ( rs Lens.^? listEnvironmentsResponse_nextToken Prelude.. Lens._Just ) = Prelude.Nothing | Core.stop ( rs Lens.^? listEnvironmentsResponse_environmentIds Prelude.. Lens._Just ) = Prelude.Nothing | Prelude.otherwise = Prelude.Just Prelude.$ rq Prelude.& listEnvironments_nextToken Lens..~ rs Lens.^? listEnvironmentsResponse_nextToken Prelude.. Lens._Just instance Core.AWSRequest ListEnvironments where type AWSResponse ListEnvironments = ListEnvironmentsResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> ListEnvironmentsResponse' Prelude.<$> (x Data..?> "environmentIds" Core..!@ Prelude.mempty) Prelude.<*> (x Data..?> "nextToken") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable ListEnvironments where hashWithSalt _salt ListEnvironments' {..} = _salt `Prelude.hashWithSalt` maxResults `Prelude.hashWithSalt` nextToken instance Prelude.NFData ListEnvironments where rnf ListEnvironments' {..} = Prelude.rnf maxResults `Prelude.seq` Prelude.rnf nextToken instance Data.ToHeaders ListEnvironments where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ( "AWSCloud9WorkspaceManagementService.ListEnvironments" :: Prelude.ByteString ), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON ListEnvironments where toJSON ListEnvironments' {..} = Data.object ( Prelude.catMaybes [ ("maxResults" Data..=) Prelude.<$> maxResults, ("nextToken" Data..=) Prelude.<$> nextToken ] ) instance Data.ToPath ListEnvironments where toPath = Prelude.const "/" instance Data.ToQuery ListEnvironments where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newListEnvironmentsResponse' smart constructor. data ListEnvironmentsResponse = ListEnvironmentsResponse' { -- | The list of environment identifiers. environmentIds :: Prelude.Maybe [Prelude.Text], -- | If there are more than 25 items in the list, only the first 25 items are -- returned, along with a unique string called a /next token/. To get the -- next batch of items in the list, call this operation again, adding the -- next token to the 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 'ListEnvironmentsResponse' 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: -- -- 'environmentIds', 'listEnvironmentsResponse_environmentIds' - The list of environment identifiers. -- -- 'nextToken', 'listEnvironmentsResponse_nextToken' - If there are more than 25 items in the list, only the first 25 items are -- returned, along with a unique string called a /next token/. To get the -- next batch of items in the list, call this operation again, adding the -- next token to the call. -- -- 'httpStatus', 'listEnvironmentsResponse_httpStatus' - The response's http status code. newListEnvironmentsResponse :: -- | 'httpStatus' Prelude.Int -> ListEnvironmentsResponse newListEnvironmentsResponse pHttpStatus_ = ListEnvironmentsResponse' { environmentIds = Prelude.Nothing, nextToken = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | The list of environment identifiers. listEnvironmentsResponse_environmentIds :: Lens.Lens' ListEnvironmentsResponse (Prelude.Maybe [Prelude.Text]) listEnvironmentsResponse_environmentIds = Lens.lens (\ListEnvironmentsResponse' {environmentIds} -> environmentIds) (\s@ListEnvironmentsResponse' {} a -> s {environmentIds = a} :: ListEnvironmentsResponse) Prelude.. Lens.mapping Lens.coerced -- | If there are more than 25 items in the list, only the first 25 items are -- returned, along with a unique string called a /next token/. To get the -- next batch of items in the list, call this operation again, adding the -- next token to the call. listEnvironmentsResponse_nextToken :: Lens.Lens' ListEnvironmentsResponse (Prelude.Maybe Prelude.Text) listEnvironmentsResponse_nextToken = Lens.lens (\ListEnvironmentsResponse' {nextToken} -> nextToken) (\s@ListEnvironmentsResponse' {} a -> s {nextToken = a} :: ListEnvironmentsResponse) -- | The response's http status code. listEnvironmentsResponse_httpStatus :: Lens.Lens' ListEnvironmentsResponse Prelude.Int listEnvironmentsResponse_httpStatus = Lens.lens (\ListEnvironmentsResponse' {httpStatus} -> httpStatus) (\s@ListEnvironmentsResponse' {} a -> s {httpStatus = a} :: ListEnvironmentsResponse) instance Prelude.NFData ListEnvironmentsResponse where rnf ListEnvironmentsResponse' {..} = Prelude.rnf environmentIds `Prelude.seq` Prelude.rnf nextToken `Prelude.seq` Prelude.rnf httpStatus