{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.MetricStreamEntry
-- 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)
module Amazonka.CloudWatch.Types.MetricStreamEntry where

import Amazonka.CloudWatch.Types.MetricStreamOutputFormat
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | This structure contains the configuration information about one metric
-- stream.
--
-- /See:/ 'newMetricStreamEntry' smart constructor.
data MetricStreamEntry = MetricStreamEntry'
  { -- | The current state of this stream. Valid values are @running@ and
    -- @stopped@.
    MetricStreamEntry -> Maybe Text
state :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the metric stream.
    MetricStreamEntry -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the Kinesis Firehose devlivery stream that is used for this
    -- metric stream.
    MetricStreamEntry -> Maybe Text
firehoseArn :: Prelude.Maybe Prelude.Text,
    -- | The output format of this metric stream. Valid values are @json@ and
    -- @opentelemetry0.7@.
    MetricStreamEntry -> Maybe MetricStreamOutputFormat
outputFormat :: Prelude.Maybe MetricStreamOutputFormat,
    -- | The date that the configuration of this metric stream was most recently
    -- updated.
    MetricStreamEntry -> Maybe ISO8601
lastUpdateDate :: Prelude.Maybe Core.ISO8601,
    -- | The name of the metric stream.
    MetricStreamEntry -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The date that the metric stream was originally created.
    MetricStreamEntry -> Maybe ISO8601
creationDate :: Prelude.Maybe Core.ISO8601
  }
  deriving (MetricStreamEntry -> MetricStreamEntry -> Bool
(MetricStreamEntry -> MetricStreamEntry -> Bool)
-> (MetricStreamEntry -> MetricStreamEntry -> Bool)
-> Eq MetricStreamEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricStreamEntry -> MetricStreamEntry -> Bool
$c/= :: MetricStreamEntry -> MetricStreamEntry -> Bool
== :: MetricStreamEntry -> MetricStreamEntry -> Bool
$c== :: MetricStreamEntry -> MetricStreamEntry -> Bool
Prelude.Eq, ReadPrec [MetricStreamEntry]
ReadPrec MetricStreamEntry
Int -> ReadS MetricStreamEntry
ReadS [MetricStreamEntry]
(Int -> ReadS MetricStreamEntry)
-> ReadS [MetricStreamEntry]
-> ReadPrec MetricStreamEntry
-> ReadPrec [MetricStreamEntry]
-> Read MetricStreamEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricStreamEntry]
$creadListPrec :: ReadPrec [MetricStreamEntry]
readPrec :: ReadPrec MetricStreamEntry
$creadPrec :: ReadPrec MetricStreamEntry
readList :: ReadS [MetricStreamEntry]
$creadList :: ReadS [MetricStreamEntry]
readsPrec :: Int -> ReadS MetricStreamEntry
$creadsPrec :: Int -> ReadS MetricStreamEntry
Prelude.Read, Int -> MetricStreamEntry -> ShowS
[MetricStreamEntry] -> ShowS
MetricStreamEntry -> String
(Int -> MetricStreamEntry -> ShowS)
-> (MetricStreamEntry -> String)
-> ([MetricStreamEntry] -> ShowS)
-> Show MetricStreamEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricStreamEntry] -> ShowS
$cshowList :: [MetricStreamEntry] -> ShowS
show :: MetricStreamEntry -> String
$cshow :: MetricStreamEntry -> String
showsPrec :: Int -> MetricStreamEntry -> ShowS
$cshowsPrec :: Int -> MetricStreamEntry -> ShowS
Prelude.Show, (forall x. MetricStreamEntry -> Rep MetricStreamEntry x)
-> (forall x. Rep MetricStreamEntry x -> MetricStreamEntry)
-> Generic MetricStreamEntry
forall x. Rep MetricStreamEntry x -> MetricStreamEntry
forall x. MetricStreamEntry -> Rep MetricStreamEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricStreamEntry x -> MetricStreamEntry
$cfrom :: forall x. MetricStreamEntry -> Rep MetricStreamEntry x
Prelude.Generic)

-- |
-- Create a value of 'MetricStreamEntry' 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:
--
-- 'state', 'metricStreamEntry_state' - The current state of this stream. Valid values are @running@ and
-- @stopped@.
--
-- 'arn', 'metricStreamEntry_arn' - The ARN of the metric stream.
--
-- 'firehoseArn', 'metricStreamEntry_firehoseArn' - The ARN of the Kinesis Firehose devlivery stream that is used for this
-- metric stream.
--
-- 'outputFormat', 'metricStreamEntry_outputFormat' - The output format of this metric stream. Valid values are @json@ and
-- @opentelemetry0.7@.
--
-- 'lastUpdateDate', 'metricStreamEntry_lastUpdateDate' - The date that the configuration of this metric stream was most recently
-- updated.
--
-- 'name', 'metricStreamEntry_name' - The name of the metric stream.
--
-- 'creationDate', 'metricStreamEntry_creationDate' - The date that the metric stream was originally created.
newMetricStreamEntry ::
  MetricStreamEntry
newMetricStreamEntry :: MetricStreamEntry
newMetricStreamEntry =
  MetricStreamEntry' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe MetricStreamOutputFormat
-> Maybe ISO8601
-> Maybe Text
-> Maybe ISO8601
-> MetricStreamEntry
MetricStreamEntry'
    { $sel:state:MetricStreamEntry' :: Maybe Text
state = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:MetricStreamEntry' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:firehoseArn:MetricStreamEntry' :: Maybe Text
firehoseArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:outputFormat:MetricStreamEntry' :: Maybe MetricStreamOutputFormat
outputFormat = Maybe MetricStreamOutputFormat
forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdateDate:MetricStreamEntry' :: Maybe ISO8601
lastUpdateDate = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing,
      $sel:name:MetricStreamEntry' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationDate:MetricStreamEntry' :: Maybe ISO8601
creationDate = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing
    }

-- | The current state of this stream. Valid values are @running@ and
-- @stopped@.
metricStreamEntry_state :: Lens.Lens' MetricStreamEntry (Prelude.Maybe Prelude.Text)
metricStreamEntry_state :: (Maybe Text -> f (Maybe Text))
-> MetricStreamEntry -> f MetricStreamEntry
metricStreamEntry_state = (MetricStreamEntry -> Maybe Text)
-> (MetricStreamEntry -> Maybe Text -> MetricStreamEntry)
-> Lens
     MetricStreamEntry MetricStreamEntry (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricStreamEntry' {Maybe Text
state :: Maybe Text
$sel:state:MetricStreamEntry' :: MetricStreamEntry -> Maybe Text
state} -> Maybe Text
state) (\s :: MetricStreamEntry
s@MetricStreamEntry' {} Maybe Text
a -> MetricStreamEntry
s {$sel:state:MetricStreamEntry' :: Maybe Text
state = Maybe Text
a} :: MetricStreamEntry)

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

-- | The ARN of the Kinesis Firehose devlivery stream that is used for this
-- metric stream.
metricStreamEntry_firehoseArn :: Lens.Lens' MetricStreamEntry (Prelude.Maybe Prelude.Text)
metricStreamEntry_firehoseArn :: (Maybe Text -> f (Maybe Text))
-> MetricStreamEntry -> f MetricStreamEntry
metricStreamEntry_firehoseArn = (MetricStreamEntry -> Maybe Text)
-> (MetricStreamEntry -> Maybe Text -> MetricStreamEntry)
-> Lens
     MetricStreamEntry MetricStreamEntry (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricStreamEntry' {Maybe Text
firehoseArn :: Maybe Text
$sel:firehoseArn:MetricStreamEntry' :: MetricStreamEntry -> Maybe Text
firehoseArn} -> Maybe Text
firehoseArn) (\s :: MetricStreamEntry
s@MetricStreamEntry' {} Maybe Text
a -> MetricStreamEntry
s {$sel:firehoseArn:MetricStreamEntry' :: Maybe Text
firehoseArn = Maybe Text
a} :: MetricStreamEntry)

-- | The output format of this metric stream. Valid values are @json@ and
-- @opentelemetry0.7@.
metricStreamEntry_outputFormat :: Lens.Lens' MetricStreamEntry (Prelude.Maybe MetricStreamOutputFormat)
metricStreamEntry_outputFormat :: (Maybe MetricStreamOutputFormat
 -> f (Maybe MetricStreamOutputFormat))
-> MetricStreamEntry -> f MetricStreamEntry
metricStreamEntry_outputFormat = (MetricStreamEntry -> Maybe MetricStreamOutputFormat)
-> (MetricStreamEntry
    -> Maybe MetricStreamOutputFormat -> MetricStreamEntry)
-> Lens
     MetricStreamEntry
     MetricStreamEntry
     (Maybe MetricStreamOutputFormat)
     (Maybe MetricStreamOutputFormat)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricStreamEntry' {Maybe MetricStreamOutputFormat
outputFormat :: Maybe MetricStreamOutputFormat
$sel:outputFormat:MetricStreamEntry' :: MetricStreamEntry -> Maybe MetricStreamOutputFormat
outputFormat} -> Maybe MetricStreamOutputFormat
outputFormat) (\s :: MetricStreamEntry
s@MetricStreamEntry' {} Maybe MetricStreamOutputFormat
a -> MetricStreamEntry
s {$sel:outputFormat:MetricStreamEntry' :: Maybe MetricStreamOutputFormat
outputFormat = Maybe MetricStreamOutputFormat
a} :: MetricStreamEntry)

