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

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

-- | An object that defines an Amazon CloudWatch destination for email
-- events. You can use Amazon CloudWatch to monitor and gain insights on
-- your email sending metrics.
--
-- /See:/ 'newCloudWatchDestination' smart constructor.
data CloudWatchDestination = CloudWatchDestination'
  { -- | An array of objects that define the dimensions to use when you send
    -- email 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' - An array of objects that define the dimensions to use when you send
-- email 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
    }

-- | An array of objects that define the dimensions to use when you send
-- email 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.FromJSON CloudWatchDestination where
  parseJSON :: Value -> Parser CloudWatchDestination
parseJSON =
    String
-> (Object -> Parser CloudWatchDestination)
-> Value
-> Parser CloudWatchDestination
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CloudWatchDestination"
      ( \Object
x ->
          [CloudWatchDimensionConfiguration] -> CloudWatchDestination
CloudWatchDestination'
            ([CloudWatchDimensionConfiguration] -> CloudWatchDestination)
-> Parser [CloudWatchDimensionConfiguration]
-> Parser CloudWatchDestination
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe [CloudWatchDimensionConfiguration])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DimensionConfigurations"
                            Parser (Maybe [CloudWatchDimensionConfiguration])
-> [CloudWatchDimensionConfiguration]
-> Parser [CloudWatchDimensionConfiguration]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [CloudWatchDimensionConfiguration]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable CloudWatchDestination

instance Prelude.NFData CloudWatchDestination

instance Core.ToJSON CloudWatchDestination where
  toJSON :: CloudWatchDestination -> Value
toJSON CloudWatchDestination' {[CloudWatchDimensionConfiguration]
dimensionConfigurations :: [CloudWatchDimensionConfiguration]
$sel:dimensionConfigurations:CloudWatchDestination' :: CloudWatchDestination -> [CloudWatchDimensionConfiguration]
..} =
    [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
"DimensionConfigurations"
                  Text -> [CloudWatchDimensionConfiguration] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [CloudWatchDimensionConfiguration]
dimensionConfigurations
              )
          ]
      )