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

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

-- | An object that defines the dimension configuration to use when you send
-- email events to Amazon CloudWatch.
--
-- /See:/ 'newCloudWatchDimensionConfiguration' smart constructor.
data CloudWatchDimensionConfiguration = CloudWatchDimensionConfiguration'
  { -- | The name of an Amazon CloudWatch dimension associated with an email
    -- sending metric. The name has to meet the following criteria:
    --
    -- -   It can only contain ASCII letters (a–z, A–Z), numbers (0–9),
    --     underscores (_), or dashes (-).
    --
    -- -   It can contain no more than 256 characters.
    CloudWatchDimensionConfiguration -> Text
dimensionName :: Prelude.Text,
    -- | The location where the Amazon SES API v2 finds the value of a dimension
    -- to publish to Amazon CloudWatch. To use the message tags that you
    -- specify using an @X-SES-MESSAGE-TAGS@ header or a parameter to the
    -- @SendEmail@ or @SendRawEmail@ API, choose @messageTag@. To use your own
    -- email headers, choose @emailHeader@. To use link tags, choose
    -- @linkTags@.
    CloudWatchDimensionConfiguration -> DimensionValueSource
dimensionValueSource :: DimensionValueSource,
    -- | The default value of the dimension that is published to Amazon
    -- CloudWatch if you don\'t provide the value of the dimension when you
    -- send an email. This value has to meet the following criteria:
    --
    -- -   It can only contain ASCII letters (a–z, A–Z), numbers (0–9),
    --     underscores (_), or dashes (-).
    --
    -- -   It can contain no more 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 has to meet the following criteria:
--
-- -   It can only contain ASCII letters (a–z, A–Z), numbers (0–9),
--     underscores (_), or dashes (-).
--
-- -   It can contain no more than 256 characters.
--
-- 'dimensionValueSource', 'cloudWatchDimensionConfiguration_dimensionValueSource' - The location where the Amazon SES API v2 finds the value of a dimension
-- to publish to Amazon CloudWatch. To use the message tags that you
-- specify using an @X-SES-MESSAGE-TAGS@ header or a parameter to the
-- @SendEmail@ or @SendRawEmail@ API, choose @messageTag@. To use your own
-- email headers, choose @emailHeader@. To use link tags, choose
-- @linkTags@.
--
-- 'defaultDimensionValue', 'cloudWatchDimensionConfiguration_defaultDimensionValue' - The default value of the dimension that is published to Amazon
-- CloudWatch if you don\'t provide the value of the dimension when you
-- send an email. This value has to meet the following criteria:
--
-- -   It can only contain ASCII letters (a–z, A–Z), numbers (0–9),
--     underscores (_), or dashes (-).
--
-- -   It can contain no more 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 has to meet the following criteria:
--
-- -   It can only contain ASCII letters (a–z, A–Z), numbers (0–9),
--     underscores (_), or dashes (-).
--
-- -   It can contain no more 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 location where the Amazon SES API v2 finds the value of a dimension
-- to publish to Amazon CloudWatch. To use the message tags that you
-- specify using an @X-SES-MESSAGE-TAGS@ header or a parameter to the
-- @SendEmail@ or @SendRawEmail@ API, choose @messageTag@. To use your own
-- email headers, choose @emailHeader@. To use link tags, choose
-- @linkTags@.
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 don\'t provide the value of the dimension when you
-- send an email. This value has to meet the following criteria:
--
-- -   It can only contain ASCII letters (a–z, A–Z), numbers (0–9),
--     underscores (_), or dashes (-).
--
-- -   It can contain no more 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.FromJSON
    CloudWatchDimensionConfiguration
  where
  parseJSON :: Value -> Parser CloudWatchDimensionConfiguration
parseJSON =
    String
-> (Object -> Parser CloudWatchDimensionConfiguration)
-> Value
-> Parser CloudWatchDimensionConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CloudWatchDimensionConfiguration"
      ( \Object
x ->
          Text
-> DimensionValueSource -> Text -> CloudWatchDimensionConfiguration
CloudWatchDimensionConfiguration'
            (Text
 -> DimensionValueSource
 -> Text
 -> CloudWatchDimensionConfiguration)
-> Parser Text
-> Parser
     (DimensionValueSource -> Text -> CloudWatchDimensionConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DimensionName")
            Parser
  (DimensionValueSource -> Text -> CloudWatchDimensionConfiguration)
-> Parser DimensionValueSource
-> Parser (Text -> CloudWatchDimensionConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser DimensionValueSource
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DimensionValueSource")
            Parser (Text -> CloudWatchDimensionConfiguration)
-> Parser Text -> Parser CloudWatchDimensionConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DefaultDimensionValue")
      )

instance
  Prelude.Hashable
    CloudWatchDimensionConfiguration

instance
  Prelude.NFData
    CloudWatchDimensionConfiguration

instance Core.ToJSON CloudWatchDimensionConfiguration where
  toJSON :: CloudWatchDimensionConfiguration -> Value
toJSON CloudWatchDimensionConfiguration' {Text
DimensionValueSource
defaultDimensionValue :: Text
dimensionValueSource :: DimensionValueSource
dimensionName :: Text
$sel:defaultDimensionValue:CloudWatchDimensionConfiguration' :: CloudWatchDimensionConfiguration -> Text
$sel:dimensionValueSource:CloudWatchDimensionConfiguration' :: CloudWatchDimensionConfiguration -> DimensionValueSource
$sel:dimensionName:CloudWatchDimensionConfiguration' :: CloudWatchDimensionConfiguration -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"DimensionName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
dimensionName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"DimensionValueSource"
                  Text -> DimensionValueSource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DimensionValueSource
dimensionValueSource
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"DefaultDimensionValue"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
defaultDimensionValue
              )
          ]
      )