{-# 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.MGN.ListApplications -- 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 all applications or multiple applications by ID. -- -- This operation returns paginated results. module Amazonka.MGN.ListApplications ( -- * Creating a Request ListApplications (..), newListApplications, -- * Request Lenses listApplications_filters, listApplications_maxResults, listApplications_nextToken, -- * Destructuring the Response ListApplicationsResponse (..), newListApplicationsResponse, -- * Response Lenses listApplicationsResponse_items, listApplicationsResponse_nextToken, listApplicationsResponse_httpStatus, ) where import qualified Amazonka.Core as Core import qualified Amazonka.Core.Lens.Internal as Lens import qualified Amazonka.Data as Data import Amazonka.MGN.Types import qualified Amazonka.Prelude as Prelude import qualified Amazonka.Request as Request import qualified Amazonka.Response as Response -- | /See:/ 'newListApplications' smart constructor. data ListApplications = ListApplications' { -- | Applications list filters. filters :: Prelude.Maybe ListApplicationsRequestFilters, -- | Maximum results to return when listing applications. maxResults :: Prelude.Maybe Prelude.Natural, -- | Request next token. nextToken :: Prelude.Maybe Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListApplications' 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: -- -- 'filters', 'listApplications_filters' - Applications list filters. -- -- 'maxResults', 'listApplications_maxResults' - Maximum results to return when listing applications. -- -- 'nextToken', 'listApplications_nextToken' - Request next token. newListApplications :: ListApplications newListApplications = ListApplications' { filters = Prelude.Nothing, maxResults = Prelude.Nothing, nextToken = Prelude.Nothing } -- | Applications list filters. listApplications_filters :: Lens.Lens' ListApplications (Prelude.Maybe ListApplicationsRequestFilters) listApplications_filters = Lens.lens (\ListApplications' {filters} -> filters) (\s@ListApplications' {} a -> s {filters = a} :: ListApplications) -- | Maximum results to return when listing applications. listApplications_maxResults :: Lens.Lens' ListApplications (Prelude.Maybe Prelude.Natural) listApplications_maxResults = Lens.lens (\ListApplications' {maxResults} -> maxResults) (\s@ListApplications' {} a -> s {maxResults = a} :: ListApplications) -- | Request next token. listApplications_nextToken :: Lens.Lens' ListApplications (Prelude.Maybe Prelude.Text) listApplications_nextToken = Lens.lens (\ListApplications' {nextToken} -> nextToken) (\s@ListApplications' {} a -> s {nextToken = a} :: ListApplications) instance Core.AWSPager ListApplications where page rq rs | Core.stop ( rs Lens.^? listApplicationsResponse_nextToken Prelude.. Lens._Just ) = Prelude.Nothing | Core.stop ( rs Lens.^? listApplicationsResponse_items Prelude.. Lens._Just ) = Prelude.Nothing | Prelude.otherwise = Prelude.Just Prelude.$ rq Prelude.& listApplications_nextToken Lens..~ rs Lens.^? listApplicationsResponse_nextToken Prelude.. Lens._Just instance Core.AWSRequest ListApplications where type AWSResponse ListApplications = ListApplicationsResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> ListApplicationsResponse' Prelude.<$> (x Data..?> "items" Core..!@ Prelude.mempty) Prelude.<*> (x Data..?> "nextToken") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable ListApplications where hashWithSalt _salt ListApplications' {..} = _salt `Prelude.hashWithSalt` filters `Prelude.hashWithSalt` maxResults `Prelude.hashWithSalt` nextToken instance Prelude.NFData ListApplications where rnf ListApplications' {..} = Prelude.rnf filters `Prelude.seq` Prelude.rnf maxResults `Prelude.seq` Prelude.rnf nextToken instance Data.ToHeaders ListApplications where toHeaders = Prelude.const ( Prelude.mconcat [ "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON ListApplications where toJSON ListApplications' {..} = Data.object ( Prelude.catMaybes [ ("filters" Data..=) Prelude.<$> filters, ("maxResults" Data..=) Prelude.<$> maxResults, ("nextToken" Data..=) Prelude.<$> nextToken ] ) instance Data.ToPath ListApplications where toPath = Prelude.const "/ListApplications" instance Data.ToQuery ListApplications where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newListApplicationsResponse' smart constructor. data ListApplicationsResponse = ListApplicationsResponse' { -- | Applications list. items :: Prelude.Maybe [Application], -- | Response next token. nextToken :: Prelude.Maybe Prelude.Text, -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListApplicationsResponse' 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: -- -- 'items', 'listApplicationsResponse_items' - Applications list. -- -- 'nextToken', 'listApplicationsResponse_nextToken' - Response next token. -- -- 'httpStatus', 'listApplicationsResponse_httpStatus' - The response's http status code. newListApplicationsResponse :: -- | 'httpStatus' Prelude.Int -> ListApplicationsResponse newListApplicationsResponse pHttpStatus_ = ListApplicationsResponse' { items = Prelude.Nothing, nextToken = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | Applications list. listApplicationsResponse_items :: Lens.Lens' ListApplicationsResponse (Prelude.Maybe [Application]) listApplicationsResponse_items = Lens.lens (\ListApplicationsResponse' {items} -> items) (\s@ListApplicationsResponse' {} a -> s {items = a} :: ListApplicationsResponse) Prelude.. Lens.mapping Lens.coerced -- | Response next token. listApplicationsResponse_nextToken :: Lens.Lens' ListApplicationsResponse (Prelude.Maybe Prelude.Text) listApplicationsResponse_nextToken = Lens.lens (\ListApplicationsResponse' {nextToken} -> nextToken) (\s@ListApplicationsResponse' {} a -> s {nextToken = a} :: ListApplicationsResponse) -- | The response's http status code. listApplicationsResponse_httpStatus :: Lens.Lens' ListApplicationsResponse Prelude.Int listApplicationsResponse_httpStatus = Lens.lens (\ListApplicationsResponse' {httpStatus} -> httpStatus) (\s@ListApplicationsResponse' {} a -> s {httpStatus = a} :: ListApplicationsResponse) instance Prelude.NFData ListApplicationsResponse where rnf ListApplicationsResponse' {..} = Prelude.rnf items `Prelude.seq` Prelude.rnf nextToken `Prelude.seq` Prelude.rnf httpStatus