{-# 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.BackupGateway.ListGateways -- 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 backup gateways owned by an Amazon Web Services account in an -- Amazon Web Services Region. The returned list is ordered by gateway -- Amazon Resource Name (ARN). -- -- This operation returns paginated results. module Amazonka.BackupGateway.ListGateways ( -- * Creating a Request ListGateways (..), newListGateways, -- * Request Lenses listGateways_maxResults, listGateways_nextToken, -- * Destructuring the Response ListGatewaysResponse (..), newListGatewaysResponse, -- * Response Lenses listGatewaysResponse_gateways, listGatewaysResponse_nextToken, listGatewaysResponse_httpStatus, ) where import Amazonka.BackupGateway.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:/ 'newListGateways' smart constructor. data ListGateways = ListGateways' { -- | The maximum number of gateways to list. maxResults :: Prelude.Maybe Prelude.Natural, -- | The next item following a partial list of returned resources. For -- example, if a request is made to return @MaxResults@ number of -- resources, @NextToken@ allows you to return more items in your list -- starting at the location pointed to by the next token. nextToken :: Prelude.Maybe Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListGateways' 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', 'listGateways_maxResults' - The maximum number of gateways to list. -- -- 'nextToken', 'listGateways_nextToken' - The next item following a partial list of returned resources. For -- example, if a request is made to return @MaxResults@ number of -- resources, @NextToken@ allows you to return more items in your list -- starting at the location pointed to by the next token. newListGateways :: ListGateways newListGateways = ListGateways' { maxResults = Prelude.Nothing, nextToken = Prelude.Nothing } -- | The maximum number of gateways to list. listGateways_maxResults :: Lens.Lens' ListGateways (Prelude.Maybe Prelude.Natural) listGateways_maxResults = Lens.lens (\ListGateways' {maxResults} -> maxResults) (\s@ListGateways' {} a -> s {maxResults = a} :: ListGateways) -- | The next item following a partial list of returned resources. For -- example, if a request is made to return @MaxResults@ number of -- resources, @NextToken@ allows you to return more items in your list -- starting at the location pointed to by the next token. listGateways_nextToken :: Lens.Lens' ListGateways (Prelude.Maybe Prelude.Text) listGateways_nextToken = Lens.lens (\ListGateways' {nextToken} -> nextToken) (\s@ListGateways' {} a -> s {nextToken = a} :: ListGateways) instance Core.AWSPager ListGateways where page rq rs | Core.stop ( rs Lens.^? listGatewaysResponse_nextToken Prelude.. Lens._Just ) = Prelude.Nothing | Core.stop ( rs Lens.^? listGatewaysResponse_gateways Prelude.. Lens._Just ) = Prelude.Nothing | Prelude.otherwise = Prelude.Just Prelude.$ rq Prelude.& listGateways_nextToken Lens..~ rs Lens.^? listGatewaysResponse_nextToken Prelude.. Lens._Just instance Core.AWSRequest ListGateways where type AWSResponse ListGateways = ListGatewaysResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> ListGatewaysResponse' Prelude.<$> (x Data..?> "Gateways" Core..!@ Prelude.mempty) Prelude.<*> (x Data..?> "NextToken") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable ListGateways where hashWithSalt _salt ListGateways' {..} = _salt `Prelude.hashWithSalt` maxResults `Prelude.hashWithSalt` nextToken instance Prelude.NFData ListGateways where rnf ListGateways' {..} = Prelude.rnf maxResults `Prelude.seq` Prelude.rnf nextToken instance Data.ToHeaders ListGateways where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ( "BackupOnPremises_v20210101.ListGateways" :: Prelude.ByteString ), "Content-Type" Data.=# ( "application/x-amz-json-1.0" :: Prelude.ByteString ) ] ) instance Data.ToJSON ListGateways where toJSON ListGateways' {..} = Data.object ( Prelude.catMaybes [ ("MaxResults" Data..=) Prelude.<$> maxResults, ("NextToken" Data..=) Prelude.<$> nextToken ] ) instance Data.ToPath ListGateways where toPath = Prelude.const "/" instance Data.ToQuery ListGateways where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newListGatewaysResponse' smart constructor. data ListGatewaysResponse = ListGatewaysResponse' { -- | A list of your gateways. gateways :: Prelude.Maybe [Gateway], -- | The next item following a partial list of returned resources. For -- example, if a request is made to return @maxResults@ number of -- resources, @NextToken@ allows you to return more items in your list -- starting at the location pointed to by the next token. 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 'ListGatewaysResponse' 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: -- -- 'gateways', 'listGatewaysResponse_gateways' - A list of your gateways. -- -- 'nextToken', 'listGatewaysResponse_nextToken' - The next item following a partial list of returned resources. For -- example, if a request is made to return @maxResults@ number of -- resources, @NextToken@ allows you to return more items in your list -- starting at the location pointed to by the next token. -- -- 'httpStatus', 'listGatewaysResponse_httpStatus' - The response's http status code. newListGatewaysResponse :: -- | 'httpStatus' Prelude.Int -> ListGatewaysResponse newListGatewaysResponse pHttpStatus_ = ListGatewaysResponse' { gateways = Prelude.Nothing, nextToken = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | A list of your gateways. listGatewaysResponse_gateways :: Lens.Lens' ListGatewaysResponse (Prelude.Maybe [Gateway]) listGatewaysResponse_gateways = Lens.lens (\ListGatewaysResponse' {gateways} -> gateways) (\s@ListGatewaysResponse' {} a -> s {gateways = a} :: ListGatewaysResponse) Prelude.. Lens.mapping Lens.coerced -- | The next item following a partial list of returned resources. For -- example, if a request is made to return @maxResults@ number of -- resources, @NextToken@ allows you to return more items in your list -- starting at the location pointed to by the next token. listGatewaysResponse_nextToken :: Lens.Lens' ListGatewaysResponse (Prelude.Maybe Prelude.Text) listGatewaysResponse_nextToken = Lens.lens (\ListGatewaysResponse' {nextToken} -> nextToken) (\s@ListGatewaysResponse' {} a -> s {nextToken = a} :: ListGatewaysResponse) -- | The response's http status code. listGatewaysResponse_httpStatus :: Lens.Lens' ListGatewaysResponse Prelude.Int listGatewaysResponse_httpStatus = Lens.lens (\ListGatewaysResponse' {httpStatus} -> httpStatus) (\s@ListGatewaysResponse' {} a -> s {httpStatus = a} :: ListGatewaysResponse) instance Prelude.NFData ListGatewaysResponse where rnf ListGatewaysResponse' {..} = Prelude.rnf gateways `Prelude.seq` Prelude.rnf nextToken `Prelude.seq` Prelude.rnf httpStatus