{-# 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.KinesisVideoWebRtcStorage.JoinStorageSession
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Join the ongoing one way-video and\/or multi-way audio WebRTC session as
-- a video producing device for an input channel. If there’s no existing
-- session for the channel, a new streaming session needs to be created,
-- and the Amazon Resource Name (ARN) of the signaling channel must be
-- provided.
--
-- Currently for the @SINGLE_MASTER@ type, a video producing device is able
-- to ingest both audio and video media into a stream, while viewers can
-- only ingest audio. Both a video producing device and viewers can join
-- the session first, and wait for other participants.
--
-- While participants are having peer to peer conversations through webRTC,
-- the ingested media session will be stored into the Kinesis Video Stream.
-- Multiple viewers are able to playback real-time media.
--
-- Customers can also use existing Kinesis Video Streams features like
-- @HLS@ or @DASH@ playback, Image generation, and more with ingested
-- WebRTC media.
--
-- Assume that only one video producing device client can be associated
-- with a session for the channel. If more than one client joins the
-- session of a specific channel as a video producing device, the most
-- recent client request takes precedence.
module Amazonka.KinesisVideoWebRtcStorage.JoinStorageSession
  ( -- * Creating a Request
    JoinStorageSession (..),
    newJoinStorageSession,

    -- * Request Lenses
    joinStorageSession_channelArn,

    -- * Destructuring the Response
    JoinStorageSessionResponse (..),
    newJoinStorageSessionResponse,
  )
where

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

-- | /See:/ 'newJoinStorageSession' smart constructor.
data JoinStorageSession = JoinStorageSession'
  { -- | The Amazon Resource Name (ARN) of the signaling channel.
    JoinStorageSession -> Text
channelArn :: Prelude.Text
  }
  deriving (JoinStorageSession -> JoinStorageSession -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JoinStorageSession -> JoinStorageSession -> Bool
$c/= :: JoinStorageSession -> JoinStorageSession -> Bool
== :: JoinStorageSession -> JoinStorageSession -> Bool
$c== :: JoinStorageSession -> JoinStorageSession -> Bool
Prelude.Eq, ReadPrec [JoinStorageSession]
ReadPrec JoinStorageSession
Int -> ReadS JoinStorageSession
ReadS [JoinStorageSession]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JoinStorageSession]
$creadListPrec :: ReadPrec [JoinStorageSession]
readPrec :: ReadPrec JoinStorageSession
$creadPrec :: ReadPrec JoinStorageSession
readList :: ReadS [JoinStorageSession]
$creadList :: ReadS [JoinStorageSession]
readsPrec :: Int -> ReadS JoinStorageSession
$creadsPrec :: Int -> ReadS JoinStorageSession
Prelude.Read, Int -> JoinStorageSession -> ShowS
[JoinStorageSession] -> ShowS
JoinStorageSession -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JoinStorageSession] -> ShowS
$cshowList :: [JoinStorageSession] -> ShowS
show :: JoinStorageSession -> String
$cshow :: JoinStorageSession -> String
showsPrec :: Int -> JoinStorageSession -> ShowS
$cshowsPrec :: Int -> JoinStorageSession -> ShowS
Prelude.Show, forall x. Rep JoinStorageSession x -> JoinStorageSession
forall x. JoinStorageSession -> Rep JoinStorageSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JoinStorageSession x -> JoinStorageSession
$cfrom :: forall x. JoinStorageSession -> Rep JoinStorageSession x
Prelude.Generic)

-- |
-- Create a value of 'JoinStorageSession' 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:
--
-- 'channelArn', 'joinStorageSession_channelArn' - The Amazon Resource Name (ARN) of the signaling channel.
newJoinStorageSession ::
  -- | 'channelArn'
  Prelude.Text ->
  JoinStorageSession
newJoinStorageSession :: Text -> JoinStorageSession
newJoinStorageSession Text
pChannelArn_ =
  JoinStorageSession' {$sel:channelArn:JoinStorageSession' :: Text
channelArn = Text
pChannelArn_}

-- | The Amazon Resource Name (ARN) of the signaling channel.
joinStorageSession_channelArn :: Lens.Lens' JoinStorageSession Prelude.Text
joinStorageSession_channelArn :: Lens' JoinStorageSession Text
joinStorageSession_channelArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JoinStorageSession' {Text
channelArn :: Text
$sel:channelArn:JoinStorageSession' :: JoinStorageSession -> Text
channelArn} -> Text
channelArn) (\s :: JoinStorageSession
s@JoinStorageSession' {} Text
a -> JoinStorageSession
s {$sel:channelArn:JoinStorageSession' :: Text
channelArn = Text
a} :: JoinStorageSession)

instance Core.AWSRequest JoinStorageSession where
  type
    AWSResponse JoinStorageSession =
      JoinStorageSessionResponse
  request :: (Service -> Service)
-> JoinStorageSession -> Request JoinStorageSession
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 JoinStorageSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse JoinStorageSession)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull JoinStorageSessionResponse
JoinStorageSessionResponse'

instance Prelude.Hashable JoinStorageSession where
  hashWithSalt :: Int -> JoinStorageSession -> Int
hashWithSalt Int
_salt JoinStorageSession' {Text
channelArn :: Text
$sel:channelArn:JoinStorageSession' :: JoinStorageSession -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
channelArn

instance Prelude.NFData JoinStorageSession where
  rnf :: JoinStorageSession -> ()
rnf JoinStorageSession' {Text
channelArn :: Text
$sel:channelArn:JoinStorageSession' :: JoinStorageSession -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
channelArn

instance Data.ToHeaders JoinStorageSession where
  toHeaders :: JoinStorageSession -> [Header]
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 -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON JoinStorageSession where
  toJSON :: JoinStorageSession -> Value
toJSON JoinStorageSession' {Text
channelArn :: Text
$sel:channelArn:JoinStorageSession' :: JoinStorageSession -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"channelArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
channelArn)]
      )

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

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

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

-- |
-- Create a value of 'JoinStorageSessionResponse' 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.
newJoinStorageSessionResponse ::
  JoinStorageSessionResponse
newJoinStorageSessionResponse :: JoinStorageSessionResponse
newJoinStorageSessionResponse =
  JoinStorageSessionResponse
JoinStorageSessionResponse'

instance Prelude.NFData JoinStorageSessionResponse where
  rnf :: JoinStorageSessionResponse -> ()
rnf JoinStorageSessionResponse
_ = ()