{-# 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.CognitoSync.ListDatasets -- 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 datasets for an identity. With Amazon Cognito Sync, each identity -- has access only to its own data. Thus, the credentials used to make this -- API call need to have access to the identity data. -- -- ListDatasets can be called with temporary user credentials provided by -- Cognito Identity or with developer credentials. You should use the -- Cognito Identity credentials to make this API call. module Amazonka.CognitoSync.ListDatasets ( -- * Creating a Request ListDatasets (..), newListDatasets, -- * Request Lenses listDatasets_maxResults, listDatasets_nextToken, listDatasets_identityId, listDatasets_identityPoolId, -- * Destructuring the Response ListDatasetsResponse (..), newListDatasetsResponse, -- * Response Lenses listDatasetsResponse_count, listDatasetsResponse_datasets, listDatasetsResponse_nextToken, listDatasetsResponse_httpStatus, ) where import Amazonka.CognitoSync.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 -- | Request for a list of datasets for an identity. -- -- /See:/ 'newListDatasets' smart constructor. data ListDatasets = ListDatasets' { -- | The maximum number of results to be returned. maxResults :: Prelude.Maybe Prelude.Int, -- | A pagination token for obtaining the next page of results. nextToken :: Prelude.Maybe Prelude.Text, -- | A name-spaced GUID (for example, -- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon -- Cognito. GUID generation is unique within a region. identityId :: Prelude.Text, -- | A name-spaced GUID (for example, -- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon -- Cognito. GUID generation is unique within a region. identityPoolId :: Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListDatasets' 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', 'listDatasets_maxResults' - The maximum number of results to be returned. -- -- 'nextToken', 'listDatasets_nextToken' - A pagination token for obtaining the next page of results. -- -- 'identityId', 'listDatasets_identityId' - A name-spaced GUID (for example, -- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon -- Cognito. GUID generation is unique within a region. -- -- 'identityPoolId', 'listDatasets_identityPoolId' - A name-spaced GUID (for example, -- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon -- Cognito. GUID generation is unique within a region. newListDatasets :: -- | 'identityId' Prelude.Text -> -- | 'identityPoolId' Prelude.Text -> ListDatasets newListDatasets pIdentityId_ pIdentityPoolId_ = ListDatasets' { maxResults = Prelude.Nothing, nextToken = Prelude.Nothing, identityId = pIdentityId_, identityPoolId = pIdentityPoolId_ } -- | The maximum number of results to be returned. listDatasets_maxResults :: Lens.Lens' ListDatasets (Prelude.Maybe Prelude.Int) listDatasets_maxResults = Lens.lens (\ListDatasets' {maxResults} -> maxResults) (\s@ListDatasets' {} a -> s {maxResults = a} :: ListDatasets) -- | A pagination token for obtaining the next page of results. listDatasets_nextToken :: Lens.Lens' ListDatasets (Prelude.Maybe Prelude.Text) listDatasets_nextToken = Lens.lens (\ListDatasets' {nextToken} -> nextToken) (\s@ListDatasets' {} a -> s {nextToken = a} :: ListDatasets) -- | A name-spaced GUID (for example, -- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon -- Cognito. GUID generation is unique within a region. listDatasets_identityId :: Lens.Lens' ListDatasets Prelude.Text listDatasets_identityId = Lens.lens (\ListDatasets' {identityId} -> identityId) (\s@ListDatasets' {} a -> s {identityId = a} :: ListDatasets) -- | A name-spaced GUID (for example, -- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon -- Cognito. GUID generation is unique within a region. listDatasets_identityPoolId :: Lens.Lens' ListDatasets Prelude.Text listDatasets_identityPoolId = Lens.lens (\ListDatasets' {identityPoolId} -> identityPoolId) (\s@ListDatasets' {} a -> s {identityPoolId = a} :: ListDatasets) instance Core.AWSRequest ListDatasets where type AWSResponse ListDatasets = ListDatasetsResponse request overrides = Request.get (overrides defaultService) response = Response.receiveJSON ( \s h x -> ListDatasetsResponse' Prelude.<$> (x Data..?> "Count") Prelude.<*> (x Data..?> "Datasets" Core..!@ Prelude.mempty) Prelude.<*> (x Data..?> "NextToken") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable ListDatasets where hashWithSalt _salt ListDatasets' {..} = _salt `Prelude.hashWithSalt` maxResults `Prelude.hashWithSalt` nextToken `Prelude.hashWithSalt` identityId `Prelude.hashWithSalt` identityPoolId instance Prelude.NFData ListDatasets where rnf ListDatasets' {..} = Prelude.rnf maxResults `Prelude.seq` Prelude.rnf nextToken `Prelude.seq` Prelude.rnf identityId `Prelude.seq` Prelude.rnf identityPoolId instance Data.ToHeaders ListDatasets where toHeaders = Prelude.const ( Prelude.mconcat [ "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToPath ListDatasets where toPath ListDatasets' {..} = Prelude.mconcat [ "/identitypools/", Data.toBS identityPoolId, "/identities/", Data.toBS identityId, "/datasets" ] instance Data.ToQuery ListDatasets where toQuery ListDatasets' {..} = Prelude.mconcat [ "maxResults" Data.=: maxResults, "nextToken" Data.=: nextToken ] -- | Returned for a successful ListDatasets request. -- -- /See:/ 'newListDatasetsResponse' smart constructor. data ListDatasetsResponse = ListDatasetsResponse' { -- | Number of datasets returned. count :: Prelude.Maybe Prelude.Int, -- | A set of datasets. datasets :: Prelude.Maybe [Dataset], -- | A pagination token for obtaining the next page of results. 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 'ListDatasetsResponse' 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: -- -- 'count', 'listDatasetsResponse_count' - Number of datasets returned. -- -- 'datasets', 'listDatasetsResponse_datasets' - A set of datasets. -- -- 'nextToken', 'listDatasetsResponse_nextToken' - A pagination token for obtaining the next page of results. -- -- 'httpStatus', 'listDatasetsResponse_httpStatus' - The response's http status code. newListDatasetsResponse :: -- | 'httpStatus' Prelude.Int -> ListDatasetsResponse newListDatasetsResponse pHttpStatus_ = ListDatasetsResponse' { count = Prelude.Nothing, datasets = Prelude.Nothing, nextToken = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | Number of datasets returned. listDatasetsResponse_count :: Lens.Lens' ListDatasetsResponse (Prelude.Maybe Prelude.Int) listDatasetsResponse_count = Lens.lens (\ListDatasetsResponse' {count} -> count) (\s@ListDatasetsResponse' {} a -> s {count = a} :: ListDatasetsResponse) -- | A set of datasets. listDatasetsResponse_datasets :: Lens.Lens' ListDatasetsResponse (Prelude.Maybe [Dataset]) listDatasetsResponse_datasets = Lens.lens (\ListDatasetsResponse' {datasets} -> datasets) (\s@ListDatasetsResponse' {} a -> s {datasets = a} :: ListDatasetsResponse) Prelude.. Lens.mapping Lens.coerced -- | A pagination token for obtaining the next page of results. listDatasetsResponse_nextToken :: Lens.Lens' ListDatasetsResponse (Prelude.Maybe Prelude.Text) listDatasetsResponse_nextToken = Lens.lens (\ListDatasetsResponse' {nextToken} -> nextToken) (\s@ListDatasetsResponse' {} a -> s {nextToken = a} :: ListDatasetsResponse) -- | The response's http status code. listDatasetsResponse_httpStatus :: Lens.Lens' ListDatasetsResponse Prelude.Int listDatasetsResponse_httpStatus = Lens.lens (\ListDatasetsResponse' {httpStatus} -> httpStatus) (\s@ListDatasetsResponse' {} a -> s {httpStatus = a} :: ListDatasetsResponse) instance Prelude.NFData ListDatasetsResponse where rnf ListDatasetsResponse' {..} = Prelude.rnf count `Prelude.seq` Prelude.rnf datasets `Prelude.seq` Prelude.rnf nextToken `Prelude.seq` Prelude.rnf httpStatus