{-# 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.CreateSession
(
CreateSession (..),
newCreateSession,
createSession_clientToken,
createSession_description,
createSession_tags,
createSession_assistantId,
createSession_name,
CreateSessionResponse (..),
newCreateSessionResponse,
createSessionResponse_session,
createSessionResponse_httpStatus,
)
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 CreateSession = CreateSession'
{
CreateSession -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
CreateSession -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
CreateSession -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
CreateSession -> Text
assistantId :: Prelude.Text,
CreateSession -> Text
name :: Prelude.Text
}
deriving (CreateSession -> CreateSession -> Bool
(CreateSession -> CreateSession -> Bool)
-> (CreateSession -> CreateSession -> Bool) -> Eq CreateSession
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSession -> CreateSession -> Bool
$c/= :: CreateSession -> CreateSession -> Bool
== :: CreateSession -> CreateSession -> Bool
$c== :: CreateSession -> CreateSession -> Bool
Prelude.Eq, ReadPrec [CreateSession]
ReadPrec CreateSession
Int -> ReadS CreateSession
ReadS [CreateSession]
(Int -> ReadS CreateSession)
-> ReadS [CreateSession]
-> ReadPrec CreateSession
-> ReadPrec [CreateSession]
-> Read CreateSession
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSession]
$creadListPrec :: ReadPrec [CreateSession]
readPrec :: ReadPrec CreateSession
$creadPrec :: ReadPrec CreateSession
readList :: ReadS [CreateSession]
$creadList :: ReadS [CreateSession]
readsPrec :: Int -> ReadS CreateSession
$creadsPrec :: Int -> ReadS CreateSession
Prelude.Read, Int -> CreateSession -> ShowS
[CreateSession] -> ShowS
CreateSession -> String
(Int -> CreateSession -> ShowS)
-> (CreateSession -> String)
-> ([CreateSession] -> ShowS)
-> Show CreateSession
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSession] -> ShowS
$cshowList :: [CreateSession] -> ShowS
show :: CreateSession -> String
$cshow :: CreateSession -> String
showsPrec :: Int -> CreateSession -> ShowS
$cshowsPrec :: Int -> CreateSession -> ShowS
Prelude.Show, (forall x. CreateSession -> Rep CreateSession x)
-> (forall x. Rep CreateSession x -> CreateSession)
-> Generic CreateSession
forall x. Rep CreateSession x -> CreateSession
forall x. CreateSession -> Rep CreateSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateSession x -> CreateSession
$cfrom :: forall x. CreateSession -> Rep CreateSession x
Prelude.Generic)
newCreateSession ::
Prelude.Text ->
Prelude.Text ->
CreateSession
newCreateSession :: Text -> Text -> CreateSession
newCreateSession Text
pAssistantId_ Text
pName_ =
CreateSession' :: Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> CreateSession
CreateSession'
{ $sel:clientToken:CreateSession' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:description:CreateSession' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateSession' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:assistantId:CreateSession' :: Text
assistantId = Text
pAssistantId_,
$sel:name:CreateSession' :: Text
name = Text
pName_
}
createSession_clientToken :: Lens.Lens' CreateSession (Prelude.Maybe Prelude.Text)
createSession_clientToken :: (Maybe Text -> f (Maybe Text)) -> CreateSession -> f CreateSession
createSession_clientToken = (CreateSession -> Maybe Text)
-> (CreateSession -> Maybe Text -> CreateSession)
-> Lens CreateSession CreateSession (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSession' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:CreateSession' :: CreateSession -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: CreateSession
s@CreateSession' {} Maybe Text
a -> CreateSession
s {$sel:clientToken:CreateSession' :: Maybe Text
clientToken = Maybe Text
a} :: CreateSession)
createSession_description :: Lens.Lens' CreateSession (Prelude.Maybe Prelude.Text)
createSession_description :: (Maybe Text -> f (Maybe Text)) -> CreateSession -> f CreateSession
createSession_description = (CreateSession -> Maybe Text)
-> (CreateSession -> Maybe Text -> CreateSession)
-> Lens CreateSession CreateSession (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSession' {Maybe Text
description :: Maybe Text
$sel:description:CreateSession' :: CreateSession -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateSession
s@CreateSession' {} Maybe Text
a -> CreateSession
s {$sel:description:CreateSession' :: Maybe Text
description = Maybe Text
a} :: CreateSession)
createSession_tags :: Lens.Lens' CreateSession (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createSession_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateSession -> f CreateSession
createSession_tags = (CreateSession -> Maybe (HashMap Text Text))
-> (CreateSession -> Maybe (HashMap Text Text) -> CreateSession)
-> Lens
CreateSession
CreateSession
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSession' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateSession' :: CreateSession -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateSession
s@CreateSession' {} Maybe (HashMap Text Text)
a -> CreateSession
s {$sel:tags:CreateSession' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateSession) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateSession -> f CreateSession)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateSession
-> f CreateSession
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
-> Iso
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
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 AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createSession_assistantId :: Lens.Lens' CreateSession Prelude.Text
createSession_assistantId :: (Text -> f Text) -> CreateSession -> f CreateSession
createSession_assistantId = (CreateSession -> Text)
-> (CreateSession -> Text -> CreateSession)
-> Lens CreateSession CreateSession Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSession' {Text
assistantId :: Text
$sel:assistantId:CreateSession' :: CreateSession -> Text
assistantId} -> Text
assistantId) (\s :: CreateSession
s@CreateSession' {} Text
a -> CreateSession
s {$sel:assistantId:CreateSession' :: Text
assistantId = Text
a} :: CreateSession)
createSession_name :: Lens.Lens' CreateSession Prelude.Text
createSession_name :: (Text -> f Text) -> CreateSession -> f CreateSession
createSession_name = (CreateSession -> Text)
-> (CreateSession -> Text -> CreateSession)
-> Lens CreateSession CreateSession Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSession' {Text
name :: Text
$sel:name:CreateSession' :: CreateSession -> Text
name} -> Text
name) (\s :: CreateSession
s@CreateSession' {} Text
a -> CreateSession
s {$sel:name:CreateSession' :: Text
name = Text
a} :: CreateSession)
instance Core.AWSRequest CreateSession where
type
AWSResponse CreateSession =
CreateSessionResponse
request :: CreateSession -> Request CreateSession
request = Service -> CreateSession -> Request CreateSession
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateSession
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateSession)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateSession))
-> Logger
-> Service
-> Proxy CreateSession
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateSession)))
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 SessionData -> Int -> CreateSessionResponse
CreateSessionResponse'
(Maybe SessionData -> Int -> CreateSessionResponse)
-> Either String (Maybe SessionData)
-> Either String (Int -> CreateSessionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe SessionData)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"session")
Either String (Int -> CreateSessionResponse)
-> Either String Int -> Either String CreateSessionResponse
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))
)
instance Prelude.Hashable CreateSession
instance Prelude.NFData CreateSession
instance Core.ToHeaders CreateSession where
toHeaders :: CreateSession -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateSession -> 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 CreateSession where
toJSON :: CreateSession -> Value
toJSON CreateSession' {Maybe Text
Maybe (HashMap Text Text)
Text
name :: Text
assistantId :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
clientToken :: Maybe Text
$sel:name:CreateSession' :: CreateSession -> Text
$sel:assistantId:CreateSession' :: CreateSession -> Text
$sel:tags:CreateSession' :: CreateSession -> Maybe (HashMap Text Text)
$sel:description:CreateSession' :: CreateSession -> Maybe Text
$sel:clientToken:CreateSession' :: CreateSession -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"clientToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientToken,
(Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
(Text
"tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
]
)
instance Core.ToPath CreateSession where
toPath :: CreateSession -> ByteString
toPath CreateSession' {Maybe Text
Maybe (HashMap Text Text)
Text
name :: Text
assistantId :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
clientToken :: Maybe Text
$sel:name:CreateSession' :: CreateSession -> Text
$sel:assistantId:CreateSession' :: CreateSession -> Text
$sel:tags:CreateSession' :: CreateSession -> Maybe (HashMap Text Text)
$sel:description:CreateSession' :: CreateSession -> Maybe Text
$sel:clientToken:CreateSession' :: CreateSession -> Maybe Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/assistants/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
assistantId, ByteString
"/sessions"]
instance Core.ToQuery CreateSession where
toQuery :: CreateSession -> QueryString
toQuery = QueryString -> CreateSession -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateSessionResponse = CreateSessionResponse'
{
CreateSessionResponse -> Maybe SessionData
session :: Prelude.Maybe SessionData,
CreateSessionResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateSessionResponse -> CreateSessionResponse -> Bool
(CreateSessionResponse -> CreateSessionResponse -> Bool)
-> (CreateSessionResponse -> CreateSessionResponse -> Bool)
-> Eq CreateSessionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSessionResponse -> CreateSessionResponse -> Bool
$c/= :: CreateSessionResponse -> CreateSessionResponse -> Bool
== :: CreateSessionResponse -> CreateSessionResponse -> Bool
$c== :: CreateSessionResponse -> CreateSessionResponse -> Bool
Prelude.Eq, ReadPrec [CreateSessionResponse]
ReadPrec CreateSessionResponse
Int -> ReadS CreateSessionResponse
ReadS [CreateSessionResponse]
(Int -> ReadS CreateSessionResponse)
-> ReadS [CreateSessionResponse]
-> ReadPrec CreateSessionResponse
-> ReadPrec [CreateSessionResponse]
-> Read CreateSessionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSessionResponse]
$creadListPrec :: ReadPrec [CreateSessionResponse]
readPrec :: ReadPrec CreateSessionResponse
$creadPrec :: ReadPrec CreateSessionResponse
readList :: ReadS [CreateSessionResponse]
$creadList :: ReadS [CreateSessionResponse]
readsPrec :: Int -> ReadS CreateSessionResponse
$creadsPrec :: Int -> ReadS CreateSessionResponse
Prelude.Read, Int -> CreateSessionResponse -> ShowS
[CreateSessionResponse] -> ShowS
CreateSessionResponse -> String
(Int -> CreateSessionResponse -> ShowS)
-> (CreateSessionResponse -> String)
-> ([CreateSessionResponse] -> ShowS)
-> Show CreateSessionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSessionResponse] -> ShowS
$cshowList :: [CreateSessionResponse] -> ShowS
show :: CreateSessionResponse -> String
$cshow :: CreateSessionResponse -> String
showsPrec :: Int -> CreateSessionResponse -> ShowS
$cshowsPrec :: Int -> CreateSessionResponse -> ShowS
Prelude.Show, (forall x. CreateSessionResponse -> Rep CreateSessionResponse x)
-> (forall x. Rep CreateSessionResponse x -> CreateSessionResponse)
-> Generic CreateSessionResponse
forall x. Rep CreateSessionResponse x -> CreateSessionResponse
forall x. CreateSessionResponse -> Rep CreateSessionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateSessionResponse x -> CreateSessionResponse
$cfrom :: forall x. CreateSessionResponse -> Rep CreateSessionResponse x
Prelude.Generic)
newCreateSessionResponse ::
Prelude.Int ->
CreateSessionResponse
newCreateSessionResponse :: Int -> CreateSessionResponse
newCreateSessionResponse Int
pHttpStatus_ =
CreateSessionResponse' :: Maybe SessionData -> Int -> CreateSessionResponse
CreateSessionResponse'
{ $sel:session:CreateSessionResponse' :: Maybe SessionData
session = Maybe SessionData
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateSessionResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createSessionResponse_session :: Lens.Lens' CreateSessionResponse (Prelude.Maybe SessionData)
createSessionResponse_session :: (Maybe SessionData -> f (Maybe SessionData))
-> CreateSessionResponse -> f CreateSessionResponse
createSessionResponse_session = (CreateSessionResponse -> Maybe SessionData)
-> (CreateSessionResponse
-> Maybe SessionData -> CreateSessionResponse)
-> Lens
CreateSessionResponse
CreateSessionResponse
(Maybe SessionData)
(Maybe SessionData)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSessionResponse' {Maybe SessionData
session :: Maybe SessionData
$sel:session:CreateSessionResponse' :: CreateSessionResponse -> Maybe SessionData
session} -> Maybe SessionData
session) (\s :: CreateSessionResponse
s@CreateSessionResponse' {} Maybe SessionData
a -> CreateSessionResponse
s {$sel:session:CreateSessionResponse' :: Maybe SessionData
session = Maybe SessionData
a} :: CreateSessionResponse)
createSessionResponse_httpStatus :: Lens.Lens' CreateSessionResponse Prelude.Int
createSessionResponse_httpStatus :: (Int -> f Int) -> CreateSessionResponse -> f CreateSessionResponse
createSessionResponse_httpStatus = (CreateSessionResponse -> Int)
-> (CreateSessionResponse -> Int -> CreateSessionResponse)
-> Lens CreateSessionResponse CreateSessionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSessionResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateSessionResponse' :: CreateSessionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateSessionResponse
s@CreateSessionResponse' {} Int
a -> CreateSessionResponse
s {$sel:httpStatus:CreateSessionResponse' :: Int
httpStatus = Int
a} :: CreateSessionResponse)
instance Prelude.NFData CreateSessionResponse