{-# 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.KinesisVideo.CreateStream
(
CreateStream (..),
newCreateStream,
createStream_mediaType,
createStream_dataRetentionInHours,
createStream_kmsKeyId,
createStream_deviceName,
createStream_tags,
createStream_streamName,
CreateStreamResponse (..),
newCreateStreamResponse,
createStreamResponse_streamARN,
createStreamResponse_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
data CreateStream = CreateStream'
{
CreateStream -> Maybe Text
mediaType :: Prelude.Maybe Prelude.Text,
CreateStream -> Maybe Natural
dataRetentionInHours :: Prelude.Maybe Prelude.Natural,
CreateStream -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
CreateStream -> Maybe Text
deviceName :: Prelude.Maybe Prelude.Text,
CreateStream -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
CreateStream -> Text
streamName :: Prelude.Text
}
deriving (CreateStream -> CreateStream -> Bool
(CreateStream -> CreateStream -> Bool)
-> (CreateStream -> CreateStream -> Bool) -> Eq CreateStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateStream -> CreateStream -> Bool
$c/= :: CreateStream -> CreateStream -> Bool
== :: CreateStream -> CreateStream -> Bool
$c== :: CreateStream -> CreateStream -> Bool
Prelude.Eq, ReadPrec [CreateStream]
ReadPrec CreateStream
Int -> ReadS CreateStream
ReadS [CreateStream]
(Int -> ReadS CreateStream)
-> ReadS [CreateStream]
-> ReadPrec CreateStream
-> ReadPrec [CreateStream]
-> Read CreateStream
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateStream]
$creadListPrec :: ReadPrec [CreateStream]
readPrec :: ReadPrec CreateStream
$creadPrec :: ReadPrec CreateStream
readList :: ReadS [CreateStream]
$creadList :: ReadS [CreateStream]
readsPrec :: Int -> ReadS CreateStream
$creadsPrec :: Int -> ReadS CreateStream
Prelude.Read, Int -> CreateStream -> ShowS
[CreateStream] -> ShowS
CreateStream -> String
(Int -> CreateStream -> ShowS)
-> (CreateStream -> String)
-> ([CreateStream] -> ShowS)
-> Show CreateStream
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateStream] -> ShowS
$cshowList :: [CreateStream] -> ShowS
show :: CreateStream -> String
$cshow :: CreateStream -> String
showsPrec :: Int -> CreateStream -> ShowS
$cshowsPrec :: Int -> CreateStream -> ShowS
Prelude.Show, (forall x. CreateStream -> Rep CreateStream x)
-> (forall x. Rep CreateStream x -> CreateStream)
-> Generic CreateStream
forall x. Rep CreateStream x -> CreateStream
forall x. CreateStream -> Rep CreateStream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateStream x -> CreateStream
$cfrom :: forall x. CreateStream -> Rep CreateStream x
Prelude.Generic)
newCreateStream ::
Prelude.Text ->
CreateStream
newCreateStream :: Text -> CreateStream
newCreateStream Text
pStreamName_ =
CreateStream' :: Maybe Text
-> Maybe Natural
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> CreateStream
CreateStream'
{ $sel:mediaType:CreateStream' :: Maybe Text
mediaType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:dataRetentionInHours:CreateStream' :: Maybe Natural
dataRetentionInHours = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:kmsKeyId:CreateStream' :: Maybe Text
kmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:deviceName:CreateStream' :: Maybe Text
deviceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateStream' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:streamName:CreateStream' :: Text
streamName = Text
pStreamName_
}
createStream_mediaType :: Lens.Lens' CreateStream (Prelude.Maybe Prelude.Text)
createStream_mediaType :: (Maybe Text -> f (Maybe Text)) -> CreateStream -> f CreateStream
createStream_mediaType = (CreateStream -> Maybe Text)
-> (CreateStream -> Maybe Text -> CreateStream)
-> Lens CreateStream CreateStream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStream' {Maybe Text
mediaType :: Maybe Text
$sel:mediaType:CreateStream' :: CreateStream -> Maybe Text
mediaType} -> Maybe Text
mediaType) (\s :: CreateStream
s@CreateStream' {} Maybe Text
a -> CreateStream
s {$sel:mediaType:CreateStream' :: Maybe Text
mediaType = Maybe Text
a} :: CreateStream)
createStream_dataRetentionInHours :: Lens.Lens' CreateStream (Prelude.Maybe Prelude.Natural)
createStream_dataRetentionInHours :: (Maybe Natural -> f (Maybe Natural))
-> CreateStream -> f CreateStream
createStream_dataRetentionInHours = (CreateStream -> Maybe Natural)
-> (CreateStream -> Maybe Natural -> CreateStream)
-> Lens CreateStream CreateStream (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStream' {Maybe Natural
dataRetentionInHours :: Maybe Natural
$sel:dataRetentionInHours:CreateStream' :: CreateStream -> Maybe Natural
dataRetentionInHours} -> Maybe Natural
dataRetentionInHours) (\s :: CreateStream
s@CreateStream' {} Maybe Natural
a -> CreateStream
s {$sel:dataRetentionInHours:CreateStream' :: Maybe Natural
dataRetentionInHours = Maybe Natural
a} :: CreateStream)
createStream_kmsKeyId :: Lens.Lens' CreateStream (Prelude.Maybe Prelude.Text)
createStream_kmsKeyId :: (Maybe Text -> f (Maybe Text)) -> CreateStream -> f CreateStream
createStream_kmsKeyId = (CreateStream -> Maybe Text)
-> (CreateStream -> Maybe Text -> CreateStream)
-> Lens CreateStream CreateStream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStream' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:CreateStream' :: CreateStream -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: CreateStream
s@CreateStream' {} Maybe Text
a -> CreateStream
s {$sel:kmsKeyId:CreateStream' :: Maybe Text
kmsKeyId = Maybe Text
a} :: CreateStream)
createStream_deviceName :: Lens.Lens' CreateStream (Prelude.Maybe Prelude.Text)
createStream_deviceName :: (Maybe Text -> f (Maybe Text)) -> CreateStream -> f CreateStream
createStream_deviceName = (CreateStream -> Maybe Text)
-> (CreateStream -> Maybe Text -> CreateStream)
-> Lens CreateStream CreateStream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStream' {Maybe Text
deviceName :: Maybe Text
$sel:deviceName:CreateStream' :: CreateStream -> Maybe Text
deviceName} -> Maybe Text
deviceName) (\s :: CreateStream
s@CreateStream' {} Maybe Text
a -> CreateStream
s {$sel:deviceName:CreateStream' :: Maybe Text
deviceName = Maybe Text
a} :: CreateStream)
createStream_tags :: Lens.Lens' CreateStream (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createStream_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateStream -> f CreateStream
createStream_tags = (CreateStream -> Maybe (HashMap Text Text))
-> (CreateStream -> Maybe (HashMap Text Text) -> CreateStream)
-> Lens
CreateStream
CreateStream
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStream' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateStream' :: CreateStream -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateStream
s@CreateStream' {} Maybe (HashMap Text Text)
a -> CreateStream
s {$sel:tags:CreateStream' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateStream) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateStream -> f CreateStream)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateStream
-> f CreateStream
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
-> Iso
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createStream_streamName :: Lens.Lens' CreateStream Prelude.Text
createStream_streamName :: (Text -> f Text) -> CreateStream -> f CreateStream
createStream_streamName = (CreateStream -> Text)
-> (CreateStream -> Text -> CreateStream)
-> Lens CreateStream CreateStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStream' {Text
streamName :: Text
$sel:streamName:CreateStream' :: CreateStream -> Text
streamName} -> Text
streamName) (\s :: CreateStream
s@CreateStream' {} Text
a -> CreateStream
s {$sel:streamName:CreateStream' :: Text
streamName = Text
a} :: CreateStream)
instance Core.AWSRequest CreateStream where
type AWSResponse CreateStream = CreateStreamResponse
request :: CreateStream -> Request CreateStream
request = Service -> CreateStream -> Request CreateStream
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateStream
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateStream)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateStream))
-> Logger
-> Service
-> Proxy CreateStream
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateStream)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text -> Int -> CreateStreamResponse
CreateStreamResponse'
(Maybe Text -> Int -> CreateStreamResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateStreamResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"StreamARN")
Either String (Int -> CreateStreamResponse)
-> Either String Int -> Either String CreateStreamResponse
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))
)
instance Prelude.Hashable CreateStream
instance Prelude.NFData CreateStream
instance Core.ToHeaders CreateStream where
toHeaders :: CreateStream -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateStream -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToJSON CreateStream where
toJSON :: CreateStream -> Value
toJSON CreateStream' {Maybe Natural
Maybe Text
Maybe (HashMap Text Text)
Text
streamName :: Text
tags :: Maybe (HashMap Text Text)
deviceName :: Maybe Text
kmsKeyId :: Maybe Text
dataRetentionInHours :: Maybe Natural
mediaType :: Maybe Text
$sel:streamName:CreateStream' :: CreateStream -> Text
$sel:tags:CreateStream' :: CreateStream -> Maybe (HashMap Text Text)
$sel:deviceName:CreateStream' :: CreateStream -> Maybe Text
$sel:kmsKeyId:CreateStream' :: CreateStream -> Maybe Text
$sel:dataRetentionInHours:CreateStream' :: CreateStream -> Maybe Natural
$sel:mediaType:CreateStream' :: CreateStream -> 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
"DataRetentionInHours" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
dataRetentionInHours,
(Text
"KmsKeyId" 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
kmsKeyId,
(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
"Tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"StreamName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
streamName)
]
)
instance Core.ToPath CreateStream where
toPath :: CreateStream -> ByteString
toPath = ByteString -> CreateStream -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/createStream"
instance Core.ToQuery CreateStream where
toQuery :: CreateStream -> QueryString
toQuery = QueryString -> CreateStream -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateStreamResponse = CreateStreamResponse'
{
CreateStreamResponse -> Maybe Text
streamARN :: Prelude.Maybe Prelude.Text,
CreateStreamResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateStreamResponse -> CreateStreamResponse -> Bool
(CreateStreamResponse -> CreateStreamResponse -> Bool)
-> (CreateStreamResponse -> CreateStreamResponse -> Bool)
-> Eq CreateStreamResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateStreamResponse -> CreateStreamResponse -> Bool
$c/= :: CreateStreamResponse -> CreateStreamResponse -> Bool
== :: CreateStreamResponse -> CreateStreamResponse -> Bool
$c== :: CreateStreamResponse -> CreateStreamResponse -> Bool
Prelude.Eq, ReadPrec [CreateStreamResponse]
ReadPrec CreateStreamResponse
Int -> ReadS CreateStreamResponse
ReadS [CreateStreamResponse]
(Int -> ReadS CreateStreamResponse)
-> ReadS [CreateStreamResponse]
-> ReadPrec CreateStreamResponse
-> ReadPrec [CreateStreamResponse]
-> Read CreateStreamResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateStreamResponse]
$creadListPrec :: ReadPrec [CreateStreamResponse]
readPrec :: ReadPrec CreateStreamResponse
$creadPrec :: ReadPrec CreateStreamResponse
readList :: ReadS [CreateStreamResponse]
$creadList :: ReadS [CreateStreamResponse]
readsPrec :: Int -> ReadS CreateStreamResponse
$creadsPrec :: Int -> ReadS CreateStreamResponse
Prelude.Read, Int -> CreateStreamResponse -> ShowS
[CreateStreamResponse] -> ShowS
CreateStreamResponse -> String
(Int -> CreateStreamResponse -> ShowS)
-> (CreateStreamResponse -> String)
-> ([CreateStreamResponse] -> ShowS)
-> Show CreateStreamResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateStreamResponse] -> ShowS
$cshowList :: [CreateStreamResponse] -> ShowS
show :: CreateStreamResponse -> String
$cshow :: CreateStreamResponse -> String
showsPrec :: Int -> CreateStreamResponse -> ShowS
$cshowsPrec :: Int -> CreateStreamResponse -> ShowS
Prelude.Show, (forall x. CreateStreamResponse -> Rep CreateStreamResponse x)
-> (forall x. Rep CreateStreamResponse x -> CreateStreamResponse)
-> Generic CreateStreamResponse
forall x. Rep CreateStreamResponse x -> CreateStreamResponse
forall x. CreateStreamResponse -> Rep CreateStreamResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateStreamResponse x -> CreateStreamResponse
$cfrom :: forall x. CreateStreamResponse -> Rep CreateStreamResponse x
Prelude.Generic)
newCreateStreamResponse ::
Prelude.Int ->
CreateStreamResponse
newCreateStreamResponse :: Int -> CreateStreamResponse
newCreateStreamResponse Int
pHttpStatus_ =
CreateStreamResponse' :: Maybe Text -> Int -> CreateStreamResponse
CreateStreamResponse'
{ $sel:streamARN:CreateStreamResponse' :: Maybe Text
streamARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateStreamResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createStreamResponse_streamARN :: Lens.Lens' CreateStreamResponse (Prelude.Maybe Prelude.Text)
createStreamResponse_streamARN :: (Maybe Text -> f (Maybe Text))
-> CreateStreamResponse -> f CreateStreamResponse
createStreamResponse_streamARN = (CreateStreamResponse -> Maybe Text)
-> (CreateStreamResponse -> Maybe Text -> CreateStreamResponse)
-> Lens
CreateStreamResponse CreateStreamResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStreamResponse' {Maybe Text
streamARN :: Maybe Text
$sel:streamARN:CreateStreamResponse' :: CreateStreamResponse -> Maybe Text
streamARN} -> Maybe Text
streamARN) (\s :: CreateStreamResponse
s@CreateStreamResponse' {} Maybe Text
a -> CreateStreamResponse
s {$sel:streamARN:CreateStreamResponse' :: Maybe Text
streamARN = Maybe Text
a} :: CreateStreamResponse)
createStreamResponse_httpStatus :: Lens.Lens' CreateStreamResponse Prelude.Int
createStreamResponse_httpStatus :: (Int -> f Int) -> CreateStreamResponse -> f CreateStreamResponse
createStreamResponse_httpStatus = (CreateStreamResponse -> Int)
-> (CreateStreamResponse -> Int -> CreateStreamResponse)
-> Lens CreateStreamResponse CreateStreamResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStreamResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateStreamResponse' :: CreateStreamResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateStreamResponse
s@CreateStreamResponse' {} Int
a -> CreateStreamResponse
s {$sel:httpStatus:CreateStreamResponse' :: Int
httpStatus = Int
a} :: CreateStreamResponse)
instance Prelude.NFData CreateStreamResponse