{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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/CloudWatch-Metric-Streams.html Using Metric Streams>.
--
-- To create a metric stream, you must be signed in 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@.
--
-- By default, a metric stream always sends the @MAX@, @MIN@, @SUM@, and
-- @SAMPLECOUNT@ statistics for each metric that is streamed. You can use
-- the @StatisticsConfigurations@ parameter to have the metric stream send
-- additional statistics in the stream. Streaming additional statistics
-- incurs additional costs. For more information, see
-- <https://aws.amazon.com/cloudwatch/pricing/ Amazon CloudWatch Pricing>.
--
-- 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_excludeFilters,
    putMetricStream_includeFilters,
    putMetricStream_statisticsConfigurations,
    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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 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],
    -- | 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],
    -- | By default, a metric stream always sends the @MAX@, @MIN@, @SUM@, and
    -- @SAMPLECOUNT@ statistics for each metric that is streamed. You can use
    -- this parameter to have the metric stream also send additional statistics
    -- in the stream. This array can have up to 100 members.
    --
    -- For each entry in this array, you specify one or more metrics and the
    -- list of additional statistics to stream for those metrics. The
    -- additional statistics that you can stream depend on the stream\'s
    -- @OutputFormat@. If the @OutputFormat@ is @json@, you can stream any
    -- additional statistic that is supported by CloudWatch, listed in
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Statistics-definitions.html.html CloudWatch statistics definitions>.
    -- If the @OutputFormat@ is @opentelemetry0.7@, you can stream percentile
    -- statistics such as p95, p99.9, and so on.
    PutMetricStream -> Maybe [MetricStreamStatisticsConfiguration]
statisticsConfigurations :: Prelude.Maybe [MetricStreamStatisticsConfiguration],
    -- | 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 Data Firehose delivery stream to use for
    -- this metric stream. This Amazon Kinesis Data 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 Data 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
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]
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
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. 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:
--
-- '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.
--
-- '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.
--
-- 'statisticsConfigurations', 'putMetricStream_statisticsConfigurations' - By default, a metric stream always sends the @MAX@, @MIN@, @SUM@, and
-- @SAMPLECOUNT@ statistics for each metric that is streamed. You can use
-- this parameter to have the metric stream also send additional statistics
-- in the stream. This array can have up to 100 members.
--
-- For each entry in this array, you specify one or more metrics and the
-- list of additional statistics to stream for those metrics. The
-- additional statistics that you can stream depend on the stream\'s
-- @OutputFormat@. If the @OutputFormat@ is @json@, you can stream any
-- additional statistic that is supported by CloudWatch, listed in
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Statistics-definitions.html.html CloudWatch statistics definitions>.
-- If the @OutputFormat@ is @opentelemetry0.7@, you can stream percentile
-- statistics such as p95, p99.9, and so on.
--
-- '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 Data Firehose delivery stream to use for
-- this metric stream. This Amazon Kinesis Data 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 Data 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'
      { $sel:excludeFilters:PutMetricStream' :: Maybe [MetricStreamFilter]
excludeFilters = forall a. Maybe a
Prelude.Nothing,
        $sel:includeFilters:PutMetricStream' :: Maybe [MetricStreamFilter]
includeFilters = forall a. Maybe a
Prelude.Nothing,
        $sel:statisticsConfigurations:PutMetricStream' :: Maybe [MetricStreamStatisticsConfiguration]
statisticsConfigurations = forall a. Maybe a
Prelude.Nothing,
        $sel:tags:PutMetricStream' :: Maybe [Tag]
tags = 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 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 :: Lens' PutMetricStream (Maybe [MetricStreamFilter])
putMetricStream_excludeFilters = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 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 :: Lens' PutMetricStream (Maybe [MetricStreamFilter])
putMetricStream_includeFilters = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | By default, a metric stream always sends the @MAX@, @MIN@, @SUM@, and
-- @SAMPLECOUNT@ statistics for each metric that is streamed. You can use
-- this parameter to have the metric stream also send additional statistics
-- in the stream. This array can have up to 100 members.
--
-- For each entry in this array, you specify one or more metrics and the
-- list of additional statistics to stream for those metrics. The
-- additional statistics that you can stream depend on the stream\'s
-- @OutputFormat@. If the @OutputFormat@ is @json@, you can stream any
-- additional statistic that is supported by CloudWatch, listed in
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Statistics-definitions.html.html CloudWatch statistics definitions>.
-- If the @OutputFormat@ is @opentelemetry0.7@, you can stream percentile
-- statistics such as p95, p99.9, and so on.
putMetricStream_statisticsConfigurations :: Lens.Lens' PutMetricStream (Prelude.Maybe [MetricStreamStatisticsConfiguration])
putMetricStream_statisticsConfigurations :: Lens' PutMetricStream (Maybe [MetricStreamStatisticsConfiguration])
putMetricStream_statisticsConfigurations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetricStream' {Maybe [MetricStreamStatisticsConfiguration]
statisticsConfigurations :: Maybe [MetricStreamStatisticsConfiguration]
$sel:statisticsConfigurations:PutMetricStream' :: PutMetricStream -> Maybe [MetricStreamStatisticsConfiguration]
statisticsConfigurations} -> Maybe [MetricStreamStatisticsConfiguration]
statisticsConfigurations) (\s :: PutMetricStream
s@PutMetricStream' {} Maybe [MetricStreamStatisticsConfiguration]
a -> PutMetricStream
s {$sel:statisticsConfigurations:PutMetricStream' :: Maybe [MetricStreamStatisticsConfiguration]
statisticsConfigurations = Maybe [MetricStreamStatisticsConfiguration]
a} :: PutMetricStream) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' PutMetricStream (Maybe [Tag])
putMetricStream_tags = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' PutMetricStream Text
putMetricStream_name = 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 Data Firehose delivery stream to use for
-- this metric stream. This Amazon Kinesis Data 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 :: Lens' PutMetricStream Text
putMetricStream_firehoseArn = 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 Data 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 :: Lens' PutMetricStream Text
putMetricStream_roleArn = 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 :: Lens' PutMetricStream MetricStreamOutputFormat
putMetricStream_outputFormat = 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 :: (Service -> Service) -> PutMetricStream -> Request PutMetricStream
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PutMetricStream
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutMetricStream)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> 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'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Arn")
            forall (f :: * -> *) a b. Applicative f => 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 PutMetricStream where
  hashWithSalt :: Int -> PutMetricStream -> Int
hashWithSalt Int
_salt PutMetricStream' {Maybe [MetricStreamFilter]
Maybe [MetricStreamStatisticsConfiguration]
Maybe [Tag]
Text
MetricStreamOutputFormat
outputFormat :: MetricStreamOutputFormat
roleArn :: Text
firehoseArn :: Text
name :: Text
tags :: Maybe [Tag]
statisticsConfigurations :: Maybe [MetricStreamStatisticsConfiguration]
includeFilters :: Maybe [MetricStreamFilter]
excludeFilters :: 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:statisticsConfigurations:PutMetricStream' :: PutMetricStream -> Maybe [MetricStreamStatisticsConfiguration]
$sel:includeFilters:PutMetricStream' :: PutMetricStream -> Maybe [MetricStreamFilter]
$sel:excludeFilters:PutMetricStream' :: PutMetricStream -> Maybe [MetricStreamFilter]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [MetricStreamFilter]
excludeFilters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [MetricStreamFilter]
includeFilters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [MetricStreamStatisticsConfiguration]
statisticsConfigurations
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
firehoseArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` MetricStreamOutputFormat
outputFormat

instance Prelude.NFData PutMetricStream where
  rnf :: PutMetricStream -> ()
rnf PutMetricStream' {Maybe [MetricStreamFilter]
Maybe [MetricStreamStatisticsConfiguration]
Maybe [Tag]
Text
MetricStreamOutputFormat
outputFormat :: MetricStreamOutputFormat
roleArn :: Text
firehoseArn :: Text
name :: Text
tags :: Maybe [Tag]
statisticsConfigurations :: Maybe [MetricStreamStatisticsConfiguration]
includeFilters :: Maybe [MetricStreamFilter]
excludeFilters :: 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:statisticsConfigurations:PutMetricStream' :: PutMetricStream -> Maybe [MetricStreamStatisticsConfiguration]
$sel:includeFilters:PutMetricStream' :: PutMetricStream -> Maybe [MetricStreamFilter]
$sel:excludeFilters:PutMetricStream' :: PutMetricStream -> Maybe [MetricStreamFilter]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [MetricStreamFilter]
excludeFilters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [MetricStreamFilter]
includeFilters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [MetricStreamStatisticsConfiguration]
statisticsConfigurations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
firehoseArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
roleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf MetricStreamOutputFormat
outputFormat

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

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

instance Data.ToQuery PutMetricStream where
  toQuery :: PutMetricStream -> QueryString
toQuery PutMetricStream' {Maybe [MetricStreamFilter]
Maybe [MetricStreamStatisticsConfiguration]
Maybe [Tag]
Text
MetricStreamOutputFormat
outputFormat :: MetricStreamOutputFormat
roleArn :: Text
firehoseArn :: Text
name :: Text
tags :: Maybe [Tag]
statisticsConfigurations :: Maybe [MetricStreamStatisticsConfiguration]
includeFilters :: Maybe [MetricStreamFilter]
excludeFilters :: 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:statisticsConfigurations:PutMetricStream' :: PutMetricStream -> Maybe [MetricStreamStatisticsConfiguration]
$sel:includeFilters:PutMetricStream' :: PutMetricStream -> Maybe [MetricStreamFilter]
$sel:excludeFilters:PutMetricStream' :: PutMetricStream -> Maybe [MetricStreamFilter]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"PutMetricStream" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-08-01" :: Prelude.ByteString),
        ByteString
"ExcludeFilters"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member"
                forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [MetricStreamFilter]
excludeFilters
            ),
        ByteString
"IncludeFilters"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member"
                forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [MetricStreamFilter]
includeFilters
            ),
        ByteString
"StatisticsConfigurations"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member"
                forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [MetricStreamStatisticsConfiguration]
statisticsConfigurations
            ),
        ByteString
"Tags"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags),
        ByteString
"Name" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
name,
        ByteString
"FirehoseArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
firehoseArn,
        ByteString
"RoleArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
roleArn,
        ByteString
"OutputFormat" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: 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
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]
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
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. 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'
    { $sel:arn:PutMetricStreamResponse' :: Maybe Text
arn = 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 :: Lens' PutMetricStreamResponse (Maybe Text)
putMetricStreamResponse_arn = 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 :: Lens' PutMetricStreamResponse Int
putMetricStreamResponse_httpStatus = 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 where
  rnf :: PutMetricStreamResponse -> ()
rnf PutMetricStreamResponse' {Int
Maybe Text
httpStatus :: Int
arn :: Maybe Text
$sel:httpStatus:PutMetricStreamResponse' :: PutMetricStreamResponse -> Int
$sel:arn:PutMetricStreamResponse' :: PutMetricStreamResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus