{-# 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.AppStream.ExpireSession
-- 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)
--
-- Immediately stops the specified streaming session.
module Amazonka.AppStream.ExpireSession
  ( -- * Creating a Request
    ExpireSession (..),
    newExpireSession,

    -- * Request Lenses
    expireSession_sessionId,

    -- * Destructuring the Response
    ExpireSessionResponse (..),
    newExpireSessionResponse,

    -- * Response Lenses
    expireSessionResponse_httpStatus,
  )
where

import Amazonka.AppStream.Types
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

-- | /See:/ 'newExpireSession' smart constructor.
data ExpireSession = ExpireSession'
  { -- | The identifier of the streaming session.
    ExpireSession -> Text
sessionId :: Prelude.Text
  }
  deriving (ExpireSession -> ExpireSession -> Bool
(ExpireSession -> ExpireSession -> Bool)
-> (ExpireSession -> ExpireSession -> Bool) -> Eq ExpireSession
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExpireSession -> ExpireSession -> Bool
$c/= :: ExpireSession -> ExpireSession -> Bool
== :: ExpireSession -> ExpireSession -> Bool
$c== :: ExpireSession -> ExpireSession -> Bool
Prelude.Eq, ReadPrec [ExpireSession]
ReadPrec ExpireSession
Int -> ReadS ExpireSession
ReadS [ExpireSession]
(Int -> ReadS ExpireSession)
-> ReadS [ExpireSession]
-> ReadPrec ExpireSession
-> ReadPrec [ExpireSession]
-> Read ExpireSession
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExpireSession]
$creadListPrec :: ReadPrec [ExpireSession]
readPrec :: ReadPrec ExpireSession
$creadPrec :: ReadPrec ExpireSession
readList :: ReadS [ExpireSession]
$creadList :: ReadS [ExpireSession]
readsPrec :: Int -> ReadS ExpireSession
$creadsPrec :: Int -> ReadS ExpireSession
Prelude.Read, Int -> ExpireSession -> ShowS
[ExpireSession] -> ShowS
ExpireSession -> String
(Int -> ExpireSession -> ShowS)
-> (ExpireSession -> String)
-> ([ExpireSession] -> ShowS)
-> Show ExpireSession
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExpireSession] -> ShowS
$cshowList :: [ExpireSession] -> ShowS
show :: ExpireSession -> String
$cshow :: ExpireSession -> String
showsPrec :: Int -> ExpireSession -> ShowS
$cshowsPrec :: Int -> ExpireSession -> ShowS
Prelude.Show, (forall x. ExpireSession -> Rep ExpireSession x)
-> (forall x. Rep ExpireSession x -> ExpireSession)
-> Generic ExpireSession
forall x. Rep ExpireSession x -> ExpireSession
forall x. ExpireSession -> Rep ExpireSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExpireSession x -> ExpireSession
$cfrom :: forall x. ExpireSession -> Rep ExpireSession x
Prelude.Generic)

-- |
-- Create a value of 'ExpireSession' 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:
--
-- 'sessionId', 'expireSession_sessionId' - The identifier of the streaming session.
newExpireSession ::
  -- | 'sessionId'
  Prelude.Text ->
  ExpireSession
newExpireSession :: Text -> ExpireSession
newExpireSession Text
pSessionId_ =
  ExpireSession' :: Text -> ExpireSession
ExpireSession' {$sel:sessionId:ExpireSession' :: Text
sessionId = Text
pSessionId_}

-- | The identifier of the streaming session.
expireSession_sessionId :: Lens.Lens' ExpireSession Prelude.Text
expireSession_sessionId :: (Text -> f Text) -> ExpireSession -> f ExpireSession
expireSession_sessionId = (ExpireSession -> Text)
-> (ExpireSession -> Text -> ExpireSession)
-> Lens ExpireSession ExpireSession Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExpireSession' {Text
sessionId :: Text
$sel:sessionId:ExpireSession' :: ExpireSession -> Text
sessionId} -> Text
sessionId) (\s :: ExpireSession
s@ExpireSession' {} Text
a -> ExpireSession
s {$sel:sessionId:ExpireSession' :: Text
sessionId = Text
a} :: ExpireSession)

instance Core.AWSRequest ExpireSession where
  type
    AWSResponse ExpireSession =
      ExpireSessionResponse
  request :: ExpireSession -> Request ExpireSession
request = Service -> ExpireSession -> Request ExpireSession
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ExpireSession
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ExpireSession)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse ExpireSession))
-> Logger
-> Service
-> Proxy ExpireSession
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ExpireSession)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> ExpireSessionResponse
ExpireSessionResponse'
            (Int -> ExpireSessionResponse)
-> Either String Int -> Either String ExpireSessionResponse
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))
      )

instance Prelude.Hashable ExpireSession

instance Prelude.NFData ExpireSession

instance Core.ToHeaders ExpireSession where
  toHeaders :: ExpireSession -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ExpireSession -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"PhotonAdminProxyService.ExpireSession" ::
                          Prelude.ByteString
                      ),
            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 ExpireSession where
  toJSON :: ExpireSession -> Value
toJSON ExpireSession' {Text
sessionId :: Text
$sel:sessionId:ExpireSession' :: ExpireSession -> 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
"SessionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
sessionId)]
      )

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

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

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

-- |
-- Create a value of 'ExpireSessionResponse' 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:
--
-- 'httpStatus', 'expireSessionResponse_httpStatus' - The response's http status code.
newExpireSessionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ExpireSessionResponse
newExpireSessionResponse :: Int -> ExpireSessionResponse
newExpireSessionResponse Int
pHttpStatus_ =
  ExpireSessionResponse' :: Int -> ExpireSessionResponse
ExpireSessionResponse' {$sel:httpStatus:ExpireSessionResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData ExpireSessionResponse