{-# 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-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 delivery stream. A tag is a
-- key-value pair 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. 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 /AWS 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 Amazonka.Firehose.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:/ '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
(TagDeliveryStream -> TagDeliveryStream -> Bool)
-> (TagDeliveryStream -> TagDeliveryStream -> Bool)
-> Eq TagDeliveryStream
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]
(Int -> ReadS TagDeliveryStream)
-> ReadS [TagDeliveryStream]
-> ReadPrec TagDeliveryStream
-> ReadPrec [TagDeliveryStream]
-> Read 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
(Int -> TagDeliveryStream -> ShowS)
-> (TagDeliveryStream -> String)
-> ([TagDeliveryStream] -> ShowS)
-> Show TagDeliveryStream
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. TagDeliveryStream -> Rep TagDeliveryStream x)
-> (forall x. Rep TagDeliveryStream x -> TagDeliveryStream)
-> Generic TagDeliveryStream
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' :: Text -> NonEmpty Tag -> TagDeliveryStream
TagDeliveryStream'
    { $sel:deliveryStreamName:TagDeliveryStream' :: Text
deliveryStreamName =
        Text
pDeliveryStreamName_,
      $sel:tags:TagDeliveryStream' :: NonEmpty Tag
tags = Tagged (NonEmpty Tag) (Identity (NonEmpty Tag))
-> Tagged (NonEmpty Tag) (Identity (NonEmpty Tag))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Tag) (Identity (NonEmpty Tag))
 -> Tagged (NonEmpty Tag) (Identity (NonEmpty Tag)))
-> NonEmpty Tag -> NonEmpty Tag
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 :: (Text -> f Text) -> TagDeliveryStream -> f TagDeliveryStream
tagDeliveryStream_deliveryStreamName = (TagDeliveryStream -> Text)
-> (TagDeliveryStream -> Text -> TagDeliveryStream)
-> Lens TagDeliveryStream TagDeliveryStream Text Text
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 :: (NonEmpty Tag -> f (NonEmpty Tag))
-> TagDeliveryStream -> f TagDeliveryStream
tagDeliveryStream_tags = (TagDeliveryStream -> NonEmpty Tag)
-> (TagDeliveryStream -> NonEmpty Tag -> TagDeliveryStream)
-> Lens
     TagDeliveryStream TagDeliveryStream (NonEmpty Tag) (NonEmpty Tag)
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) ((NonEmpty Tag -> f (NonEmpty Tag))
 -> TagDeliveryStream -> f TagDeliveryStream)
-> ((NonEmpty Tag -> f (NonEmpty Tag))
    -> NonEmpty Tag -> f (NonEmpty Tag))
-> (NonEmpty Tag -> f (NonEmpty Tag))
-> TagDeliveryStream
-> f TagDeliveryStream
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Tag -> f (NonEmpty Tag))
-> NonEmpty Tag -> f (NonEmpty Tag)
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 :: TagDeliveryStream -> Request TagDeliveryStream
request = Service -> TagDeliveryStream -> Request TagDeliveryStream
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy TagDeliveryStream
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse TagDeliveryStream)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse TagDeliveryStream))
-> Logger
-> Service
-> Proxy TagDeliveryStream
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse TagDeliveryStream)))
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 -> TagDeliveryStreamResponse
TagDeliveryStreamResponse'
            (Int -> TagDeliveryStreamResponse)
-> Either String Int -> Either String TagDeliveryStreamResponse
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 TagDeliveryStream

instance Prelude.NFData TagDeliveryStream

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"DeliveryStreamName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
deliveryStreamName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Tags" Text -> NonEmpty Tag -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Tag
tags)
          ]
      )

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

instance Core.ToQuery TagDeliveryStream where
  toQuery :: TagDeliveryStream -> QueryString
toQuery = QueryString -> TagDeliveryStream -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(TagDeliveryStreamResponse -> TagDeliveryStreamResponse -> Bool)
-> (TagDeliveryStreamResponse -> TagDeliveryStreamResponse -> Bool)
-> Eq TagDeliveryStreamResponse
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]
(Int -> ReadS TagDeliveryStreamResponse)
-> ReadS [TagDeliveryStreamResponse]
-> ReadPrec TagDeliveryStreamResponse
-> ReadPrec [TagDeliveryStreamResponse]
-> Read 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
(Int -> TagDeliveryStreamResponse -> ShowS)
-> (TagDeliveryStreamResponse -> String)
-> ([TagDeliveryStreamResponse] -> ShowS)
-> Show TagDeliveryStreamResponse
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.
 TagDeliveryStreamResponse -> Rep TagDeliveryStreamResponse x)
-> (forall x.
    Rep TagDeliveryStreamResponse x -> TagDeliveryStreamResponse)
-> Generic TagDeliveryStreamResponse
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' :: Int -> TagDeliveryStreamResponse
TagDeliveryStreamResponse'
    { $sel:httpStatus:TagDeliveryStreamResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
tagDeliveryStreamResponse_httpStatus :: Lens.Lens' TagDeliveryStreamResponse Prelude.Int
tagDeliveryStreamResponse_httpStatus :: (Int -> f Int)
-> TagDeliveryStreamResponse -> f TagDeliveryStreamResponse
tagDeliveryStreamResponse_httpStatus = (TagDeliveryStreamResponse -> Int)
-> (TagDeliveryStreamResponse -> Int -> TagDeliveryStreamResponse)
-> Lens TagDeliveryStreamResponse TagDeliveryStreamResponse Int Int
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