{-# 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.CloudWatchDestination
-- 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.CloudWatchDestination where

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

-- | Contains information associated with an Amazon CloudWatch event
-- destination to which email sending events are published.
--
-- Event destinations, such as Amazon CloudWatch, are associated with
-- configuration sets, which enable you to publish email sending events.
-- For information about using configuration sets, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/monitor-sending-activity.html Amazon SES Developer Guide>.
--
-- /See:/ 'newCloudWatchDestination' smart constructor.
data CloudWatchDestination = CloudWatchDestination'
  { -- | A list of dimensions upon which to categorize your emails when you
    -- publish email sending events to Amazon CloudWatch.
    CloudWatchDestination -> [CloudWatchDimensionConfiguration]
dimensionConfigurations :: [CloudWatchDimensionConfiguration]
  }
  deriving (CloudWatchDestination -> CloudWatchDestination -> Bool
(CloudWatchDestination -> CloudWatchDestination -> Bool)
-> (CloudWatchDestination -> CloudWatchDestination -> Bool)
-> Eq CloudWatchDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CloudWatchDestination -> CloudWatchDestination -> Bool
$c/= :: CloudWatchDestination -> CloudWatchDestination -> Bool
== :: CloudWatchDestination -> CloudWatchDestination -> Bool
$c== :: CloudWatchDestination -> CloudWatchDestination -> Bool
Prelude.Eq, ReadPrec [CloudWatchDestination]
ReadPrec CloudWatchDestination
Int -> ReadS CloudWatchDestination
ReadS [CloudWatchDestination]
(Int -> ReadS CloudWatchDestination)
-> ReadS [CloudWatchDestination]
-> ReadPrec CloudWatchDestination
-> ReadPrec [CloudWatchDestination]
-> Read CloudWatchDestination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CloudWatchDestination]
$creadListPrec :: ReadPrec [CloudWatchDestination]
readPrec :: ReadPrec CloudWatchDestination
$creadPrec :: ReadPrec CloudWatchDestination
readList :: ReadS [CloudWatchDestination]
$creadList :: ReadS [CloudWatchDestination]
readsPrec :: Int -> ReadS CloudWatchDestination
$creadsPrec :: Int -> ReadS CloudWatchDestination
Prelude.Read, Int -> CloudWatchDestination -> ShowS
[CloudWatchDestination] -> ShowS
CloudWatchDestination -> String
(Int -> CloudWatchDestination -> ShowS)
-> (CloudWatchDestination -> String)
-> ([CloudWatchDestination] -> ShowS)
-> Show CloudWatchDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CloudWatchDestination] -> ShowS
$cshowList :: [CloudWatchDestination] -> ShowS
show :: CloudWatchDestination -> String
$cshow :: CloudWatchDestination -> String
showsPrec :: Int -> CloudWatchDestination -> ShowS
$cshowsPrec :: Int -> CloudWatchDestination -> ShowS
Prelude.Show, (forall x. CloudWatchDestination -> Rep CloudWatchDestination x)
-> (forall x. Rep CloudWatchDestination x -> CloudWatchDestination)
-> Generic CloudWatchDestination
forall x. Rep CloudWatchDestination x -> CloudWatchDestination
forall x. CloudWatchDestination -> Rep CloudWatchDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CloudWatchDestination x -> CloudWatchDestination
$cfrom :: forall x. CloudWatchDestination -> Rep CloudWatchDestination x
Prelude.Generic)

-- |
-- Create a value of 'CloudWatchDestination' 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:
--
-- 'dimensionConfigurations', 'cloudWatchDestination_dimensionConfigurations' - A list of dimensions upon which to categorize your emails when you
-- publish email sending events to Amazon CloudWatch.
newCloudWatchDestination ::
  CloudWatchDestination
newCloudWatchDestination :: CloudWatchDestination
newCloudWatchDestination =
  CloudWatchDestination' :: [CloudWatchDimensionConfiguration] -> CloudWatchDestination
