{-# 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 #-}
module Amazonka.KinesisVideoMedia.GetMedia
(
GetMedia (..),
newGetMedia,
getMedia_streamARN,
getMedia_streamName,
getMedia_startSelector,
GetMediaResponse (..),
newGetMediaResponse,
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
data GetMedia = GetMedia'
{
GetMedia -> Maybe Text
streamARN :: Prelude.Maybe Prelude.Text,
GetMedia -> Maybe Text
streamName :: Prelude.Maybe Prelude.Text,
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)
newGetMedia ::
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_
}
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)
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)
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
data GetMediaResponse = GetMediaResponse'
{
GetMediaResponse -> Maybe Text
contentType :: Prelude.Maybe Prelude.Text,
GetMediaResponse -> Int
httpStatus :: Prelude.Int,
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)
newGetMediaResponse ::
Prelude.Int ->
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_
}
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)
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)
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)