{-# 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.Firehose.TagDeliveryStream
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Adds or updates tags for the specified delivery stream. A tag is a
-- key-value pair that you can define and assign to Amazon Web Services
-- resources. If you specify a tag that already exists, the tag value is
-- replaced with the value that you specify in the request. Tags are
-- metadata. For example, you can add friendly names and descriptions or
-- other types of information that can help you distinguish the delivery
-- stream. For more information about tags, see
-- <https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html Using Cost Allocation Tags>
-- in the /Amazon Web Services Billing and Cost Management User Guide/.
--
-- Each delivery stream can have up to 50 tags.
--
-- This operation has a limit of five transactions per second per account.
module Amazonka.Firehose.TagDeliveryStream
  ( -- * Creating a Request
    TagDeliveryStream (..),
    newTagDeliveryStream,

    -- * Request Lenses
    tagDeliveryStream_deliveryStreamName,
    tagDeliveryStream_tags,

    -- * Destructuring the Response
    TagDeliveryStreamResponse (..),
    newTagDeliveryStreamResponse,

    -- * Response Lenses
    tagDeliveryStreamResponse_httpStatus,
  )
where

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

-- | /See:/ 'newTagDeliveryStream' smart constructor.
data TagDeliveryStream = TagDeliveryStream'
  { -- | The name of the delivery stream to which you want to add the tags.
    TagDeliveryStream -> Text
deliveryStreamName :: Prelude.Text,
    -- | A set of key-value pairs to use to create the tags.
    TagDeliveryStream -> NonEmpty Tag
tags :: Prelude.NonEmpty Tag
  }
  deriving (TagDeliveryStream -> TagDeliveryStream -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagDeliveryStream -> TagDeliveryStream -> Bool
$c/= :: TagDeliveryStream -> TagDeliveryStream -> Bool
== :: TagDeliveryStream -> TagDeliveryStream -> Bool
$c== :: TagDeliveryStream -> TagDeliveryStream -> Bool
Prelude.Eq, ReadPrec [TagDeliveryStream]
ReadPrec TagDeliveryStream
Int -> ReadS TagDeliveryStream
ReadS [TagDeliveryStream]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TagDeliveryStream]
$creadListPrec :: ReadPrec [TagDeliveryStream]
readPrec :: ReadPrec TagDeliveryStream
$creadPrec :: ReadPrec TagDeliveryStream
readList :: ReadS [TagDeliveryStream]
$creadList :: ReadS [TagDeliveryStream]
readsPrec :: Int -> ReadS TagDeliveryStream
$creadsPrec :: Int -> ReadS TagDeliveryStream
Prelude.Read, Int -> TagDeliveryStream -> ShowS
[TagDeliveryStream] -> ShowS
TagDeliveryStream -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagDeliveryStream] -> ShowS
$cshowList :: [TagDeliveryStream] -> ShowS
show :: TagDeliveryStream -> String
$cshow :: TagDeliveryStream -> String
showsPrec :: Int -> TagDeliveryStream -> ShowS
$cshowsPrec :: Int -> TagDeliveryStream -> ShowS
Prelude.Show, forall x. Rep TagDeliveryStream x -> TagDeliveryStream
forall x. TagDeliveryStream -> Rep TagDeliveryStream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TagDeliveryStream x -> TagDeliveryStream
$cfrom :: forall x. TagDeliveryStream -> Rep TagDeliveryStream x
Prelude.Generic)

-- |
-- Create a value of 'TagDeliveryStream' 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:
--
-- 'deliveryStreamName', 'tagDeliveryStream_deliveryStreamName' - The name of the delivery stream to which you want to add the tags.
--
-- 'tags', 'tagDeliveryStream_tags' - A set of key-value pairs to use to create the tags.
newTagDeliveryStream ::
  -- | 'deliveryStreamName'
  Prelude.Text ->
  -- | 'tags'
  Prelude.NonEmpty Tag ->
  TagDeliveryStream
newTagDeliveryStream :: Text -> NonEmpty Tag -> TagDeliveryStream
newTagDeliveryStream Text
pDeliveryStreamName_ NonEmpty Tag
pTags_ =
  TagDeliveryStream'
    { $sel:deliveryStreamName:TagDeliveryStream' :: Text
deliveryStreamName =
        Text
pDeliveryStreamName_,
      $sel:tags:TagDeliveryStream' :: NonEmpty Tag
tags = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Tag
pTags_
    }

-- | The name of the delivery stream to which you want to add the tags.
tagDeliveryStream_deliveryStreamName :: Lens.Lens' TagDeliveryStream Prelude.Text
tagDeliveryStream_deliveryStreamName :: Lens' TagDeliveryStream Text
tagDeliveryStream_deliveryStreamName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagDeliveryStream' {Text
deliveryStreamName :: Text
$sel:deliveryStreamName:TagDeliveryStream' :: TagDeliveryStream -> Text
deliveryStreamName} -> Text
deliveryStreamName) (\s :: TagDeliveryStream
s@TagDeliveryStream' {} Text
a -> TagDeliveryStream
s {$sel:deliveryStreamName:TagDeliveryStream' :: Text
deliveryStreamName = Text
a} :: TagDeliveryStream)

-- | A set of key-value pairs to use to create the tags.
tagDeliveryStream_tags :: Lens.Lens' TagDeliveryStream (Prelude.NonEmpty Tag)
tagDeliveryStream_tags :: Lens' TagDeliveryStream (NonEmpty Tag)
tagDeliveryStream_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagDeliveryStream' {NonEmpty Tag
tags :: NonEmpty Tag
$sel:tags:TagDeliveryStream' :: TagDeliveryStream -> NonEmpty Tag
tags} -> NonEmpty Tag
tags) (\s :: TagDeliveryStream
s@TagDeliveryStream' {} NonEmpty Tag
a -> TagDeliveryStream
s {$sel:tags:TagDeliveryStream' :: NonEmpty Tag
tags = NonEmpty Tag
a} :: TagDeliveryStream) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest TagDeliveryStream where
  type
    AWSResponse TagDeliveryStream =
      TagDeliveryStreamResponse
  request :: (Service -> Service)
-> TagDeliveryStream -> Request TagDeliveryStream
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 TagDeliveryStream
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse TagDeliveryStream)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> TagDeliveryStreamResponse
TagDeliveryStreamResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable TagDeliveryStream where
  hashWithSalt :: Int -> TagDeliveryStream -> Int
hashWithSalt Int
_salt TagDeliveryStream' {NonEmpty Tag
Text
tags :: NonEmpty Tag
deliveryStreamName :: Text
$sel:tags:TagDeliveryStream' :: TagDeliveryStream -> NonEmpty Tag
$sel:deliveryStreamName:TagDeliveryStream' :: TagDeliveryStream -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
deliveryStreamName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Tag
tags

instance Prelude.NFData TagDeliveryStream where
  rnf :: TagDeliveryStream -> ()
rnf TagDeliveryStream' {NonEmpty Tag
Text
tags :: NonEmpty Tag
deliveryStreamName :: Text
$sel:tags:TagDeliveryStream' :: TagDeliveryStream -> NonEmpty Tag
$sel:deliveryStreamName:TagDeliveryStream' :: TagDeliveryStream -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
deliveryStreamName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Tag
tags

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

instance Data.ToJSON TagDeliveryStream where
  toJSON :: TagDeliveryStream -> Value
toJSON TagDeliveryStream' {NonEmpty Tag
Text
tags :: NonEmpty Tag
deliveryStreamName :: Text
$sel:tags:TagDeliveryStream' :: TagDeliveryStream -> NonEmpty Tag
$sel:deliveryStreamName:TagDeliveryStream' :: TagDeliveryStream -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"DeliveryStreamName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
deliveryStreamName),
            forall a. a -> Maybe a
Prelude.Just (Key
"Tags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Tag
tags)
          ]
      )

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

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

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

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

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

instance Prelude.NFData TagDeliveryStreamResponse where
  rnf :: TagDeliveryStreamResponse -> ()
rnf TagDeliveryStreamResponse' {Int
httpStatus :: Int
$sel:httpStatus:TagDeliveryStreamResponse' :: TagDeliveryStreamResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus