{-# 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.UpdateStream
-- 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 stream metadata, such as the device name and media type.
--
-- You must provide the stream name or the Amazon Resource Name (ARN) of
-- the stream.
--
-- To make sure that you have the latest version of the stream before
-- updating it, you can specify the stream version. Kinesis Video Streams
-- assigns a version to each stream. When you update a stream, Kinesis
-- Video Streams assigns a new version number. To get the latest stream
-- version, use the @DescribeStream@ API.
--
-- @UpdateStream@ is an asynchronous operation, and takes time to complete.
module Amazonka.KinesisVideo.UpdateStream
  ( -- * Creating a Request
    UpdateStream (..),
    newUpdateStream,

    -- * Request Lenses
    updateStream_mediaType,
    updateStream_streamARN,
    updateStream_deviceName,
    updateStream_streamName,
    updateStream_currentVersion,

    -- * Destructuring the Response
    UpdateStreamResponse (..),
    newUpdateStreamResponse,

    -- * Response Lenses
    updateStreamResponse_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:/ 'newUpdateStream' smart constructor.
data UpdateStream = UpdateStream'
  { -- | The stream\'s media type. Use @MediaType@ to specify the type of content
    -- that the stream contains to the consumers of the stream. For more
    -- information about media types, see
    -- <http://www.iana.org/assignments/media-types/media-types.xhtml Media Types>.
    -- If you choose to specify the @MediaType@, see
    -- <https://tools.ietf.org/html/rfc6838#section-4.2 Naming Requirements>.
    --
    -- To play video on the console, you must specify the correct video type.
    -- For example, if the video in the stream is H.264, specify @video\/h264@
    -- as the @MediaType@.
    UpdateStream -> Maybe Text
mediaType :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the stream whose metadata you want to update.
    UpdateStream -> Maybe Text
streamARN :: Prelude.Maybe Prelude.Text,
    -- | The name of the device that is writing to the stream.
    --
    -- In the current implementation, Kinesis Video Streams does not use this
    -- name.
    UpdateStream -> Maybe Text
deviceName :: Prelude.Maybe Prelude.Text,
    -- | The name of the stream whose metadata you want to update.
    --
    -- The stream name is an identifier for the stream, and must be unique for
    -- each account and region.
    UpdateStream -> Maybe Text
streamName :: Prelude.Maybe Prelude.Text,
    -- | The version of the stream whose metadata you want to update.
    UpdateStream -> Text
currentVersion :: Prelude.Text
  }
  deriving (UpdateStream -> UpdateStream -> Bool
(UpdateStream -> UpdateStream -> Bool)
-> (UpdateStream -> UpdateStream -> Bool) -> Eq UpdateStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateStream -> UpdateStream -> Bool
$c/= :: UpdateStream -> UpdateStream -> Bool
== :: UpdateStream -> UpdateStream -> Bool
$c== :: UpdateStream -> UpdateStream -> Bool
Prelude.Eq, ReadPrec [UpdateStream]
ReadPrec UpdateStream
Int -> ReadS UpdateStream
ReadS [UpdateStream]
(Int -> ReadS UpdateStream)
-> ReadS [UpdateStream]
-> ReadPrec UpdateStream
-> ReadPrec [UpdateStream]
-> Read UpdateStream
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateStream]
$creadListPrec :: ReadPrec [UpdateStream]
readPrec :: ReadPrec UpdateStream
$creadPrec :: ReadPrec UpdateStream
readList :: ReadS [UpdateStream]
$creadList :: ReadS [UpdateStream]
readsPrec :: Int -> ReadS UpdateStream
$creadsPrec :: Int -> ReadS UpdateStream
Prelude.Read, Int -> UpdateStream -> ShowS
[UpdateStream] -> ShowS
UpdateStream -> String
(Int -> UpdateStream -> ShowS)
-> (UpdateStream -> String)
-> ([UpdateStream] -> ShowS)
-> Show UpdateStream
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateStream] -> ShowS
$cshowList :: [UpdateStream] -> ShowS
show :: UpdateStream -> String
$cshow :: UpdateStream -> String
showsPrec :: Int -> UpdateStream -> ShowS
$cshowsPrec :: Int -> UpdateStream -> ShowS
Prelude.Show, (forall x. UpdateStream -> Rep UpdateStream x)
-> (forall x. Rep UpdateStream x -> UpdateStream)
-> Generic UpdateStream
forall x. Rep UpdateStream x -> UpdateStream
forall x. UpdateStream -> Rep UpdateStream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateStream x -> UpdateStream
$cfrom :: forall x. UpdateStream -> Rep UpdateStream x
Prelude.Generic)

-- |
-- Create a value of 'UpdateStream' 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:
--
-- 'mediaType', 'updateStream_mediaType' - The stream\'s media type. Use @MediaType@ to specify the type of content
-- that the stream contains to the consumers of the stream. For more
-- information about media types, see
-- <http://www.iana.org/assignments/media-types/media-types.xhtml Media Types>.
-- If you choose to specify the @MediaType@, see
-- <https://tools.ietf.org/html/rfc6838#section-4.2 Naming Requirements>.
--
-- To play video on the console, you must specify the correct video type.
-- For example, if the video in the stream is H.264, specify @video\/h264@
-- as the @MediaType@.
--
-- 'streamARN', 'updateStream_streamARN' - The ARN of the stream whose metadata you want to update.
--
-- 'deviceName', 'updateStream_deviceName' - The name of the device that is writing to the stream.
--
-- In the current implementation, Kinesis Video Streams does not use this
-- name.
--
-- 'streamName', 'updateStream_streamName' - The name of the stream whose metadata you want to update.
--
-- The stream name is an identifier for the stream, and must be unique for
-- each account and region.
--
-- 'currentVersion', 'updateStream_currentVersion' - The version of the stream whose metadata you want to update.
newUpdateStream ::
  -- | 'currentVersion'
  Prelude.Text ->
  UpdateStream
newUpdateStream :: Text -> UpdateStream
newUpdateStream Text
pCurrentVersion_ =
  UpdateStream' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> Text -> UpdateStream
UpdateStream'
    { $sel:mediaType:UpdateStream' :: Maybe Text
mediaType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:streamARN:UpdateStream' :: Maybe Text
streamARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceName:UpdateStream' :: Maybe Text
deviceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:streamName:UpdateStream' :: Maybe Text
streamName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:currentVersion:UpdateStream' :: Text
currentVersion = Text
pCurrentVersion_
    }

-- | The stream\'s media type. Use @MediaType@ to specify the type of content
-- that the stream contains to the consumers of the stream. For more
-- information about media types, see
-- <http://www.iana.org/assignments/media-types/media-types.xhtml Media Types>.
-- If you choose to specify the @MediaType@, see
-- <https://tools.ietf.org/html/rfc6838#section-4.2 Naming Requirements>.
--
-- To play video on the console, you must specify the correct video type.
-- For example, if the video in the stream is H.264, specify @video\/h264@
-- as the @MediaType@.
updateStream_mediaType :: Lens.Lens' UpdateStream (Prelude.Maybe Prelude.Text)
updateStream_mediaType :: (Maybe Text -> f (Maybe Text)) -> UpdateStream -> f UpdateStream
updateStream_mediaType = (UpdateStream -> Maybe Text)
-> (UpdateStream -> Maybe Text -> UpdateStream)
-> Lens UpdateStream UpdateStream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateStream' {Maybe Text
mediaType :: Maybe Text
$sel:mediaType:UpdateStream' :: UpdateStream -> Maybe Text
mediaType} -> Maybe Text
mediaType) (\s :: UpdateStream
s@UpdateStream' {} Maybe Text
a -> UpdateStream
s {$sel:mediaType:UpdateStream' :: Maybe Text
mediaType = Maybe Text
a} :: UpdateStream)

-- | The ARN of the stream whose metadata you want to update.
updateStream_streamARN :: Lens.Lens' UpdateStream (Prelude.Maybe Prelude.Text)
updateStream_streamARN :: (Maybe Text -> f (Maybe Text)) -> UpdateStream -> f UpdateStream
updateStream_streamARN = (UpdateStream -> Maybe Text)
-> (UpdateStream -> Maybe Text -> UpdateStream)
-> Lens UpdateStream UpdateStream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateStream' {Maybe Text
streamARN :: Maybe Text
$sel:streamARN:UpdateStream' :: UpdateStream -> Maybe Text
streamARN} -> Maybe Text
streamARN) (\s :: UpdateStream
s@UpdateStream' {} Maybe Text
a -> UpdateStream
s {$sel:streamARN:UpdateStream' :: Maybe Text
streamARN = Maybe Text
a} :: UpdateStream)

-- | The name of the device that is writing to the stream.
--
-- In the current implementation, Kinesis Video Streams does not use this
-- name.
updateStream_deviceName :: Lens.Lens' UpdateStream (Prelude.Maybe Prelude.Text)
updateStream_deviceName :: (Maybe Text -> f (Maybe Text)) -> UpdateStream -> f UpdateStream
updateStream_deviceName = (UpdateStream -> Maybe Text)
-> (UpdateStream -> Maybe Text -> UpdateStream)
-> Lens UpdateStream UpdateStream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateStream' {Maybe Text
deviceName :: Maybe Text
$sel:deviceName:UpdateStream' :: UpdateStream -> Maybe Text
deviceName} -> Maybe Text
deviceName) (\s :: UpdateStream
s@UpdateStream' {} Maybe Text
a -> UpdateStream
s {$sel:deviceName:UpdateStream' :: Maybe Text
deviceName = Maybe Text
a} :: UpdateStream)

-- | The name of the stream whose metadata you want to update.
--
-- The stream name is an identifier for the stream, and must be unique for
-- each account and region.
updateStream_streamName :: Lens.Lens' UpdateStream (Prelude.Maybe Prelude.Text)
updateStream_streamName :: (Maybe Text -> f (Maybe Text)) -> UpdateStream -> f UpdateStream
updateStream_streamName = (UpdateStream -> Maybe Text)
-> (UpdateStream -> Maybe Text -> UpdateStream)
-> Lens UpdateStream UpdateStream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateStream' {Maybe Text
streamName :: Maybe Text
$sel:streamName:UpdateStream' :: UpdateStream -> Maybe Text
streamName} -> Maybe Text
streamName) (\s :: UpdateStream
s@UpdateStream' {} Maybe Text
a -> UpdateStream
s {$sel:streamName:UpdateStream' :: Maybe Text
streamName = Maybe Text
a} :: UpdateStream)

-- | The version of the stream whose metadata you want to update.
updateStream_currentVersion :: Lens.Lens' UpdateStream Prelude.Text
updateStream_currentVersion :: (Text -> f Text) -> UpdateStream -> f UpdateStream
updateStream_currentVersion = (UpdateStream -> Text)
-> (UpdateStream -> Text -> UpdateStream)
-> Lens UpdateStream UpdateStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateStream' {Text
currentVersion :: Text
$sel:currentVersion:UpdateStream' :: UpdateStream -> Text
currentVersion} -> Text
currentVersion) (\s :: UpdateStream
s@UpdateStream' {} Text
a -> UpdateStream
s {$sel:currentVersion:UpdateStream' :: Text
currentVersion = Text
a} :: UpdateStream)

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

instance Prelude.NFData UpdateStream

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

instance Core.ToJSON UpdateStream where
  toJSON :: UpdateStream -> Value
toJSON UpdateStream' {Maybe Text
Text
currentVersion :: Text
streamName :: Maybe Text
deviceName :: Maybe Text
streamARN :: Maybe Text
mediaType :: Maybe Text
$sel:currentVersion:UpdateStream' :: UpdateStream -> Text
$sel:streamName:UpdateStream' :: UpdateStream -> Maybe Text
$sel:deviceName:UpdateStream' :: UpdateStream -> Maybe Text
$sel:streamARN:UpdateStream' :: UpdateStream -> Maybe Text
$sel:mediaType:UpdateStream' :: UpdateStream -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MediaType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
mediaType,
            (Text
"StreamARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
streamARN,
            (Text
"DeviceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
deviceName,
            (Text
"StreamName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
streamName,
            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 UpdateStream where
  toPath :: UpdateStream -> ByteString
toPath = ByteString -> UpdateStream -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/updateStream"

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

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

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

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

instance Prelude.NFData UpdateStreamResponse