{-# 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.KinesisVideo.TagStream
-- 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 one or more tags to a stream. A /tag/ is a key-value pair (the
-- value is optional) that you can define and assign to AWS resources. If
-- you specify a tag that already exists, the tag value is replaced with
-- the value that you specify in the request. For more information, see
-- <https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html Using Cost Allocation Tags>
-- in the /AWS Billing and Cost Management User Guide/.
--
-- You must provide either the @StreamName@ or the @StreamARN@.
--
-- This operation requires permission for the @KinesisVideo:TagStream@
-- action.
--
-- Kinesis video streams support up to 50 tags.
module Amazonka.KinesisVideo.TagStream
  ( -- * Creating a Request
    TagStream (..),
    newTagStream,

    -- * Request Lenses
    tagStream_streamARN,
    tagStream_streamName,
    tagStream_tags,

    -- * Destructuring the Response
    TagStreamResponse (..),
    newTagStreamResponse,

    -- * Response Lenses
    tagStreamResponse_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

-- | /See:/ 'newTagStream' smart constructor.
data TagStream = TagStream'
  { -- | The Amazon Resource Name (ARN) of the resource that you want to add the
    -- tag or tags to.
    TagStream -> Maybe Text
streamARN :: Prelude.Maybe Prelude.Text,
    -- | The name of the stream that you want to add the tag or tags to.
    TagStream -> Maybe Text
streamName :: Prelude.Maybe Prelude.Text,
    -- | A list of tags to associate with the specified stream. Each tag is a
    -- key-value pair (the value is optional).
    TagStream -> HashMap Text Text
tags :: Prelude.HashMap Prelude.Text Prelude.Text
  }
  deriving (TagStream -> TagStream -> Bool
(TagStream -> TagStream -> Bool)
-> (TagStream -> TagStream -> Bool) -> Eq TagStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagStream -> TagStream -> Bool
$c/= :: TagStream -> TagStream -> Bool
== :: TagStream -> TagStream -> Bool
$c== :: TagStream -> TagStream -> Bool
Prelude.Eq, ReadPrec [TagStream]
ReadPrec TagStream
Int -> ReadS TagStream
ReadS [TagStream]
(Int -> ReadS TagStream)
-> ReadS [TagStream]
-> ReadPrec TagStream
-> ReadPrec [TagStream]
-> Read TagStream
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TagStream]
$creadListPrec :: ReadPrec [TagStream]
readPrec :: ReadPrec TagStream
$creadPrec :: ReadPrec TagStream
readList :: ReadS [TagStream]
$creadList :: ReadS [TagStream]
readsPrec :: Int -> ReadS TagStream
$creadsPrec :: Int -> ReadS TagStream
Prelude.Read, Int -> TagStream -> ShowS
[TagStream] -> ShowS
TagStream -> String
(Int -> TagStream -> ShowS)
-> (TagStream -> String)
-> ([TagStream] -> ShowS)
-> Show TagStream
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagStream] -> ShowS
$cshowList :: [TagStream] -> ShowS
show :: TagStream -> String
$cshow :: TagStream -> String
showsPrec :: Int -> TagStream -> ShowS
$cshowsPrec :: Int -> TagStream -> ShowS
Prelude.Show, (forall x. TagStream -> Rep TagStream x)
-> (forall x. Rep TagStream x -> TagStream) -> Generic TagStream
forall x. Rep TagStream x -> TagStream
forall x. TagStream -> Rep TagStream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TagStream x -> TagStream
$cfrom :: forall x. TagStream -> Rep TagStream x
Prelude.Generic)

-- |
-- Create a value of 'TagStream' 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', 'tagStream_streamARN' - The Amazon Resource Name (ARN) of the resource that you want to add the
-- tag or tags to.
--
-- 'streamName', 'tagStream_streamName' - The name of the stream that you want to add the tag or tags to.
--
-- 'tags', 'tagStream_tags' - A list of tags to associate with the specified stream. Each tag is a
-- key-value pair (the value is optional).
newTagStream ::
  TagStream
newTagStream :: TagStream
newTagStream =
  TagStream' :: Maybe Text -> Maybe Text -> HashMap Text Text -> TagStream
TagStream'
    { $sel:streamARN:TagStream' :: Maybe Text
streamARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:streamName:TagStream' :: Maybe Text
streamName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:TagStream' :: HashMap Text Text
tags = HashMap Text Text
forall a. Monoid a => a
Prelude.mempty
    }

-- | The Amazon Resource Name (ARN) of the resource that you want to add the
-- tag or tags to.
tagStream_streamARN :: Lens.Lens' TagStream (Prelude.Maybe Prelude.Text)
tagStream_streamARN :: (Maybe Text -> f (Maybe Text)) -> TagStream -> f TagStream
tagStream_streamARN = (TagStream -> Maybe Text)
-> (TagStream -> Maybe Text -> TagStream)
-> Lens TagStream TagStream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagStream' {Maybe Text
streamARN :: Maybe Text
$sel:streamARN:TagStream' :: TagStream -> Maybe Text
streamARN} -> Maybe Text
streamARN) (\s :: TagStream
s@TagStream' {} Maybe Text
a -> TagStream
s {$sel:streamARN:TagStream' :: Maybe Text
streamARN = Maybe Text
a} :: TagStream)

-- | The name of the stream that you want to add the tag or tags to.
tagStream_streamName :: Lens.Lens' TagStream (Prelude.Maybe Prelude.Text)
tagStream_streamName :: (Maybe Text -> f (Maybe Text)) -> TagStream -> f TagStream
tagStream_streamName = (TagStream -> Maybe Text)
-> (TagStream -> Maybe Text -> TagStream)
-> Lens TagStream TagStream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagStream' {Maybe Text
streamName :: Maybe Text
$sel:streamName:TagStream' :: TagStream -> Maybe Text
streamName} -> Maybe Text
streamName) (\s :: TagStream
s@TagStream' {} Maybe Text
a -> TagStream
s {$sel:streamName:TagStream' :: Maybe Text
streamName = Maybe Text
a} :: TagStream)

-- | A list of tags to associate with the specified stream. Each tag is a
-- key-value pair (the value is optional).
tagStream_tags :: Lens.Lens' TagStream (Prelude.HashMap Prelude.Text Prelude.Text)
tagStream_tags :: (HashMap Text Text -> f (HashMap Text Text))
-> TagStream -> f TagStream
tagStream_tags = (TagStream -> HashMap Text Text)
-> (TagStream -> HashMap Text Text -> TagStream)
-> Lens TagStream TagStream (HashMap Text Text) (HashMap Text Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagStream' {HashMap Text Text
tags :: HashMap Text Text
$sel:tags:TagStream' :: TagStream -> HashMap Text Text
tags} -> HashMap Text Text
tags) (\s :: TagStream
s@TagStream' {} HashMap Text Text
a -> TagStream
s {$sel:tags:TagStream' :: HashMap Text Text
tags = HashMap Text Text
a} :: TagStream) ((HashMap Text Text -> f (HashMap Text Text))
 -> TagStream -> f TagStream)
-> ((HashMap Text Text -> f (HashMap Text Text))
    -> HashMap Text Text -> f (HashMap Text Text))
-> (HashMap Text Text -> f (HashMap Text Text))
-> TagStream
-> f TagStream
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 TagStream where
  type AWSResponse TagStream = TagStreamResponse
  request :: TagStream -> Request TagStream
request = Service -> TagStream -> Request TagStream
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy TagStream
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse TagStream)))
response =
    (Int
 -> ResponseHeaders -> () -> Either String (AWSResponse TagStream))
-> Logger
-> Service
-> Proxy TagStream
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse TagStream)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> TagStreamResponse
TagStreamResponse'
            (Int -> TagStreamResponse)
-> Either String Int -> Either String TagStreamResponse
forall (f :: * -> *) a b. Functor 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 TagStream

instance Prelude.NFData TagStream

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

instance Core.ToJSON TagStream where
  toJSON :: TagStream -> Value
toJSON TagStream' {Maybe Text
HashMap Text Text
tags :: HashMap Text Text
streamName :: Maybe Text
streamARN :: Maybe Text
$sel:tags:TagStream' :: TagStream -> HashMap Text Text
$sel:streamName:TagStream' :: TagStream -> Maybe Text
$sel:streamARN:TagStream' :: TagStream -> 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
"Tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text Text
tags)
          ]
      )

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

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

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

-- |
-- Create a value of 'TagStreamResponse' 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:
--
-- 'httpStatus', 'tagStreamResponse_httpStatus' - The response's http status code.
newTagStreamResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  TagStreamResponse
newTagStreamResponse :: Int -> TagStreamResponse
newTagStreamResponse Int
pHttpStatus_ =
  TagStreamResponse' :: Int -> TagStreamResponse
TagStreamResponse' {$sel:httpStatus:TagStreamResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData TagStreamResponse