CloudWatchDestination'
    { $sel:dimensionConfigurations:CloudWatchDestination' :: [CloudWatchDimensionConfiguration]
dimensionConfigurations =
        [CloudWatchDimensionConfiguration]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A list of dimensions upon which to categorize your emails when you
-- publish email sending events to Amazon CloudWatch.
cloudWatchDestination_dimensionConfigurations :: Lens.Lens' CloudWatchDestination [CloudWatchDimensionConfiguration]
cloudWatchDestination_dimensionConfigurations :: ([CloudWatchDimensionConfiguration]
 -> f [CloudWatchDimensionConfiguration])
-> CloudWatchDestination -> f CloudWatchDestination
cloudWatchDestination_dimensionConfigurations = (CloudWatchDestination -> [CloudWatchDimensionConfiguration])
-> (CloudWatchDestination
    -> [CloudWatchDimensionConfiguration] -> CloudWatchDestination)
-> Lens
     CloudWatchDestination
     CloudWatchDestination
     [CloudWatchDimensionConfiguration]
     [CloudWatchDimensionConfiguration]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchDestination' {[CloudWatchDimensionConfiguration]
dimensionConfigurations :: [CloudWatchDimensionConfiguration]
$sel:dimensionConfigurations:CloudWatchDestination' :: CloudWatchDestination -> [CloudWatchDimensionConfiguration]
dimensionConfigurations} -> [CloudWatchDimensionConfiguration]
dimensionConfigurations) (\s :: CloudWatchDestination
s@CloudWatchDestination' {} [CloudWatchDimensionConfiguration]
a -> CloudWatchDestination
s {$sel:dimensionConfigurations:CloudWatchDestination' :: [CloudWatchDimensionConfiguration]
dimensionConfigurations = [CloudWatchDimensionConfiguration]
a} :: CloudWatchDestination) (([CloudWatchDimensionConfiguration]
  -> f [CloudWatchDimensionConfiguration])
 -> CloudWatchDestination -> f CloudWatchDestination)
-> (([CloudWatchDimensionConfiguration]
     -> f [CloudWatchDimensionConfiguration])
    -> [CloudWatchDimensionConfiguration]
    -> f [CloudWatchDimensionConfiguration])
-> ([CloudWatchDimensionConfiguration]
    -> f [CloudWatchDimensionConfiguration])
-> CloudWatchDestination
-> f CloudWatchDestination
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([CloudWatchDimensionConfiguration]
 -> f [CloudWatchDimensionConfiguration])
-> [CloudWatchDimensionConfiguration]
-> f [CloudWatchDimensionConfiguration]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML CloudWatchDestination where
  parseXML :: [Node] -> Either String CloudWatchDestination
parseXML [Node]
x =
    [CloudWatchDimensionConfiguration] -> CloudWatchDestination
CloudWatchDestination'
      ([CloudWatchDimensionConfiguration] -> CloudWatchDestination)
-> Either String [CloudWatchDimensionConfiguration]
-> Either String CloudWatchDestination
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DimensionConfigurations"
                      Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String [CloudWatchDimensionConfiguration])
-> Either String [CloudWatchDimensionConfiguration]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= Text -> [Node] -> Either String [CloudWatchDimensionConfiguration]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member"
                  )

instance Prelude.Hashable CloudWatchDestination

instance Prelude.NFData CloudWatchDestination

instance Core.ToQuery CloudWatchDestination where
  toQuery :: CloudWatchDestination -> QueryString
toQuery CloudWatchDestination' {[CloudWatchDimensionConfiguration]
dimensionConfigurations :: [CloudWatchDimensionConfiguration]
$sel:dimensionConfigurations:CloudWatchDestination' :: CloudWatchDestination -> [CloudWatchDimensionConfiguration]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"DimensionConfigurations"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [CloudWatchDimensionConfiguration] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" [CloudWatchDimensionConfiguration]
dimensionConfigurations
      ]