{-# 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.Rum.Types.MetricDestinationSummary
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Rum.Types.MetricDestinationSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rum.Types.MetricDestination

-- | A structure that displays information about one destination that
-- CloudWatch RUM sends extended metrics to.
--
-- /See:/ 'newMetricDestinationSummary' smart constructor.
data MetricDestinationSummary = MetricDestinationSummary'
  { -- | Specifies whether the destination is @CloudWatch@ or @Evidently@.
    MetricDestinationSummary -> Maybe MetricDestination
destination :: Prelude.Maybe MetricDestination,
    -- | If the destination is @Evidently@, this specifies the ARN of the
    -- Evidently experiment that receives the metrics.
    MetricDestinationSummary -> Maybe Text
destinationArn :: Prelude.Maybe Prelude.Text,
    -- | This field appears only when the destination is @Evidently@. It
    -- specifies the ARN of the IAM role that is used to write to the Evidently
    -- experiment that receives the metrics.
    MetricDestinationSummary -> Maybe Text
iamRoleArn :: Prelude.Maybe Prelude.Text
  }
  deriving (MetricDestinationSummary -> MetricDestinationSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricDestinationSummary -> MetricDestinationSummary -> Bool
$c/= :: MetricDestinationSummary -> MetricDestinationSummary -> Bool
== :: MetricDestinationSummary -> MetricDestinationSummary -> Bool
$c== :: MetricDestinationSummary -> MetricDestinationSummary -> Bool
Prelude.Eq, ReadPrec [MetricDestinationSummary]
ReadPrec MetricDestinationSummary
Int -> ReadS MetricDestinationSummary
ReadS [MetricDestinationSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricDestinationSummary]
$creadListPrec :: ReadPrec [MetricDestinationSummary]
readPrec :: ReadPrec MetricDestinationSummary
$creadPrec :: ReadPrec MetricDestinationSummary
readList :: ReadS [MetricDestinationSummary]
$creadList :: ReadS [MetricDestinationSummary]
readsPrec :: Int -> ReadS MetricDestinationSummary
$creadsPrec :: Int -> ReadS MetricDestinationSummary
Prelude.Read, Int -> MetricDestinationSummary -> ShowS
[MetricDestinationSummary] -> ShowS
MetricDestinationSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricDestinationSummary] -> ShowS
$cshowList :: [MetricDestinationSummary] -> ShowS
show :: MetricDestinationSummary -> String
$cshow :: MetricDestinationSummary -> String
showsPrec :: Int -> MetricDestinationSummary -> ShowS
$cshowsPrec :: Int -> MetricDestinationSummary -> ShowS
Prelude.Show, forall x.
Rep MetricDestinationSummary x -> MetricDestinationSummary
forall x.
MetricDestinationSummary -> Rep MetricDestinationSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep MetricDestinationSummary x -> MetricDestinationSummary
$cfrom :: forall x.
MetricDestinationSummary -> Rep MetricDestinationSummary x
Prelude.Generic)

-- |
-- Create a value of 'MetricDestinationSummary' 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:
--
-- 'destination', 'metricDestinationSummary_destination' - Specifies whether the destination is @CloudWatch@ or @Evidently@.
--
-- 'destinationArn', 'metricDestinationSummary_destinationArn' - If the destination is @Evidently@, this specifies the ARN of the
-- Evidently experiment that receives the metrics.
--
-- 'iamRoleArn', 'metricDestinationSummary_iamRoleArn' - This field appears only when the destination is @Evidently@. It
-- specifies the ARN of the IAM role that is used to write to the Evidently
-- experiment that receives the metrics.
newMetricDestinationSummary ::
  MetricDestinationSummary
newMetricDestinationSummary :: MetricDestinationSummary
newMetricDestinationSummary =
  MetricDestinationSummary'
    { $sel:destination:MetricDestinationSummary' :: Maybe MetricDestination
destination =
        forall a. Maybe a
Prelude.Nothing,
      $sel:destinationArn:MetricDestinationSummary' :: Maybe Text
destinationArn = forall a. Maybe a
Prelude.Nothing,
      $sel:iamRoleArn:MetricDestinationSummary' :: Maybe Text
iamRoleArn = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether the destination is @CloudWatch@ or @Evidently@.
metricDestinationSummary_destination :: Lens.Lens' MetricDestinationSummary (Prelude.Maybe MetricDestination)
metricDestinationSummary_destination :: Lens' MetricDestinationSummary (Maybe MetricDestination)
metricDestinationSummary_destination = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDestinationSummary' {Maybe MetricDestination
destination :: Maybe MetricDestination
$sel:destination:MetricDestinationSummary' :: MetricDestinationSummary -> Maybe MetricDestination
destination} -> Maybe MetricDestination
destination) (\s :: MetricDestinationSummary
s@MetricDestinationSummary' {} Maybe MetricDestination
a -> MetricDestinationSummary
s {$sel:destination:MetricDestinationSummary' :: Maybe MetricDestination
destination = Maybe MetricDestination
a} :: MetricDestinationSummary)

