{-# 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.Glue.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)
--
-- Deletes the session.
module Amazonka.Glue.DeleteSession
  ( -- * Creating a Request
    DeleteSession (..),
    newDeleteSession,

    -- * Request Lenses
    deleteSession_requestOrigin,
    deleteSession_id,

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

    -- * Response Lenses
    deleteSessionResponse_id,
    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.Glue.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 origin of the delete session request.
    DeleteSession -> Maybe Text
requestOrigin :: Prelude.Maybe Prelude.Text,
    -- | The ID of the session to be deleted.
    DeleteSession -> Text
id :: 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:
--
-- 'requestOrigin', 'deleteSession_requestOrigin' - The name of the origin of the delete session request.
--
-- 'id', 'deleteSession_id' - The ID of the session to be deleted.
newDeleteSession ::
  -- | 'id'
  Prelude.Text ->
  DeleteSession
newDeleteSession :: Text -> DeleteSession
newDeleteSession Text
pId_ =
  DeleteSession'
    { $sel:requestOrigin:DeleteSession' :: Maybe Text
requestOrigin = forall a. Maybe a
Prelude.Nothing,
      $sel:id:DeleteSession' :: Text
id = Text
pId_
    }

-- | The name of the origin of the delete session request.
deleteSession_requestOrigin :: Lens.Lens' DeleteSession (Prelude.Maybe Prelude.Text)
deleteSession_requestOrigin :: Lens' DeleteSession (Maybe Text)
deleteSession_requestOrigin = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSession' {Maybe Text
requestOrigin :: Maybe Text
$sel:requestOrigin:DeleteSession' :: DeleteSession -> Maybe Text
requestOrigin} -> Maybe Text
requestOrigin) (\s :: DeleteSession
s@DeleteSession' {} Maybe Text
a -> DeleteSession
s {$sel:requestOrigin:DeleteSession' :: Maybe Text
requestOrigin = Maybe Text
a} :: DeleteSession)

-- | The ID of the session to be deleted.
deleteSession_id :: Lens.Lens' DeleteSession Prelude.Text
deleteSession_id :: Lens' DeleteSession Text
deleteSession_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSession' {Text
id :: Text
$sel:id:DeleteSession' :: DeleteSession -> Text
id} -> Text
id) (\s :: DeleteSession
s@DeleteSession' {} Text
a -> DeleteSession
s {$sel:id:DeleteSession' :: Text
id = 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, ToJSON a) => Service -> a -> Request a
Request.postJSON (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 -> 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
"Id")
            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' {Maybe Text
Text
id :: Text
requestOrigin :: Maybe Text
$sel:id:DeleteSession' :: DeleteSession -> Text
$sel:requestOrigin:DeleteSession' :: DeleteSession -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
requestOrigin
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

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

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
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"AWSGlue.DeleteSession" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteSession where
  toJSON :: DeleteSession -> Value
toJSON DeleteSession' {Maybe Text
Text
id :: Text
requestOrigin :: Maybe Text
$sel:id:DeleteSession' :: DeleteSession -> Text
$sel:requestOrigin:DeleteSession' :: DeleteSession -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"RequestOrigin" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
requestOrigin,
            forall a. a -> Maybe a
Prelude.Just (Key
"Id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id)
          ]
      )

instance Data.ToPath DeleteSession where
  toPath :: DeleteSession -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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'
  { -- | Returns the ID of the deleted session.
    DeleteSessionResponse -> Maybe Text
id :: 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:
--
-- 'id', 'deleteSessionResponse_id' - Returns the ID of the deleted session.
--
-- 'httpStatus', 'deleteSessionResponse_httpStatus' - The response's http status code.
newDeleteSessionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteSessionResponse
newDeleteSessionResponse :: Int -> DeleteSessionResponse
newDeleteSessionResponse Int
pHttpStatus_ =
  DeleteSessionResponse'
    { $sel:id:DeleteSessionResponse' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteSessionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Returns the ID of the deleted session.
deleteSessionResponse_id :: Lens.Lens' DeleteSessionResponse (Prelude.Maybe Prelude.Text)
deleteSessionResponse_id :: Lens' DeleteSessionResponse (Maybe Text)
deleteSessionResponse_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSessionResponse' {Maybe Text
id :: Maybe Text
$sel:id:DeleteSessionResponse' :: DeleteSessionResponse -> Maybe Text
id} -> Maybe Text
id) (\s :: DeleteSessionResponse
s@DeleteSessionResponse' {} Maybe Text
a -> DeleteSessionResponse
s {$sel:id:DeleteSessionResponse' :: Maybe Text
id = 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
id :: Maybe Text
$sel:httpStatus:DeleteSessionResponse' :: DeleteSessionResponse -> Int
$sel:id:DeleteSessionResponse' :: DeleteSessionResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus