{-# 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.FinSpaceData.ListDataViews
-- 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 all available Dataviews for a Dataset.
--
-- This operation returns paginated results.
module Amazonka.FinSpaceData.ListDataViews
  ( -- * Creating a Request
    ListDataViews (..),
    newListDataViews,

    -- * Request Lenses
    listDataViews_maxResults,
    listDataViews_nextToken,
    listDataViews_datasetId,

    -- * Destructuring the Response
    ListDataViewsResponse (..),
    newListDataViewsResponse,

    -- * Response Lenses
    listDataViewsResponse_dataViews,
    listDataViewsResponse_nextToken,
    listDataViewsResponse_httpStatus,
  )
where

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

-- | Request for a list data views.
--
-- /See:/ 'newListDataViews' smart constructor.
data ListDataViews = ListDataViews'
  { -- | The maximum number of results per page.
    ListDataViews -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A token that indicates where a results page should begin.
    ListDataViews -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier of the Dataset for which to retrieve Dataviews.
    ListDataViews -> Text
datasetId :: Prelude.Text
  }
  deriving (ListDataViews -> ListDataViews -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDataViews -> ListDataViews -> Bool
$c/= :: ListDataViews -> ListDataViews -> Bool
== :: ListDataViews -> ListDataViews -> Bool
$c== :: ListDataViews -> ListDataViews -> Bool
Prelude.Eq, ReadPrec [ListDataViews]
ReadPrec ListDataViews
Int -> ReadS ListDataViews
ReadS [ListDataViews]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDataViews]
$creadListPrec :: ReadPrec [ListDataViews]
readPrec :: ReadPrec ListDataViews
$creadPrec :: ReadPrec ListDataViews
readList :: ReadS [ListDataViews]
$creadList :: ReadS [ListDataViews]
readsPrec :: Int -> ReadS ListDataViews
$creadsPrec :: Int -> ReadS ListDataViews
Prelude.Read, Int -> ListDataViews -> ShowS
[ListDataViews] -> ShowS
ListDataViews -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDataViews] -> ShowS
$cshowList :: [ListDataViews] -> ShowS
show :: ListDataViews -> String
$cshow :: ListDataViews -> String
showsPrec :: Int -> ListDataViews -> ShowS
$cshowsPrec :: Int -> ListDataViews -> ShowS
Prelude.Show, forall x. Rep ListDataViews x -> ListDataViews
forall x. ListDataViews -> Rep ListDataViews x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDataViews x -> ListDataViews
$cfrom :: forall x. ListDataViews -> Rep ListDataViews x
Prelude.Generic)

-- |
-- Create a value of 'ListDataViews' 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', 'listDataViews_maxResults' - The maximum number of results per page.
--
-- 'nextToken', 'listDataViews_nextToken' - A token that indicates where a results page should begin.
--
-- 'datasetId', 'listDataViews_datasetId' - The unique identifier of the Dataset for which to retrieve Dataviews.
newListDataViews ::
  -- | 'datasetId'
  Prelude.Text ->
  ListDataViews
newListDataViews :: Text -> ListDataViews
newListDataViews Text
pDatasetId_ =
  ListDataViews'
    { $sel:maxResults:ListDataViews' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDataViews' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:datasetId:ListDataViews' :: Text
datasetId = Text
pDatasetId_
    }

-- | The maximum number of results per page.
listDataViews_maxResults :: Lens.Lens' ListDataViews (Prelude.Maybe Prelude.Natural)
listDataViews_maxResults :: Lens' ListDataViews (Maybe Natural)
listDataViews_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDataViews' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListDataViews' :: ListDataViews -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListDataViews
s@ListDataViews' {} Maybe Natural
a -> ListDataViews
s {$sel:maxResults:ListDataViews' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListDataViews)

-- | A token that indicates where a results page should begin.
listDataViews_nextToken :: Lens.Lens' ListDataViews (Prelude.Maybe Prelude.Text)
listDataViews_nextToken :: Lens' ListDataViews (Maybe Text)
listDataViews_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDataViews' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDataViews' :: ListDataViews -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDataViews
s@ListDataViews' {} Maybe Text
a -> ListDataViews
s {$sel:nextToken:ListDataViews' :: Maybe Text
nextToken = Maybe Text
a} :: ListDataViews)

-- | The unique identifier of the Dataset for which to retrieve Dataviews.
listDataViews_datasetId :: Lens.Lens' ListDataViews Prelude.Text
listDataViews_datasetId :: Lens' ListDataViews Text
listDataViews_datasetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDataViews' {Text
datasetId :: Text
$sel:datasetId:ListDataViews' :: ListDataViews -> Text
datasetId} -> Text
datasetId) (\s :: ListDataViews
s@ListDataViews' {} Text
a -> ListDataViews
s {$sel:datasetId:ListDataViews' :: Text
datasetId = Text
a} :: ListDataViews)

instance Core.AWSPager ListDataViews where
  page :: ListDataViews -> AWSResponse ListDataViews -> Maybe ListDataViews
page ListDataViews
rq AWSResponse ListDataViews
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListDataViews
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListDataViewsResponse (Maybe Text)
listDataViewsResponse_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 ListDataViews
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListDataViewsResponse (Maybe [DataViewSummary])
listDataViewsResponse_dataViews
            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.$ ListDataViews
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListDataViews (Maybe Text)
listDataViews_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListDataViews
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListDataViewsResponse (Maybe Text)
listDataViewsResponse_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 ListDataViews where
  type
    AWSResponse ListDataViews =
      ListDataViewsResponse
  request :: (Service -> Service) -> ListDataViews -> Request ListDataViews
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 ListDataViews
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDataViews)))
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 [DataViewSummary]
-> Maybe Text -> Int -> ListDataViewsResponse
ListDataViewsResponse'
            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
"dataViews" 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 ListDataViews where
  hashWithSalt :: Int -> ListDataViews -> Int
hashWithSalt Int
_salt ListDataViews' {Maybe Natural
Maybe Text
Text
datasetId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:datasetId:ListDataViews' :: ListDataViews -> Text
$sel:nextToken:ListDataViews' :: ListDataViews -> Maybe Text
$sel:maxResults:ListDataViews' :: ListDataViews -> 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` Text
datasetId

instance Prelude.NFData ListDataViews where
  rnf :: ListDataViews -> ()
rnf ListDataViews' {Maybe Natural
Maybe Text
Text
datasetId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:datasetId:ListDataViews' :: ListDataViews -> Text
$sel:nextToken:ListDataViews' :: ListDataViews -> Maybe Text
$sel:maxResults:ListDataViews' :: ListDataViews -> 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 Text
datasetId

instance Data.ToHeaders ListDataViews where
  toHeaders :: ListDataViews -> 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 ListDataViews where
  toPath :: ListDataViews -> ByteString
toPath ListDataViews' {Maybe Natural
Maybe Text
Text
datasetId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:datasetId:ListDataViews' :: ListDataViews -> Text
$sel:nextToken:ListDataViews' :: ListDataViews -> Maybe Text
$sel:maxResults:ListDataViews' :: ListDataViews -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/datasets/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
datasetId, ByteString
"/dataviewsv2"]

instance Data.ToQuery ListDataViews where
  toQuery :: ListDataViews -> QueryString
toQuery ListDataViews' {Maybe Natural
Maybe Text
Text
datasetId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:datasetId:ListDataViews' :: ListDataViews -> Text
$sel:nextToken:ListDataViews' :: ListDataViews -> Maybe Text
$sel:maxResults:ListDataViews' :: ListDataViews -> 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
      ]

-- | /See:/ 'newListDataViewsResponse' smart constructor.
data ListDataViewsResponse = ListDataViewsResponse'
  { -- | A list of Dataviews.
    ListDataViewsResponse -> Maybe [DataViewSummary]
dataViews :: Prelude.Maybe [DataViewSummary],
    -- | A token that indicates where a results page should begin.
    ListDataViewsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListDataViewsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDataViewsResponse -> ListDataViewsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDataViewsResponse -> ListDataViewsResponse -> Bool
$c/= :: ListDataViewsResponse -> ListDataViewsResponse -> Bool
== :: ListDataViewsResponse -> ListDataViewsResponse -> Bool
$c== :: ListDataViewsResponse -> ListDataViewsResponse -> Bool
Prelude.Eq, ReadPrec [ListDataViewsResponse]
ReadPrec ListDataViewsResponse
Int -> ReadS ListDataViewsResponse
ReadS [ListDataViewsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDataViewsResponse]
$creadListPrec :: ReadPrec [ListDataViewsResponse]
readPrec :: ReadPrec ListDataViewsResponse
$creadPrec :: ReadPrec ListDataViewsResponse
readList :: ReadS [ListDataViewsResponse]
$creadList :: ReadS [ListDataViewsResponse]
readsPrec :: Int -> ReadS ListDataViewsResponse
$creadsPrec :: Int -> ReadS ListDataViewsResponse
Prelude.Read, Int -> ListDataViewsResponse -> ShowS
[ListDataViewsResponse] -> ShowS
ListDataViewsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDataViewsResponse] -> ShowS
$cshowList :: [ListDataViewsResponse] -> ShowS
show :: ListDataViewsResponse -> String
$cshow :: ListDataViewsResponse -> String
showsPrec :: Int -> ListDataViewsResponse -> ShowS
$cshowsPrec :: Int -> ListDataViewsResponse -> ShowS
Prelude.Show, forall x. Rep ListDataViewsResponse x -> ListDataViewsResponse
forall x. ListDataViewsResponse -> Rep ListDataViewsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDataViewsResponse x -> ListDataViewsResponse
$cfrom :: forall x. ListDataViewsResponse -> Rep ListDataViewsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListDataViewsResponse' 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:
--
-- 'dataViews', 'listDataViewsResponse_dataViews' - A list of Dataviews.
--
-- 'nextToken', 'listDataViewsResponse_nextToken' - A token that indicates where a results page should begin.
--
-- 'httpStatus', 'listDataViewsResponse_httpStatus' - The response's http status code.
newListDataViewsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDataViewsResponse
newListDataViewsResponse :: Int -> ListDataViewsResponse
newListDataViewsResponse Int
pHttpStatus_ =
  ListDataViewsResponse'
    { $sel:dataViews:ListDataViewsResponse' :: Maybe [DataViewSummary]
dataViews = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDataViewsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDataViewsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of Dataviews.
listDataViewsResponse_dataViews :: Lens.Lens' ListDataViewsResponse (Prelude.Maybe [DataViewSummary])
listDataViewsResponse_dataViews :: Lens' ListDataViewsResponse (Maybe [DataViewSummary])
listDataViewsResponse_dataViews = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDataViewsResponse' {Maybe [DataViewSummary]
dataViews :: Maybe [DataViewSummary]
$sel:dataViews:ListDataViewsResponse' :: ListDataViewsResponse -> Maybe [DataViewSummary]
dataViews} -> Maybe [DataViewSummary]
dataViews) (\s :: ListDataViewsResponse
s@ListDataViewsResponse' {} Maybe [DataViewSummary]
a -> ListDataViewsResponse
s {$sel:dataViews:ListDataViewsResponse' :: Maybe [DataViewSummary]
dataViews = Maybe [DataViewSummary]
a} :: ListDataViewsResponse) 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

-- | A token that indicates where a results page should begin.
listDataViewsResponse_nextToken :: Lens.Lens' ListDataViewsResponse (Prelude.Maybe Prelude.Text)
listDataViewsResponse_nextToken :: Lens' ListDataViewsResponse (Maybe Text)
listDataViewsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDataViewsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDataViewsResponse' :: ListDataViewsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDataViewsResponse
s@ListDataViewsResponse' {} Maybe Text
a -> ListDataViewsResponse
s {$sel:nextToken:ListDataViewsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListDataViewsResponse)

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

instance Prelude.NFData ListDataViewsResponse where
  rnf :: ListDataViewsResponse -> ()
rnf ListDataViewsResponse' {Int
Maybe [DataViewSummary]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
dataViews :: Maybe [DataViewSummary]
$sel:httpStatus:ListDataViewsResponse' :: ListDataViewsResponse -> Int
$sel:nextToken:ListDataViewsResponse' :: ListDataViewsResponse -> Maybe Text
$sel:dataViews:ListDataViewsResponse' :: ListDataViewsResponse -> Maybe [DataViewSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DataViewSummary]
dataViews
      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