{-# 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.Connect.ListInstances -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- This API is in preview release for Amazon Connect and is subject to -- change. -- -- Return a list of instances which are in active state, -- creation-in-progress state, and failed state. Instances that aren\'t -- successfully created (they are in a failed state) are returned only for -- 24 hours after the CreateInstance API was invoked. -- -- This operation returns paginated results. module Amazonka.Connect.ListInstances ( -- * Creating a Request ListInstances (..), newListInstances, -- * Request Lenses listInstances_maxResults, listInstances_nextToken, -- * Destructuring the Response ListInstancesResponse (..), newListInstancesResponse, -- * Response Lenses listInstancesResponse_instanceSummaryList, listInstancesResponse_nextToken, listInstancesResponse_httpStatus, ) where import Amazonka.Connect.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:/ 'newListInstances' smart constructor. data ListInstances = ListInstances' { -- | The maximum number of results to return per page. maxResults :: Prelude.Maybe Prelude.Natural, -- | The token for the next set of results. Use the value returned in the -- previous response in the next request to retrieve the next set of -- results. nextToken :: Prelude.Maybe Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListInstances' 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', 'listInstances_maxResults' - The maximum number of results to return per page. -- -- 'nextToken', 'listInstances_nextToken' - The token for the next set of results. Use the value returned in the -- previous response in the next request to retrieve the next set of -- results. newListInstances :: ListInstances newListInstances = ListInstances' { maxResults = Prelude.Nothing, nextToken = Prelude.Nothing } -- | The maximum number of results to return per page. listInstances_maxResults :: Lens.Lens' ListInstances (Prelude.Maybe Prelude.Natural) listInstances_maxResults = Lens.lens (\ListInstances' {maxResults} -> maxResults) (\s@ListInstances' {} a -> s {maxResults = a} :: ListInstances) -- | The token for the next set of results. Use the value returned in the -- previous response in the next request to retrieve the next set of -- results. listInstances_nextToken :: Lens.Lens' ListInstances (Prelude.Maybe Prelude.Text) listInstances_nextToken = Lens.lens (\ListInstances' {nextToken} -> nextToken) (\s@ListInstances' {} a -> s {nextToken = a} :: ListInstances) instance Core.AWSPager ListInstances where page rq rs | Core.stop ( rs Lens.^? listInstancesResponse_nextToken Prelude.. Lens._Just ) = Prelude.Nothing | Core.stop ( rs Lens.^? listInstancesResponse_instanceSummaryList Prelude.. Lens._Just ) = Prelude.Nothing | Prelude.otherwise = Prelude.Just Prelude.$ rq Prelude.& listInstances_nextToken Lens..~ rs Lens.^? listInstancesResponse_nextToken Prelude.. Lens._Just instance Core.AWSRequest ListInstances where type AWSResponse ListInstances = ListInstancesResponse request overrides = Request.get (overrides defaultService) response = Response.receiveJSON ( \s h x -> ListInstancesResponse' Prelude.<$> ( x Data..?> "InstanceSummaryList" Core..!@ Prelude.mempty ) Prelude.<*> (x Data..?> "NextToken") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable ListInstances where hashWithSalt _salt ListInstances' {..} = _salt `Prelude.hashWithSalt` maxResults `Prelude.hashWithSalt` nextToken instance Prelude.NFData ListInstances where rnf ListInstances' {..} = Prelude.rnf maxResults `Prelude.seq` Prelude.rnf nextToken instance Data.ToHeaders ListInstances where toHeaders = Prelude.const ( Prelude.mconcat [ "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToPath ListInstances where toPath = Prelude.const "/instance" instance Data.ToQuery ListInstances where toQuery ListInstances' {..} = Prelude.mconcat [ "maxResults" Data.=: maxResults, "nextToken" Data.=: nextToken ] -- | /See:/ 'newListInstancesResponse' smart constructor. data ListInstancesResponse = ListInstancesResponse' { -- | Information about the instances. instanceSummaryList :: Prelude.Maybe [InstanceSummary], -- | If there are additional results, this is the token for the next set of -- results. 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 'ListInstancesResponse' 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: -- -- 'instanceSummaryList', 'listInstancesResponse_instanceSummaryList' - Information about the instances. -- -- 'nextToken', 'listInstancesResponse_nextToken' - If there are additional results, this is the token for the next set of -- results. -- -- 'httpStatus', 'listInstancesResponse_httpStatus' - The response's http status code. newListInstancesResponse :: -- | 'httpStatus' Prelude.Int -> ListInstancesResponse newListInstancesResponse pHttpStatus_ = ListInstancesResponse' { instanceSummaryList = Prelude.Nothing, nextToken = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | Information about the instances. listInstancesResponse_instanceSummaryList :: Lens.Lens' ListInstancesResponse (Prelude.Maybe [InstanceSummary]) listInstancesResponse_instanceSummaryList = Lens.lens (\ListInstancesResponse' {instanceSummaryList} -> instanceSummaryList) (\s@ListInstancesResponse' {} a -> s {instanceSummaryList = a} :: ListInstancesResponse) Prelude.. Lens.mapping Lens.coerced -- | If there are additional results, this is the token for the next set of -- results. listInstancesResponse_nextToken :: Lens.Lens' ListInstancesResponse (Prelude.Maybe Prelude.Text) listInstancesResponse_nextToken = Lens.lens (\ListInstancesResponse' {nextToken} -> nextToken) (\s@ListInstancesResponse' {} a -> s {nextToken = a} :: ListInstancesResponse) -- | The response's http status code. listInstancesResponse_httpStatus :: Lens.Lens' ListInstancesResponse Prelude.Int listInstancesResponse_httpStatus = Lens.lens (\ListInstancesResponse' {httpStatus} -> httpStatus) (\s@ListInstancesResponse' {} a -> s {httpStatus = a} :: ListInstancesResponse) instance Prelude.NFData ListInstancesResponse where rnf ListInstancesResponse' {..} = Prelude.rnf instanceSummaryList `Prelude.seq` Prelude.rnf nextToken `Prelude.seq` Prelude.rnf httpStatus