{-# 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.Proton.ListServices -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- List services with summaries of detail data. -- -- This operation returns paginated results. module Amazonka.Proton.ListServices ( -- * Creating a Request ListServices (..), newListServices, -- * Request Lenses listServices_maxResults, listServices_nextToken, -- * Destructuring the Response ListServicesResponse (..), newListServicesResponse, -- * Response Lenses listServicesResponse_nextToken, listServicesResponse_httpStatus, listServicesResponse_services, ) where 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 Amazonka.Proton.Types import qualified Amazonka.Request as Request import qualified Amazonka.Response as Response -- | /See:/ 'newListServices' smart constructor. data ListServices = ListServices' { -- | The maximum number of services to list. maxResults :: Prelude.Maybe Prelude.Natural, -- | A token that indicates the location of the next service in the array of -- services, after the list of services that was previously requested. nextToken :: Prelude.Maybe Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListServices' 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', 'listServices_maxResults' - The maximum number of services to list. -- -- 'nextToken', 'listServices_nextToken' - A token that indicates the location of the next service in the array of -- services, after the list of services that was previously requested. newListServices :: ListServices newListServices = ListServices' { maxResults = Prelude.Nothing, nextToken = Prelude.Nothing } -- | The maximum number of services to list. listServices_maxResults :: Lens.Lens' ListServices (Prelude.Maybe Prelude.Natural) listServices_maxResults = Lens.lens (\ListServices' {maxResults} -> maxResults) (\s@ListServices' {} a -> s {maxResults = a} :: ListServices) -- | A token that indicates the location of the next service in the array of -- services, after the list of services that was previously requested. listServices_nextToken :: Lens.Lens' ListServices (Prelude.Maybe Prelude.Text) listServices_nextToken = Lens.lens (\ListServices' {nextToken} -> nextToken) (\s@ListServices' {} a -> s {nextToken = a} :: ListServices) instance Core.AWSPager ListServices where page rq rs | Core.stop ( rs Lens.^? listServicesResponse_nextToken Prelude.. Lens._Just ) = Prelude.Nothing | Core.stop (rs Lens.^. listServicesResponse_services) = Prelude.Nothing | Prelude.otherwise = Prelude.Just Prelude.$ rq Prelude.& listServices_nextToken Lens..~ rs Lens.^? listServicesResponse_nextToken Prelude.. Lens._Just instance Core.AWSRequest ListServices where type AWSResponse ListServices = ListServicesResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> ListServicesResponse' Prelude.<$> (x Data..?> "nextToken") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) Prelude.<*> (x Data..?> "services" Core..!@ Prelude.mempty) ) instance Prelude.Hashable ListServices where hashWithSalt _salt ListServices' {..} = _salt `Prelude.hashWithSalt` maxResults `Prelude.hashWithSalt` nextToken instance Prelude.NFData ListServices where rnf ListServices' {..} = Prelude.rnf maxResults `Prelude.seq` Prelude.rnf nextToken instance Data.ToHeaders ListServices where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ( "AwsProton20200720.ListServices" :: Prelude.ByteString ), "Content-Type" Data.=# ( "application/x-amz-json-1.0" :: Prelude.ByteString ) ] ) instance Data.ToJSON ListServices where toJSON ListServices' {..} = Data.object ( Prelude.catMaybes [ ("maxResults" Data..=) Prelude.<$> maxResults, ("nextToken" Data..=) Prelude.<$> nextToken ] ) instance Data.ToPath ListServices where toPath = Prelude.const "/" instance Data.ToQuery ListServices where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newListServicesResponse' smart constructor. data ListServicesResponse = ListServicesResponse' { -- | A token that indicates the location of the next service in the array of -- services, after the current requested list of services. nextToken :: Prelude.Maybe Prelude.Text, -- | The response's http status code. httpStatus :: Prelude.Int, -- | An array of services with summaries of detail data. services :: [ServiceSummary] } deriving (Prelude.Eq, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListServicesResponse' 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', 'listServicesResponse_nextToken' - A token that indicates the location of the next service in the array of -- services, after the current requested list of services. -- -- 'httpStatus', 'listServicesResponse_httpStatus' - The response's http status code. -- -- 'services', 'listServicesResponse_services' - An array of services with summaries of detail data. newListServicesResponse :: -- | 'httpStatus' Prelude.Int -> ListServicesResponse newListServicesResponse pHttpStatus_ = ListServicesResponse' { nextToken = Prelude.Nothing, httpStatus = pHttpStatus_, services = Prelude.mempty } -- | A token that indicates the location of the next service in the array of -- services, after the current requested list of services. listServicesResponse_nextToken :: Lens.Lens' ListServicesResponse (Prelude.Maybe Prelude.Text) listServicesResponse_nextToken = Lens.lens (\ListServicesResponse' {nextToken} -> nextToken) (\s@ListServicesResponse' {} a -> s {nextToken = a} :: ListServicesResponse) -- | The response's http status code. listServicesResponse_httpStatus :: Lens.Lens' ListServicesResponse Prelude.Int listServicesResponse_httpStatus = Lens.lens (\ListServicesResponse' {httpStatus} -> httpStatus) (\s@ListServicesResponse' {} a -> s {httpStatus = a} :: ListServicesResponse) -- | An array of services with summaries of detail data. listServicesResponse_services :: Lens.Lens' ListServicesResponse [ServiceSummary] listServicesResponse_services = Lens.lens (\ListServicesResponse' {services} -> services) (\s@ListServicesResponse' {} a -> s {services = a} :: ListServicesResponse) Prelude.. Lens.coerced instance Prelude.NFData ListServicesResponse where rnf ListServicesResponse' {..} = Prelude.rnf nextToken `Prelude.seq` Prelude.rnf httpStatus `Prelude.seq` Prelude.rnf services