{-# 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 #-}
module Amazonka.Wisdom.ListContents
(
ListContents (..),
newListContents,
listContents_nextToken,
listContents_maxResults,
listContents_knowledgeBaseId,
ListContentsResponse (..),
newListContentsResponse,
listContentsResponse_nextToken,
listContentsResponse_httpStatus,
listContentsResponse_contentSummaries,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Wisdom.Types
data ListContents = ListContents'
{
ListContents -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListContents -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
ListContents -> Text
knowledgeBaseId :: Prelude.Text
}
deriving (ListContents -> ListContents -> Bool
(ListContents -> ListContents -> Bool)
-> (ListContents -> ListContents -> Bool) -> Eq ListContents
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListContents -> ListContents -> Bool
$c/= :: ListContents -> ListContents -> Bool
== :: ListContents -> ListContents -> Bool
$c== :: ListContents -> ListContents -> Bool
Prelude.Eq, ReadPrec [ListContents]
ReadPrec ListContents
Int -> ReadS ListContents
ReadS [ListContents]
(Int -> ReadS ListContents)
-> ReadS [ListContents]
-> ReadPrec ListContents
-> ReadPrec [ListContents]
-> Read ListContents
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListContents]
$creadListPrec :: ReadPrec [ListContents]
readPrec :: ReadPrec ListContents
$creadPrec :: ReadPrec ListContents
readList :: ReadS [ListContents]
$creadList :: ReadS [ListContents]
readsPrec :: Int -> ReadS ListContents
$creadsPrec :: Int -> ReadS ListContents
Prelude.Read, Int -> ListContents -> ShowS
[ListContents] -> ShowS
ListContents -> String
(Int -> ListContents -> ShowS)
-> (ListContents -> String)
-> ([ListContents] -> ShowS)
-> Show ListContents
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListContents] -> ShowS
$cshowList :: [ListContents] -> ShowS
show :: ListContents -> String
$cshow :: ListContents -> String
showsPrec :: Int -> ListContents -> ShowS
$cshowsPrec :: Int -> ListContents -> ShowS
Prelude.Show, (forall x. ListContents -> Rep ListContents x)
-> (forall x. Rep ListContents x -> ListContents)
-> Generic ListContents
forall x. Rep ListContents x -> ListContents
forall x. ListContents -> Rep ListContents x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListContents x -> ListContents
$cfrom :: forall x. ListContents -> Rep ListContents x
Prelude.Generic)
newListContents ::
Prelude.Text ->
ListContents
newListContents :: Text -> ListContents
newListContents Text
pKnowledgeBaseId_ =
ListContents' :: Maybe Text -> Maybe Natural -> Text -> ListContents
ListContents'
{ $sel:nextToken:ListContents' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:maxResults:ListContents' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:knowledgeBaseId:ListContents' :: Text
knowledgeBaseId = Text
pKnowledgeBaseId_
}
listContents_nextToken :: Lens.Lens' ListContents (Prelude.Maybe Prelude.Text)
listContents_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListContents -> f ListContents
listContents_nextToken = (ListContents -> Maybe Text)
-> (ListContents -> Maybe Text -> ListContents)
-> Lens ListContents ListContents (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContents' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListContents' :: ListContents -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListContents
s@ListContents' {} Maybe Text
a -> ListContents
s {$sel:nextToken:ListContents' :: Maybe Text
nextToken = Maybe Text
a} :: ListContents)
listContents_maxResults :: Lens.Lens' ListContents (Prelude.Maybe Prelude.Natural)
listContents_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListContents -> f ListContents
listContents_maxResults = (ListContents -> Maybe Natural)
-> (ListContents -> Maybe Natural -> ListContents)
-> Lens ListContents ListContents (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContents' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListContents' :: ListContents -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListContents
s@ListContents' {} Maybe Natural
a -> ListContents
s {$sel:maxResults:ListContents' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListContents)
listContents_knowledgeBaseId :: Lens.Lens' ListContents Prelude.Text
listContents_knowledgeBaseId :: (Text -> f Text) -> ListContents -> f ListContents
listContents_knowledgeBaseId = (ListContents -> Text)
-> (ListContents -> Text -> ListContents)
-> Lens ListContents ListContents Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContents' {Text
knowledgeBaseId :: Text
$sel:knowledgeBaseId:ListContents' :: ListContents -> Text
knowledgeBaseId} -> Text
knowledgeBaseId) (\s :: ListContents
s@ListContents' {} Text
a -> ListContents
s {$sel:knowledgeBaseId:ListContents' :: Text
knowledgeBaseId = Text
a} :: ListContents)
instance Core.AWSPager ListContents where
page :: ListContents -> AWSResponse ListContents -> Maybe ListContents
page ListContents
rq AWSResponse ListContents
rs
| Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListContents
ListContentsResponse
rs
ListContentsResponse
-> Getting (First Text) ListContentsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListContentsResponse -> Const (First Text) ListContentsResponse
Lens' ListContentsResponse (Maybe Text)
listContentsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> ListContentsResponse -> Const (First Text) ListContentsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListContentsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe ListContents
forall a. Maybe a
Prelude.Nothing
| [ContentSummary] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
(AWSResponse ListContents
ListContentsResponse
rs ListContentsResponse
-> Getting [ContentSummary] ListContentsResponse [ContentSummary]
-> [ContentSummary]
forall s a. s -> Getting a s a -> a
Lens.^. Getting [ContentSummary] ListContentsResponse [ContentSummary]
Lens' ListContentsResponse [ContentSummary]
listContentsResponse_contentSummaries) =
Maybe ListContents
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
ListContents -> Maybe ListContents
forall a. a -> Maybe a
Prelude.Just (ListContents -> Maybe ListContents)
-> ListContents -> Maybe ListContents
forall a b. (a -> b) -> a -> b
Prelude.$
ListContents
rq
ListContents -> (ListContents -> ListContents) -> ListContents
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListContents -> Identity ListContents
Lens ListContents ListContents (Maybe Text) (Maybe Text)
listContents_nextToken
((Maybe Text -> Identity (Maybe Text))
-> ListContents -> Identity ListContents)
-> Maybe Text -> ListContents -> ListContents
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListContents
ListContentsResponse
rs
ListContentsResponse
-> Getting (First Text) ListContentsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListContentsResponse -> Const (First Text) ListContentsResponse
Lens' ListContentsResponse (Maybe Text)
listContentsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> ListContentsResponse -> Const (First Text) ListContentsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListContentsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
instance Core.AWSRequest ListContents where
type AWSResponse ListContents = ListContentsResponse
request :: ListContents -> Request ListContents
request = Service -> ListContents -> Request ListContents
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
response :: Logger
-> Service
-> Proxy ListContents
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListContents)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse ListContents))
-> Logger
-> Service
-> Proxy ListContents
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListContents)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text -> Int -> [ContentSummary] -> ListContentsResponse
ListContentsResponse'
(Maybe Text -> Int -> [ContentSummary] -> ListContentsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> [ContentSummary] -> ListContentsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextToken")
Either String (Int -> [ContentSummary] -> ListContentsResponse)
-> Either String Int
-> Either String ([ContentSummary] -> ListContentsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
Either String ([ContentSummary] -> ListContentsResponse)
-> Either String [ContentSummary]
-> Either String ListContentsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe [ContentSummary])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"contentSummaries"
Either String (Maybe [ContentSummary])
-> [ContentSummary] -> Either String [ContentSummary]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [ContentSummary]
forall a. Monoid a => a
Prelude.mempty
)
)
instance Prelude.Hashable ListContents
instance Prelude.NFData ListContents
instance Core.ToHeaders ListContents where
toHeaders :: ListContents -> ResponseHeaders
toHeaders =
ResponseHeaders -> ListContents -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToPath ListContents where
toPath :: ListContents -> ByteString
toPath ListContents' {Maybe Natural
Maybe Text
Text
knowledgeBaseId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:knowledgeBaseId:ListContents' :: ListContents -> Text
$sel:maxResults:ListContents' :: ListContents -> Maybe Natural
$sel:nextToken:ListContents' :: ListContents -> Maybe Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/knowledgeBases/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
knowledgeBaseId,
ByteString
"/contents"
]
instance Core.ToQuery ListContents where
toQuery :: ListContents -> QueryString
toQuery ListContents' {Maybe Natural
Maybe Text
Text
knowledgeBaseId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:knowledgeBaseId:ListContents' :: ListContents -> Text
$sel:maxResults:ListContents' :: ListContents -> Maybe Natural
$sel:nextToken:ListContents' :: ListContents -> Maybe Text
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"nextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
ByteString
"maxResults" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxResults
]
data ListContentsResponse = ListContentsResponse'
{
ListContentsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListContentsResponse -> Int
httpStatus :: Prelude.Int,
ListContentsResponse -> [ContentSummary]
contentSummaries :: [ContentSummary]
}
deriving (ListContentsResponse -> ListContentsResponse -> Bool
(ListContentsResponse -> ListContentsResponse -> Bool)
-> (ListContentsResponse -> ListContentsResponse -> Bool)
-> Eq ListContentsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListContentsResponse -> ListContentsResponse -> Bool
$c/= :: ListContentsResponse -> ListContentsResponse -> Bool
== :: ListContentsResponse -> ListContentsResponse -> Bool
$c== :: ListContentsResponse -> ListContentsResponse -> Bool
Prelude.Eq, ReadPrec [ListContentsResponse]
ReadPrec ListContentsResponse
Int -> ReadS ListContentsResponse
ReadS [ListContentsResponse]
(Int -> ReadS ListContentsResponse)
-> ReadS [ListContentsResponse]
-> ReadPrec ListContentsResponse
-> ReadPrec [ListContentsResponse]
-> Read ListContentsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListContentsResponse]
$creadListPrec :: ReadPrec [ListContentsResponse]
readPrec :: ReadPrec ListContentsResponse
$creadPrec :: ReadPrec ListContentsResponse
readList :: ReadS [ListContentsResponse]
$creadList :: ReadS [ListContentsResponse]
readsPrec :: Int -> ReadS ListContentsResponse
$creadsPrec :: Int -> ReadS ListContentsResponse
Prelude.Read, Int -> ListContentsResponse -> ShowS
[ListContentsResponse] -> ShowS
ListContentsResponse -> String
(Int -> ListContentsResponse -> ShowS)
-> (ListContentsResponse -> String)
-> ([ListContentsResponse] -> ShowS)
-> Show ListContentsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListContentsResponse] -> ShowS
$cshowList :: [ListContentsResponse] -> ShowS
show :: ListContentsResponse -> String
$cshow :: ListContentsResponse -> String
showsPrec :: Int -> ListContentsResponse -> ShowS
$cshowsPrec :: Int -> ListContentsResponse -> ShowS
Prelude.Show, (forall x. ListContentsResponse -> Rep ListContentsResponse x)
-> (forall x. Rep ListContentsResponse x -> ListContentsResponse)
-> Generic ListContentsResponse
forall x. Rep ListContentsResponse x -> ListContentsResponse
forall x. ListContentsResponse -> Rep ListContentsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListContentsResponse x -> ListContentsResponse
$cfrom :: forall x. ListContentsResponse -> Rep ListContentsResponse x
Prelude.Generic)
newListContentsResponse ::
Prelude.Int ->
ListContentsResponse
newListContentsResponse :: Int -> ListContentsResponse
newListContentsResponse Int
pHttpStatus_ =
ListContentsResponse' :: Maybe Text -> Int -> [ContentSummary] -> ListContentsResponse
ListContentsResponse'
{ $sel:nextToken:ListContentsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ListContentsResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:contentSummaries:ListContentsResponse' :: [ContentSummary]
contentSummaries = [ContentSummary]
forall a. Monoid a => a
Prelude.mempty
}
listContentsResponse_nextToken :: Lens.Lens' ListContentsResponse (Prelude.Maybe Prelude.Text)
listContentsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListContentsResponse -> f ListContentsResponse
listContentsResponse_nextToken = (ListContentsResponse -> Maybe Text)
-> (ListContentsResponse -> Maybe Text -> ListContentsResponse)
-> Lens' ListContentsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContentsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListContentsResponse' :: ListContentsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListContentsResponse
s@ListContentsResponse' {} Maybe Text
a -> ListContentsResponse
s {$sel:nextToken:ListContentsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListContentsResponse)
listContentsResponse_httpStatus :: Lens.Lens' ListContentsResponse Prelude.Int
listContentsResponse_httpStatus :: (Int -> f Int) -> ListContentsResponse -> f ListContentsResponse
listContentsResponse_httpStatus = (ListContentsResponse -> Int)
-> (ListContentsResponse -> Int -> ListContentsResponse)
-> Lens ListContentsResponse ListContentsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContentsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListContentsResponse' :: ListContentsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListContentsResponse
s@ListContentsResponse' {} Int
a -> ListContentsResponse
s {$sel:httpStatus:ListContentsResponse' :: Int
httpStatus = Int
a} :: ListContentsResponse)
listContentsResponse_contentSummaries :: Lens.Lens' ListContentsResponse [ContentSummary]
listContentsResponse_contentSummaries :: ([ContentSummary] -> f [ContentSummary])
-> ListContentsResponse -> f ListContentsResponse
listContentsResponse_contentSummaries = (ListContentsResponse -> [ContentSummary])
-> (ListContentsResponse
-> [ContentSummary] -> ListContentsResponse)
-> Lens' ListContentsResponse [ContentSummary]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContentsResponse' {[ContentSummary]
contentSummaries :: [ContentSummary]
$sel:contentSummaries:ListContentsResponse' :: ListContentsResponse -> [ContentSummary]
contentSummaries} -> [ContentSummary]
contentSummaries) (\s :: ListContentsResponse
s@ListContentsResponse' {} [ContentSummary]
a -> ListContentsResponse
s {$sel:contentSummaries:ListContentsResponse' :: [ContentSummary]
contentSummaries = [ContentSummary]
a} :: ListContentsResponse) (([ContentSummary] -> f [ContentSummary])
-> ListContentsResponse -> f ListContentsResponse)
-> (([ContentSummary] -> f [ContentSummary])
-> [ContentSummary] -> f [ContentSummary])
-> ([ContentSummary] -> f [ContentSummary])
-> ListContentsResponse
-> f ListContentsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ContentSummary] -> f [ContentSummary])
-> [ContentSummary] -> f [ContentSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Prelude.NFData ListContentsResponse