-- | If the destination is @Evidently@, this specifies the ARN of the
-- Evidently experiment that receives the metrics.
metricDestinationSummary_destinationArn :: Lens.Lens' MetricDestinationSummary (Prelude.Maybe Prelude.Text)
metricDestinationSummary_destinationArn :: Lens' MetricDestinationSummary (Maybe Text)
metricDestinationSummary_destinationArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDestinationSummary' {Maybe Text
destinationArn :: Maybe Text
$sel:destinationArn:MetricDestinationSummary' :: MetricDestinationSummary -> Maybe Text
destinationArn} -> Maybe Text
destinationArn) (\s :: MetricDestinationSummary
s@MetricDestinationSummary' {} Maybe Text
a -> MetricDestinationSummary
s {$sel:destinationArn:MetricDestinationSummary' :: Maybe Text
destinationArn = Maybe Text
a} :: MetricDestinationSummary)

-- | This field appears only when the destination is @Evidently@. It
-- specifies the ARN of the IAM role that is used to write to the Evidently
-- experiment that receives the metrics.
metricDestinationSummary_iamRoleArn :: Lens.Lens' MetricDestinationSummary (Prelude.Maybe Prelude.Text)
metricDestinationSummary_iamRoleArn :: Lens' MetricDestinationSummary (Maybe Text)
metricDestinationSummary_iamRoleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDestinationSummary' {Maybe Text
iamRoleArn :: Maybe Text
$sel:iamRoleArn:MetricDestinationSummary' :: MetricDestinationSummary -> Maybe Text
iamRoleArn} -> Maybe Text
iamRoleArn) (\s :: MetricDestinationSummary
s@MetricDestinationSummary' {} Maybe Text
a -> MetricDestinationSummary
s {$sel:iamRoleArn:MetricDestinationSummary' :: Maybe Text
iamRoleArn = Maybe Text
a} :: MetricDestinationSummary)

instance Data.FromJSON MetricDestinationSummary where
  parseJSON :: Value -> Parser MetricDestinationSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MetricDestinationSummary"
      ( \Object
x ->
          Maybe MetricDestination
-> Maybe Text -> Maybe Text -> MetricDestinationSummary
MetricDestinationSummary'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Destination")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DestinationArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"IamRoleArn")
      )

instance Prelude.Hashable MetricDestinationSummary where
  hashWithSalt :: Int -> MetricDestinationSummary -> Int
hashWithSalt Int
_salt MetricDestinationSummary' {Maybe Text
Maybe MetricDestination
iamRoleArn :: Maybe Text
destinationArn :: Maybe Text
destination :: Maybe MetricDestination
$sel:iamRoleArn:MetricDestinationSummary' :: MetricDestinationSummary -> Maybe Text
$sel:destinationArn:MetricDestinationSummary' :: MetricDestinationSummary -> Maybe Text
$sel:destination:MetricDestinationSummary' :: MetricDestinationSummary -> Maybe MetricDestination
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MetricDestination
destination
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
destinationArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
iamRoleArn

instance Prelude.NFData MetricDestinationSummary where
  rnf :: MetricDestinationSummary -> ()
rnf MetricDestinationSummary' {Maybe Text
Maybe MetricDestination
iamRoleArn :: Maybe Text
destinationArn :: Maybe Text
destination :: Maybe MetricDestination
$sel:iamRoleArn:MetricDestinationSummary' :: MetricDestinationSummary -> Maybe Text
$sel:destinationArn:MetricDestinationSummary' :: MetricDestinationSummary -> Maybe Text
$sel:destination:MetricDestinationSummary' :: MetricDestinationSummary -> Maybe MetricDestination
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe MetricDestination
destination
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
destinationArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
iamRoleArn