{-# 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.KinesisVideoMedia.GetMedia
-- 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)
--
-- Use this API to retrieve media content from a Kinesis video stream. In
-- the request, you identify the stream name or stream Amazon Resource Name
-- (ARN), and the starting chunk. Kinesis Video Streams then returns a
-- stream of chunks in order by fragment number.
--
-- You must first call the @GetDataEndpoint@ API to get an endpoint. Then
-- send the @GetMedia@ requests to this endpoint using the
-- <https://docs.aws.amazon.com/cli/latest/reference/ --endpoint-url parameter>.
--
-- When you put media data (fragments) on a stream, Kinesis Video Streams
-- stores each incoming fragment and related metadata in what is called a
-- \"chunk.\" For more information, see
-- <https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/API_dataplane_PutMedia.html PutMedia>.
-- The @GetMedia@ API returns a stream of these chunks starting from the
-- chunk that you specify in the request.
--
-- The following limits apply when using the @GetMedia@ API:
--
-- -   A client can call @GetMedia@ up to five times per second per stream.
--
-- -   Kinesis Video Streams sends media data at a rate of up to 25
--     megabytes per second (or 200 megabits per second) during a
--     @GetMedia@ session.
--
-- If an error is thrown after invoking a Kinesis Video Streams media API,
-- in addition to the HTTP status code and the response body, it includes
-- the following pieces of information:
--
-- -   @x-amz-ErrorType@ HTTP header – contains a more specific error type
--     in addition to what the HTTP status code provides.
--
-- -   @x-amz-RequestId@ HTTP header – if you want to report an issue to
--     AWS, the support team can better diagnose the problem if given the
--     Request Id.
--
-- Both the HTTP status code and the ErrorType header can be utilized to
-- make programmatic decisions about whether errors are retry-able and
-- under what conditions, as well as provide information on what actions
-- the client programmer might need to take in order to successfully try
-- again.
--
-- For more information, see the __Errors__ section at the bottom of this
-- topic, as well as
-- <https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/CommonErrors.html Common Errors>.
module Amazonka.KinesisVideoMedia.GetMedia
  ( -- * Creating a Request
    GetMedia (..),
    newGetMedia,

    -- * Request Lenses
    getMedia_streamARN,
    getMedia_streamName,
    getMedia_startSelector,

    -- * Destructuring the Response
    GetMediaResponse (..),
    newGetMediaResponse,

    -- * Response Lenses
    getMediaResponse_contentType,
    getMediaResponse_httpStatus,
    getMediaResponse_payload,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.KinesisVideoMedia.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:/ 'newGetMedia' smart constructor.
data GetMedia = GetMedia'
  { -- | The ARN of the stream from where you want to get the media content. If
    -- you don\'t specify the @streamARN@, you must specify the @streamName@.
    GetMedia -> Maybe Text
streamARN :: Prelude.Maybe Prelude.Text,
    -- | The Kinesis video stream name from where you want to get the media
    -- content. If you don\'t specify the @streamName@, you must specify the
    -- @streamARN@.
    GetMedia -> Maybe Text
streamName :: Prelude.Maybe Prelude.Text,
    -- | Identifies the starting chunk to get from the specified stream.
    GetMedia -> StartSelector
startSelector :: StartSelector
  }
  deriving (GetMedia -> GetMedia -> Bool
(GetMedia -> GetMedia -> Bool)
-> (GetMedia -> GetMedia -> Bool) -> Eq GetMedia
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetMedia -> GetMedia -> Bool
$c/= :: GetMedia -> GetMedia -> Bool
== :: GetMedia -> GetMedia -> Bool
$c== :: GetMedia -> GetMedia -> Bool
Prelude.Eq, ReadPrec [GetMedia]
ReadPrec GetMedia
Int -> ReadS GetMedia
ReadS [GetMedia]
(Int -> ReadS GetMedia)
-> ReadS [GetMedia]
-> ReadPrec GetMedia
-> ReadPrec [GetMedia]
-> Read GetMedia
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetMedia]
$creadListPrec :: ReadPrec [GetMedia]
readPrec :: ReadPrec GetMedia
$creadPrec :: ReadPrec GetMedia
readList :: ReadS [GetMedia]
$creadList :: ReadS [GetMedia]
readsPrec :: Int -> ReadS GetMedia
$creadsPrec :: Int -> ReadS GetMedia
Prelude.Read, Int -> GetMedia -> ShowS
[GetMedia] -> ShowS
GetMedia -> String
(Int -> GetMedia -> ShowS)
-> (GetMedia -> String) -> ([GetMedia] -> ShowS) -> Show GetMedia
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetMedia] -> ShowS
$cshowList :: [GetMedia] -> ShowS
show :: GetMedia -> String
$cshow :: GetMedia -> String
showsPrec :: Int -> GetMedia -> ShowS
$cshowsPrec :: Int -> GetMedia -> ShowS
Prelude.Show, (forall x. GetMedia -> Rep GetMedia x)
-> (forall x. Rep GetMedia x -> GetMedia) -> Generic GetMedia
forall x. Rep GetMedia x -> GetMedia
forall x. GetMedia -> Rep GetMedia x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetMedia x -> GetMedia
$cfrom :: forall x. GetMedia -> Rep GetMedia x
Prelude.Generic)

-- |
-- Create a value of 'GetMedia' 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:
--
-- 'streamARN', 'getMedia_streamARN' - The ARN of the stream from where you want to get the media content. If
-- you don\'t specify the @streamARN@, you must specify the @streamName@.
--
-- 'streamName', 'getMedia_streamName' - The Kinesis video stream name from where you want to get the media
-- content. If you don\'t specify the @streamName@, you must specify the
-- @streamARN@.
--
-- 'startSelector', 'getMedia_startSelector' - Identifies the starting chunk to get from the specified stream.
newGetMedia ::
  -- | 'startSelector'
  StartSelector ->
  GetMedia
newGetMedia :: StartSelector -> GetMedia
newGetMedia StartSelector
pStartSelector_ =
  GetMedia' :: Maybe Text -> Maybe Text -> StartSelector -> GetMedia
GetMedia'
    { $sel:streamARN:GetMedia' :: Maybe Text
streamARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:streamName:GetMedia' :: Maybe Text
streamName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:startSelector:GetMedia' :: StartSelector
startSelector = StartSelector
pStartSelector_
    }

-- | The ARN of the stream from where you want to get the media content. If
-- you don\'t specify the @streamARN@, you must specify the @streamName@.
getMedia_streamARN :: Lens.Lens' GetMedia (Prelude.Maybe Prelude.Text)
getMedia_streamARN :: (Maybe Text -> f (Maybe Text)) -> GetMedia -> f GetMedia
getMedia_streamARN = (GetMedia -> Maybe Text)
-> (GetMedia -> Maybe Text -> GetMedia)
-> Lens GetMedia GetMedia (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMedia' {Maybe Text
streamARN :: Maybe Text
$sel:streamARN:GetMedia' :: GetMedia -> Maybe Text
streamARN} -> Maybe Text
streamARN) (\s :: GetMedia
s@GetMedia' {} Maybe Text
a -> GetMedia
s {$sel:streamARN:GetMedia' :: Maybe Text
streamARN = Maybe Text
a} :: GetMedia)

-- | The Kinesis video stream name from where you want to get the media
-- content. If you don\'t specify the @streamName@, you must specify the
-- @streamARN@.
getMedia_streamName :: Lens.Lens' GetMedia (Prelude.Maybe Prelude.Text)
getMedia_streamName :: (Maybe Text -> f (Maybe Text)) -> GetMedia -> f GetMedia
getMedia_streamName = (GetMedia -> Maybe Text)
-> (GetMedia -> Maybe Text -> GetMedia)
-> Lens GetMedia GetMedia (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMedia' {Maybe Text
streamName :: Maybe Text
$sel:streamName:GetMedia' :: GetMedia -> Maybe Text
streamName} -> Maybe Text
streamName) (\s :: GetMedia
s@GetMedia' {} Maybe Text
a -> GetMedia
s {$sel:streamName:GetMedia' :: Maybe Text
streamName = Maybe Text
a} :: GetMedia)

-- | Identifies the starting chunk to get from the specified stream.
getMedia_startSelector :: Lens.Lens' GetMedia StartSelector
getMedia_startSelector :: (StartSelector -> f StartSelector) -> GetMedia -> f GetMedia
getMedia_startSelector = (GetMedia -> StartSelector)
-> (GetMedia -> StartSelector -> GetMedia)
-> Lens GetMedia GetMedia StartSelector StartSelector
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMedia' {StartSelector
startSelector :: StartSelector
$sel:startSelector:GetMedia' :: GetMedia -> StartSelector
startSelector} -> StartSelector
startSelector) (\s :: GetMedia
s@GetMedia' {} StartSelector
a -> GetMedia
s {$sel:startSelector:GetMedia' :: StartSelector
startSelector = StartSelector
a} :: GetMedia)

instance Core.AWSRequest GetMedia where
  type AWSResponse GetMedia = GetMediaResponse
  request :: GetMedia -> Request GetMedia
request = Service -> GetMedia -> Request GetMedia
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetMedia
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetMedia)))
response =
    (Int
 -> ResponseHeaders
 -> ResponseBody
 -> Either String (AWSResponse GetMedia))
-> Logger
-> Service
-> Proxy GetMedia
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetMedia)))
forall (m :: * -> *) a.
MonadResource m =>
(Int
 -> ResponseHeaders
 -> ResponseBody
 -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveBody
      ( \Int
s ResponseHeaders
h ResponseBody
x ->
          Maybe Text -> Int -> ResponseBody -> GetMediaResponse
GetMediaResponse'
            (Maybe Text -> Int -> ResponseBody -> GetMediaResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ResponseBody -> GetMediaResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"Content-Type")
            Either String (Int -> ResponseBody -> GetMediaResponse)
-> Either String Int
-> Either String (ResponseBody -> GetMediaResponse)
forall (f :: * -> *) a b. Applicative f => 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))
            Either String (ResponseBody -> GetMediaResponse)
-> Either String ResponseBody -> Either String GetMediaResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (ResponseBody -> Either String ResponseBody
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure ResponseBody
x)
      )

instance Prelude.Hashable GetMedia

instance Prelude.NFData GetMedia

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

instance Core.ToJSON GetMedia where
  toJSON :: GetMedia -> Value
toJSON GetMedia' {Maybe Text
StartSelector
startSelector :: StartSelector
streamName :: Maybe Text
streamARN :: Maybe Text
$sel:startSelector:GetMedia' :: GetMedia -> StartSelector
$sel:streamName:GetMedia' :: GetMedia -> Maybe Text
$sel:streamARN:GetMedia' :: GetMedia -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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
"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
"StartSelector" Text -> StartSelector -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= StartSelector
startSelector)
          ]
      )

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

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

-- | /See:/ 'newGetMediaResponse' smart constructor.
data GetMediaResponse = GetMediaResponse'
  { -- | The content type of the requested media.
    GetMediaResponse -> Maybe Text
contentType :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetMediaResponse -> Int
httpStatus :: Prelude.Int,
    -- | The payload Kinesis Video Streams returns is a sequence of chunks from
    -- the specified stream. For information about the chunks, see . The chunks
    -- that Kinesis Video Streams returns in the @GetMedia@ call also include
    -- the following additional Matroska (MKV) tags:
    --
    -- -   AWS_KINESISVIDEO_CONTINUATION_TOKEN (UTF-8 string) - In the event
    --     your @GetMedia@ call terminates, you can use this continuation token
    --     in your next request to get the next chunk where the last request
    --     terminated.
    --
    -- -   AWS_KINESISVIDEO_MILLIS_BEHIND_NOW (UTF-8 string) - Client
    --     applications can use this tag value to determine how far behind the
    --     chunk returned in the response is from the latest chunk on the
    --     stream.
    --
    -- -   AWS_KINESISVIDEO_FRAGMENT_NUMBER - Fragment number returned in the
    --     chunk.
    --
    -- -   AWS_KINESISVIDEO_SERVER_TIMESTAMP - Server timestamp of the
    --     fragment.
    --
    -- -   AWS_KINESISVIDEO_PRODUCER_TIMESTAMP - Producer timestamp of the
    --     fragment.
    --
    -- The following tags will be present if an error occurs:
    --
    -- -   AWS_KINESISVIDEO_ERROR_CODE - String description of an error that
    --     caused GetMedia to stop.
    --
    -- -   AWS_KINESISVIDEO_ERROR_ID: Integer code of the error.
    --
    -- The error codes are as follows:
    --
    -- -   3002 - Error writing to the stream
    --
    -- -   4000 - Requested fragment is not found
    --
    -- -   4500 - Access denied for the stream\'s KMS key
    --
    -- -   4501 - Stream\'s KMS key is disabled
    --
    -- -   4502 - Validation error on the stream\'s KMS key
    --
    -- -   4503 - KMS key specified in the stream is unavailable
    --
    -- -   4504 - Invalid usage of the KMS key specified in the stream
    --
    -- -   4505 - Invalid state of the KMS key specified in the stream
    --
    -- -   4506 - Unable to find the KMS key specified in the stream
    --
    -- -   5000 - Internal error
    GetMediaResponse -> ResponseBody
payload :: Core.ResponseBody
  }
  deriving (Int -> GetMediaResponse -> ShowS
[GetMediaResponse] -> ShowS
GetMediaResponse -> String
(Int -> GetMediaResponse -> ShowS)
-> (GetMediaResponse -> String)
-> ([GetMediaResponse] -> ShowS)
-> Show GetMediaResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetMediaResponse] -> ShowS
$cshowList :: [GetMediaResponse] -> ShowS
show :: GetMediaResponse -> String
$cshow :: GetMediaResponse -> String
showsPrec :: Int -> GetMediaResponse -> ShowS
$cshowsPrec :: Int -> GetMediaResponse -> ShowS
Prelude.Show, (forall x. GetMediaResponse -> Rep GetMediaResponse x)
-> (forall x. Rep GetMediaResponse x -> GetMediaResponse)
-> Generic GetMediaResponse
forall x. Rep GetMediaResponse x -> GetMediaResponse
forall x. GetMediaResponse -> Rep GetMediaResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetMediaResponse x -> GetMediaResponse
$cfrom :: forall x. GetMediaResponse -> Rep GetMediaResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetMediaResponse' 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:
--
-- 'contentType', 'getMediaResponse_contentType' - The content type of the requested media.
--
-- 'httpStatus', 'getMediaResponse_httpStatus' - The response's http status code.
--
-- 'payload', 'getMediaResponse_payload' - The payload Kinesis Video Streams returns is a sequence of chunks from
-- the specified stream. For information about the chunks, see . The chunks
-- that Kinesis Video Streams returns in the @GetMedia@ call also include
-- the following additional Matroska (MKV) tags:
--
-- -   AWS_KINESISVIDEO_CONTINUATION_TOKEN (UTF-8 string) - In the event
--     your @GetMedia@ call terminates, you can use this continuation token
--     in your next request to get the next chunk where the last request
--     terminated.
--
-- -   AWS_KINESISVIDEO_MILLIS_BEHIND_NOW (UTF-8 string) - Client
--     applications can use this tag value to determine how far behind the
--     chunk returned in the response is from the latest chunk on the
--     stream.
--
-- -   AWS_KINESISVIDEO_FRAGMENT_NUMBER - Fragment number returned in the
--     chunk.
--
-- -   AWS_KINESISVIDEO_SERVER_TIMESTAMP - Server timestamp of the
--     fragment.
--
-- -   AWS_KINESISVIDEO_PRODUCER_TIMESTAMP - Producer timestamp of the
--     fragment.
--
-- The following tags will be present if an error occurs:
--
-- -   AWS_KINESISVIDEO_ERROR_CODE - String description of an error that
--     caused GetMedia to stop.
--
-- -   AWS_KINESISVIDEO_ERROR_ID: Integer code of the error.
--
-- The error codes are as follows:
--
-- -   3002 - Error writing to the stream
--
-- -   4000 - Requested fragment is not found
--
-- -   4500 - Access denied for the stream\'s KMS key
--
-- -   4501 - Stream\'s KMS key is disabled
--
-- -   4502 - Validation error on the stream\'s KMS key
--
-- -   4503 - KMS key specified in the stream is unavailable
--
-- -   4504 - Invalid usage of the KMS key specified in the stream
--
-- -   4505 - Invalid state of the KMS key specified in the stream
--
-- -   4506 - Unable to find the KMS key specified in the stream
--
-- -   5000 - Internal error
newGetMediaResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'payload'
  Core.ResponseBody ->
  GetMediaResponse
newGetMediaResponse :: Int -> ResponseBody -> GetMediaResponse
newGetMediaResponse Int
pHttpStatus_ ResponseBody
pPayload_ =
  GetMediaResponse' :: Maybe Text -> Int -> ResponseBody -> GetMediaResponse
GetMediaResponse'
    { $sel:contentType:GetMediaResponse' :: Maybe Text
contentType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetMediaResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:payload:GetMediaResponse' :: ResponseBody
payload = ResponseBody
pPayload_
    }

-- | The content type of the requested media.
getMediaResponse_contentType :: Lens.Lens' GetMediaResponse (Prelude.Maybe Prelude.Text)
getMediaResponse_contentType :: (Maybe Text -> f (Maybe Text))
-> GetMediaResponse -> f GetMediaResponse
getMediaResponse_contentType = (GetMediaResponse -> Maybe Text)
-> (GetMediaResponse -> Maybe Text -> GetMediaResponse)
-> Lens GetMediaResponse GetMediaResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMediaResponse' {Maybe Text
contentType :: Maybe Text
$sel:contentType:GetMediaResponse' :: GetMediaResponse -> Maybe Text
contentType} -> Maybe Text
contentType) (\s :: GetMediaResponse
s@GetMediaResponse' {} Maybe Text
a -> GetMediaResponse
s {$sel:contentType:GetMediaResponse' :: Maybe Text
contentType = Maybe Text
a} :: GetMediaResponse)

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

-- | The payload Kinesis Video Streams returns is a sequence of chunks from
-- the specified stream. For information about the chunks, see . The chunks
-- that Kinesis Video Streams returns in the @GetMedia@ call also include
-- the following additional Matroska (MKV) tags:
--
-- -   AWS_KINESISVIDEO_CONTINUATION_TOKEN (UTF-8 string) - In the event
--     your @GetMedia@ call terminates, you can use this continuation token
--     in your next request to get the next chunk where the last request
--     terminated.
--
-- -   AWS_KINESISVIDEO_MILLIS_BEHIND_NOW (UTF-8 string) - Client
--     applications can use this tag value to determine how far behind the
--     chunk returned in the response is from the latest chunk on the
--     stream.
--
-- -   AWS_KINESISVIDEO_FRAGMENT_NUMBER - Fragment number returned in the
--     chunk.
--
-- -   AWS_KINESISVIDEO_SERVER_TIMESTAMP - Server timestamp of the
--     fragment.
--
-- -   AWS_KINESISVIDEO_PRODUCER_TIMESTAMP - Producer timestamp of the
--     fragment.
--
-- The following tags will be present if an error occurs:
--
-- -   AWS_KINESISVIDEO_ERROR_CODE - String description of an error that
--     caused GetMedia to stop.
--
-- -   AWS_KINESISVIDEO_ERROR_ID: Integer code of the error.
--
-- The error codes are as follows:
--
-- -   3002 - Error writing to the stream
--
-- -   4000 - Requested fragment is not found
--
-- -   4500 - Access denied for the stream\'s KMS key
--
-- -   4501 - Stream\'s KMS key is disabled
--
-- -   4502 - Validation error on the stream\'s KMS key
--
-- -   4503 - KMS key specified in the stream is unavailable
--
-- -   4504 - Invalid usage of the KMS key specified in the stream
--
-- -   4505 - Invalid state of the KMS key specified in the stream
--
-- -   4506 - Unable to find the KMS key specified in the stream
--
-- -   5000 - Internal error
getMediaResponse_payload :: Lens.Lens' GetMediaResponse Core.ResponseBody
getMediaResponse_payload :: (ResponseBody -> f ResponseBody)
-> GetMediaResponse -> f GetMediaResponse
getMediaResponse_payload = (GetMediaResponse -> ResponseBody)
-> (GetMediaResponse -> ResponseBody -> GetMediaResponse)
-> Lens GetMediaResponse GetMediaResponse ResponseBody ResponseBody
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMediaResponse' {ResponseBody
payload :: ResponseBody
$sel:payload:GetMediaResponse' :: GetMediaResponse -> ResponseBody
payload} -> ResponseBody
payload) (\s :: GetMediaResponse
s@GetMediaResponse' {} ResponseBody
a -> GetMediaResponse
s {$sel:payload:GetMediaResponse' :: ResponseBody
payload = ResponseBody
a} :: GetMediaResponse)