{-# 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.KinesisVideo.UpdateSignalingChannel
-- 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)
--
-- Updates the existing signaling channel. This is an asynchronous
-- operation and takes time to complete.
--
-- If the @MessageTtlSeconds@ value is updated (either increased or
-- reduced), it only applies to new messages sent via this channel after
-- it\'s been updated. Existing messages are still expired as per the
-- previous @MessageTtlSeconds@ value.
module Amazonka.KinesisVideo.UpdateSignalingChannel
  ( -- * Creating a Request
    UpdateSignalingChannel (..),
    newUpdateSignalingChannel,

    -- * Request Lenses
    updateSignalingChannel_singleMasterConfiguration,
    updateSignalingChannel_channelARN,
    updateSignalingChannel_currentVersion,

    -- * Destructuring the Response
    UpdateSignalingChannelResponse (..),
    newUpdateSignalingChannelResponse,

    -- * Response Lenses
    updateSignalingChannelResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.KinesisVideo.Types
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:/ 'newUpdateSignalingChannel' smart constructor.
data UpdateSignalingChannel = UpdateSignalingChannel'
  { -- | The structure containing the configuration for the @SINGLE_MASTER@ type
    -- of the signaling channel that you want to update.
    UpdateSignalingChannel -> Maybe SingleMasterConfiguration
singleMasterConfiguration :: Prelude.Maybe SingleMasterConfiguration,
    -- | The Amazon Resource Name (ARN) of the signaling channel that you want to
    -- update.
    UpdateSignalingChannel -> Text
channelARN :: Prelude.Text,
    -- | The current version of the signaling channel that you want to update.
    UpdateSignalingChannel -> Text
currentVersion :: Prelude.Text
  }
  deriving (UpdateSignalingChannel -> UpdateSignalingChannel -> Bool
(UpdateSignalingChannel -> UpdateSignalingChannel -> Bool)
-> (UpdateSignalingChannel -> UpdateSignalingChannel -> Bool)
-> Eq UpdateSignalingChannel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSignalingChannel -> UpdateSignalingChannel -> Bool
$c/= :: UpdateSignalingChannel -> UpdateSignalingChannel -> Bool
== :: UpdateSignalingChannel -> UpdateSignalingChannel -> Bool
$c== :: UpdateSignalingChannel -> UpdateSignalingChannel -> Bool
Prelude.Eq, ReadPrec [UpdateSignalingChannel]
ReadPrec UpdateSignalingChannel
Int -> ReadS UpdateSignalingChannel
ReadS [UpdateSignalingChannel]
(Int -> ReadS UpdateSignalingChannel)
-> ReadS [UpdateSignalingChannel]
-> ReadPrec UpdateSignalingChannel
-> ReadPrec [UpdateSignalingChannel]
-> Read UpdateSignalingChannel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSignalingChannel]
$creadListPrec :: ReadPrec [UpdateSignalingChannel]
readPrec :: ReadPrec UpdateSignalingChannel
$creadPrec :: ReadPrec UpdateSignalingChannel
readList :: ReadS [UpdateSignalingChannel]
$creadList :: ReadS [UpdateSignalingChannel]
readsPrec :: Int -> ReadS UpdateSignalingChannel
$creadsPrec :: Int -> ReadS UpdateSignalingChannel
Prelude.Read, Int -> UpdateSignalingChannel -> ShowS
[UpdateSignalingChannel] -> ShowS
UpdateSignalingChannel -> String
(Int -> UpdateSignalingChannel -> ShowS)
-> (UpdateSignalingChannel -> String)
-> ([UpdateSignalingChannel] -> ShowS)
-> Show UpdateSignalingChannel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSignalingChannel] -> ShowS
$cshowList :: [UpdateSignalingChannel] -> ShowS
show :: UpdateSignalingChannel -> String
$cshow :: UpdateSignalingChannel -> String
showsPrec :: Int -> UpdateSignalingChannel -> ShowS
$cshowsPrec :: Int -> UpdateSignalingChannel -> ShowS
Prelude.Show, (forall x. UpdateSignalingChannel -> Rep UpdateSignalingChannel x)
-> (forall x.
    Rep UpdateSignalingChannel x -> UpdateSignalingChannel)
-> Generic UpdateSignalingChannel
forall x. Rep UpdateSignalingChannel x -> UpdateSignalingChannel
forall x. UpdateSignalingChannel -> Rep UpdateSignalingChannel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateSignalingChannel x -> UpdateSignalingChannel
$cfrom :: forall x. UpdateSignalingChannel -> Rep UpdateSignalingChannel x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSignalingChannel' 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:
--
-- 'singleMasterConfiguration', 'updateSignalingChannel_singleMasterConfiguration' - The structure containing the configuration for the @SINGLE_MASTER@ type
-- of the signaling channel that you want to update.
--
-- 'channelARN', 'updateSignalingChannel_channelARN' - The Amazon Resource Name (ARN) of the signaling channel that you want to
-- update.
--
-- 'currentVersion', 'updateSignalingChannel_currentVersion' - The current version of the signaling channel that you want to update.
newUpdateSignalingChannel ::
  -- | 'channelARN'
  Prelude.Text ->
  -- | 'currentVersion'
  Prelude.Text ->
  UpdateSignalingChannel
newUpdateSignalingChannel :: Text -> Text -> UpdateSignalingChannel
newUpdateSignalingChannel
  Text
pChannelARN_
  Text
pCurrentVersion_ =
    UpdateSignalingChannel' :: Maybe SingleMasterConfiguration
-> Text -> Text -> UpdateSignalingChannel
UpdateSignalingChannel'
      { $sel:singleMasterConfiguration:UpdateSignalingChannel' :: Maybe SingleMasterConfiguration
singleMasterConfiguration =
          Maybe SingleMasterConfiguration
forall a. Maybe a
Prelude.Nothing,
        $sel:channelARN:UpdateSignalingChannel' :: Text
channelARN = Text
pChannelARN_,
        $sel:currentVersion:UpdateSignalingChannel' :: Text
currentVersion = Text
pCurrentVersion_
      }

-- | The structure containing the configuration for the @SINGLE_MASTER@ type
-- of the signaling channel that you want to update.
updateSignalingChannel_singleMasterConfiguration :: Lens.Lens' UpdateSignalingChannel (Prelude.Maybe SingleMasterConfiguration)
updateSignalingChannel_singleMasterConfiguration :: (Maybe SingleMasterConfiguration
 -> f (Maybe SingleMasterConfiguration))
-> UpdateSignalingChannel -> f UpdateSignalingChannel
updateSignalingChannel_singleMasterConfiguration = (UpdateSignalingChannel -> Maybe SingleMasterConfiguration)
-> (UpdateSignalingChannel
    -> Maybe SingleMasterConfiguration -> UpdateSignalingChannel)
-> Lens
     UpdateSignalingChannel
     UpdateSignalingChannel
     (Maybe SingleMasterConfiguration)
     (Maybe SingleMasterConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSignalingChannel' {Maybe SingleMasterConfiguration
singleMasterConfiguration :: Maybe SingleMasterConfiguration
$sel:singleMasterConfiguration:UpdateSignalingChannel' :: UpdateSignalingChannel -> Maybe SingleMasterConfiguration
singleMasterConfiguration} -> Maybe SingleMasterConfiguration
singleMasterConfiguration) (\s :: UpdateSignalingChannel
s@UpdateSignalingChannel' {} Maybe SingleMasterConfiguration
a -> UpdateSignalingChannel
s {$sel:singleMasterConfiguration:UpdateSignalingChannel' :: Maybe SingleMasterConfiguration
singleMasterConfiguration = Maybe SingleMasterConfiguration
a} :: UpdateSignalingChannel)

-- | The Amazon Resource Name (ARN) of the signaling channel that you want to
-- update.
updateSignalingChannel_channelARN :: Lens.Lens' UpdateSignalingChannel Prelude.Text
updateSignalingChannel_channelARN :: (Text -> f Text)
-> UpdateSignalingChannel -> f UpdateSignalingChannel
updateSignalingChannel_channelARN = (UpdateSignalingChannel -> Text)
-> (UpdateSignalingChannel -> Text -> UpdateSignalingChannel)
-> Lens UpdateSignalingChannel UpdateSignalingChannel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSignalingChannel' {Text
channelARN :: Text
$sel:channelARN:UpdateSignalingChannel' :: UpdateSignalingChannel -> Text
channelARN} -> Text
channelARN) (\s :: UpdateSignalingChannel
s@UpdateSignalingChannel' {} Text
a -> UpdateSignalingChannel
s {$sel:channelARN:UpdateSignalingChannel' :: Text
channelARN = Text
a} :: UpdateSignalingChannel)

-- | The current version of the signaling channel that you want to update.
updateSignalingChannel_currentVersion :: Lens.Lens' UpdateSignalingChannel Prelude.Text
updateSignalingChannel_currentVersion :: (Text -> f Text)
-> UpdateSignalingChannel -> f UpdateSignalingChannel
updateSignalingChannel_currentVersion = (UpdateSignalingChannel -> Text)
-> (UpdateSignalingChannel -> Text -> UpdateSignalingChannel)
-> Lens UpdateSignalingChannel UpdateSignalingChannel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSignalingChannel' {Text
currentVersion :: Text
$sel:currentVersion:UpdateSignalingChannel' :: UpdateSignalingChannel -> Text
currentVersion} -> Text
currentVersion) (\s :: UpdateSignalingChannel
s@UpdateSignalingChannel' {} Text
a -> UpdateSignalingChannel
s {$sel:currentVersion:UpdateSignalingChannel' :: Text
currentVersion = Text
a} :: UpdateSignalingChannel)

instance Core.AWSRequest UpdateSignalingChannel where
  type
    AWSResponse UpdateSignalingChannel =
      UpdateSignalingChannelResponse
  request :: UpdateSignalingChannel -> Request UpdateSignalingChannel
request = Service -> UpdateSignalingChannel -> Request UpdateSignalingChannel
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateSignalingChannel
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateSignalingChannel)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateSignalingChannel))
-> Logger
-> Service
-> Proxy UpdateSignalingChannel
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateSignalingChannel)))
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 -> UpdateSignalingChannelResponse
UpdateSignalingChannelResponse'
            (Int -> UpdateSignalingChannelResponse)
-> Either String Int
-> Either String UpdateSignalingChannelResponse
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 UpdateSignalingChannel

instance Prelude.NFData UpdateSignalingChannel

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

instance Core.ToJSON UpdateSignalingChannel where
  toJSON :: UpdateSignalingChannel -> Value
toJSON UpdateSignalingChannel' {Maybe SingleMasterConfiguration
Text
currentVersion :: Text
channelARN :: Text
singleMasterConfiguration :: Maybe SingleMasterConfiguration
$sel:currentVersion:UpdateSignalingChannel' :: UpdateSignalingChannel -> Text
$sel:channelARN:UpdateSignalingChannel' :: UpdateSignalingChannel -> Text
$sel:singleMasterConfiguration:UpdateSignalingChannel' :: UpdateSignalingChannel -> Maybe SingleMasterConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SingleMasterConfiguration" Text -> SingleMasterConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SingleMasterConfiguration -> Pair)
-> Maybe SingleMasterConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SingleMasterConfiguration
singleMasterConfiguration,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ChannelARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
channelARN),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"CurrentVersion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
currentVersion)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    UpdateSignalingChannelResponse