{-# 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.StartStreamingSession
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Transitions sessions from the @STOPPED@ state into the @READY@ state.
-- The @START_IN_PROGRESS@ state is the intermediate state between the
-- @STOPPED@ and @READY@ states.
module Amazonka.Nimble.StartStreamingSession
  ( -- * Creating a Request
    StartStreamingSession (..),
    newStartStreamingSession,

    -- * Request Lenses
    startStreamingSession_backupId,
    startStreamingSession_clientToken,
    startStreamingSession_sessionId,
    startStreamingSession_studioId,

    -- * Destructuring the Response
    StartStreamingSessionResponse (..),
    newStartStreamingSessionResponse,

    -- * Response Lenses
    startStreamingSessionResponse_session,
    startStreamingSessionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newStartStreamingSession' smart constructor.
data StartStreamingSession = StartStreamingSession'
  { -- | The ID of the backup.
    StartStreamingSession -> Maybe Text
backupId :: Prelude.Maybe Prelude.Text,
    -- | Unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request. If you don’t specify a client token, the
    -- Amazon Web Services SDK automatically generates a client token and uses
    -- it for the request to ensure idempotency.
    StartStreamingSession -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The streaming session ID for the @StartStreamingSessionRequest@.
    StartStreamingSession -> Text
sessionId :: Prelude.Text,
    -- | The studio ID for the StartStreamingSessionRequest.
    StartStreamingSession -> Text
studioId :: Prelude.Text
  }
  deriving (StartStreamingSession -> StartStreamingSession -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartStreamingSession -> StartStreamingSession -> Bool
$c/= :: StartStreamingSession -> StartStreamingSession -> Bool
== :: StartStreamingSession -> StartStreamingSession -> Bool
$c== :: StartStreamingSession -> StartStreamingSession -> Bool
Prelude.Eq, ReadPrec [StartStreamingSession]
ReadPrec StartStreamingSession
Int -> ReadS StartStreamingSession
ReadS [StartStreamingSession]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartStreamingSession]
$creadListPrec :: ReadPrec [StartStreamingSession]
readPrec :: ReadPrec StartStreamingSession
$creadPrec :: ReadPrec StartStreamingSession
readList :: ReadS [StartStreamingSession]
$creadList :: ReadS [StartStreamingSession]
readsPrec :: Int -> ReadS StartStreamingSession
$creadsPrec :: Int -> ReadS StartStreamingSession
Prelude.Read, Int -> StartStreamingSession -> ShowS
[StartStreamingSession] -> ShowS
StartStreamingSession -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartStreamingSession] -> ShowS
$cshowList :: [StartStreamingSession] -> ShowS
show :: StartStreamingSession -> String
$cshow :: StartStreamingSession -> String
showsPrec :: Int -> StartStreamingSession -> ShowS
$cshowsPrec :: Int -> StartStreamingSession -> ShowS
Prelude.Show, forall x. Rep StartStreamingSession x -> StartStreamingSession
forall x. StartStreamingSession -> Rep StartStreamingSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartStreamingSession x -> StartStreamingSession
$cfrom :: forall x. StartStreamingSession -> Rep StartStreamingSession x
Prelude.Generic)

-- |
-- Create a value of 'StartStreamingSession' 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:
--
-- 'backupId', 'startStreamingSession_backupId' - The ID of the backup.
--
-- 'clientToken', 'startStreamingSession_clientToken' - Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. If you don’t specify a client token, the
-- Amazon Web Services SDK automatically generates a client token and uses
-- it for the request to ensure idempotency.
--
-- 'sessionId', 'startStreamingSession_sessionId' - The streaming session ID for the @StartStreamingSessionRequest@.
--
-- 'studioId', 'startStreamingSession_studioId' - The studio ID for the StartStreamingSessionRequest.
newStartStreamingSession ::
  -- | 'sessionId'
  Prelude.Text ->
  -- | 'studioId'
  Prelude.Text ->
  StartStreamingSession
newStartStreamingSession :: Text -> Text -> StartStreamingSession
newStartStreamingSession Text
pSessionId_ Text
pStudioId_ =
  StartStreamingSession'
    { $sel:backupId:StartStreamingSession' :: Maybe Text
backupId = forall a. Maybe a
Prelude.Nothing,
      $sel:clientToken:StartStreamingSession' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
      $sel:sessionId:StartStreamingSession' :: Text
sessionId = Text
pSessionId_,
      $sel:studioId:StartStreamingSession' :: Text
studioId = Text
pStudioId_
    }

-- | The ID of the backup.
startStreamingSession_backupId :: Lens.Lens' StartStreamingSession (Prelude.Maybe Prelude.Text)
startStreamingSession_backupId :: Lens' StartStreamingSession (Maybe Text)
startStreamingSession_backupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartStreamingSession' {Maybe Text
backupId :: Maybe Text
$sel:backupId:StartStreamingSession' :: StartStreamingSession -> Maybe Text
backupId} -> Maybe Text
backupId) (\s :: StartStreamingSession
s@StartStreamingSession' {} Maybe Text
a -> StartStreamingSession
s {$sel:backupId:StartStreamingSession' :: Maybe Text
backupId = Maybe Text
a} :: StartStreamingSession)

-- | Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. If you don’t specify a client token, the
-- Amazon Web Services SDK automatically generates a client token and uses
-- it for the request to ensure idempotency.
startStreamingSession_clientToken :: Lens.Lens' StartStreamingSession (Prelude.Maybe Prelude.Text)
startStreamingSession_clientToken :: Lens' StartStreamingSession (Maybe Text)
startStreamingSession_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartStreamingSession' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:StartStreamingSession' :: StartStreamingSession -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: StartStreamingSession
s@StartStreamingSession' {} Maybe Text
a -> StartStreamingSession
s {$sel:clientToken:StartStreamingSession' :: Maybe Text
clientToken = Maybe Text
a} :: StartStreamingSession)

-- | The streaming session ID for the @StartStreamingSessionRequest@.
startStreamingSession_sessionId :: Lens.Lens' StartStreamingSession Prelude.Text
startStreamingSession_sessionId :: Lens' StartStreamingSession Text
startStreamingSession_sessionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartStreamingSession' {Text
sessionId :: Text
$sel:sessionId:StartStreamingSession' :: StartStreamingSession -> Text
sessionId} -> Text
sessionId) (\s :: StartStreamingSession
s@StartStreamingSession' {} Text
a -> StartStreamingSession
s {$sel:sessionId:StartStreamingSession' :: Text
sessionId = Text
a} :: StartStreamingSession)

-- | The studio ID for the StartStreamingSessionRequest.
startStreamingSession_studioId :: Lens.Lens' StartStreamingSession Prelude.Text
startStreamingSession_studioId :: Lens' StartStreamingSession Text
startStreamingSession_studioId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartStreamingSession' {Text
studioId :: Text
$sel:studioId:StartStreamingSession' :: StartStreamingSession -> Text
studioId} -> Text
studioId) (\s :: StartStreamingSession
s@StartStreamingSession' {} Text
a -> StartStreamingSession
s {$sel:studioId:StartStreamingSession' :: Text
studioId = Text
a} :: StartStreamingSession)

instance Core.AWSRequest StartStreamingSession where
  type
    AWSResponse StartStreamingSession =
      StartStreamingSessionResponse
  request :: (Service -> Service)
-> StartStreamingSession -> Request StartStreamingSession
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 StartStreamingSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartStreamingSession)))
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 StreamingSession -> Int -> StartStreamingSessionResponse
StartStreamingSessionResponse'
            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
"session")
            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 StartStreamingSession where
  hashWithSalt :: Int -> StartStreamingSession -> Int
hashWithSalt Int
_salt StartStreamingSession' {Maybe Text
Text
studioId :: Text
sessionId :: Text
clientToken :: Maybe Text
backupId :: Maybe Text
$sel:studioId:StartStreamingSession' :: StartStreamingSession -> Text
$sel:sessionId:StartStreamingSession' :: StartStreamingSession -> Text
$sel:clientToken:StartStreamingSession' :: StartStreamingSession -> Maybe Text
$sel:backupId:StartStreamingSession' :: StartStreamingSession -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
backupId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sessionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
studioId

instance Prelude.NFData StartStreamingSession where
  rnf :: StartStreamingSession -> ()
rnf StartStreamingSession' {Maybe Text
Text
studioId :: Text
sessionId :: Text
clientToken :: Maybe Text
backupId :: Maybe Text
$sel:studioId:StartStreamingSession' :: StartStreamingSession -> Text
$sel:sessionId:StartStreamingSession' :: StartStreamingSession -> Text
$sel:clientToken:StartStreamingSession' :: StartStreamingSession -> Maybe Text
$sel:backupId:StartStreamingSession' :: StartStreamingSession -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
backupId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sessionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
studioId

instance Data.ToHeaders StartStreamingSession where
  toHeaders :: StartStreamingSession -> ResponseHeaders
toHeaders StartStreamingSession' {Maybe Text
Text
studioId :: Text
sessionId :: Text
clientToken :: Maybe Text
backupId :: Maybe Text
$sel:studioId:StartStreamingSession' :: StartStreamingSession -> Text
$sel:sessionId:StartStreamingSession' :: StartStreamingSession -> Text
$sel:clientToken:StartStreamingSession' :: StartStreamingSession -> Maybe Text
$sel:backupId:StartStreamingSession' :: StartStreamingSession -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"X-Amz-Client-Token" forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# Maybe Text
clientToken,
        HeaderName
"Content-Type"
          forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/x-amz-json-1.1" :: Prelude.ByteString)
      ]

instance Data.ToJSON StartStreamingSession where
  toJSON :: StartStreamingSession -> Value
toJSON StartStreamingSession' {Maybe Text
Text
studioId :: Text
sessionId :: Text
clientToken :: Maybe Text
backupId :: Maybe Text
$sel:studioId:StartStreamingSession' :: StartStreamingSession -> Text
$sel:sessionId:StartStreamingSession' :: StartStreamingSession -> Text
$sel:clientToken:StartStreamingSession' :: StartStreamingSession -> Maybe Text
$sel:backupId:StartStreamingSession' :: StartStreamingSession -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"backupId" 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
backupId]
      )

instance Data.ToPath StartStreamingSession where
  toPath :: StartStreamingSession -> ByteString
toPath StartStreamingSession' {Maybe Text
Text
studioId :: Text
sessionId :: Text
clientToken :: Maybe Text
backupId :: Maybe Text
$sel:studioId:StartStreamingSession' :: StartStreamingSession -> Text
$sel:sessionId:StartStreamingSession' :: StartStreamingSession -> Text
$sel:clientToken:StartStreamingSession' :: StartStreamingSession -> Maybe Text
$sel:backupId:StartStreamingSession' :: StartStreamingSession -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2020-08-01/studios/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
studioId,
        ByteString
"/streaming-sessions/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
sessionId,
        ByteString
"/start"
      ]

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

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

-- |
-- Create a value of 'StartStreamingSessionResponse' 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', 'startStreamingSessionResponse_session' - Undocumented member.
--
-- 'httpStatus', 'startStreamingSessionResponse_httpStatus' - The response's http status code.
newStartStreamingSessionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartStreamingSessionResponse
newStartStreamingSessionResponse :: Int -> StartStreamingSessionResponse
newStartStreamingSessionResponse Int
pHttpStatus_ =
  StartStreamingSessionResponse'
    { $sel:session:StartStreamingSessionResponse' :: Maybe StreamingSession
session =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartStreamingSessionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
startStreamingSessionResponse_session :: Lens.Lens' StartStreamingSessionResponse (Prelude.Maybe StreamingSession)
startStreamingSessionResponse_session :: Lens' StartStreamingSessionResponse (Maybe StreamingSession)
startStreamingSessionResponse_session = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartStreamingSessionResponse' {Maybe StreamingSession
session :: Maybe StreamingSession
$sel:session:StartStreamingSessionResponse' :: StartStreamingSessionResponse -> Maybe StreamingSession
session} -> Maybe StreamingSession
session) (\s :: StartStreamingSessionResponse
s@StartStreamingSessionResponse' {} Maybe StreamingSession
a -> StartStreamingSessionResponse
s {$sel:session:StartStreamingSessionResponse' :: Maybe StreamingSession
session = Maybe StreamingSession
a} :: StartStreamingSessionResponse)

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

instance Prelude.NFData StartStreamingSessionResponse where
  rnf :: StartStreamingSessionResponse -> ()
rnf StartStreamingSessionResponse' {Int
Maybe StreamingSession
httpStatus :: Int
session :: Maybe StreamingSession
$sel:httpStatus:StartStreamingSessionResponse' :: StartStreamingSessionResponse -> Int
$sel:session:StartStreamingSessionResponse' :: StartStreamingSessionResponse -> Maybe StreamingSession
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe StreamingSession
session
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus