{-# 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.LakeFormation.ListResources
-- 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 the resources registered to be managed by the Data Catalog.
module Amazonka.LakeFormation.ListResources
  ( -- * Creating a Request
    ListResources (..),
    newListResources,

    -- * Request Lenses
    listResources_filterConditionList,
    listResources_maxResults,
    listResources_nextToken,

    -- * Destructuring the Response
    ListResourcesResponse (..),
    newListResourcesResponse,

    -- * Response Lenses
    listResourcesResponse_nextToken,
    listResourcesResponse_resourceInfoList,
    listResourcesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListResources' smart constructor.
data ListResources = ListResources'
  { -- | Any applicable row-level and\/or column-level filtering conditions for
    -- the resources.
    ListResources -> Maybe (NonEmpty FilterCondition)
filterConditionList :: Prelude.Maybe (Prelude.NonEmpty FilterCondition),
    -- | The maximum number of resource results.
    ListResources -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A continuation token, if this is not the first call to retrieve these
    -- resources.
    ListResources -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListResources -> ListResources -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListResources -> ListResources -> Bool
$c/= :: ListResources -> ListResources -> Bool
== :: ListResources -> ListResources -> Bool
$c== :: ListResources -> ListResources -> Bool
Prelude.Eq, ReadPrec [ListResources]
ReadPrec ListResources
Int -> ReadS ListResources
ReadS [ListResources]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListResources]
$creadListPrec :: ReadPrec [ListResources]
readPrec :: ReadPrec ListResources
$creadPrec :: ReadPrec ListResources
readList :: ReadS [ListResources]
$creadList :: ReadS [ListResources]
readsPrec :: Int -> ReadS ListResources
$creadsPrec :: Int -> ReadS ListResources
Prelude.Read, Int -> ListResources -> ShowS
[ListResources] -> ShowS
ListResources -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListResources] -> ShowS
$cshowList :: [ListResources] -> ShowS
show :: ListResources -> String
$cshow :: ListResources -> String
showsPrec :: Int -> ListResources -> ShowS
$cshowsPrec :: Int -> ListResources -> ShowS
Prelude.Show, forall x. Rep ListResources x -> ListResources
forall x. ListResources -> Rep ListResources x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListResources x -> ListResources
$cfrom :: forall x. ListResources -> Rep ListResources x
Prelude.Generic)

-- |
-- Create a value of 'ListResources' 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:
--
-- 'filterConditionList', 'listResources_filterConditionList' - Any applicable row-level and\/or column-level filtering conditions for
-- the resources.
--
-- 'maxResults', 'listResources_maxResults' - The maximum number of resource results.
--
-- 'nextToken', 'listResources_nextToken' - A continuation token, if this is not the first call to retrieve these
-- resources.
newListResources ::
  ListResources
newListResources :: ListResources
newListResources =
  ListResources'
    { $sel:filterConditionList:ListResources' :: Maybe (NonEmpty FilterCondition)
filterConditionList =
        forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListResources' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListResources' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | Any applicable row-level and\/or column-level filtering conditions for
-- the resources.
listResources_filterConditionList :: Lens.Lens' ListResources (Prelude.Maybe (Prelude.NonEmpty FilterCondition))
listResources_filterConditionList :: Lens' ListResources (Maybe (NonEmpty FilterCondition))
listResources_filterConditionList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResources' {Maybe (NonEmpty FilterCondition)
filterConditionList :: Maybe (NonEmpty FilterCondition)
$sel:filterConditionList:ListResources' :: ListResources -> Maybe (NonEmpty FilterCondition)
filterConditionList} -> Maybe (NonEmpty FilterCondition)
filterConditionList) (\s :: ListResources
s@ListResources' {} Maybe (NonEmpty FilterCondition)
a -> ListResources
s {$sel:filterConditionList:ListResources' :: Maybe (NonEmpty FilterCondition)
filterConditionList = Maybe (NonEmpty FilterCondition)
a} :: ListResources) 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 maximum number of resource results.
listResources_maxResults :: Lens.Lens' ListResources (Prelude.Maybe Prelude.Natural)
listResources_maxResults :: Lens' ListResources (Maybe Natural)
listResources_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResources' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListResources' :: ListResources -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListResources
s@ListResources' {} Maybe Natural
a -> ListResources
s {$sel:maxResults:ListResources' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListResources)

-- | A continuation token, if this is not the first call to retrieve these
-- resources.
listResources_nextToken :: Lens.Lens' ListResources (Prelude.Maybe Prelude.Text)
listResources_nextToken :: Lens' ListResources (Maybe Text)
listResources_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResources' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListResources' :: ListResources -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListResources
s@ListResources' {} Maybe Text
a -> ListResources
s {$sel:nextToken:ListResources' :: Maybe Text
nextToken = Maybe Text
a} :: ListResources)

instance Core.AWSRequest ListResources where
  type
    AWSResponse ListResources =
      ListResourcesResponse
  request :: (Service -> Service) -> ListResources -> Request ListResources
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListResources
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListResources)))
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 Text -> Maybe [ResourceInfo] -> Int -> ListResourcesResponse
ListResourcesResponse'
            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
"NextToken")
            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
"ResourceInfoList"
                            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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListResources where
  hashWithSalt :: Int -> ListResources -> Int
hashWithSalt Int
_salt ListResources' {Maybe Natural
Maybe (NonEmpty FilterCondition)
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
filterConditionList :: Maybe (NonEmpty FilterCondition)
$sel:nextToken:ListResources' :: ListResources -> Maybe Text
$sel:maxResults:ListResources' :: ListResources -> Maybe Natural
$sel:filterConditionList:ListResources' :: ListResources -> Maybe (NonEmpty FilterCondition)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty FilterCondition)
filterConditionList
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListResources where
  rnf :: ListResources -> ()
rnf ListResources' {Maybe Natural
Maybe (NonEmpty FilterCondition)
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
filterConditionList :: Maybe (NonEmpty FilterCondition)
$sel:nextToken:ListResources' :: ListResources -> Maybe Text
$sel:maxResults:ListResources' :: ListResources -> Maybe Natural
$sel:filterConditionList:ListResources' :: ListResources -> Maybe (NonEmpty FilterCondition)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty FilterCondition)
filterConditionList
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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

instance Data.ToHeaders ListResources where
  toHeaders :: ListResources -> 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.ToJSON ListResources where
  toJSON :: ListResources -> Value
toJSON ListResources' {Maybe Natural
Maybe (NonEmpty FilterCondition)
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
filterConditionList :: Maybe (NonEmpty FilterCondition)
$sel:nextToken:ListResources' :: ListResources -> Maybe Text
$sel:maxResults:ListResources' :: ListResources -> Maybe Natural
$sel:filterConditionList:ListResources' :: ListResources -> Maybe (NonEmpty FilterCondition)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"FilterConditionList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty FilterCondition)
filterConditionList,
            (Key
"MaxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            (Key
"NextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken
          ]
      )

instance Data.ToPath ListResources where
  toPath :: ListResources -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/ListResources"

instance Data.ToQuery ListResources where
  toQuery :: ListResources -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListResourcesResponse' smart constructor.
data ListResourcesResponse = ListResourcesResponse'
  { -- | A continuation token, if this is not the first call to retrieve these
    -- resources.
    ListResourcesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A summary of the data lake resources.
    ListResourcesResponse -> Maybe [ResourceInfo]
resourceInfoList :: Prelude.Maybe [ResourceInfo],
    -- | The response's http status code.
    ListResourcesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListResourcesResponse -> ListResourcesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListResourcesResponse -> ListResourcesResponse -> Bool
$c/= :: ListResourcesResponse -> ListResourcesResponse -> Bool
== :: ListResourcesResponse -> ListResourcesResponse -> Bool
$c== :: ListResourcesResponse -> ListResourcesResponse -> Bool
Prelude.Eq, ReadPrec [ListResourcesResponse]
ReadPrec ListResourcesResponse
Int -> ReadS ListResourcesResponse
ReadS [ListResourcesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListResourcesResponse]
$creadListPrec :: ReadPrec [ListResourcesResponse]
readPrec :: ReadPrec ListResourcesResponse
$creadPrec :: ReadPrec ListResourcesResponse
readList :: ReadS [ListResourcesResponse]
$creadList :: ReadS [ListResourcesResponse]
readsPrec :: Int -> ReadS ListResourcesResponse
$creadsPrec :: Int -> ReadS ListResourcesResponse
Prelude.Read, Int -> ListResourcesResponse -> ShowS
[ListResourcesResponse] -> ShowS
ListResourcesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListResourcesResponse] -> ShowS
$cshowList :: [ListResourcesResponse] -> ShowS
show :: ListResourcesResponse -> String
$cshow :: ListResourcesResponse -> String
showsPrec :: Int -> ListResourcesResponse -> ShowS
$cshowsPrec :: Int -> ListResourcesResponse -> ShowS
Prelude.Show, forall x. Rep ListResourcesResponse x -> ListResourcesResponse
forall x. ListResourcesResponse -> Rep ListResourcesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListResourcesResponse x -> ListResourcesResponse
$cfrom :: forall x. ListResourcesResponse -> Rep ListResourcesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListResourcesResponse' 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:
--
-- 'nextToken', 'listResourcesResponse_nextToken' - A continuation token, if this is not the first call to retrieve these
-- resources.
--
-- 'resourceInfoList', 'listResourcesResponse_resourceInfoList' - A summary of the data lake resources.
--
-- 'httpStatus', 'listResourcesResponse_httpStatus' - The response's http status code.
newListResourcesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListResourcesResponse
newListResourcesResponse :: Int -> ListResourcesResponse
newListResourcesResponse Int
pHttpStatus_ =
  ListResourcesResponse'
    { $sel:nextToken:ListResourcesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceInfoList:ListResourcesResponse' :: Maybe [ResourceInfo]
resourceInfoList = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListResourcesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A continuation token, if this is not the first call to retrieve these
-- resources.
listResourcesResponse_nextToken :: Lens.Lens' ListResourcesResponse (Prelude.Maybe Prelude.Text)
listResourcesResponse_nextToken :: Lens' ListResourcesResponse (Maybe Text)
listResourcesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResourcesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListResourcesResponse' :: ListResourcesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListResourcesResponse
s@ListResourcesResponse' {} Maybe Text
a -> ListResourcesResponse
s {$sel:nextToken:ListResourcesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListResourcesResponse)

-- | A summary of the data lake resources.
listResourcesResponse_resourceInfoList :: Lens.Lens' ListResourcesResponse (Prelude.Maybe [ResourceInfo])
listResourcesResponse_resourceInfoList :: Lens' ListResourcesResponse (Maybe [ResourceInfo])
listResourcesResponse_resourceInfoList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResourcesResponse' {Maybe [ResourceInfo]
resourceInfoList :: Maybe [ResourceInfo]
$sel:resourceInfoList:ListResourcesResponse' :: ListResourcesResponse -> Maybe [ResourceInfo]
resourceInfoList} -> Maybe [ResourceInfo]
resourceInfoList) (\s :: ListResourcesResponse
s@ListResourcesResponse' {} Maybe [ResourceInfo]
a -> ListResourcesResponse
s {$sel:resourceInfoList:ListResourcesResponse' :: Maybe [ResourceInfo]
resourceInfoList = Maybe [ResourceInfo]
a} :: ListResourcesResponse) 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 response's http status code.
listResourcesResponse_httpStatus :: Lens.Lens' ListResourcesResponse Prelude.Int
listResourcesResponse_httpStatus :: Lens' ListResourcesResponse Int
listResourcesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResourcesResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListResourcesResponse' :: ListResourcesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListResourcesResponse
s@ListResourcesResponse' {} Int
a -> ListResourcesResponse
s {$sel:httpStatus:ListResourcesResponse' :: Int
httpStatus = Int
a} :: ListResourcesResponse)

instance Prelude.NFData ListResourcesResponse where
  rnf :: ListResourcesResponse -> ()
rnf ListResourcesResponse' {Int
Maybe [ResourceInfo]
Maybe Text
httpStatus :: Int
resourceInfoList :: Maybe [ResourceInfo]
nextToken :: Maybe Text
$sel:httpStatus:ListResourcesResponse' :: ListResourcesResponse -> Int
$sel:resourceInfoList:ListResourcesResponse' :: ListResourcesResponse -> Maybe [ResourceInfo]
$sel:nextToken:ListResourcesResponse' :: ListResourcesResponse -> Maybe Text
..} =
    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 [ResourceInfo]
resourceInfoList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus