{-# 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.SES.Types.CloudWatchDimensionConfiguration
-- 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.SES.Types.CloudWatchDimensionConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SES.Types.DimensionValueSource

-- | Contains the dimension configuration to use when you publish email
-- sending events to Amazon CloudWatch.
--
-- For information about publishing email sending events to Amazon
-- CloudWatch, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/monitor-sending-activity.html Amazon SES Developer Guide>.
--
-- /See:/ 'newCloudWatchDimensionConfiguration' smart constructor.
data CloudWatchDimensionConfiguration = CloudWatchDimensionConfiguration'
  { -- | The name of an Amazon CloudWatch dimension associated with an email
    -- sending metric. The name must:
    --
    -- -   This value can only contain ASCII letters (a-z, A-Z), numbers (0-9),
    --     underscores (_), or dashes (-).
    --
    -- -   Contain less than 256 characters.
    CloudWatchDimensionConfiguration -> Text
dimensionName :: Prelude.Text,
    -- | The place where Amazon SES finds the value of a dimension to publish to
    -- Amazon CloudWatch. If you want Amazon SES to use the message tags that
    -- you specify using an @X-SES-MESSAGE-TAGS@ header or a parameter to the
    -- @SendEmail@\/@SendRawEmail@ API, choose @messageTag@. If you want Amazon
    -- SES to use your own email headers, choose @emailHeader@.
    CloudWatchDimensionConfiguration -> DimensionValueSource
dimensionValueSource :: DimensionValueSource,
    -- | The default value of the dimension that is published to Amazon
    -- CloudWatch if you do not provide the value of the dimension when you
    -- send an email. The default value must:
    --
    -- -   This value can only contain ASCII letters (a-z, A-Z), numbers (0-9),
    --     underscores (_), or dashes (-).
    --
    -- -   Contain less than 256 characters.
    CloudWatchDimensionConfiguration -> Text
defaultDimensionValue :: Prelude.Text
  }
  deriving (CloudWatchDimensionConfiguration
-> CloudWatchDimensionConfiguration -> Bool
(CloudWatchDimensionConfiguration
 -> CloudWatchDimensionConfiguration -> Bool)
-> (CloudWatchDimensionConfiguration
    -> CloudWatchDimensionConfiguration -> Bool)
-> Eq CloudWatchDimensionConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CloudWatchDimensionConfiguration
-> CloudWatchDimensionConfiguration -> Bool
$c/= :: CloudWatchDimensionConfiguration
-> CloudWatchDimensionConfiguration -> Bool
== :: CloudWatchDimensionConfiguration
-> CloudWatchDimensionConfiguration -> Bool
$c== :: CloudWatchDimensionConfiguration
-> CloudWatchDimensionConfiguration -> Bool
Prelude.Eq, ReadPrec [CloudWatchDimensionConfiguration]
ReadPrec CloudWatchDimensionConfiguration
Int -> ReadS CloudWatchDimensionConfiguration
ReadS [CloudWatchDimensionConfiguration]
(Int -> ReadS CloudWatchDimensionConfiguration)
-> ReadS [CloudWatchDimensionConfiguration]
-> ReadPrec CloudWatchDimensionConfiguration
-> ReadPrec [CloudWatchDimensionConfiguration]
-> Read CloudWatchDimensionConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CloudWatchDimensionConfiguration]
$creadListPrec :: ReadPrec [CloudWatchDimensionConfiguration]
readPrec :: ReadPrec CloudWatchDimensionConfiguration
$creadPrec :: ReadPrec CloudWatchDimensionConfiguration
readList :: ReadS [CloudWatchDimensionConfiguration]
$creadList :: ReadS [CloudWatchDimensionConfiguration]
readsPrec :: Int -> ReadS CloudWatchDimensionConfiguration
$creadsPrec :: Int -> ReadS CloudWatchDimensionConfiguration
Prelude.Read, Int -> CloudWatchDimensionConfiguration -> ShowS
[CloudWatchDimensionConfiguration] -> ShowS
CloudWatchDimensionConfiguration -> String
(Int -> CloudWatchDimensionConfiguration -> ShowS)
-> (CloudWatchDimensionConfiguration -> String)
-> ([CloudWatchDimensionConfiguration] -> ShowS)
-> Show CloudWatchDimensionConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CloudWatchDimensionConfiguration] -> ShowS
$cshowList :: [CloudWatchDimensionConfiguration] -> ShowS
show :: CloudWatchDimensionConfiguration -> String
$cshow :: CloudWatchDimensionConfiguration -> String
showsPrec :: Int -> CloudWatchDimensionConfiguration -> ShowS
$cshowsPrec :: Int -> CloudWatchDimensionConfiguration -> ShowS
Prelude.Show, (forall x.
 CloudWatchDimensionConfiguration
 -> Rep CloudWatchDimensionConfiguration x)
-> (forall x.
    Rep CloudWatchDimensionConfiguration x
    -> CloudWatchDimensionConfiguration)
-> Generic CloudWatchDimensionConfiguration
forall x.
Rep CloudWatchDimensionConfiguration x
-> CloudWatchDimensionConfiguration
forall x.
CloudWatchDimensionConfiguration
-> Rep CloudWatchDimensionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CloudWatchDimensionConfiguration x
-> CloudWatchDimensionConfiguration
$cfrom :: forall x.
CloudWatchDimensionConfiguration
-> Rep CloudWatchDimensionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'CloudWatchDimensionConfiguration' 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:
--
-- 'dimensionName', 'cloudWatchDimensionConfiguration_dimensionName' - The name of an Amazon CloudWatch dimension associated with an email
-- sending metric. The name must:
--
-- -   This value can only contain ASCII letters (a-z, A-Z), numbers (0-9),
--     underscores (_), or dashes (-).
--
-- -   Contain less than 256 characters.
--
-- 'dimensionValueSource', 'cloudWatchDimensionConfiguration_dimensionValueSource' - The place where Amazon SES finds the value of a dimension to publish to
-- Amazon CloudWatch. If you want Amazon SES to use the message tags that
-- you specify using an @X-SES-MESSAGE-TAGS@ header or a parameter to the
-- @SendEmail@\/@SendRawEmail@ API, choose @messageTag@. If you want Amazon
-- SES to use your own email headers, choose @emailHeader@.
--
-- 'defaultDimensionValue', 'cloudWatchDimensionConfiguration_defaultDimensionValue' - The default value of the dimension that is published to Amazon
-- CloudWatch if you do not provide the value of the dimension when you
-- send an email. The default value must:
--
-- -   This value can only contain ASCII letters (a-z, A-Z), numbers (0-9),
--     underscores (_), or dashes (-).
--
-- -   Contain less than 256 characters.
newCloudWatchDimensionConfiguration ::
  -- | 'dimensionName'
  Prelude.Text ->
  -- | 'dimensionValueSource'
  DimensionValueSource ->
  -- | 'defaultDimensionValue'
  Prelude.Text ->
  CloudWatchDimensionConfiguration
newCloudWatchDimensionConfiguration :: Text
-> DimensionValueSource -> Text -> CloudWatchDimensionConfiguration
newCloudWatchDimensionConfiguration
  Text
pDimensionName_
  DimensionValueSource
pDimensionValueSource_
  Text
pDefaultDimensionValue_ =
    CloudWatchDimensionConfiguration' :: Text
-> DimensionValueSource -> Text -> CloudWatchDimensionConfiguration
CloudWatchDimensionConfiguration'
      { $sel:dimensionName:CloudWatchDimensionConfiguration' :: Text
dimensionName =
          Text
pDimensionName_,
        $sel:dimensionValueSource:CloudWatchDimensionConfiguration' :: DimensionValueSource
dimensionValueSource =
          DimensionValueSource
pDimensionValueSource_,
        $sel:defaultDimensionValue:CloudWatchDimensionConfiguration' :: Text
defaultDimensionValue =
          Text
pDefaultDimensionValue_
      }

-- | The name of an Amazon CloudWatch dimension associated with an email
-- sending metric. The name must:
--
-- -   This value can only contain ASCII letters (a-z, A-Z), numbers (0-9),
--     underscores (_), or dashes (-).
--
-- -   Contain less than 256 characters.
cloudWatchDimensionConfiguration_dimensionName :: Lens.Lens' CloudWatchDimensionConfiguration Prelude.Text
cloudWatchDimensionConfiguration_dimensionName :: (Text -> f Text)
-> CloudWatchDimensionConfiguration
-> f CloudWatchDimensionConfiguration
cloudWatchDimensionConfiguration_dimensionName = (CloudWatchDimensionConfiguration -> Text)
-> (CloudWatchDimensionConfiguration
    -> Text -> CloudWatchDimensionConfiguration)
-> Lens
     CloudWatchDimensionConfiguration
     CloudWatchDimensionConfiguration
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchDimensionConfiguration' {Text
dimensionName :: Text
$sel:dimensionName:CloudWatchDimensionConfiguration' :: CloudWatchDimensionConfiguration -> Text
dimensionName} -> Text
dimensionName) (\s :: CloudWatchDimensionConfiguration
s@CloudWatchDimensionConfiguration' {} Text
a -> CloudWatchDimensionConfiguration
s {$sel:dimensionName:CloudWatchDimensionConfiguration' :: Text
dimensionName = Text
a} :: CloudWatchDimensionConfiguration)

-- | The place where Amazon SES finds the value of a dimension to publish to
-- Amazon CloudWatch. If you want Amazon SES to use the message tags that
-- you specify using an @X-SES-MESSAGE-TAGS@ header or a parameter to the
-- @SendEmail@\/@SendRawEmail@ API, choose @messageTag@. If you want Amazon
-- SES to use your own email headers, choose @emailHeader@.
cloudWatchDimensionConfiguration_dimensionValueSource :: Lens.Lens' CloudWatchDimensionConfiguration DimensionValueSource
cloudWatchDimensionConfiguration_dimensionValueSource :: (DimensionValueSource -> f DimensionValueSource)
-> CloudWatchDimensionConfiguration
-> f CloudWatchDimensionConfiguration
cloudWatchDimensionConfiguration_dimensionValueSource = (CloudWatchDimensionConfiguration -> DimensionValueSource)
-> (CloudWatchDimensionConfiguration
    -> DimensionValueSource -> CloudWatchDimensionConfiguration)
-> Lens
     CloudWatchDimensionConfiguration
     CloudWatchDimensionConfiguration
     DimensionValueSource
     DimensionValueSource
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchDimensionConfiguration' {DimensionValueSource
dimensionValueSource :: DimensionValueSource
$sel:dimensionValueSource:CloudWatchDimensionConfiguration' :: CloudWatchDimensionConfiguration -> DimensionValueSource
dimensionValueSource} -> DimensionValueSource
dimensionValueSource) (\s :: CloudWatchDimensionConfiguration
s@CloudWatchDimensionConfiguration' {} DimensionValueSource
a -> CloudWatchDimensionConfiguration
s {$sel:dimensionValueSource:CloudWatchDimensionConfiguration' :: DimensionValueSource
dimensionValueSource = DimensionValueSource
a} :: CloudWatchDimensionConfiguration)

-- | The default value of the dimension that is published to Amazon
-- CloudWatch if you do not provide the value of the dimension when you
-- send an email. The default value must:
--
-- -   This value can only contain ASCII letters (a-z, A-Z), numbers (0-9),
--     underscores (_), or dashes (-).
--
-- -   Contain less than 256 characters.
cloudWatchDimensionConfiguration_defaultDimensionValue :: Lens.Lens' CloudWatchDimensionConfiguration Prelude.Text
cloudWatchDimensionConfiguration_defaultDimensionValue :: (Text -> f Text)
-> CloudWatchDimensionConfiguration
-> f CloudWatchDimensionConfiguration
cloudWatchDimensionConfiguration_defaultDimensionValue = (CloudWatchDimensionConfiguration -> Text)
-> (CloudWatchDimensionConfiguration
    -> Text -> CloudWatchDimensionConfiguration)
-> Lens
     CloudWatchDimensionConfiguration
     CloudWatchDimensionConfiguration
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchDimensionConfiguration' {Text
defaultDimensionValue :: Text
$sel:defaultDimensionValue:CloudWatchDimensionConfiguration' :: CloudWatchDimensionConfiguration -> Text
defaultDimensionValue} -> Text
defaultDimensionValue) (\s :: CloudWatchDimensionConfiguration
s@CloudWatchDimensionConfiguration' {} Text
a -> CloudWatchDimensionConfiguration
s {$sel:defaultDimensionValue:CloudWatchDimensionConfiguration' :: Text
defaultDimensionValue = Text
a} :: CloudWatchDimensionConfiguration)

instance
  Core.FromXML
    CloudWatchDimensionConfiguration
  where
  parseXML :: [Node] -> Either String CloudWatchDimensionConfiguration
parseXML [Node]
x =
    Text
-> DimensionValueSource -> Text -> CloudWatchDimensionConfiguration
CloudWatchDimensionConfiguration'
      (Text
 -> DimensionValueSource
 -> Text
 -> CloudWatchDimensionConfiguration)
-> Either String Text
-> Either
     String
     (DimensionValueSource -> Text -> CloudWatchDimensionConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"DimensionName")
      Either
  String
  (DimensionValueSource -> Text -> CloudWatchDimensionConfiguration)
-> Either String DimensionValueSource
-> Either String (Text -> CloudWatchDimensionConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String DimensionValueSource
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"DimensionValueSource")
      Either String (Text -> CloudWatchDimensionConfiguration)
-> Either String Text
-> Either String CloudWatchDimensionConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"DefaultDimensionValue")

instance
  Prelude.Hashable
    CloudWatchDimensionConfiguration

instance
  Prelude.NFData
    CloudWatchDimensionConfiguration

instance
  Core.ToQuery
    CloudWatchDimensionConfiguration
  where
  toQuery :: CloudWatchDimensionConfiguration -> QueryString
toQuery CloudWatchDimensionConfiguration' {Text
DimensionValueSource
defaultDimensionValue :: Text
dimensionValueSource :: DimensionValueSource
dimensionName :: Text
$sel:defaultDimensionValue:CloudWatchDimensionConfiguration' :: CloudWatchDimensionConfiguration -> Text
$sel:dimensionValueSource:CloudWatchDimensionConfiguration' :: CloudWatchDimensionConfiguration -> DimensionValueSource
$sel:dimensionName:CloudWatchDimensionConfiguration' :: CloudWatchDimensionConfiguration -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"DimensionName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
dimensionName,
        ByteString
"DimensionValueSource" ByteString -> DimensionValueSource -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: DimensionValueSource
dimensionValueSource,
        ByteString
"DefaultDimensionValue"
          ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
defaultDimensionValue
      ]