-- | The date that the configuration of this metric stream was most recently
-- updated.
metricStreamEntry_lastUpdateDate :: Lens.Lens' MetricStreamEntry (Prelude.Maybe Prelude.UTCTime)
metricStreamEntry_lastUpdateDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> MetricStreamEntry -> f MetricStreamEntry
metricStreamEntry_lastUpdateDate = (MetricStreamEntry -> Maybe ISO8601)
-> (MetricStreamEntry -> Maybe ISO8601 -> MetricStreamEntry)
-> Lens
     MetricStreamEntry MetricStreamEntry (Maybe ISO8601) (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricStreamEntry' {Maybe ISO8601
lastUpdateDate :: Maybe ISO8601
$sel:lastUpdateDate:MetricStreamEntry' :: MetricStreamEntry -> Maybe ISO8601
lastUpdateDate} -> Maybe ISO8601
lastUpdateDate) (\s :: MetricStreamEntry
s@MetricStreamEntry' {} Maybe ISO8601
a -> MetricStreamEntry
s {$sel:lastUpdateDate:MetricStreamEntry' :: Maybe ISO8601
lastUpdateDate = Maybe ISO8601
a} :: MetricStreamEntry) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> MetricStreamEntry -> f MetricStreamEntry)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> MetricStreamEntry
-> f MetricStreamEntry
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (Maybe UTCTime) (Maybe UTCTime)
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 ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

-- | The date that the metric stream was originally created.
metricStreamEntry_creationDate :: Lens.Lens' MetricStreamEntry (Prelude.Maybe Prelude.UTCTime)
metricStreamEntry_creationDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> MetricStreamEntry -> f MetricStreamEntry
metricStreamEntry_creationDate = (MetricStreamEntry -> Maybe ISO8601)
-> (MetricStreamEntry -> Maybe ISO8601 -> MetricStreamEntry)
-> Lens
     MetricStreamEntry MetricStreamEntry (Maybe ISO8601) (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricStreamEntry' {Maybe ISO8601
creationDate :: Maybe ISO8601
$sel:creationDate:MetricStreamEntry' :: MetricStreamEntry -> Maybe ISO8601
creationDate} -> Maybe ISO8601
creationDate) (\s :: MetricStreamEntry
s@MetricStreamEntry' {} Maybe ISO8601
a -> MetricStreamEntry
s {$sel:creationDate:MetricStreamEntry' :: Maybe ISO8601
creationDate = Maybe ISO8601
a} :: MetricStreamEntry) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> MetricStreamEntry -> f MetricStreamEntry)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> MetricStreamEntry
-> f MetricStreamEntry
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (Maybe UTCTime) (Maybe UTCTime)
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 ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromXML MetricStreamEntry where
  parseXML :: [Node] -> Either String MetricStreamEntry
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe MetricStreamOutputFormat
-> Maybe ISO8601
-> Maybe Text
-> Maybe ISO8601
-> MetricStreamEntry
MetricStreamEntry'
      (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe MetricStreamOutputFormat
 -> Maybe ISO8601
 -> Maybe Text
 -> Maybe ISO8601
 -> MetricStreamEntry)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe MetricStreamOutputFormat
      -> Maybe ISO8601
      -> Maybe Text
      -> Maybe ISO8601
      -> MetricStreamEntry)
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
"State")
      Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe MetricStreamOutputFormat
   -> Maybe ISO8601
   -> Maybe Text
   -> Maybe ISO8601
   -> MetricStreamEntry)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe MetricStreamOutputFormat
      -> Maybe ISO8601
      -> Maybe Text
      -> Maybe ISO8601
      -> MetricStreamEntry)
forall (f :: * -> *) a b. Applicative f => 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
  (Maybe Text
   -> Maybe MetricStreamOutputFormat
   -> Maybe ISO8601
   -> Maybe Text
   -> Maybe ISO8601
   -> MetricStreamEntry)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe MetricStreamOutputFormat
      -> Maybe ISO8601
      -> Maybe Text
      -> Maybe ISO8601
      -> MetricStreamEntry)
forall (f :: * -> *) a b. Applicative f => 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
"FirehoseArn")
      Either
  String
  (Maybe MetricStreamOutputFormat
   -> Maybe ISO8601
   -> Maybe Text
   -> Maybe ISO8601
   -> MetricStreamEntry)
-> Either String (Maybe MetricStreamOutputFormat)
-> Either
     String
     (Maybe ISO8601 -> Maybe Text -> Maybe ISO8601 -> MetricStreamEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe MetricStreamOutputFormat)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"OutputFormat")
      Either
  String
  (Maybe ISO8601 -> Maybe Text -> Maybe ISO8601 -> MetricStreamEntry)
-> Either String (Maybe ISO8601)
-> Either String (Maybe Text -> Maybe ISO8601 -> MetricStreamEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"LastUpdateDate")
      Either String (Maybe Text -> Maybe ISO8601 -> MetricStreamEntry)
-> Either String (Maybe Text)
-> Either String (Maybe ISO8601 -> MetricStreamEntry)
forall (f :: * -> *) a b. Applicative f => 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
"Name")
      Either String (Maybe ISO8601 -> MetricStreamEntry)
-> Either String (Maybe ISO8601) -> Either String MetricStreamEntry
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CreationDate")

instance Prelude.Hashable MetricStreamEntry

instance Prelude.NFData MetricStreamEntry