{-# 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.Wisdom.GetSession
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves information for a specified session.
module Amazonka.Wisdom.GetSession
  ( -- * Creating a Request
    GetSession (..),
    newGetSession,

    -- * Request Lenses
    getSession_assistantId,
    getSession_sessionId,

    -- * Destructuring the Response
    GetSessionResponse (..),
    newGetSessionResponse,

    -- * Response Lenses
    getSessionResponse_session,
    getSessionResponse_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

-- | /See:/ 'newGetSession' smart constructor.
data GetSession = GetSession'
  { -- | The identifier of the Wisdom assistant. Can be either the ID or the ARN.
    -- URLs cannot contain the ARN.
    GetSession -> Text
assistantId :: Prelude.Text,
    -- | The identifier of the session. Can be either the ID or the ARN. URLs
    -- cannot contain the ARN.
    GetSession -> Text
sessionId :: Prelude.Text
  }
  deriving (GetSession -> GetSession -> Bool
(GetSession -> GetSession -> Bool)
-> (GetSession -> GetSession -> Bool) -> Eq GetSession
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSession -> GetSession -> Bool
$c/= :: GetSession -> GetSession -> Bool
== :: GetSession -> GetSession -> Bool
$c== :: GetSession -> GetSession -> Bool
Prelude.Eq, ReadPrec [GetSession]
ReadPrec GetSession
Int -> ReadS GetSession
ReadS [GetSession]
(Int -> ReadS GetSession)
-> ReadS [GetSession]
-> ReadPrec GetSession
-> ReadPrec [GetSession]
-> Read GetSession
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSession]
$creadListPrec :: ReadPrec [GetSession]
readPrec :: ReadPrec GetSession
$creadPrec :: ReadPrec GetSession
readList :: ReadS [GetSession]
$creadList :: ReadS [GetSession]
readsPrec :: Int -> ReadS GetSession
$creadsPrec :: Int -> ReadS GetSession
Prelude.Read, Int -> GetSession -> ShowS
[GetSession] -> ShowS
GetSession -> String
(Int -> GetSession -> ShowS)
-> (GetSession -> String)
-> ([GetSession] -> ShowS)
-> Show GetSession
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSession] -> ShowS
$cshowList :: [GetSession] -> ShowS
show :: GetSession -> String
$cshow :: GetSession -> String
showsPrec :: Int -> GetSession -> ShowS
$cshowsPrec :: Int -> GetSession -> ShowS
Prelude.Show, (forall x. GetSession -> Rep GetSession x)
-> (forall x. Rep GetSession x -> GetSession) -> Generic GetSession
forall x. Rep GetSession x -> GetSession
forall x. GetSession -> Rep GetSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSession x -> GetSession
$cfrom :: forall x. GetSession -> Rep GetSession x
Prelude.Generic)

-- |
-- Create a value of 'GetSession' 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:
--
-- 'assistantId', 'getSession_assistantId' - The identifier of the Wisdom assistant. Can be either the ID or the ARN.
-- URLs cannot contain the ARN.
--
-- 'sessionId', 'getSession_sessionId' - The identifier of the session. Can be either the ID or the ARN. URLs
-- cannot contain the ARN.
newGetSession ::
  -- | 'assistantId'
  Prelude.Text ->
  -- | 'sessionId'
  Prelude.Text ->
  GetSession
newGetSession :: Text -> Text -> GetSession
newGetSession Text
pAssistantId_ Text
pSessionId_ =
  GetSession' :: Text -> Text -> GetSession
GetSession'
    { $sel:assistantId:GetSession' :: Text
assistantId = Text
pAssistantId_,
      $sel:sessionId:GetSession' :: Text
sessionId = Text
pSessionId_
    }

-- | The identifier of the Wisdom assistant. Can be either the ID or the ARN.
-- URLs cannot contain the ARN.
getSession_assistantId :: Lens.Lens' GetSession Prelude.Text
getSession_assistantId :: (Text -> f Text) -> GetSession -> f GetSession
getSession_assistantId = (GetSession -> Text)
-> (GetSession -> Text -> GetSession)
-> Lens GetSession GetSession Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSession' {Text
assistantId :: Text
$sel:assistantId:GetSession' :: GetSession -> Text
assistantId} -> Text
assistantId) (\s :: GetSession
s@GetSession' {} Text
a -> GetSession
s {$sel:assistantId:GetSession' :: Text
assistantId = Text
a} :: GetSession)

-- | The identifier of the session. Can be either the ID or the ARN. URLs
-- cannot contain the ARN.
getSession_sessionId :: Lens.Lens' GetSession Prelude.Text
getSession_sessionId :: (Text -> f Text) -> GetSession -> f GetSession
getSession_sessionId = (GetSession -> Text)
-> (GetSession -> Text -> GetSession)
-> Lens GetSession GetSession Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSession' {Text
sessionId :: Text
$sel:sessionId:GetSession' :: GetSession -> Text
sessionId} -> Text
sessionId) (\s :: GetSession
s@GetSession' {} Text
a -> GetSession
s {$sel:sessionId:GetSession' :: Text
sessionId = Text
a} :: GetSession)

instance Core.AWSRequest GetSession where
  type AWSResponse GetSession = GetSessionResponse
  request :: GetSession -> Request GetSession
request = Service -> GetSession -> Request GetSession
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetSession
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetSession)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetSession))
-> Logger
-> Service
-> Proxy GetSession
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetSession)))
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 -> GetSessionResponse
GetSessionResponse'
            (Maybe SessionData -> Int -> GetSessionResponse)
-> Either String (Maybe SessionData)
-> Either String (Int -> GetSessionResponse)
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 -> GetSessionResponse)
-> Either String Int -> Either String GetSessionResponse
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 GetSession

instance Prelude.NFData GetSession

instance Core.ToHeaders GetSession where
  toHeaders :: GetSession -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetSession -> 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 GetSession where
  toPath :: GetSession -> ByteString
toPath GetSession' {Text
sessionId :: Text
assistantId :: Text
$sel:sessionId:GetSession' :: GetSession -> Text
$sel:assistantId:GetSession' :: GetSession -> 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/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
sessionId
      ]

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

-- | /See:/ 'newGetSessionResponse' smart constructor.
data GetSessionResponse = GetSessionResponse'
  { -- | The session.
    GetSessionResponse -> Maybe SessionData
session :: Prelude.Maybe SessionData,
    -- | The response's http status code.
    GetSessionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetSessionResponse -> GetSessionResponse -> Bool
(GetSessionResponse -> GetSessionResponse -> Bool)
-> (GetSessionResponse -> GetSessionResponse -> Bool)
-> Eq GetSessionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSessionResponse -> GetSessionResponse -> Bool
$c/= :: GetSessionResponse -> GetSessionResponse -> Bool
== :: GetSessionResponse -> GetSessionResponse -> Bool
$c== :: GetSessionResponse -> GetSessionResponse -> Bool
Prelude.Eq, ReadPrec [GetSessionResponse]
ReadPrec GetSessionResponse
Int -> ReadS GetSessionResponse
ReadS [GetSessionResponse]
(Int -> ReadS GetSessionResponse)
-> ReadS [GetSessionResponse]
-> ReadPrec GetSessionResponse
-> ReadPrec [GetSessionResponse]
-> Read GetSessionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSessionResponse]
$creadListPrec :: ReadPrec [GetSessionResponse]
readPrec :: ReadPrec GetSessionResponse
$creadPrec :: ReadPrec GetSessionResponse
readList :: ReadS [GetSessionResponse]
$creadList :: ReadS [GetSessionResponse]
readsPrec :: Int -> ReadS GetSessionResponse
$creadsPrec :: Int -> ReadS GetSessionResponse
Prelude.Read, Int -> GetSessionResponse -> ShowS
[GetSessionResponse] -> ShowS
GetSessionResponse -> String
(Int -> GetSessionResponse -> ShowS)
-> (GetSessionResponse -> String)
-> ([GetSessionResponse] -> ShowS)
-> Show GetSessionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSessionResponse] -> ShowS
$cshowList :: [GetSessionResponse] -> ShowS
show :: GetSessionResponse -> String
$cshow :: GetSessionResponse -> String
showsPrec :: Int -> GetSessionResponse -> ShowS
$cshowsPrec :: Int -> GetSessionResponse -> ShowS
Prelude.Show, (forall x. GetSessionResponse -> Rep GetSessionResponse x)
-> (forall x. Rep GetSessionResponse x -> GetSessionResponse)
-> Generic GetSessionResponse
forall x. Rep GetSessionResponse x -> GetSessionResponse
forall x. GetSessionResponse -> Rep GetSessionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSessionResponse x -> GetSessionResponse
$cfrom :: forall x. GetSessionResponse -> Rep GetSessionResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetSessionResponse' 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:
--
-- 'session', 'getSessionResponse_session' - The session.
--
-- 'httpStatus', 'getSessionResponse_httpStatus' - The response's http status code.
newGetSessionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetSessionResponse
newGetSessionResponse :: Int -> GetSessionResponse
newGetSessionResponse Int
pHttpStatus_ =
  GetSessionResponse' :: Maybe SessionData -> Int -> GetSessionResponse
GetSessionResponse'
    { $sel:session:GetSessionResponse' :: Maybe SessionData
session = Maybe SessionData
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetSessionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The session.
getSessionResponse_session :: Lens.Lens' GetSessionResponse (Prelude.Maybe SessionData)
getSessionResponse_session :: (Maybe SessionData -> f (Maybe SessionData))
-> GetSessionResponse -> f GetSessionResponse
getSessionResponse_session = (GetSessionResponse -> Maybe SessionData)
-> (GetSessionResponse -> Maybe SessionData -> GetSessionResponse)
-> Lens
     GetSessionResponse
     GetSessionResponse
     (Maybe SessionData)
     (Maybe SessionData)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSessionResponse' {Maybe SessionData
session :: Maybe SessionData
$sel:session:GetSessionResponse' :: GetSessionResponse -> Maybe SessionData
session} -> Maybe SessionData
session) (\s :: GetSessionResponse
s@GetSessionResponse' {} Maybe SessionData
a -> GetSessionResponse
s {$sel:session:GetSessionResponse' :: Maybe SessionData
session = Maybe SessionData
a} :: GetSessionResponse)

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

instance Prelude.NFData GetSessionResponse