{-# 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.IVS.PutMetadata
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Inserts metadata into the active stream of the specified channel. At
-- most 5 requests per second per channel are allowed, each with a maximum
-- 1 KB payload. (If 5 TPS is not sufficient for your needs, we recommend
-- batching your data into a single PutMetadata call.) At most 155 requests
-- per second per account are allowed. Also see
-- <https://docs.aws.amazon.com/ivs/latest/userguide/metadata.html Embedding Metadata within a Video Stream>
-- in the /Amazon IVS User Guide/.
module Amazonka.IVS.PutMetadata
  ( -- * Creating a Request
    PutMetadata (..),
    newPutMetadata,

    -- * Request Lenses
    putMetadata_channelArn,
    putMetadata_metadata,

    -- * Destructuring the Response
    PutMetadataResponse (..),
    newPutMetadataResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IVS.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newPutMetadata' smart constructor.
data PutMetadata = PutMetadata'
  { -- | ARN of the channel into which metadata is inserted. This channel must
    -- have an active stream.
    PutMetadata -> Text
channelArn :: Prelude.Text,
    -- | Metadata to insert into the stream. Maximum: 1 KB per request.
    PutMetadata -> Sensitive Text
metadata :: Data.Sensitive Prelude.Text
  }
  deriving (PutMetadata -> PutMetadata -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutMetadata -> PutMetadata -> Bool
$c/= :: PutMetadata -> PutMetadata -> Bool
== :: PutMetadata -> PutMetadata -> Bool
$c== :: PutMetadata -> PutMetadata -> Bool
Prelude.Eq, Int -> PutMetadata -> ShowS
[PutMetadata] -> ShowS
PutMetadata -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutMetadata] -> ShowS
$cshowList :: [PutMetadata] -> ShowS
show :: PutMetadata -> String
$cshow :: PutMetadata -> String
showsPrec :: Int -> PutMetadata -> ShowS
$cshowsPrec :: Int -> PutMetadata -> ShowS
Prelude.Show, forall x. Rep PutMetadata x -> PutMetadata
forall x. PutMetadata -> Rep PutMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutMetadata x -> PutMetadata
$cfrom :: forall x. PutMetadata -> Rep PutMetadata x
Prelude.Generic)

-- |
-- Create a value of 'PutMetadata' 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:
--
-- 'channelArn', 'putMetadata_channelArn' - ARN of the channel into which metadata is inserted. This channel must
-- have an active stream.
--
-- 'metadata', 'putMetadata_metadata' - Metadata to insert into the stream. Maximum: 1 KB per request.
newPutMetadata ::
  -- | 'channelArn'
  Prelude.Text ->
  -- | 'metadata'
  Prelude.Text ->
  PutMetadata
newPutMetadata :: Text -> Text -> PutMetadata
newPutMetadata Text
pChannelArn_ Text
pMetadata_ =
  PutMetadata'
    { $sel:channelArn:PutMetadata' :: Text
channelArn = Text
pChannelArn_,
      $sel:metadata:PutMetadata' :: Sensitive Text
metadata = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pMetadata_
    }

-- | ARN of the channel into which metadata is inserted. This channel must
-- have an active stream.
putMetadata_channelArn :: Lens.Lens' PutMetadata Prelude.Text
putMetadata_channelArn :: Lens' PutMetadata Text
putMetadata_channelArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetadata' {Text
channelArn :: Text
$sel:channelArn:PutMetadata' :: PutMetadata -> Text
channelArn} -> Text
channelArn) (\s :: PutMetadata
s@PutMetadata' {} Text
a -> PutMetadata
s {$sel:channelArn:PutMetadata' :: Text
channelArn = Text
a} :: PutMetadata)

-- | Metadata to insert into the stream. Maximum: 1 KB per request.
putMetadata_metadata :: Lens.Lens' PutMetadata Prelude.Text
putMetadata_metadata :: Lens' PutMetadata Text
putMetadata_metadata = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetadata' {Sensitive Text
metadata :: Sensitive Text
$sel:metadata:PutMetadata' :: PutMetadata -> Sensitive Text
metadata} -> Sensitive Text
metadata) (\s :: PutMetadata
s@PutMetadata' {} Sensitive Text
a -> PutMetadata
s {$sel:metadata:PutMetadata' :: Sensitive Text
metadata = Sensitive Text
a} :: PutMetadata) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Core.AWSRequest PutMetadata where
  type AWSResponse PutMetadata = PutMetadataResponse
  request :: (Service -> Service) -> PutMetadata -> Request PutMetadata
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PutMetadata
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutMetadata)))
response = forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull PutMetadataResponse
PutMetadataResponse'

instance Prelude.Hashable PutMetadata where
  hashWithSalt :: Int -> PutMetadata -> Int
hashWithSalt Int
_salt PutMetadata' {Text
Sensitive Text
metadata :: Sensitive Text
channelArn :: Text
$sel:metadata:PutMetadata' :: PutMetadata -> Sensitive Text
$sel:channelArn:PutMetadata' :: PutMetadata -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
channelArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
metadata

instance Prelude.NFData PutMetadata where
  rnf :: PutMetadata -> ()
rnf PutMetadata' {Text
Sensitive Text
metadata :: Sensitive Text
channelArn :: Text
$sel:metadata:PutMetadata' :: PutMetadata -> Sensitive Text
$sel:channelArn:PutMetadata' :: PutMetadata -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
channelArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
metadata

instance Data.ToHeaders PutMetadata where
  toHeaders :: PutMetadata -> [Header]
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON PutMetadata where
  toJSON :: PutMetadata -> Value
toJSON PutMetadata' {Text
Sensitive Text
metadata :: Sensitive Text
channelArn :: Text
$sel:metadata:PutMetadata' :: PutMetadata -> Sensitive Text
$sel:channelArn:PutMetadata' :: PutMetadata -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"channelArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
channelArn),
            forall a. a -> Maybe a
Prelude.Just (Key
"metadata" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
metadata)
          ]
      )

instance Data.ToPath PutMetadata where
  toPath :: PutMetadata -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/PutMetadata"

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

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

-- |
-- Create a value of 'PutMetadataResponse' 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.
newPutMetadataResponse ::
  PutMetadataResponse
newPutMetadataResponse :: PutMetadataResponse
newPutMetadataResponse = PutMetadataResponse
PutMetadataResponse'

instance Prelude.NFData PutMetadataResponse where
  rnf :: PutMetadataResponse -> ()
rnf PutMetadataResponse
_ = ()