{-# 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.CloudWatch.PutMetricStream
-- 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)
--
-- Creates or updates a metric stream. Metric streams can automatically
-- stream CloudWatch metrics to Amazon Web Services destinations including
-- Amazon S3 and to many third-party solutions.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Metric-Streams.html Using Metric Streams>.
--
-- To create a metric stream, you must be logged on to an account that has
-- the @iam:PassRole@ permission and either the @CloudWatchFullAccess@
-- policy or the @cloudwatch:PutMetricStream@ permission.
--
-- When you create or update a metric stream, you choose one of the
-- following:
--
-- -   Stream metrics from all metric namespaces in the account.
--
-- -   Stream metrics from all metric namespaces in the account, except for
--     the namespaces that you list in @ExcludeFilters@.
--
-- -   Stream metrics from only the metric namespaces that you list in
--     @IncludeFilters@.
--
-- When you use @PutMetricStream@ to create a new metric stream, the stream
-- is created in the @running@ state. If you use it to update an existing
-- stream, the state of the stream is not changed.
module Amazonka.CloudWatch.PutMetricStream
  ( -- * Creating a Request
    PutMetricStream (..),
    newPutMetricStream,

    -- * Request Lenses
    putMetricStream_includeFilters,
    putMetricStream_excludeFilters,
    putMetricStream_tags,
    putMetricStream_name,
    putMetricStream_firehoseArn,
    putMetricStream_roleArn,
    putMetricStream_outputFormat,

    -- * Destructuring the Response
    PutMetricStreamResponse (..),
    newPutMetricStreamResponse,

    -- * Response Lenses
    putMetricStreamResponse_arn,
    putMetricStreamResponse_httpStatus,
  )
where

import Amazonka.CloudWatch.Types
import qualified Amazonka.Core as Core
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:/ 'newPutMetricStream' smart constructor.
data PutMetricStream = PutMetricStream'
  { -- | If you specify this parameter, the stream sends only the metrics from
    -- the metric namespaces that you specify here.
    --
    -- You cannot include @IncludeFilters@ and @ExcludeFilters@ in the same
    -- operation.
    PutMetricStream -> Maybe [MetricStreamFilter]
includeFilters :: Prelude.Maybe [MetricStreamFilter],
    -- | If you specify this parameter, the stream sends metrics from all metric
    -- namespaces except for the namespaces that you specify here.
    --
    -- You cannot include @ExcludeFilters@ and @IncludeFilters@ in the same
    -- operation.
    PutMetricStream -> Maybe [MetricStreamFilter]
excludeFilters :: Prelude.Maybe [MetricStreamFilter],
    -- | A list of key-value pairs to associate with the metric stream. You can
    -- associate as many as 50 tags with a metric stream.
    --
    -- Tags can help you organize and categorize your resources. You can also
    -- use them to scope user permissions by granting a user permission to
    -- access or change only resources with certain tag values.
    --
    -- You can use this parameter only when you are creating a new metric
    -- stream. If you are using this operation to update an existing metric
    -- stream, any tags you specify in this parameter are ignored. To change
    -- the tags of an existing metric stream, use
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_TagResource.html TagResource>
    -- or
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_UntagResource.html UntagResource>.
    PutMetricStream -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | If you are creating a new metric stream, this is the name for the new
    -- stream. The name must be different than the names of other metric
    -- streams in this account and Region.
    --
    -- If you are updating a metric stream, specify the name of that stream
    -- here.
    --
    -- Valid characters are A-Z, a-z, 0-9, \"-\" and \"_\".
    PutMetricStream -> Text
name :: Prelude.Text,
    -- | The ARN of the Amazon Kinesis Firehose delivery stream to use for this
    -- metric stream. This Amazon Kinesis Firehose delivery stream must already
    -- exist and must be in the same account as the metric stream.
    PutMetricStream -> Text
firehoseArn :: Prelude.Text,
    -- | The ARN of an IAM role that this metric stream will use to access Amazon
    -- Kinesis Firehose resources. This IAM role must already exist and must be
    -- in the same account as the metric stream. This IAM role must include the
    -- following permissions:
    --
    -- -   firehose:PutRecord
    --
    -- -   firehose:PutRecordBatch
    PutMetricStream -> Text
roleArn :: Prelude.Text,
    -- | The output format for the stream. Valid values are @json@ and
    -- @opentelemetry0.7@. For more information about metric stream output
    -- formats, see
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-metric-streams-formats.html Metric streams output formats>.
    PutMetricStream -> MetricStreamOutputFormat
outputFormat :: MetricStreamOutputFormat
  }
  deriving (PutMetricStream -> PutMetricStream -> Bool
(PutMetricStream -> PutMetricStream -> Bool)
-> (PutMetricStream -> PutMetricStream -> Bool)
-> Eq PutMetricStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutMetricStream -> PutMetricStream -> Bool
$c/= :: PutMetricStream -> PutMetricStream -> Bool
== :: PutMetricStream -> PutMetricStream -> Bool
$c== :: PutMetricStream -> PutMetricStream -> Bool
Prelude.Eq, ReadPrec [PutMetricStream]
ReadPrec PutMetricStream
Int -> ReadS PutMetricStream
ReadS [PutMetricStream]
(Int -> ReadS PutMetricStream)
-> ReadS [PutMetricStream]
-> ReadPrec PutMetricStream
-> ReadPrec [PutMetricStream]
-> Read PutMetricStream
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutMetricStream]
$creadListPrec :: ReadPrec [PutMetricStream]
readPrec :: ReadPrec PutMetricStream
$creadPrec :: ReadPrec PutMetricStream
readList :: ReadS [PutMetricStream]
$creadList :: ReadS [PutMetricStream]
readsPrec :: Int -> ReadS PutMetricStream
$creadsPrec :: Int -> ReadS PutMetricStream
Prelude.Read, Int -> PutMetricStream -> ShowS
[PutMetricStream] -> ShowS
PutMetricStream -> String
(Int -> PutMetricStream -> ShowS)
-> (PutMetricStream -> String)
-> ([PutMetricStream] -> ShowS)
-> Show PutMetricStream
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutMetricStream] -> ShowS
$cshowList :: [PutMetricStream] -> ShowS
show :: PutMetricStream -> String
$cshow :: PutMetricStream -> String
showsPrec :: Int -> PutMetricStream -> ShowS
$cshowsPrec :: Int -> PutMetricStream -> ShowS
Prelude.Show, (forall x. PutMetricStream -> Rep PutMetricStream x)
-> (forall x. Rep PutMetricStream x -> PutMetricStream)
-> Generic PutMetricStream
forall x. Rep PutMetricStream x -> PutMetricStream
forall x. PutMetricStream -> Rep PutMetricStream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutMetricStream x -> PutMetricStream
$cfrom :: forall x. PutMetricStream -> Rep PutMetricStream x
Prelude.Generic)

-- |
-- Create a value of 'PutMetricStream' 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:
--
-- 'includeFilters', 'putMetricStream_includeFilters' - If you specify this parameter, the stream sends only the metrics from
-- the metric namespaces that you specify here.
--
-- You cannot include @IncludeFilters@ and @ExcludeFilters@ in the same
-- operation.
--
-- 'excludeFilters', 'putMetricStream_excludeFilters' - If you specify this parameter, the stream sends metrics from all metric
-- namespaces except for the namespaces that you specify here.
--
-- You cannot include @ExcludeFilters@ and @IncludeFilters@ in the same
-- operation.
--
-- 'tags', 'putMetricStream_tags' - A list of key-value pairs to associate with the metric stream. You can
-- associate as many as 50 tags with a metric stream.
--
-- Tags can help you organize and categorize your resources. You can also
-- use them to scope user permissions by granting a user permission to
-- access or change only resources with certain tag values.
--
-- You can use this parameter only when you are creating a new metric
-- stream. If you are using this operation to update an existing metric
-- stream, any tags you specify in this parameter are ignored. To change
-- the tags of an existing metric stream, use
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_TagResource.html TagResource>
-- or
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_UntagResource.html UntagResource>.
--
-- 'name', 'putMetricStream_name' - If you are creating a new metric stream, this is the name for the new
-- stream. The name must be different than the names of other metric
-- streams in this account and Region.
--
-- If you are updating a metric stream, specify the name of that stream
-- here.
--
-- Valid characters are A-Z, a-z, 0-9, \"-\" and \"_\".
--
-- 'firehoseArn', 'putMetricStream_firehoseArn' - The ARN of the Amazon Kinesis Firehose delivery stream to use for this
-- metric stream. This Amazon Kinesis Firehose delivery stream must already
-- exist and must be in the same account as the metric stream.
--
-- 'roleArn', 'putMetricStream_roleArn' - The ARN of an IAM role that this metric stream will use to access Amazon
-- Kinesis Firehose resources. This IAM role must already exist and must be
-- in the same account as the metric stream. This IAM role must include the
-- following permissions:
--
-- -   firehose:PutRecord
--
-- -   firehose:PutRecordBatch
--
-- 'outputFormat', 'putMetricStream_outputFormat' - The output format for the stream. Valid values are @json@ and
-- @opentelemetry0.7@. For more information about metric stream output
-- formats, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-metric-streams-formats.html Metric streams output formats>.
newPutMetricStream ::
  -- | 'name'
  Prelude.Text ->
  -- | 'firehoseArn'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  -- | 'outputFormat'
  MetricStreamOutputFormat ->
  PutMetricStream
newPutMetricStream :: Text -> Text -> Text -> MetricStreamOutputFormat -> PutMetricStream
newPutMetricStream
  Text
pName_
  Text
pFirehoseArn_
  Text
pRoleArn_
  MetricStreamOutputFormat
pOutputFormat_ =
    PutMetricStream' :: Maybe [MetricStreamFilter]
-> Maybe [MetricStreamFilter]
-> Maybe [Tag]
-> Text
-> Text
-> Text
-> MetricStreamOutputFormat
-> PutMetricStream
PutMetricStream'
      { $sel:includeFilters:PutMetricStream' :: Maybe [MetricStreamFilter]
includeFilters = Maybe [MetricStreamFilter]
forall a. Maybe a
Prelude.Nothing,
        $sel:excludeFilters:PutMetricStream' :: Maybe [MetricStreamFilter]
excludeFilters = Maybe [MetricStreamFilter]
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:PutMetricStream' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
        $sel:name:PutMetricStream' :: Text
name = Text
pName_,
        $sel:firehoseArn:PutMetricStream' :: Text
firehoseArn = Text
pFirehoseArn_,
        $sel:roleArn:PutMetricStream' :: Text
roleArn = Text
pRoleArn_,
        $sel:outputFormat:PutMetricStream' :: MetricStreamOutputFormat
outputFormat = MetricStreamOutputFormat
pOutputFormat_
      }

-- | If you specify this parameter, the stream sends only the metrics from
-- the metric namespaces that you specify here.
--
-- You cannot include @IncludeFilters@ and @ExcludeFilters@ in the same
-- operation.
putMetricStream_includeFilters :: Lens.Lens' PutMetricStream (Prelude.Maybe [MetricStreamFilter])
putMetricStream_includeFilters :: (Maybe [MetricStreamFilter] -> f (Maybe [MetricStreamFilter]))
-> PutMetricStream -> f PutMetricStream
putMetricStream_includeFilters = (PutMetricStream -> Maybe [MetricStreamFilter])
-> (PutMetricStream
    -> Maybe [MetricStreamFilter] -> PutMetricStream)
-> Lens
     PutMetricStream
     PutMetricStream
     (Maybe [MetricStreamFilter])
     (Maybe [MetricStreamFilter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetricStream' {Maybe [MetricStreamFilter]
includeFilters :: Maybe [MetricStreamFilter]
$sel:includeFilters:PutMetricStream' :: PutMetricStream -> Maybe [MetricStreamFilter]
includeFilters} -> Maybe [MetricStreamFilter]
includeFilters) (\s :: PutMetricStream
s@PutMetricStream' {} Maybe [MetricStreamFilter]
a -> PutMetricStream
s {$sel:includeFilters:PutMetricStream' :: Maybe [MetricStreamFilter]
includeFilters = Maybe [MetricStreamFilter]
a} :: PutMetricStream) ((Maybe [MetricStreamFilter] -> f (Maybe [MetricStreamFilter]))
 -> PutMetricStream -> f PutMetricStream)
-> ((Maybe [MetricStreamFilter] -> f (Maybe [MetricStreamFilter]))
    -> Maybe [MetricStreamFilter] -> f (Maybe [MetricStreamFilter]))
-> (Maybe [MetricStreamFilter] -> f (Maybe [MetricStreamFilter]))
-> PutMetricStream
-> f PutMetricStream
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [MetricStreamFilter]
  [MetricStreamFilter]
  [MetricStreamFilter]
  [MetricStreamFilter]
-> Iso
     (Maybe [MetricStreamFilter])
     (Maybe [MetricStreamFilter])
     (Maybe [MetricStreamFilter])
     (Maybe [MetricStreamFilter])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [MetricStreamFilter]
  [MetricStreamFilter]
  [MetricStreamFilter]
  [MetricStreamFilter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If you specify this parameter, the stream sends metrics from all metric
-- namespaces except for the namespaces that you specify here.
--
-- You cannot include @ExcludeFilters@ and @IncludeFilters@ in the same
-- operation.
putMetricStream_excludeFilters :: Lens.Lens' PutMetricStream (Prelude.Maybe [MetricStreamFilter])
putMetricStream_excludeFilters :: (Maybe [MetricStreamFilter] -> f (Maybe [MetricStreamFilter]))
-> PutMetricStream -> f PutMetricStream
putMetricStream_excludeFilters = (PutMetricStream -> Maybe [MetricStreamFilter])
-> (PutMetricStream
    -> Maybe [MetricStreamFilter] -> PutMetricStream)
-> Lens
     PutMetricStream
     PutMetricStream
     (Maybe [MetricStreamFilter])
     (Maybe [MetricStreamFilter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetricStream' {Maybe [MetricStreamFilter]
excludeFilters :: Maybe [MetricStreamFilter]
$sel:excludeFilters:PutMetricStream' :: PutMetricStream -> Maybe [MetricStreamFilter]
excludeFilters} -> Maybe [MetricStreamFilter]
excludeFilters) (\s :: PutMetricStream
s@PutMetricStream' {} Maybe [MetricStreamFilter]
a -> PutMetricStream
s {$sel:excludeFilters:PutMetricStream' :: Maybe [MetricStreamFilter]
excludeFilters = Maybe [MetricStreamFilter]
a} :: PutMetricStream) ((Maybe [MetricStreamFilter] -> f (Maybe [MetricStreamFilter]))
 -> PutMetricStream -> f PutMetricStream)
-> ((Maybe [MetricStreamFilter] -> f (Maybe [MetricStreamFilter]))
    -> Maybe [MetricStreamFilter] -> f (Maybe [MetricStreamFilter]))
-> (Maybe [MetricStreamFilter] -> f (Maybe [MetricStreamFilter]))
-> PutMetricStream
-> f PutMetricStream
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [MetricStreamFilter]
  [MetricStreamFilter]
  [MetricStreamFilter]
  [MetricStreamFilter]
-> Iso
     (Maybe [MetricStreamFilter])
     (Maybe [MetricStreamFilter])
     (Maybe [MetricStreamFilter])
     (Maybe [MetricStreamFilter])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [MetricStreamFilter]
  [MetricStreamFilter]
  [MetricStreamFilter]
  [MetricStreamFilter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of key-value pairs to associate with the metric stream. You can
-- associate as many as 50 tags with a metric stream.
--
-- Tags can help you organize and categorize your resources. You can also
-- use them to scope user permissions by granting a user permission to
-- access or change only resources with certain tag values.
--
-- You can use this parameter only when you are creating a new metric
-- stream. If you are using this operation to update an existing metric
-- stream, any tags you specify in this parameter are ignored. To change
-- the tags of an existing metric stream, use
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_TagResource.html TagResource>
-- or
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_UntagResource.html UntagResource>.
putMetricStream_tags :: Lens.Lens' PutMetricStream (Prelude.Maybe [Tag])
putMetricStream_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> PutMetricStream -> f PutMetricStream
putMetricStream_tags = (PutMetricStream -> Maybe [Tag])
-> (PutMetricStream -> Maybe [Tag] -> PutMetricStream)
-> Lens PutMetricStream PutMetricStream (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetricStream' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:PutMetricStream' :: PutMetricStream -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: PutMetricStream
s@PutMetricStream' {} Maybe [Tag]
a -> PutMetricStream
s {$sel:tags:PutMetricStream' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: PutMetricStream) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> PutMetricStream -> f PutMetricStream)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> PutMetricStream
-> f PutMetricStream
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If you are creating a new metric stream, this is the name for the new
-- stream. The name must be different than the names of other metric
-- streams in this account and Region.
--
-- If you are updating a metric stream, specify the name of that stream
-- here.
--
-- Valid characters are A-Z, a-z, 0-9, \"-\" and \"_\".
putMetricStream_name :: Lens.Lens' PutMetricStream Prelude.Text
putMetricStream_name :: (Text -> f Text) -> PutMetricStream -> f PutMetricStream
putMetricStream_name = (PutMetricStream -> Text)
-> (PutMetricStream -> Text -> PutMetricStream)
-> Lens PutMetricStream PutMetricStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetricStream' {Text
name :: Text
$sel:name:PutMetricStream' :: PutMetricStream -> Text
name} -> Text
name) (\s :: PutMetricStream
s@PutMetricStream' {} Text
a -> PutMetricStream
s {$sel:name:PutMetricStream' :: Text
name = Text
a} :: PutMetricStream)

-- | The ARN of the Amazon Kinesis Firehose delivery stream to use for this
-- metric stream. This Amazon Kinesis Firehose delivery stream must already
-- exist and must be in the same account as the metric stream.
putMetricStream_firehoseArn :: Lens.Lens' PutMetricStream Prelude.Text
putMetricStream_firehoseArn :: (Text -> f Text) -> PutMetricStream -> f PutMetricStream
putMetricStream_firehoseArn = (PutMetricStream -> Text)
-> (PutMetricStream -> Text -> PutMetricStream)
-> Lens PutMetricStream PutMetricStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetricStream' {Text
firehoseArn :: Text
$sel:firehoseArn:PutMetricStream' :: PutMetricStream -> Text
firehoseArn} -> Text
firehoseArn) (\s :: PutMetricStream
s@PutMetricStream' {} Text
a -> PutMetricStream
s {$sel:firehoseArn:PutMetricStream' :: Text
firehoseArn = Text
a} :: PutMetricStream)

-- | The ARN of an IAM role that this metric stream will use to access Amazon
-- Kinesis Firehose resources. This IAM role must already exist and must be
-- in the same account as the metric stream. This IAM role must include the
-- following permissions:
--
-- -   firehose:PutRecord
--
-- -   firehose:PutRecordBatch
putMetricStream_roleArn :: Lens.Lens' PutMetricStream Prelude.Text
putMetricStream_roleArn :: (Text -> f Text) -> PutMetricStream -> f PutMetricStream
putMetricStream_roleArn = (PutMetricStream -> Text)
-> (PutMetricStream -> Text -> PutMetricStream)
-> Lens PutMetricStream PutMetricStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetricStream' {Text
roleArn :: Text
$sel:roleArn:PutMetricStream' :: PutMetricStream -> Text
roleArn} -> Text
roleArn) (\s :: PutMetricStream
s@PutMetricStream' {} Text
a -> PutMetricStream
s {$sel:roleArn:PutMetricStream' :: Text
roleArn = Text
a} :: PutMetricStream)

-- | The output format for the stream. Valid values are @json@ and
-- @opentelemetry0.7@. For more information about metric stream output
-- formats, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-metric-streams-formats.html Metric streams output formats>.
putMetricStream_outputFormat :: Lens.Lens' PutMetricStream MetricStreamOutputFormat
putMetricStream_outputFormat :: (MetricStreamOutputFormat -> f MetricStreamOutputFormat)
-> PutMetricStream -> f PutMetricStream
putMetricStream_outputFormat = (PutMetricStream -> MetricStreamOutputFormat)
-> (PutMetricStream -> MetricStreamOutputFormat -> PutMetricStream)
-> Lens
     PutMetricStream
     PutMetricStream
     MetricStreamOutputFormat
     MetricStreamOutputFormat
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetricStream' {MetricStreamOutputFormat
outputFormat :: MetricStreamOutputFormat
$sel:outputFormat:PutMetricStream' :: PutMetricStream -> MetricStreamOutputFormat
outputFormat} -> MetricStreamOutputFormat
outputFormat) (\s :: PutMetricStream
s@PutMetricStream' {} MetricStreamOutputFormat
a -> PutMetricStream
s {$sel:outputFormat:PutMetricStream' :: MetricStreamOutputFormat
outputFormat = MetricStreamOutputFormat
a} :: PutMetricStream)

instance Core.AWSRequest PutMetricStream where
  type
    AWSResponse PutMetricStream =
      PutMetricStreamResponse
  request :: PutMetricStream -> Request PutMetricStream
request = Service -> PutMetricStream -> Request PutMetricStream
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy PutMetricStream
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutMetricStream)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse PutMetricStream))
-> Logger
-> Service
-> Proxy PutMetricStream
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutMetricStream)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"PutMetricStreamResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text -> Int -> PutMetricStreamResponse
PutMetricStreamResponse'
            (Maybe Text -> Int -> PutMetricStreamResponse)
-> Either String (Maybe Text)
-> Either String (Int -> PutMetricStreamResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Arn")
            Either String (Int -> PutMetricStreamResponse)
-> Either String Int -> Either String PutMetricStreamResponse
forall (f :: * -> *) a b. Applicative f => 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 PutMetricStream

instance Prelude.NFData PutMetricStream

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

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

instance Core.ToQuery PutMetricStream where
  toQuery :: PutMetricStream -> QueryString
toQuery PutMetricStream' {Maybe [MetricStreamFilter]
Maybe [Tag]
Text
MetricStreamOutputFormat
outputFormat :: MetricStreamOutputFormat
roleArn :: Text
firehoseArn :: Text
name :: Text
tags :: Maybe [Tag]
excludeFilters :: Maybe [MetricStreamFilter]
includeFilters :: Maybe [MetricStreamFilter]
$sel:outputFormat:PutMetricStream' :: PutMetricStream -> MetricStreamOutputFormat
$sel:roleArn:PutMetricStream' :: PutMetricStream -> Text
$sel:firehoseArn:PutMetricStream' :: PutMetricStream -> Text
$sel:name:PutMetricStream' :: PutMetricStream -> Text
$sel:tags:PutMetricStream' :: PutMetricStream -> Maybe [Tag]
$sel:excludeFilters:PutMetricStream' :: PutMetricStream -> Maybe [MetricStreamFilter]
$sel:includeFilters:PutMetricStream' :: PutMetricStream -> Maybe [MetricStreamFilter]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"PutMetricStream" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-08-01" :: Prelude.ByteString),
        ByteString
"IncludeFilters"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString -> [MetricStreamFilter] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member"
                ([MetricStreamFilter] -> QueryString)
-> Maybe [MetricStreamFilter] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [MetricStreamFilter]
includeFilters
            ),
        ByteString
"ExcludeFilters"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString -> [MetricStreamFilter] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member"
                ([MetricStreamFilter] -> QueryString)
-> Maybe [MetricStreamFilter] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [MetricStreamFilter]
excludeFilters
            ),
        ByteString
"Tags"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Tag] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Tag] -> QueryString) -> Maybe [Tag] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags),
        ByteString
"Name" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
name,
        ByteString
"FirehoseArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
firehoseArn,
        ByteString
"RoleArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
roleArn,
        ByteString
"OutputFormat" ByteString -> MetricStreamOutputFormat -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: MetricStreamOutputFormat
outputFormat
      ]

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

-- |
-- Create a value of 'PutMetricStreamResponse' 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:
--
-- 'arn', 'putMetricStreamResponse_arn' - The ARN of the metric stream.
--
-- 'httpStatus', 'putMetricStreamResponse_httpStatus' - The response's http status code.
newPutMetricStreamResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutMetricStreamResponse
newPutMetricStreamResponse :: Int -> PutMetricStreamResponse
newPutMetricStreamResponse Int
pHttpStatus_ =
  PutMetricStreamResponse' :: Maybe Text -> Int -> PutMetricStreamResponse
PutMetricStreamResponse'
    { $sel:arn:PutMetricStreamResponse' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutMetricStreamResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the metric stream.
putMetricStreamResponse_arn :: Lens.Lens' PutMetricStreamResponse (Prelude.Maybe Prelude.Text)
putMetricStreamResponse_arn :: (Maybe Text -> f (Maybe Text))
-> PutMetricStreamResponse -> f PutMetricStreamResponse
putMetricStreamResponse_arn = (PutMetricStreamResponse -> Maybe Text)
-> (PutMetricStreamResponse
    -> Maybe Text -> PutMetricStreamResponse)
-> Lens
     PutMetricStreamResponse
     PutMetricStreamResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetricStreamResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:PutMetricStreamResponse' :: PutMetricStreamResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: PutMetricStreamResponse
s@PutMetricStreamResponse' {} Maybe Text
a -> PutMetricStreamResponse
s {$sel:arn:PutMetricStreamResponse' :: Maybe Text
arn = Maybe Text
a} :: PutMetricStreamResponse)

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

instance Prelude.NFData PutMetricStreamResponse