{-# 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.Connect.Types.CurrentMetric
-- 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.Connect.Types.CurrentMetric where

import Amazonka.Connect.Types.CurrentMetricName
import Amazonka.Connect.Types.Unit
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a real-time metric. For a description of each
-- metric, see
-- <https://docs.aws.amazon.com/connect/latest/adminguide/real-time-metrics-definitions.html Real-time Metrics Definitions>
-- in the /Amazon Connect Administrator Guide/.
--
-- /See:/ 'newCurrentMetric' smart constructor.
data CurrentMetric = CurrentMetric'
  { -- | The name of the metric.
    CurrentMetric -> Maybe CurrentMetricName
name :: Prelude.Maybe CurrentMetricName,
    -- | The unit for the metric.
    CurrentMetric -> Maybe Unit
unit :: Prelude.Maybe Unit
  }
  deriving (CurrentMetric -> CurrentMetric -> Bool
(CurrentMetric -> CurrentMetric -> Bool)
-> (CurrentMetric -> CurrentMetric -> Bool) -> Eq CurrentMetric
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CurrentMetric -> CurrentMetric -> Bool
$c/= :: CurrentMetric -> CurrentMetric -> Bool
== :: CurrentMetric -> CurrentMetric -> Bool
$c== :: CurrentMetric -> CurrentMetric -> Bool
Prelude.Eq, ReadPrec [CurrentMetric]
ReadPrec CurrentMetric
Int -> ReadS CurrentMetric
ReadS [CurrentMetric]
(Int -> ReadS CurrentMetric)
-> ReadS [CurrentMetric]
-> ReadPrec CurrentMetric
-> ReadPrec [CurrentMetric]
-> Read CurrentMetric
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CurrentMetric]
$creadListPrec :: ReadPrec [CurrentMetric]
readPrec :: ReadPrec CurrentMetric
$creadPrec :: ReadPrec CurrentMetric
readList :: ReadS [CurrentMetric]
$creadList :: ReadS [CurrentMetric]
readsPrec :: Int -> ReadS CurrentMetric
$creadsPrec :: Int -> ReadS CurrentMetric
Prelude.Read, Int -> CurrentMetric -> ShowS
[CurrentMetric] -> ShowS
CurrentMetric -> String
(Int -> CurrentMetric -> ShowS)
-> (CurrentMetric -> String)
-> ([CurrentMetric] -> ShowS)
-> Show CurrentMetric
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CurrentMetric] -> ShowS
$cshowList :: [CurrentMetric] -> ShowS
show :: CurrentMetric -> String
$cshow :: CurrentMetric -> String
showsPrec :: Int -> CurrentMetric -> ShowS
$cshowsPrec :: Int -> CurrentMetric -> ShowS
Prelude.Show, (forall x. CurrentMetric -> Rep CurrentMetric x)
-> (forall x. Rep CurrentMetric x -> CurrentMetric)
-> Generic CurrentMetric
forall x. Rep CurrentMetric x -> CurrentMetric
forall x. CurrentMetric -> Rep CurrentMetric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CurrentMetric x -> CurrentMetric
$cfrom :: forall x. CurrentMetric -> Rep CurrentMetric x
Prelude.Generic)

-- |
-- Create a value of 'CurrentMetric' 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:
--
-- 'name', 'currentMetric_name' - The name of the metric.
--
-- 'unit', 'currentMetric_unit' - The unit for the metric.
newCurrentMetric ::
  CurrentMetric
newCurrentMetric :: CurrentMetric
newCurrentMetric =
  CurrentMetric' :: Maybe CurrentMetricName -> Maybe Unit -> CurrentMetric
CurrentMetric'
    { $sel:name:CurrentMetric' :: Maybe CurrentMetricName
name = Maybe CurrentMetricName
forall a. Maybe a
Prelude.Nothing,
      $sel:unit:CurrentMetric' :: Maybe Unit
unit = Maybe Unit
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the metric.
currentMetric_name :: Lens.Lens' CurrentMetric (Prelude.Maybe CurrentMetricName)
currentMetric_name :: (Maybe CurrentMetricName -> f (Maybe CurrentMetricName))
-> CurrentMetric -> f CurrentMetric
currentMetric_name = (CurrentMetric -> Maybe CurrentMetricName)
-> (CurrentMetric -> Maybe CurrentMetricName -> CurrentMetric)
-> Lens
     CurrentMetric
     CurrentMetric
     (Maybe CurrentMetricName)
     (Maybe CurrentMetricName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CurrentMetric' {Maybe CurrentMetricName
name :: Maybe CurrentMetricName
$sel:name:CurrentMetric' :: CurrentMetric -> Maybe CurrentMetricName
name} -> Maybe CurrentMetricName
name) (\s :: CurrentMetric
s@CurrentMetric' {} Maybe CurrentMetricName
a -> CurrentMetric
s {$sel:name:CurrentMetric' :: Maybe CurrentMetricName
name = Maybe CurrentMetricName
a} :: CurrentMetric)

-- | The unit for the metric.
currentMetric_unit :: Lens.Lens' CurrentMetric (Prelude.Maybe Unit)
currentMetric_unit :: (Maybe Unit -> f (Maybe Unit)) -> CurrentMetric -> f CurrentMetric
currentMetric_unit = (CurrentMetric -> Maybe Unit)
-> (CurrentMetric -> Maybe Unit -> CurrentMetric)
-> Lens CurrentMetric CurrentMetric (Maybe Unit) (Maybe Unit)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CurrentMetric' {Maybe Unit
unit :: Maybe Unit
$sel:unit:CurrentMetric' :: CurrentMetric -> Maybe Unit
unit} -> Maybe Unit
unit) (\s :: CurrentMetric
s@CurrentMetric' {} Maybe Unit
a -> CurrentMetric
s {$sel:unit:CurrentMetric' :: Maybe Unit
unit = Maybe Unit
a} :: CurrentMetric)

instance Core.FromJSON CurrentMetric where
  parseJSON :: Value -> Parser CurrentMetric
parseJSON =
    String
-> (Object -> Parser CurrentMetric)
-> Value
-> Parser CurrentMetric
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CurrentMetric"
      ( \Object
x ->
          Maybe CurrentMetricName -> Maybe Unit -> CurrentMetric
CurrentMetric'
            (Maybe CurrentMetricName -> Maybe Unit -> CurrentMetric)
-> Parser (Maybe CurrentMetricName)
-> Parser (Maybe Unit -> CurrentMetric)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe CurrentMetricName)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name") Parser (Maybe Unit -> CurrentMetric)
-> Parser (Maybe Unit) -> Parser CurrentMetric
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Unit)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Unit")
      )

instance Prelude.Hashable CurrentMetric

instance Prelude.NFData CurrentMetric

instance Core.ToJSON CurrentMetric where
  toJSON :: CurrentMetric -> Value
toJSON CurrentMetric' {Maybe CurrentMetricName
Maybe Unit
unit :: Maybe Unit
name :: Maybe CurrentMetricName
$sel:unit:CurrentMetric' :: CurrentMetric -> Maybe Unit
$sel:name:CurrentMetric' :: CurrentMetric -> Maybe CurrentMetricName
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Name" Text -> CurrentMetricName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CurrentMetricName -> Pair)
-> Maybe CurrentMetricName -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CurrentMetricName
name,
            (Text
"Unit" Text -> Unit -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Unit -> Pair) -> Maybe Unit -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Unit
unit
          ]
      )