{-# 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.Nimble.DeleteStreamingSession
-- 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)
--
-- Deletes streaming session resource.
--
-- After invoking this operation, use GetStreamingSession to poll the
-- resource until it transitions to a DELETED state.
--
-- A streaming session will count against your streaming session quota
-- until it is marked DELETED.
module Amazonka.Nimble.DeleteStreamingSession
  ( -- * Creating a Request
    DeleteStreamingSession (..),
    newDeleteStreamingSession,

    -- * Request Lenses
    deleteStreamingSession_clientToken,
    deleteStreamingSession_studioId,
    deleteStreamingSession_sessionId,

    -- * Destructuring the Response
    DeleteStreamingSessionResponse (..),
    newDeleteStreamingSessionResponse,

    -- * Response Lenses
    deleteStreamingSessionResponse_session,
    deleteStreamingSessionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Nimble.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteStreamingSession' smart constructor.
data DeleteStreamingSession = DeleteStreamingSession'
  { -- | To make an idempotent API request using one of these actions, specify a
    -- client token in the request. You should not reuse the same client token
    -- for other API requests. If you retry a request that completed
    -- successfully using the same client token and the same parameters, the
    -- retry succeeds without performing any further actions. If you retry a
    -- successful request using the same client token, but one or more of the
    -- parameters are different, the retry fails with a ValidationException
    -- error.
    DeleteStreamingSession -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The studio ID.
    DeleteStreamingSession -> Text
studioId :: Prelude.Text,
    -- | The session ID.
    DeleteStreamingSession -> Text
sessionId :: Prelude.Text
  }
  deriving (DeleteStreamingSession -> DeleteStreamingSession -> Bool
(DeleteStreamingSession -> DeleteStreamingSession -> Bool)
-> (DeleteStreamingSession -> DeleteStreamingSession -> Bool)
-> Eq DeleteStreamingSession
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteStreamingSession -> DeleteStreamingSession -> Bool
$c/= :: DeleteStreamingSession -> DeleteStreamingSession -> Bool
== :: DeleteStreamingSession -> DeleteStreamingSession -> Bool
$c== :: DeleteStreamingSession -> DeleteStreamingSession -> Bool
Prelude.Eq, ReadPrec [DeleteStreamingSession]
ReadPrec DeleteStreamingSession
Int -> ReadS DeleteStreamingSession
ReadS [DeleteStreamingSession]
(Int -> ReadS DeleteStreamingSession)
-> ReadS [DeleteStreamingSession]
-> ReadPrec DeleteStreamingSession
-> ReadPrec [DeleteStreamingSession]
-> Read DeleteStreamingSession
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteStreamingSession]
$creadListPrec :: ReadPrec [DeleteStreamingSession]
readPrec :: ReadPrec DeleteStreamingSession
$creadPrec :: ReadPrec DeleteStreamingSession
readList :: ReadS [DeleteStreamingSession]
$creadList :: ReadS [DeleteStreamingSession]
readsPrec :: Int -> ReadS DeleteStreamingSession
$creadsPrec :: Int -> ReadS DeleteStreamingSession
Prelude.Read, Int -> DeleteStreamingSession -> ShowS
[DeleteStreamingSession] -> ShowS
DeleteStreamingSession -> String
(Int -> DeleteStreamingSession -> ShowS)
-> (DeleteStreamingSession -> String)
-> ([DeleteStreamingSession] -> ShowS)
-> Show DeleteStreamingSession
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteStreamingSession] -> ShowS
$cshowList :: [DeleteStreamingSession] -> ShowS
show :: DeleteStreamingSession -> String
$cshow :: DeleteStreamingSession -> String
showsPrec :: Int -> DeleteStreamingSession -> ShowS
$cshowsPrec :: Int -> DeleteStreamingSession -> ShowS
Prelude.Show, (forall x. DeleteStreamingSession -> Rep DeleteStreamingSession x)
-> (forall x.
    Rep DeleteStreamingSession x -> DeleteStreamingSession)
-> Generic DeleteStreamingSession
forall x. Rep DeleteStreamingSession x -> DeleteStreamingSession
forall x. DeleteStreamingSession -> Rep DeleteStreamingSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteStreamingSession x -> DeleteStreamingSession
$cfrom :: forall x. DeleteStreamingSession -> Rep DeleteStreamingSession x
Prelude.Generic)

-- |
-- Create a value of 'DeleteStreamingSession' 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:
--
-- 'clientToken', 'deleteStreamingSession_clientToken' - To make an idempotent API request using one of these actions, specify a
-- client token in the request. You should not reuse the same client token
-- for other API requests. If you retry a request that completed
-- successfully using the same client token and the same parameters, the
-- retry succeeds without performing any further actions. If you retry a
-- successful request using the same client token, but one or more of the
-- parameters are different, the retry fails with a ValidationException
-- error.
--
-- 'studioId', 'deleteStreamingSession_studioId' - The studio ID.
--
-- 'sessionId', 'deleteStreamingSession_sessionId' - The session ID.
newDeleteStreamingSession ::
  -- | 'studioId'
  Prelude.Text ->
  -- | 'sessionId'
  Prelude.Text ->
  DeleteStreamingSession
newDeleteStreamingSession :: Text -> Text -> DeleteStreamingSession
newDeleteStreamingSession Text
pStudioId_ Text
pSessionId_ =
  DeleteStreamingSession' :: Maybe Text -> Text -> Text -> DeleteStreamingSession
DeleteStreamingSession'
    { $sel:clientToken:DeleteStreamingSession' :: Maybe Text
clientToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:studioId:DeleteStreamingSession' :: Text
studioId = Text
pStudioId_,
      $sel:sessionId:DeleteStreamingSession' :: Text
sessionId = Text
pSessionId_
    }

-- | To make an idempotent API request using one of these actions, specify a
-- client token in the request. You should not reuse the same client token
-- for other API requests. If you retry a request that completed
-- successfully using the same client token and the same parameters, the
-- retry succeeds without performing any further actions. If you retry a
-- successful request using the same client token, but one or more of the
-- parameters are different, the retry fails with a ValidationException
-- error.
deleteStreamingSession_clientToken :: Lens.Lens' DeleteStreamingSession (Prelude.Maybe Prelude.Text)
deleteStreamingSession_clientToken :: (Maybe Text -> f (Maybe Text))
-> DeleteStreamingSession -> f DeleteStreamingSession
deleteStreamingSession_clientToken = (DeleteStreamingSession -> Maybe Text)
-> (DeleteStreamingSession -> Maybe Text -> DeleteStreamingSession)
-> Lens
     DeleteStreamingSession
     DeleteStreamingSession
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteStreamingSession' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:DeleteStreamingSession' :: DeleteStreamingSession -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: DeleteStreamingSession
s@DeleteStreamingSession' {} Maybe Text
a -> DeleteStreamingSession
s {$sel:clientToken:DeleteStreamingSession' :: Maybe Text
clientToken = Maybe Text
a} :: DeleteStreamingSession)

-- | The studio ID.
deleteStreamingSession_studioId :: Lens.Lens' DeleteStreamingSession Prelude.Text
deleteStreamingSession_studioId :: (Text -> f Text)
-> DeleteStreamingSession -> f DeleteStreamingSession
deleteStreamingSession_studioId = (DeleteStreamingSession -> Text)
-> (DeleteStreamingSession -> Text -> DeleteStreamingSession)
-> Lens DeleteStreamingSession DeleteStreamingSession Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteStreamingSession' {Text
studioId :: Text
$sel:studioId:DeleteStreamingSession' :: DeleteStreamingSession -> Text
studioId} -> Text
studioId) (\s :: DeleteStreamingSession
s@DeleteStreamingSession' {} Text
a -> DeleteStreamingSession
s {$sel:studioId:DeleteStreamingSession' :: Text
studioId = Text
a} :: DeleteStreamingSession)

-- | The session ID.
deleteStreamingSession_sessionId :: Lens.Lens' DeleteStreamingSession Prelude.Text
deleteStreamingSession_sessionId :: (Text -> f Text)
-> DeleteStreamingSession -> f DeleteStreamingSession
deleteStreamingSession_sessionId = (DeleteStreamingSession -> Text)
-> (DeleteStreamingSession -> Text -> DeleteStreamingSession)
-> Lens DeleteStreamingSession DeleteStreamingSession Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteStreamingSession' {Text
sessionId :: Text
$sel:sessionId:DeleteStreamingSession' :: DeleteStreamingSession -> Text
sessionId} -> Text
sessionId) (\s :: DeleteStreamingSession
s@DeleteStreamingSession' {} Text
a -> DeleteStreamingSession
s {$sel:sessionId:DeleteStreamingSession' :: Text
sessionId = Text
a} :: DeleteStreamingSession)

instance Core.AWSRequest DeleteStreamingSession where
  type
    AWSResponse DeleteStreamingSession =
      DeleteStreamingSessionResponse
  request :: DeleteStreamingSession -> Request DeleteStreamingSession
request = Service -> DeleteStreamingSession -> Request DeleteStreamingSession
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteStreamingSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteStreamingSession)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteStreamingSession))
-> Logger
-> Service
-> Proxy DeleteStreamingSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteStreamingSession)))
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 StreamingSession -> Int -> DeleteStreamingSessionResponse
DeleteStreamingSessionResponse'
            (Maybe StreamingSession -> Int -> DeleteStreamingSessionResponse)
-> Either String (Maybe StreamingSession)
-> Either String (Int -> DeleteStreamingSessionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe StreamingSession)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"session")
            Either String (Int -> DeleteStreamingSessionResponse)
-> Either String Int
-> Either String DeleteStreamingSessionResponse
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 DeleteStreamingSession

instance Prelude.NFData DeleteStreamingSession

instance Core.ToHeaders DeleteStreamingSession where
  toHeaders :: DeleteStreamingSession -> ResponseHeaders
toHeaders DeleteStreamingSession' {Maybe Text
Text
sessionId :: Text
studioId :: Text
clientToken :: Maybe Text
$sel:sessionId:DeleteStreamingSession' :: DeleteStreamingSession -> Text
$sel:studioId:DeleteStreamingSession' :: DeleteStreamingSession -> Text
$sel:clientToken:DeleteStreamingSession' :: DeleteStreamingSession -> Maybe Text
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"X-Amz-Client-Token" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
clientToken,
        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 DeleteStreamingSession where
  toPath :: DeleteStreamingSession -> ByteString
toPath DeleteStreamingSession' {Maybe Text
Text
sessionId :: Text
studioId :: Text
clientToken :: Maybe Text
$sel:sessionId:DeleteStreamingSession' :: DeleteStreamingSession -> Text
$sel:studioId:DeleteStreamingSession' :: DeleteStreamingSession -> Text
$sel:clientToken:DeleteStreamingSession' :: DeleteStreamingSession -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2020-08-01/studios/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
studioId,
        ByteString
"/streaming-sessions/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
sessionId
      ]

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

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

-- |
-- Create a value of 'DeleteStreamingSessionResponse' 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', 'deleteStreamingSessionResponse_session' - The session.
--
-- 'httpStatus', 'deleteStreamingSessionResponse_httpStatus' - The response's http status code.
newDeleteStreamingSessionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteStreamingSessionResponse
newDeleteStreamingSessionResponse :: Int -> DeleteStreamingSessionResponse
newDeleteStreamingSessionResponse Int
pHttpStatus_ =
  DeleteStreamingSessionResponse' :: Maybe StreamingSession -> Int -> DeleteStreamingSessionResponse
DeleteStreamingSessionResponse'
    { $sel:session:DeleteStreamingSessionResponse' :: Maybe StreamingSession
session =
        Maybe StreamingSession
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteStreamingSessionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

instance
  Prelude.NFData
    DeleteStreamingSessionResponse