{-# 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.KinesisVideoSignaling.SendAlexaOfferToMaster
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- This API allows you to connect WebRTC-enabled devices with Alexa display
-- devices. When invoked, it sends the Alexa Session Description Protocol
-- (SDP) offer to the master peer. The offer is delivered as soon as the
-- master is connected to the specified signaling channel. This API returns
-- the SDP answer from the connected master. If the master is not connected
-- to the signaling channel, redelivery requests are made until the message
-- expires.
module Amazonka.KinesisVideoSignaling.SendAlexaOfferToMaster
  ( -- * Creating a Request
    SendAlexaOfferToMaster (..),
    newSendAlexaOfferToMaster,

    -- * Request Lenses
    sendAlexaOfferToMaster_channelARN,
    sendAlexaOfferToMaster_senderClientId,
    sendAlexaOfferToMaster_messagePayload,

    -- * Destructuring the Response
    SendAlexaOfferToMasterResponse (..),
    newSendAlexaOfferToMasterResponse,

    -- * Response Lenses
    sendAlexaOfferToMasterResponse_answer,
    sendAlexaOfferToMasterResponse_httpStatus,
  )
where

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

-- | /See:/ 'newSendAlexaOfferToMaster' smart constructor.
data SendAlexaOfferToMaster = SendAlexaOfferToMaster'
  { -- | The ARN of the signaling channel by which Alexa and the master peer
    -- communicate.
    SendAlexaOfferToMaster -> Text
channelARN :: Prelude.Text,
    -- | The unique identifier for the sender client.
    SendAlexaOfferToMaster -> Text
senderClientId :: Prelude.Text,
    -- | The base64-encoded SDP offer content.
    SendAlexaOfferToMaster -> Text
messagePayload :: Prelude.Text
  }
  deriving (SendAlexaOfferToMaster -> SendAlexaOfferToMaster -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendAlexaOfferToMaster -> SendAlexaOfferToMaster -> Bool
$c/= :: SendAlexaOfferToMaster -> SendAlexaOfferToMaster -> Bool
== :: SendAlexaOfferToMaster -> SendAlexaOfferToMaster -> Bool
$c== :: SendAlexaOfferToMaster -> SendAlexaOfferToMaster -> Bool
Prelude.Eq, ReadPrec [SendAlexaOfferToMaster]
ReadPrec SendAlexaOfferToMaster
Int -> ReadS SendAlexaOfferToMaster
ReadS [SendAlexaOfferToMaster]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendAlexaOfferToMaster]
$creadListPrec :: ReadPrec [SendAlexaOfferToMaster]
readPrec :: ReadPrec SendAlexaOfferToMaster
$creadPrec :: ReadPrec SendAlexaOfferToMaster
readList :: ReadS [SendAlexaOfferToMaster]
$creadList :: ReadS [SendAlexaOfferToMaster]
readsPrec :: Int -> ReadS SendAlexaOfferToMaster
$creadsPrec :: Int -> ReadS SendAlexaOfferToMaster
Prelude.Read, Int -> SendAlexaOfferToMaster -> ShowS
[SendAlexaOfferToMaster] -> ShowS
SendAlexaOfferToMaster -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendAlexaOfferToMaster] -> ShowS
$cshowList :: [SendAlexaOfferToMaster] -> ShowS
show :: SendAlexaOfferToMaster -> String
$cshow :: SendAlexaOfferToMaster -> String
showsPrec :: Int -> SendAlexaOfferToMaster -> ShowS
$cshowsPrec :: Int -> SendAlexaOfferToMaster -> ShowS
Prelude.Show, forall x. Rep SendAlexaOfferToMaster x -> SendAlexaOfferToMaster
forall x. SendAlexaOfferToMaster -> Rep SendAlexaOfferToMaster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendAlexaOfferToMaster x -> SendAlexaOfferToMaster
$cfrom :: forall x. SendAlexaOfferToMaster -> Rep SendAlexaOfferToMaster x
Prelude.Generic)

-- |
-- Create a value of 'SendAlexaOfferToMaster' 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', 'sendAlexaOfferToMaster_channelARN' - The ARN of the signaling channel by which Alexa and the master peer
-- communicate.
--
-- 'senderClientId', 'sendAlexaOfferToMaster_senderClientId' - The unique identifier for the sender client.
--
-- 'messagePayload', 'sendAlexaOfferToMaster_messagePayload' - The base64-encoded SDP offer content.
newSendAlexaOfferToMaster ::
  -- | 'channelARN'
  Prelude.Text ->
  -- | 'senderClientId'
  Prelude.Text ->
  -- | 'messagePayload'
  Prelude.Text ->
  SendAlexaOfferToMaster
newSendAlexaOfferToMaster :: Text -> Text -> Text -> SendAlexaOfferToMaster
newSendAlexaOfferToMaster
  Text
pChannelARN_
  Text
pSenderClientId_
  Text
pMessagePayload_ =
    SendAlexaOfferToMaster'
      { $sel:channelARN:SendAlexaOfferToMaster' :: Text
channelARN = Text
pChannelARN_,
        $sel:senderClientId:SendAlexaOfferToMaster' :: Text
senderClientId = Text
pSenderClientId_,
        $sel:messagePayload:SendAlexaOfferToMaster' :: Text
messagePayload = Text
pMessagePayload_
      }

-- | The ARN of the signaling channel by which Alexa and the master peer
-- communicate.
sendAlexaOfferToMaster_channelARN :: Lens.Lens' SendAlexaOfferToMaster Prelude.Text
sendAlexaOfferToMaster_channelARN :: Lens' SendAlexaOfferToMaster Text
sendAlexaOfferToMaster_channelARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendAlexaOfferToMaster' {Text
channelARN :: Text
$sel:channelARN:SendAlexaOfferToMaster' :: SendAlexaOfferToMaster -> Text
channelARN} -> Text
channelARN) (\s :: SendAlexaOfferToMaster
s@SendAlexaOfferToMaster' {} Text
a -> SendAlexaOfferToMaster
s {$sel:channelARN:SendAlexaOfferToMaster' :: Text
channelARN = Text
a} :: SendAlexaOfferToMaster)

-- | The unique identifier for the sender client.
sendAlexaOfferToMaster_senderClientId :: Lens.Lens' SendAlexaOfferToMaster Prelude.Text
sendAlexaOfferToMaster_senderClientId :: Lens' SendAlexaOfferToMaster Text
sendAlexaOfferToMaster_senderClientId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendAlexaOfferToMaster' {Text
senderClientId :: Text
$sel:senderClientId:SendAlexaOfferToMaster' :: SendAlexaOfferToMaster -> Text
senderClientId} -> Text
senderClientId) (\s :: SendAlexaOfferToMaster
s@SendAlexaOfferToMaster' {} Text
a -> SendAlexaOfferToMaster
s {$sel:senderClientId:SendAlexaOfferToMaster' :: Text
senderClientId = Text
a} :: SendAlexaOfferToMaster)

-- | The base64-encoded SDP offer content.
sendAlexaOfferToMaster_messagePayload :: Lens.Lens' SendAlexaOfferToMaster Prelude.Text
sendAlexaOfferToMaster_messagePayload :: Lens' SendAlexaOfferToMaster Text
sendAlexaOfferToMaster_messagePayload = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendAlexaOfferToMaster' {Text
messagePayload :: Text
$sel:messagePayload:SendAlexaOfferToMaster' :: SendAlexaOfferToMaster -> Text
messagePayload} -> Text
messagePayload) (\s :: SendAlexaOfferToMaster
s@SendAlexaOfferToMaster' {} Text
a -> SendAlexaOfferToMaster
s {$sel:messagePayload:SendAlexaOfferToMaster' :: Text
messagePayload = Text
a} :: SendAlexaOfferToMaster)

instance Core.AWSRequest SendAlexaOfferToMaster where
  type
    AWSResponse SendAlexaOfferToMaster =
      SendAlexaOfferToMasterResponse
  request :: (Service -> Service)
-> SendAlexaOfferToMaster -> Request SendAlexaOfferToMaster
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 SendAlexaOfferToMaster
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SendAlexaOfferToMaster)))
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 -> SendAlexaOfferToMasterResponse
SendAlexaOfferToMasterResponse'
            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
