{-# 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.StartContentUpload
(
StartContentUpload (..),
newStartContentUpload,
startContentUpload_contentType,
startContentUpload_knowledgeBaseId,
StartContentUploadResponse (..),
newStartContentUploadResponse,
startContentUploadResponse_httpStatus,
startContentUploadResponse_headersToInclude,
startContentUploadResponse_uploadId,
startContentUploadResponse_url,
startContentUploadResponse_urlExpiry,
)
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 StartContentUpload = StartContentUpload'
{
StartContentUpload -> Text
contentType :: Prelude.Text,
StartContentUpload -> Text
knowledgeBaseId :: Prelude.Text
}
deriving (StartContentUpload -> StartContentUpload -> Bool
(StartContentUpload -> StartContentUpload -> Bool)
-> (StartContentUpload -> StartContentUpload -> Bool)
-> Eq StartContentUpload
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartContentUpload -> StartContentUpload -> Bool
$c/= :: StartContentUpload -> StartContentUpload -> Bool
== :: StartContentUpload -> StartContentUpload -> Bool
$c== :: StartContentUpload -> StartContentUpload -> Bool
Prelude.Eq, ReadPrec [StartContentUpload]
ReadPrec StartContentUpload
Int -> ReadS StartContentUpload
ReadS [StartContentUpload]
(Int -> ReadS StartContentUpload)
-> ReadS [StartContentUpload]
-> ReadPrec StartContentUpload
-> ReadPrec [StartContentUpload]
-> Read StartContentUpload
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartContentUpload]
$creadListPrec :: ReadPrec [StartContentUpload]
readPrec :: ReadPrec StartContentUpload
$creadPrec :: ReadPrec StartContentUpload
readList :: ReadS [StartContentUpload]
$creadList :: ReadS [StartContentUpload]
readsPrec :: Int -> ReadS StartContentUpload
$creadsPrec :: Int -> ReadS StartContentUpload
Prelude.Read, Int -> StartContentUpload -> ShowS
[StartContentUpload] -> ShowS
StartContentUpload -> String
(Int -> StartContentUpload -> ShowS)
-> (StartContentUpload -> String)
-> ([StartContentUpload] -> ShowS)
-> Show StartContentUpload
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartContentUpload] -> ShowS
$cshowList :: [StartContentUpload] -> ShowS
show :: StartContentUpload -> String
$cshow :: StartContentUpload -> String
showsPrec :: Int -> StartContentUpload -> ShowS
$cshowsPrec :: Int -> StartContentUpload -> ShowS
Prelude.Show, (forall x. StartContentUpload -> Rep StartContentUpload x)
-> (forall x. Rep StartContentUpload x -> StartContentUpload)
-> Generic StartContentUpload
forall x. Rep StartContentUpload x -> StartContentUpload
forall x. StartContentUpload -> Rep StartContentUpload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartContentUpload x -> StartContentUpload
$cfrom :: forall x. StartContentUpload -> Rep StartContentUpload x
Prelude.Generic)
newStartContentUpload ::
Prelude.Text ->
Prelude.Text ->
StartContentUpload
newStartContentUpload :: Text -> Text -> StartContentUpload
newStartContentUpload Text
pContentType_ Text
pKnowledgeBaseId_ =
StartContentUpload' :: Text -> Text -> StartContentUpload
StartContentUpload'
{ $sel:contentType:StartContentUpload' :: Text
contentType = Text
pContentType_,
$sel:knowledgeBaseId:StartContentUpload' :: Text
knowledgeBaseId = Text
pKnowledgeBaseId_
}
startContentUpload_contentType :: Lens.Lens' StartContentUpload Prelude.Text
startContentUpload_contentType :: (Text -> f Text) -> StartContentUpload -> f StartContentUpload
startContentUpload_contentType = (StartContentUpload -> Text)
-> (StartContentUpload -> Text -> StartContentUpload)
-> Lens StartContentUpload StartContentUpload Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartContentUpload' {Text
contentType :: Text
$sel:contentType:StartContentUpload' :: StartContentUpload -> Text
contentType} -> Text
contentType) (\s :: StartContentUpload
s@StartContentUpload' {} Text
a -> StartContentUpload
s {$sel:contentType:StartContentUpload' :: Text
contentType = Text
a} :: StartContentUpload)
startContentUpload_knowledgeBaseId :: Lens.Lens' StartContentUpload Prelude.Text
startContentUpload_knowledgeBaseId :: (Text -> f Text) -> StartContentUpload -> f StartContentUpload
startContentUpload_knowledgeBaseId = (StartContentUpload -> Text)
-> (StartContentUpload -> Text -> StartContentUpload)
-> Lens StartContentUpload StartContentUpload Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartContentUpload' {Text
knowledgeBaseId :: Text
$sel:knowledgeBaseId:StartContentUpload' :: StartContentUpload -> Text
knowledgeBaseId} -> Text
knowledgeBaseId) (\s :: StartContentUpload
s@StartContentUpload' {} Text
a -> StartContentUpload
s {$sel:knowledgeBaseId:StartContentUpload' :: Text
knowledgeBaseId = Text
a} :: StartContentUpload)
instance Core.AWSRequest StartContentUpload where
type
AWSResponse StartContentUpload =
StartContentUploadResponse
request :: StartContentUpload -> Request StartContentUpload
request = Service -> StartContentUpload -> Request StartContentUpload
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy StartContentUpload
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse StartContentUpload)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse StartContentUpload))
-> Logger
-> Service
-> Proxy StartContentUpload
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse StartContentUpload)))
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 ->
Int
-> HashMap Text Text
-> Text
-> Sensitive Text
-> POSIX
-> StartContentUploadResponse
StartContentUploadResponse'
(Int
-> HashMap Text Text
-> Text
-> Sensitive Text
-> POSIX
-> StartContentUploadResponse)
-> Either String Int
-> Either
String
(HashMap Text Text
-> Text -> Sensitive Text -> POSIX -> StartContentUploadResponse)
forall (f :: * -> *) a b. Functor 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
(HashMap Text Text
-> Text -> Sensitive Text -> POSIX -> StartContentUploadResponse)
-> Either String (HashMap Text Text)
-> Either
String
(Text -> Sensitive Text -> POSIX -> StartContentUploadResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe (HashMap Text Text))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"headersToInclude"
Either String (Maybe (HashMap Text Text))
-> HashMap Text Text -> Either String (HashMap Text Text)
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ HashMap Text Text
forall a. Monoid a => a
Prelude.mempty
)
Either
String
(Text -> Sensitive Text -> POSIX -> StartContentUploadResponse)
-> Either String Text
-> Either
String (Sensitive Text -> POSIX -> StartContentUploadResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"uploadId")
Either
String (Sensitive Text -> POSIX -> StartContentUploadResponse)
-> Either String (Sensitive Text)
-> Either String (POSIX -> StartContentUploadResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Sensitive Text)
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"url")
Either String (POSIX -> StartContentUploadResponse)
-> Either String POSIX -> Either String StartContentUploadResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String POSIX
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"urlExpiry")
)
instance Prelude.Hashable StartContentUpload
instance Prelude.NFData StartContentUpload
instance Core.ToHeaders StartContentUpload where
toHeaders :: StartContentUpload -> ResponseHeaders
toHeaders =
ResponseHeaders -> StartContentUpload -> 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.ToJSON StartContentUpload where
toJSON :: StartContentUpload -> Value
toJSON StartContentUpload' {Text
knowledgeBaseId :: Text
contentType :: Text
$sel:knowledgeBaseId:StartContentUpload' :: StartContentUpload -> Text
$sel:contentType:StartContentUpload' :: StartContentUpload -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"contentType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
contentType)]
)
instance Core.ToPath StartContentUpload where
toPath :: StartContentUpload -> ByteString
toPath StartContentUpload' {Text
knowledgeBaseId :: Text
contentType :: Text
$sel:knowledgeBaseId:StartContentUpload' :: StartContentUpload -> Text
$sel:contentType:StartContentUpload' :: StartContentUpload -> 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
"/upload"
]
instance Core.ToQuery StartContentUpload where
toQuery :: StartContentUpload -> QueryString
toQuery = QueryString -> StartContentUpload -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data StartContentUploadResponse = StartContentUploadResponse'
{
StartContentUploadResponse -> Int
httpStatus :: Prelude.Int,
:: Prelude.HashMap Prelude.Text Prelude.Text,
StartContentUploadResponse -> Text
uploadId :: Prelude.Text,
StartContentUploadResponse -> Sensitive Text
url :: Core.Sensitive Prelude.Text,
StartContentUploadResponse -> POSIX
urlExpiry :: Core.POSIX
}
deriving (StartContentUploadResponse -> StartContentUploadResponse -> Bool
(StartContentUploadResponse -> StartContentUploadResponse -> Bool)
-> (StartContentUploadResponse
-> StartContentUploadResponse -> Bool)
-> Eq StartContentUploadResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartContentUploadResponse -> StartContentUploadResponse -> Bool
$c/= :: StartContentUploadResponse -> StartContentUploadResponse -> Bool
== :: StartContentUploadResponse -> StartContentUploadResponse -> Bool
$c== :: StartContentUploadResponse -> StartContentUploadResponse -> Bool
Prelude.Eq, Int -> StartContentUploadResponse -> ShowS
[StartContentUploadResponse] -> ShowS
StartContentUploadResponse -> String
(Int -> StartContentUploadResponse -> ShowS)
-> (StartContentUploadResponse -> String)
-> ([StartContentUploadResponse] -> ShowS)
-> Show StartContentUploadResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartContentUploadResponse] -> ShowS
$cshowList :: [StartContentUploadResponse] -> ShowS
show :: StartContentUploadResponse -> String
$cshow :: StartContentUploadResponse -> String
showsPrec :: Int -> StartContentUploadResponse -> ShowS
$cshowsPrec :: Int -> StartContentUploadResponse -> ShowS
Prelude.Show, (forall x.
StartContentUploadResponse -> Rep StartContentUploadResponse x)
-> (forall x.
Rep StartContentUploadResponse x -> StartContentUploadResponse)
-> Generic StartContentUploadResponse
forall x.
Rep StartContentUploadResponse x -> StartContentUploadResponse
forall x.
StartContentUploadResponse -> Rep StartContentUploadResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartContentUploadResponse x -> StartContentUploadResponse
$cfrom :: forall x.
StartContentUploadResponse -> Rep StartContentUploadResponse x
Prelude.Generic)
newStartContentUploadResponse ::
Prelude.Int ->
Prelude.Text ->
Prelude.Text ->
Prelude.UTCTime ->
StartContentUploadResponse
newStartContentUploadResponse :: Int -> Text -> Text -> UTCTime -> StartContentUploadResponse
newStartContentUploadResponse
Int
pHttpStatus_
Text
pUploadId_
Text
pUrl_
UTCTime
pUrlExpiry_ =
StartContentUploadResponse' :: Int
-> HashMap Text Text
-> Text
-> Sensitive Text
-> POSIX
-> StartContentUploadResponse
StartContentUploadResponse'
{ $sel:httpStatus:StartContentUploadResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:headersToInclude:StartContentUploadResponse' :: HashMap Text Text
headersToInclude = HashMap Text Text
forall a. Monoid a => a
Prelude.mempty,
$sel:uploadId:StartContentUploadResponse' :: Text
uploadId = Text
pUploadId_,
$sel:url:StartContentUploadResponse' :: Sensitive Text
url = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pUrl_,
$sel:urlExpiry:StartContentUploadResponse' :: POSIX
urlExpiry = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
-> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pUrlExpiry_
}
startContentUploadResponse_httpStatus :: Lens.Lens' StartContentUploadResponse Prelude.Int
startContentUploadResponse_httpStatus :: (Int -> f Int)
-> StartContentUploadResponse -> f StartContentUploadResponse
startContentUploadResponse_httpStatus = (StartContentUploadResponse -> Int)
-> (StartContentUploadResponse
-> Int -> StartContentUploadResponse)
-> Lens
StartContentUploadResponse StartContentUploadResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartContentUploadResponse' {Int
httpStatus :: Int
$sel:httpStatus:StartContentUploadResponse' :: StartContentUploadResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: StartContentUploadResponse
s@StartContentUploadResponse' {} Int
a -> StartContentUploadResponse
s {$sel:httpStatus:StartContentUploadResponse' :: Int
httpStatus = Int
a} :: StartContentUploadResponse)
startContentUploadResponse_headersToInclude :: Lens.Lens' StartContentUploadResponse (Prelude.HashMap Prelude.Text Prelude.Text)
= (StartContentUploadResponse -> HashMap Text Text)
-> (StartContentUploadResponse
-> HashMap Text Text -> StartContentUploadResponse)
-> Lens
StartContentUploadResponse
StartContentUploadResponse
(HashMap Text Text)
(HashMap Text Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartContentUploadResponse' {HashMap Text Text
headersToInclude :: HashMap Text Text
$sel:headersToInclude:StartContentUploadResponse' :: StartContentUploadResponse -> HashMap Text Text
headersToInclude} -> HashMap Text Text
headersToInclude) (\s :: StartContentUploadResponse
s@StartContentUploadResponse' {} HashMap Text Text
a -> StartContentUploadResponse
s {$sel:headersToInclude:StartContentUploadResponse' :: HashMap Text Text
headersToInclude = HashMap Text Text
a} :: StartContentUploadResponse) ((HashMap Text Text -> f (HashMap Text Text))
-> StartContentUploadResponse -> f StartContentUploadResponse)
-> ((HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text))
-> (HashMap Text Text -> f (HashMap Text Text))
-> StartContentUploadResponse
-> f StartContentUploadResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
startContentUploadResponse_uploadId :: Lens.Lens' StartContentUploadResponse Prelude.Text
startContentUploadResponse_uploadId :: (Text -> f Text)
-> StartContentUploadResponse -> f StartContentUploadResponse
startContentUploadResponse_uploadId = (StartContentUploadResponse -> Text)
-> (StartContentUploadResponse
-> Text -> StartContentUploadResponse)
-> Lens
StartContentUploadResponse StartContentUploadResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartContentUploadResponse' {Text
uploadId :: Text
$sel:uploadId:StartContentUploadResponse' :: StartContentUploadResponse -> Text
uploadId} -> Text
uploadId) (\s :: StartContentUploadResponse
s@StartContentUploadResponse' {} Text
a -> StartContentUploadResponse
s {$sel:uploadId:StartContentUploadResponse' :: Text
uploadId = Text
a} :: StartContentUploadResponse)
startContentUploadResponse_url :: Lens.Lens' StartContentUploadResponse Prelude.Text
startContentUploadResponse_url :: (Text -> f Text)
-> StartContentUploadResponse -> f StartContentUploadResponse
startContentUploadResponse_url = (StartContentUploadResponse -> Sensitive Text)
-> (StartContentUploadResponse
-> Sensitive Text -> StartContentUploadResponse)
-> Lens
StartContentUploadResponse
StartContentUploadResponse
(Sensitive Text)
(Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartContentUploadResponse' {Sensitive Text
url :: Sensitive Text
$sel:url:StartContentUploadResponse' :: StartContentUploadResponse -> Sensitive Text
url} -> Sensitive Text
url) (\s :: StartContentUploadResponse
s@StartContentUploadResponse' {} Sensitive Text
a -> StartContentUploadResponse
s {$sel:url:StartContentUploadResponse' :: Sensitive Text
url = Sensitive Text
a} :: StartContentUploadResponse) ((Sensitive Text -> f (Sensitive Text))
-> StartContentUploadResponse -> f StartContentUploadResponse)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> StartContentUploadResponse
-> f StartContentUploadResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive
startContentUploadResponse_urlExpiry :: Lens.Lens' StartContentUploadResponse Prelude.UTCTime
startContentUploadResponse_urlExpiry :: (UTCTime -> f UTCTime)
-> StartContentUploadResponse -> f StartContentUploadResponse
startContentUploadResponse_urlExpiry = (StartContentUploadResponse -> POSIX)
-> (StartContentUploadResponse
-> POSIX -> StartContentUploadResponse)
-> Lens
StartContentUploadResponse StartContentUploadResponse POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartContentUploadResponse' {POSIX
urlExpiry :: POSIX
$sel:urlExpiry:StartContentUploadResponse' :: StartContentUploadResponse -> POSIX
urlExpiry} -> POSIX
urlExpiry) (\s :: StartContentUploadResponse
s@StartContentUploadResponse' {} POSIX
a -> StartContentUploadResponse
s {$sel:urlExpiry:StartContentUploadResponse' :: POSIX
urlExpiry = POSIX
a} :: StartContentUploadResponse) ((POSIX -> f POSIX)
-> StartContentUploadResponse -> f StartContentUploadResponse)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> StartContentUploadResponse
-> f StartContentUploadResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time
instance Prelude.NFData StartContentUploadResponse