{-# 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.Kinesis.AddTagsToStream
-- 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)
--
-- Adds or updates tags for the specified Kinesis data stream. Each time
-- you invoke this operation, you can specify up to 10 tags. If you want to
-- add more than 10 tags to your stream, you can invoke this operation
-- multiple times. In total, each stream can have up to 50 tags.
--
-- If tags have already been assigned to the stream, @AddTagsToStream@
-- overwrites any existing tags that correspond to the specified tag keys.
--
-- AddTagsToStream has a limit of five transactions per second per account.
module Amazonka.Kinesis.AddTagsToStream
  ( -- * Creating a Request
    AddTagsToStream (..),
    newAddTagsToStream,

    -- * Request Lenses
    addTagsToStream_streamName,
    addTagsToStream_tags,

    -- * Destructuring the Response
    AddTagsToStreamResponse (..),
    newAddTagsToStreamResponse,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Kinesis.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

-- | Represents the input for @AddTagsToStream@.
--
-- /See:/ 'newAddTagsToStream' smart constructor.
data AddTagsToStream = AddTagsToStream'
  { -- | The name of the stream.
    AddTagsToStream -> Text
streamName :: Prelude.Text,
    -- | A set of up to 10 key-value pairs to use to create the tags.
    AddTagsToStream -> HashMap Text Text
tags :: Prelude.HashMap Prelude.Text Prelude.Text
  }
  deriving (AddTagsToStream -> AddTagsToStream -> Bool
(AddTagsToStream -> AddTagsToStream -> Bool)
-> (AddTagsToStream -> AddTagsToStream -> Bool)
-> Eq AddTagsToStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddTagsToStream -> AddTagsToStream -> Bool
$c/= :: AddTagsToStream -> AddTagsToStream -> Bool
== :: AddTagsToStream -> AddTagsToStream -> Bool
$c== :: AddTagsToStream -> AddTagsToStream -> Bool
Prelude.Eq, ReadPrec [AddTagsToStream]
ReadPrec AddTagsToStream
Int -> ReadS AddTagsToStream
ReadS [AddTagsToStream]
(Int -> ReadS AddTagsToStream)
-> ReadS [AddTagsToStream]
-> ReadPrec AddTagsToStream
-> ReadPrec [AddTagsToStream]
-> Read AddTagsToStream
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddTagsToStream]
$creadListPrec :: ReadPrec [AddTagsToStream]
readPrec :: ReadPrec AddTagsToStream
$creadPrec :: ReadPrec AddTagsToStream
readList :: ReadS [AddTagsToStream]
$creadList :: ReadS [AddTagsToStream]
readsPrec :: Int -> ReadS AddTagsToStream
$creadsPrec :: Int -> ReadS AddTagsToStream
Prelude.Read, Int -> AddTagsToStream -> ShowS
[AddTagsToStream] -> ShowS
AddTagsToStream -> String
(Int -> AddTagsToStream -> ShowS)
-> (AddTagsToStream -> String)
-> ([AddTagsToStream] -> ShowS)
-> Show AddTagsToStream
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddTagsToStream] -> ShowS
$cshowList :: [AddTagsToStream] -> ShowS
show :: AddTagsToStream -> String
$cshow :: AddTagsToStream -> String
showsPrec :: Int -> AddTagsToStream -> ShowS
$cshowsPrec :: Int -> AddTagsToStream -> ShowS
Prelude.Show, (forall x. AddTagsToStream -> Rep AddTagsToStream x)
-> (forall x. Rep AddTagsToStream x -> AddTagsToStream)
-> Generic AddTagsToStream
forall x. Rep AddTagsToStream x -> AddTagsToStream
forall x. AddTagsToStream -> Rep AddTagsToStream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddTagsToStream x -> AddTagsToStream
$cfrom :: forall x. AddTagsToStream -> Rep AddTagsToStream x
Prelude.Generic)

-- |
-- Create a value of 'AddTagsToStream' 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:
--
-- 'streamName', 'addTagsToStream_streamName' - The name of the stream.
--
-- 'tags', 'addTagsToStream_tags' - A set of up to 10 key-value pairs to use to create the tags.
newAddTagsToStream ::
  -- | 'streamName'
  Prelude.Text ->
  AddTagsToStream
newAddTagsToStream :: Text -> AddTagsToStream
newAddTagsToStream Text
pStreamName_ =
  AddTagsToStream' :: Text -> HashMap Text Text -> AddTagsToStream
AddTagsToStream'
    { $sel:streamName:AddTagsToStream' :: Text
streamName = Text
pStreamName_,
      $sel:tags:AddTagsToStream' :: HashMap Text Text
tags = HashMap Text Text
forall a. Monoid a => a
Prelude.mempty
    }

-- | The name of the stream.
addTagsToStream_streamName :: Lens.Lens' AddTagsToStream Prelude.Text
addTagsToStream_streamName :: (Text -> f Text) -> AddTagsToStream -> f AddTagsToStream
addTagsToStream_streamName = (AddTagsToStream -> Text)
-> (AddTagsToStream -> Text -> AddTagsToStream)
-> Lens AddTagsToStream AddTagsToStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddTagsToStream' {Text
streamName :: Text
$sel:streamName:AddTagsToStream' :: AddTagsToStream -> Text
streamName} -> Text
streamName) (\s :: AddTagsToStream
s@AddTagsToStream' {} Text
a -> AddTagsToStream
s {$sel:streamName:AddTagsToStream' :: Text
streamName = Text
a} :: AddTagsToStream)

-- | A set of up to 10 key-value pairs to use to create the tags.
addTagsToStream_tags :: Lens.Lens' AddTagsToStream (Prelude.HashMap Prelude.Text Prelude.Text)
addTagsToStream_tags :: (HashMap Text Text -> f (HashMap Text Text))
-> AddTagsToStream -> f AddTagsToStream
addTagsToStream_tags = (AddTagsToStream -> HashMap Text Text)
-> (AddTagsToStream -> HashMap Text Text -> AddTagsToStream)
-> Lens
     AddTagsToStream
     AddTagsToStream
     (HashMap Text Text)
     (HashMap Text Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddTagsToStream' {HashMap Text Text
tags :: HashMap Text Text
$sel:tags:AddTagsToStream' :: AddTagsToStream -> HashMap Text Text
tags} -> HashMap Text Text
tags) (\s :: AddTagsToStream
s@AddTagsToStream' {} HashMap Text Text
a -> AddTagsToStream
s {$sel:tags:AddTagsToStream' :: HashMap Text Text
tags = HashMap Text Text
a} :: AddTagsToStream) ((HashMap Text Text -> f (HashMap Text Text))
 -> AddTagsToStream -> f AddTagsToStream)
-> ((HashMap Text Text -> f (HashMap Text Text))
    -> HashMap Text Text -> f (HashMap Text Text))
-> (HashMap Text Text -> f (HashMap Text Text))
-> AddTagsToStream
-> f AddTagsToStream
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable AddTagsToStream

instance Prelude.NFData AddTagsToStream

instance Core.ToHeaders AddTagsToStream where
  toHeaders :: AddTagsToStream -> [Header]
toHeaders =
    [Header] -> AddTagsToStream -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"Kinesis_20131202.AddTagsToStream" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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

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

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

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

instance Prelude.NFData AddTagsToStreamResponse