"Answer")
            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 SendAlexaOfferToMaster where
  hashWithSalt :: Int -> SendAlexaOfferToMaster -> Int
hashWithSalt Int
_salt SendAlexaOfferToMaster' {Text
messagePayload :: Text
senderClientId :: Text
channelARN :: Text
$sel:messagePayload:SendAlexaOfferToMaster' :: SendAlexaOfferToMaster -> Text
$sel:senderClientId:SendAlexaOfferToMaster' :: SendAlexaOfferToMaster -> Text
$sel:channelARN:SendAlexaOfferToMaster' :: SendAlexaOfferToMaster -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
channelARN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
senderClientId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
messagePayload

instance Prelude.NFData SendAlexaOfferToMaster where
  rnf :: SendAlexaOfferToMaster -> ()
rnf SendAlexaOfferToMaster' {Text
messagePayload :: Text
senderClientId :: Text
channelARN :: Text
$sel:messagePayload:SendAlexaOfferToMaster' :: SendAlexaOfferToMaster -> Text
$sel:senderClientId:SendAlexaOfferToMaster' :: SendAlexaOfferToMaster -> Text
$sel:channelARN:SendAlexaOfferToMaster' :: SendAlexaOfferToMaster -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
channelARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
senderClientId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
messagePayload

instance Data.ToHeaders SendAlexaOfferToMaster where
  toHeaders :: SendAlexaOfferToMaster -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToJSON SendAlexaOfferToMaster where
  toJSON :: SendAlexaOfferToMaster -> Value
toJSON SendAlexaOfferToMaster' {Text
messagePayload :: Text
senderClientId :: Text
channelARN :: Text
$sel:messagePayload:SendAlexaOfferToMaster' :: SendAlexaOfferToMaster -> Text
$sel:senderClientId:SendAlexaOfferToMaster' :: SendAlexaOfferToMaster -> Text
$sel:channelARN:SendAlexaOfferToMaster' :: SendAlexaOfferToMaster -> 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),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"SenderClientId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
senderClientId),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"MessagePayload" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
messagePayload)
          ]
      )

instance Data.ToPath SendAlexaOfferToMaster where
  toPath :: SendAlexaOfferToMaster -> ByteString
toPath =
    forall a b. a -> b -> a
Prelude.const ByteString
"/v1/send-alexa-offer-to-master"

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

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

-- |
-- Create a value of 'SendAlexaOfferToMasterResponse' 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:
--
-- 'answer', 'sendAlexaOfferToMasterResponse_answer' - The base64-encoded SDP answer content.
--
-- 'httpStatus', 'sendAlexaOfferToMasterResponse_httpStatus' - The response's http status code.
newSendAlexaOfferToMasterResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SendAlexaOfferToMasterResponse
newSendAlexaOfferToMasterResponse :: Int -> SendAlexaOfferToMasterResponse
newSendAlexaOfferToMasterResponse Int
pHttpStatus_ =
  SendAlexaOfferToMasterResponse'
    { $sel:answer:SendAlexaOfferToMasterResponse' :: Maybe Text
answer =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:SendAlexaOfferToMasterResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The base64-encoded SDP answer content.
sendAlexaOfferToMasterResponse_answer :: Lens.Lens' SendAlexaOfferToMasterResponse (Prelude.Maybe Prelude.Text)
sendAlexaOfferToMasterResponse_answer :: Lens' SendAlexaOfferToMasterResponse (Maybe Text)
sendAlexaOfferToMasterResponse_answer = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendAlexaOfferToMasterResponse' {Maybe Text
answer :: Maybe Text
$sel:answer:SendAlexaOfferToMasterResponse' :: SendAlexaOfferToMasterResponse -> Maybe Text
answer} -> Maybe Text
answer) (\s :: SendAlexaOfferToMasterResponse
s@SendAlexaOfferToMasterResponse' {} Maybe Text
a -> SendAlexaOfferToMasterResponse
s {$sel:answer:SendAlexaOfferToMasterResponse' :: Maybe Text
answer = Maybe Text
a} :: SendAlexaOfferToMasterResponse)

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

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