{-# 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.DataExchange.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)
--
-- This operation lists your data sets. When listing by origin OWNED,
-- results are sorted by CreatedAt in descending order. When listing by
-- origin ENTITLED, there is no order and the maxResults parameter is
-- ignored.
--
-- This operation returns paginated results.
module Amazonka.DataExchange.ListDataSets
  ( -- * Creating a Request
    ListDataSets (..),
    newListDataSets,

    -- * Request Lenses
    listDataSets_maxResults,
    listDataSets_nextToken,
    listDataSets_origin,

    -- * Destructuring the Response
    ListDataSetsResponse (..),
    newListDataSetsResponse,

    -- * Response Lenses
    listDataSetsResponse_dataSets,
    listDataSetsResponse_nextToken,
    listDataSetsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DataExchange.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListDataSets' smart constructor.
data ListDataSets = ListDataSets'
  { -- | The maximum number of results returned by a single call.
    ListDataSets -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token value retrieved from a previous call to access the next page
    -- of results.
    ListDataSets -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A property that defines the data set as OWNED by the account (for
    -- providers) or ENTITLED to the account (for subscribers).
    ListDataSets -> Maybe Text
origin :: Prelude.Maybe Prelude.Text
  }
  deriving (ListDataSets -> ListDataSets -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDataSets -> ListDataSets -> Bool
$c/= :: ListDataSets -> ListDataSets -> Bool
== :: ListDataSets -> ListDataSets -> Bool
$c== :: ListDataSets -> ListDataSets -> Bool
Prelude.Eq, ReadPrec [ListDataSets]
ReadPrec ListDataSets
Int -> ReadS ListDataSets
ReadS [ListDataSets]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDataSets]
$creadListPrec :: ReadPrec [ListDataSets]
readPrec :: ReadPrec ListDataSets
$creadPrec :: ReadPrec ListDataSets
readList :: ReadS [ListDataSets]
$creadList :: ReadS [ListDataSets]
readsPrec :: Int -> ReadS ListDataSets
$creadsPrec :: Int -> ReadS ListDataSets
Prelude.Read, Int -> ListDataSets -> ShowS
[ListDataSets] -> ShowS
ListDataSets -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDataSets] -> ShowS
$cshowList :: [ListDataSets] -> ShowS
show :: ListDataSets -> String
$cshow :: ListDataSets -> String
showsPrec :: Int -> ListDataSets -> ShowS
$cshowsPrec :: Int -> ListDataSets -> ShowS
Prelude.Show, forall x. Rep ListDataSets x -> ListDataSets
forall x. ListDataSets -> Rep ListDataSets x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDataSets x -> ListDataSets
$cfrom :: forall x. ListDataSets -> Rep ListDataSets x
Prelude.Generic)

-- |
-- Create a value of 'ListDataSets' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> 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 returned by a single call.
--
-- 'nextToken', 'listDataSets_nextToken' - The token value retrieved from a previous call to access the next page
-- of results.
--
-- 'origin', 'listDataSets_origin' - A property that defines the data set as OWNED by the account (for
-- providers) or ENTITLED to the account (for subscribers).
newListDataSets ::
  ListDataSets
newListDataSets :: ListDataSets
newListDataSets =
  ListDataSets'
    { $sel:maxResults:ListDataSets' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDataSets' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:origin:ListDataSets' :: Maybe Text
origin = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of results returned by a single call.
listDataSets_maxResults :: Lens.Lens' ListDataSets (Prelude.Maybe Prelude.Natural)
listDataSets_maxResults :: Lens' ListDataSets (Maybe Natural)
listDataSets_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDataSets' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListDataSets' :: ListDataSets -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListDataSets
s@ListDataSets' {} Maybe Natural
a -> ListDataSets
s {$sel:maxResults:ListDataSets' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListDataSets)

-- | The token value retrieved from a previous call to access the next page
-- of results.
listDataSets_nextToken :: Lens.Lens' ListDataSets (Prelude.Maybe Prelude.Text)
listDataSets_nextToken :: Lens' ListDataSets (Maybe Text)
listDataSets_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDataSets' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDataSets' :: ListDataSets -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDataSets
s@ListDataSets' {} Maybe Text
a -> ListDataSets
s {$sel:nextToken:ListDataSets' :: Maybe Text
nextToken = Maybe Text
a} :: ListDataSets)

-- | A property that defines the data set as OWNED by the account (for
-- providers) or ENTITLED to the account (for subscribers).
listDataSets_origin :: Lens.Lens' ListDataSets (Prelude.Maybe Prelude.Text)
listDataSets_origin :: Lens' ListDataSets (Maybe Text)
listDataSets_origin = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDataSets' {Maybe Text
origin :: Maybe Text
$sel:origin:ListDataSets' :: ListDataSets -> Maybe Text
origin} -> Maybe Text
origin) (\s :: ListDataSets
s@ListDataSets' {} Maybe Text
a -> ListDataSets
s {$sel:origin:ListDataSets' :: Maybe Text
origin = Maybe Text
a} :: ListDataSets)

instance Core.AWSPager ListDataSets where
  page :: ListDataSets -> AWSResponse ListDataSets -> Maybe ListDataSets
page ListDataSets
rq AWSResponse ListDataSets
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListDataSets
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListDataSetsResponse (Maybe Text)
listDataSetsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListDataSets
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListDataSetsResponse (Maybe [DataSetEntry])
listDataSetsResponse_dataSets
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListDataSets
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListDataSets (Maybe Text)
listDataSets_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListDataSets
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListDataSetsResponse (Maybe Text)
listDataSetsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListDataSets where
  type AWSResponse ListDataSets = ListDataSetsResponse
  request :: (Service -> Service) -> ListDataSets -> Request ListDataSets
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListDataSets
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDataSets)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [DataSetEntry] -> Maybe Text -> Int -> ListDataSetsResponse
ListDataSetsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"DataSets" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"NextToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListDataSets where
  hashWithSalt :: Int -> ListDataSets -> Int
hashWithSalt Int
_salt ListDataSets' {Maybe Natural
Maybe Text
origin :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:origin:ListDataSets' :: ListDataSets -> Maybe Text
$sel:nextToken:ListDataSets' :: ListDataSets -> Maybe Text
$sel:maxResults:ListDataSets' :: ListDataSets -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
origin

instance Prelude.NFData ListDataSets where
  rnf :: ListDataSets -> ()
rnf ListDataSets' {Maybe Natural
Maybe Text
origin :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:origin:ListDataSets' :: ListDataSets -> Maybe Text
$sel:nextToken:ListDataSets' :: ListDataSets -> Maybe Text
$sel:maxResults:ListDataSets' :: ListDataSets -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
origin

instance Data.ToHeaders ListDataSets where
  toHeaders :: ListDataSets -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath ListDataSets where
  toPath :: ListDataSets -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/v1/data-sets"

instance Data.ToQuery ListDataSets where
  toQuery :: ListDataSets -> QueryString
toQuery ListDataSets' {Maybe Natural
Maybe Text
origin :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:origin:ListDataSets' :: ListDataSets -> Maybe Text
$sel:nextToken:ListDataSets' :: ListDataSets -> Maybe Text
$sel:maxResults:ListDataSets' :: ListDataSets -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken,
        ByteString
"origin" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
origin
      ]

-- | /See:/ 'newListDataSetsResponse' smart constructor.
data ListDataSetsResponse = ListDataSetsResponse'
  { -- | The data set objects listed by the request.
    ListDataSetsResponse -> Maybe [DataSetEntry]
dataSets :: Prelude.Maybe [DataSetEntry],
    -- | The token value retrieved from a previous call to access the next page
    -- of results.
    ListDataSetsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListDataSetsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDataSetsResponse -> ListDataSetsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDataSetsResponse -> ListDataSetsResponse -> Bool
$c/= :: ListDataSetsResponse -> ListDataSetsResponse -> Bool
== :: ListDataSetsResponse -> ListDataSetsResponse -> Bool
$c== :: ListDataSetsResponse -> ListDataSetsResponse -> Bool
Prelude.Eq, ReadPrec [ListDataSetsResponse]
ReadPrec ListDataSetsResponse
Int -> ReadS ListDataSetsResponse
ReadS [ListDataSetsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDataSetsResponse]
$creadListPrec :: ReadPrec [ListDataSetsResponse]
readPrec :: ReadPrec ListDataSetsResponse
$creadPrec :: ReadPrec ListDataSetsResponse
readList :: ReadS [ListDataSetsResponse]
$creadList :: ReadS [ListDataSetsResponse]
readsPrec :: Int -> ReadS ListDataSetsResponse
$creadsPrec :: Int -> ReadS ListDataSetsResponse
Prelude.Read, Int -> ListDataSetsResponse -> ShowS
[ListDataSetsResponse] -> ShowS
ListDataSetsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDataSetsResponse] -> ShowS
$cshowList :: [ListDataSetsResponse] -> ShowS
show :: ListDataSetsResponse -> String
$cshow :: ListDataSetsResponse -> String
showsPrec :: Int -> ListDataSetsResponse -> ShowS
$cshowsPrec :: Int -> ListDataSetsResponse -> ShowS
Prelude.Show, forall x. Rep ListDataSetsResponse x -> ListDataSetsResponse
forall x. ListDataSetsResponse -> Rep ListDataSetsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDataSetsResponse x -> ListDataSetsResponse
$cfrom :: forall x. ListDataSetsResponse -> Rep ListDataSetsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListDataSetsResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'dataSets', 'listDataSetsResponse_dataSets' - The data set objects listed by the request.
--
-- 'nextToken', 'listDataSetsResponse_nextToken' - The token value retrieved from a previous call to access the next page
-- of results.
--
-- 'httpStatus', 'listDataSetsResponse_httpStatus' - The response's http status code.
newListDataSetsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDataSetsResponse
newListDataSetsResponse :: Int -> ListDataSetsResponse
newListDataSetsResponse Int
pHttpStatus_ =
  ListDataSetsResponse'
    { $sel:dataSets:ListDataSetsResponse' :: Maybe [DataSetEntry]
dataSets = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDataSetsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDataSetsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The data set objects listed by the request.
listDataSetsResponse_dataSets :: Lens.Lens' ListDataSetsResponse (Prelude.Maybe [DataSetEntry])
listDataSetsResponse_dataSets :: Lens' ListDataSetsResponse (Maybe [DataSetEntry])
listDataSetsResponse_dataSets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDataSetsResponse' {Maybe [DataSetEntry]
dataSets :: Maybe [DataSetEntry]
$sel:dataSets:ListDataSetsResponse' :: ListDataSetsResponse -> Maybe [DataSetEntry]
dataSets} -> Maybe [DataSetEntry]
dataSets) (\s :: ListDataSetsResponse
s@ListDataSetsResponse' {} Maybe [DataSetEntry]
a -> ListDataSetsResponse
s {$sel:dataSets:ListDataSetsResponse' :: Maybe [DataSetEntry]
dataSets = Maybe [DataSetEntry]
a} :: ListDataSetsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token value retrieved from a previous call to access the next page
-- of results.
listDataSetsResponse_nextToken :: Lens.Lens' ListDataSetsResponse (Prelude.Maybe Prelude.Text)
listDataSetsResponse_nextToken :: Lens' ListDataSetsResponse (Maybe Text)
listDataSetsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDataSetsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDataSetsResponse' :: ListDataSetsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDataSetsResponse
s@ListDataSetsResponse' {} Maybe Text
a -> ListDataSetsResponse
s {$sel:nextToken:ListDataSetsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListDataSetsResponse)

-- | The response's http status code.
listDataSetsResponse_httpStatus :: Lens.Lens' ListDataSetsResponse Prelude.Int
listDataSetsResponse_httpStatus :: Lens' ListDataSetsResponse Int
listDataSetsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDataSetsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListDataSetsResponse' :: ListDataSetsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListDataSetsResponse
s@ListDataSetsResponse' {} Int
a -> ListDataSetsResponse
s {$sel:httpStatus:ListDataSetsResponse' :: Int
httpStatus = Int
a} :: ListDataSetsResponse)

instance Prelude.NFData ListDataSetsResponse where
  rnf :: ListDataSetsResponse -> ()
rnf ListDataSetsResponse' {Int
Maybe [DataSetEntry]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
dataSets :: Maybe [DataSetEntry]
$sel:httpStatus:ListDataSetsResponse' :: ListDataSetsResponse -> Int
$sel:nextToken:ListDataSetsResponse' :: ListDataSetsResponse -> Maybe Text
$sel:dataSets:ListDataSetsResponse' :: ListDataSetsResponse -> Maybe [DataSetEntry]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DataSetEntry]
dataSets
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus