{-# 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.LexRuntime.DeleteSession
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Removes session information for a specified bot, alias, and user ID.
module Amazonka.LexRuntime.DeleteSession
  ( -- * Creating a Request
    DeleteSession (..),
    newDeleteSession,

    -- * Request Lenses
    deleteSession_botName,
    deleteSession_botAlias,
    deleteSession_userId,

    -- * Destructuring the Response
    DeleteSessionResponse (..),
    newDeleteSessionResponse,

    -- * Response Lenses
    deleteSessionResponse_botAlias,
    deleteSessionResponse_botName,
    deleteSessionResponse_sessionId,
    deleteSessionResponse_userId,
    deleteSessionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteSession' smart constructor.
data DeleteSession = DeleteSession'
  { -- | The name of the bot that contains the session data.
    DeleteSession -> Text
botName :: Prelude.Text,
    -- | The alias in use for the bot that contains the session data.
    DeleteSession -> Text
botAlias :: Prelude.Text,
    -- | The identifier of the user associated with the session data.
    DeleteSession -> Text
userId :: Prelude.Text
  }
  deriving (DeleteSession -> DeleteSession -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteSession -> DeleteSession -> Bool
$c/= :: DeleteSession -> DeleteSession -> Bool
== :: DeleteSession -> DeleteSession -> Bool
$c== :: DeleteSession -> DeleteSession -> Bool
Prelude.Eq, ReadPrec [DeleteSession]
ReadPrec DeleteSession
Int -> ReadS DeleteSession
ReadS [DeleteSession]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteSession]
$creadListPrec :: ReadPrec [DeleteSession]
readPrec :: ReadPrec DeleteSession
$creadPrec :: ReadPrec DeleteSession
readList :: ReadS [DeleteSession]
$creadList :: ReadS [DeleteSession]
readsPrec :: Int -> ReadS DeleteSession
$creadsPrec :: Int -> ReadS DeleteSession
Prelude.Read, Int -> DeleteSession -> ShowS
[DeleteSession] -> ShowS
DeleteSession -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteSession] -> ShowS
$cshowList :: [DeleteSession] -> ShowS
show :: DeleteSession -> String
$cshow :: DeleteSession -> String
showsPrec :: Int -> DeleteSession -> ShowS
$cshowsPrec :: Int -> DeleteSession -> ShowS
Prelude.Show, forall x. Rep DeleteSession x -> DeleteSession
forall x. DeleteSession -> Rep DeleteSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteSession x -> DeleteSession
$cfrom :: forall x. DeleteSession -> Rep DeleteSession x
Prelude.Generic)

-- |
-- Create a value of 'DeleteSession' 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:
--
-- 'botName', 'deleteSession_botName' - The name of the bot that contains the session data.
--
-- 'botAlias', 'deleteSession_botAlias' - The alias in use for the bot that contains the session data.
--
-- 'userId', 'deleteSession_userId' - The identifier of the user associated with the session data.
newDeleteSession ::
  -- | 'botName'
  Prelude.Text ->
  -- | 'botAlias'
  Prelude.Text ->
  -- | 'userId'
  Prelude.Text ->
  DeleteSession
newDeleteSession :: Text -> Text -> Text -> DeleteSession
newDeleteSession Text
pBotName_ Text
pBotAlias_ Text
pUserId_ =
  DeleteSession'
    { $sel:botName:DeleteSession' :: Text
botName = Text
pBotName_,
      $sel:botAlias:DeleteSession' :: Text
botAlias = Text
pBotAlias_,
      $sel:userId:DeleteSession' :: Text
userId = Text
pUserId_
    }

-- | The name of the bot that contains the session data.
deleteSession_botName :: Lens.Lens' DeleteSession Prelude.Text
deleteSession_botName :: Lens' DeleteSession Text
deleteSession_botName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSession' {Text
botName :: Text
$sel:botName:DeleteSession' :: DeleteSession -> Text
botName} -> Text
botName) (\s :: DeleteSession
s@DeleteSession' {} Text
a -> DeleteSession
s {$sel:botName:DeleteSession' :: Text
botName = Text
a} :: DeleteSession)

-- | The alias in use for the bot that contains the session data.
deleteSession_botAlias :: Lens.Lens' DeleteSession Prelude.Text
deleteSession_botAlias :: Lens' DeleteSession Text
deleteSession_botAlias = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSession' {Text
botAlias :: Text
$sel:botAlias:DeleteSession' :: DeleteSession -> Text
botAlias} -> Text
botAlias) (\s :: DeleteSession
s@DeleteSession' {} Text
a -> DeleteSession
s {$sel:botAlias:DeleteSession' :: Text
botAlias = Text
a} :: DeleteSession)

-- | The identifier of the user associated with the session data.
deleteSession_userId :: Lens.Lens' DeleteSession Prelude.Text
deleteSession_userId :: Lens' DeleteSession Text
deleteSession_userId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSession' {Text
userId :: Text
$sel:userId:DeleteSession' :: DeleteSession -> Text
userId} -> Text
userId) (\s :: DeleteSession
s@DeleteSession' {} Text
a -> DeleteSession
s {$sel:userId:DeleteSession' :: Text
userId = Text
a} :: DeleteSession)

instance Core.AWSRequest DeleteSession where
  type
    AWSResponse DeleteSession =
      DeleteSessionResponse
  request :: (Service -> Service) -> DeleteSession -> Request DeleteSession
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteSession
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteSession)))
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 Text
-> Maybe Text
-> Maybe Text
-> Int
-> DeleteSessionResponse
DeleteSessionResponse'
            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
"botAlias")
            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
"botName")
            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
"sessionId")
            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
"userId")
            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 DeleteSession where
  hashWithSalt :: Int -> DeleteSession -> Int
hashWithSalt Int
_salt DeleteSession' {Text
userId :: Text
botAlias :: Text
botName :: Text
$sel:userId:DeleteSession' :: DeleteSession -> Text
$sel:botAlias:DeleteSession' :: DeleteSession -> Text
$sel:botName:DeleteSession' :: DeleteSession -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
botName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
botAlias
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userId

instance Prelude.NFData DeleteSession where
  rnf :: DeleteSession -> ()
rnf DeleteSession' {Text
userId :: Text
botAlias :: Text
botName :: Text
$sel:userId:DeleteSession' :: DeleteSession -> Text
$sel:botAlias:DeleteSession' :: DeleteSession -> Text
$sel:botName:DeleteSession' :: DeleteSession -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
botName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
botAlias
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userId

instance Data.ToHeaders DeleteSession where
  toHeaders :: DeleteSession -> 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.ToPath DeleteSession where
  toPath :: DeleteSession -> ByteString
toPath DeleteSession' {Text
userId :: Text
botAlias :: Text
botName :: Text
$sel:userId:DeleteSession' :: DeleteSession -> Text
$sel:botAlias:DeleteSession' :: DeleteSession -> Text
$sel:botName:DeleteSession' :: DeleteSession -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/bot/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
botName,
        ByteString
"/alias/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
botAlias,
        ByteString
"/user/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
userId,
        ByteString
"/session"
      ]

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

-- | /See:/ 'newDeleteSessionResponse' smart constructor.
data DeleteSessionResponse = DeleteSessionResponse'
  { -- | The alias in use for the bot associated with the session data.
    DeleteSessionResponse -> Maybe Text
botAlias :: Prelude.Maybe Prelude.Text,
    -- | The name of the bot associated with the session data.
    DeleteSessionResponse -> Maybe Text
botName :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the session.
    DeleteSessionResponse -> Maybe Text
sessionId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the client application user.
    DeleteSessionResponse -> Maybe Text
userId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteSessionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteSessionResponse -> DeleteSessionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteSessionResponse -> DeleteSessionResponse -> Bool
$c/= :: DeleteSessionResponse -> DeleteSessionResponse -> Bool
== :: DeleteSessionResponse -> DeleteSessionResponse -> Bool
$c== :: DeleteSessionResponse -> DeleteSessionResponse -> Bool
Prelude.Eq, ReadPrec [DeleteSessionResponse]
ReadPrec DeleteSessionResponse
Int -> ReadS DeleteSessionResponse
ReadS [DeleteSessionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteSessionResponse]
$creadListPrec :: ReadPrec [DeleteSessionResponse]
readPrec :: ReadPrec DeleteSessionResponse
$creadPrec :: ReadPrec DeleteSessionResponse
readList :: ReadS [DeleteSessionResponse]
$creadList :: ReadS [DeleteSessionResponse]
readsPrec :: Int -> ReadS DeleteSessionResponse
$creadsPrec :: Int -> ReadS DeleteSessionResponse
Prelude.Read, Int -> DeleteSessionResponse -> ShowS
[DeleteSessionResponse] -> ShowS
DeleteSessionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteSessionResponse] -> ShowS
$cshowList :: [DeleteSessionResponse] -> ShowS
show :: DeleteSessionResponse -> String
$cshow :: DeleteSessionResponse -> String
showsPrec :: Int -> DeleteSessionResponse -> ShowS
$cshowsPrec :: Int -> DeleteSessionResponse -> ShowS
Prelude.Show, forall x. Rep DeleteSessionResponse x -> DeleteSessionResponse
forall x. DeleteSessionResponse -> Rep DeleteSessionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteSessionResponse x -> DeleteSessionResponse
$cfrom :: forall x. DeleteSessionResponse -> Rep DeleteSessionResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteSessionResponse' 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:
--
-- 'botAlias', 'deleteSessionResponse_botAlias' - The alias in use for the bot associated with the session data.
--
-- 'botName', 'deleteSessionResponse_botName' - The name of the bot associated with the session data.
--
-- 'sessionId', 'deleteSessionResponse_sessionId' - The unique identifier for the session.
--
-- 'userId', 'deleteSessionResponse_userId' - The ID of the client application user.
--
-- 'httpStatus', 'deleteSessionResponse_httpStatus' - The response's http status code.
newDeleteSessionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteSessionResponse
newDeleteSessionResponse :: Int -> DeleteSessionResponse
newDeleteSessionResponse Int
pHttpStatus_ =
  DeleteSessionResponse'
    { $sel:botAlias:DeleteSessionResponse' :: Maybe Text
botAlias = forall a. Maybe a
Prelude.Nothing,
      $sel:botName:DeleteSessionResponse' :: Maybe Text
botName = forall a. Maybe a
Prelude.Nothing,
      $sel:sessionId:DeleteSessionResponse' :: Maybe Text
sessionId = forall a. Maybe a
Prelude.Nothing,
      $sel:userId:DeleteSessionResponse' :: Maybe Text
userId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteSessionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The alias in use for the bot associated with the session data.
deleteSessionResponse_botAlias :: Lens.Lens' DeleteSessionResponse (Prelude.Maybe Prelude.Text)
deleteSessionResponse_botAlias :: Lens' DeleteSessionResponse (Maybe Text)
deleteSessionResponse_botAlias = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSessionResponse' {Maybe Text
botAlias :: Maybe Text
$sel:botAlias:DeleteSessionResponse' :: DeleteSessionResponse -> Maybe Text
botAlias} -> Maybe Text
botAlias) (\s :: DeleteSessionResponse
s@DeleteSessionResponse' {} Maybe Text
a -> DeleteSessionResponse
s {$sel:botAlias:DeleteSessionResponse' :: Maybe Text
botAlias = Maybe Text
a} :: DeleteSessionResponse)

-- | The name of the bot associated with the session data.
deleteSessionResponse_botName :: Lens.Lens' DeleteSessionResponse (Prelude.Maybe Prelude.Text)
deleteSessionResponse_botName :: Lens' DeleteSessionResponse (Maybe Text)
deleteSessionResponse_botName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSessionResponse' {Maybe Text
botName :: Maybe Text
$sel:botName:DeleteSessionResponse' :: DeleteSessionResponse -> Maybe Text
botName} -> Maybe Text
botName) (\s :: DeleteSessionResponse
s@DeleteSessionResponse' {} Maybe Text
a -> DeleteSessionResponse
s {$sel:botName:DeleteSessionResponse' :: Maybe Text
botName = Maybe Text
a} :: DeleteSessionResponse)

-- | The unique identifier for the session.
deleteSessionResponse_sessionId :: Lens.Lens' DeleteSessionResponse (Prelude.Maybe Prelude.Text)
deleteSessionResponse_sessionId :: Lens' DeleteSessionResponse (Maybe Text)
deleteSessionResponse_sessionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSessionResponse' {Maybe Text
sessionId :: Maybe Text
$sel:sessionId:DeleteSessionResponse' :: DeleteSessionResponse -> Maybe Text
sessionId} -> Maybe Text
sessionId) (\s :: DeleteSessionResponse
s@DeleteSessionResponse' {} Maybe Text
a -> DeleteSessionResponse
s {$sel:sessionId:DeleteSessionResponse' :: Maybe Text
sessionId = Maybe Text
a} :: DeleteSessionResponse)

-- | The ID of the client application user.
deleteSessionResponse_userId :: Lens.Lens' DeleteSessionResponse (Prelude.Maybe Prelude.Text)
deleteSessionResponse_userId :: Lens' DeleteSessionResponse (Maybe Text)
deleteSessionResponse_userId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSessionResponse' {Maybe Text
userId :: Maybe Text
$sel:userId:DeleteSessionResponse' :: DeleteSessionResponse -> Maybe Text
userId} -> Maybe Text
userId) (\s :: DeleteSessionResponse
s@DeleteSessionResponse' {} Maybe Text
a -> DeleteSessionResponse
s {$sel:userId:DeleteSessionResponse' :: Maybe Text
userId = Maybe Text
a} :: DeleteSessionResponse)

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

instance Prelude.NFData DeleteSessionResponse where
  rnf :: DeleteSessionResponse -> ()
rnf DeleteSessionResponse' {Int
Maybe Text
httpStatus :: Int
userId :: Maybe Text
sessionId :: Maybe Text
botName :: Maybe Text
botAlias :: Maybe Text
$sel:httpStatus:DeleteSessionResponse' :: DeleteSessionResponse -> Int
$sel:userId:DeleteSessionResponse' :: DeleteSessionResponse -> Maybe Text
$sel:sessionId:DeleteSessionResponse' :: DeleteSessionResponse -> Maybe Text
$sel:botName:DeleteSessionResponse' :: DeleteSessionResponse -> Maybe Text
$sel:botAlias:DeleteSessionResponse' :: DeleteSessionResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
botAlias
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
botName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sessionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus