{-# 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 #-}
module Amazonka.CodeGuruProfiler.Types.Metric where
import Amazonka.CodeGuruProfiler.Types.MetricType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Metric = Metric'
{
Metric -> Text
frameName :: Prelude.Text,
Metric -> [Text]
threadStates :: [Prelude.Text],
Metric -> MetricType
type' :: MetricType
}
deriving (Metric -> Metric -> Bool
(Metric -> Metric -> Bool)
-> (Metric -> Metric -> Bool) -> Eq Metric
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Metric -> Metric -> Bool
$c/= :: Metric -> Metric -> Bool
== :: Metric -> Metric -> Bool
$c== :: Metric -> Metric -> Bool
Prelude.Eq, ReadPrec [Metric]
ReadPrec Metric
Int -> ReadS Metric
ReadS [Metric]
(Int -> ReadS Metric)
-> ReadS [Metric]
-> ReadPrec Metric
-> ReadPrec [Metric]
-> Read Metric
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Metric]
$creadListPrec :: ReadPrec [Metric]
readPrec :: ReadPrec Metric
$creadPrec :: ReadPrec Metric
readList :: ReadS [Metric]
$creadList :: ReadS [Metric]
readsPrec :: Int -> ReadS Metric
$creadsPrec :: Int -> ReadS Metric
Prelude.Read, Int -> Metric -> ShowS
[Metric] -> ShowS
Metric -> String
(Int -> Metric -> ShowS)
-> (Metric -> String) -> ([Metric] -> ShowS) -> Show Metric
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Metric] -> ShowS
$cshowList :: [Metric] -> ShowS
show :: Metric -> String
$cshow :: Metric -> String
showsPrec :: Int -> Metric -> ShowS
$cshowsPrec :: Int -> Metric -> ShowS
Prelude.Show, (forall x. Metric -> Rep Metric x)
-> (forall x. Rep Metric x -> Metric) -> Generic Metric
forall x. Rep Metric x -> Metric
forall x. Metric -> Rep Metric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Metric x -> Metric
$cfrom :: forall x. Metric -> Rep Metric x
Prelude.Generic)
newMetric ::
Prelude.Text ->
MetricType ->
Metric
newMetric :: Text -> MetricType -> Metric
newMetric Text
pFrameName_ MetricType
pType_ =
Metric' :: Text -> [Text] -> MetricType -> Metric
Metric'
{ $sel:frameName:Metric' :: Text
frameName = Text
pFrameName_,
$sel:threadStates:Metric' :: [Text]
threadStates = [Text]
forall a. Monoid a => a
Prelude.mempty,
$sel:type':Metric' :: MetricType
type' = MetricType
pType_
}
metric_frameName :: Lens.Lens' Metric Prelude.Text
metric_frameName :: (Text -> f Text) -> Metric -> f Metric
metric_frameName = (Metric -> Text)
-> (Metric -> Text -> Metric) -> Lens Metric Metric Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Metric' {Text
frameName :: Text
$sel:frameName:Metric' :: Metric -> Text
frameName} -> Text
frameName) (\s :: Metric
s@Metric' {} Text
a -> Metric
s {$sel:frameName:Metric' :: Text
frameName = Text
a} :: Metric)
metric_threadStates :: Lens.Lens' Metric [Prelude.Text]
metric_threadStates :: ([Text] -> f [Text]) -> Metric -> f Metric
metric_threadStates = (Metric -> [Text])
-> (Metric -> [Text] -> Metric) -> Lens Metric Metric [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Metric' {[Text]
threadStates :: [Text]
$sel:threadStates:Metric' :: Metric -> [Text]
threadStates} -> [Text]
threadStates) (\s :: Metric
s@Metric' {} [Text]
a -> Metric
s {$sel:threadStates:Metric' :: [Text]
threadStates = [Text]
a} :: Metric) (([Text] -> f [Text]) -> Metric -> f Metric)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> Metric
-> f Metric
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
metric_type :: Lens.Lens' Metric MetricType
metric_type :: (MetricType -> f MetricType) -> Metric -> f Metric
metric_type = (Metric -> MetricType)
-> (Metric -> MetricType -> Metric)
-> Lens Metric Metric MetricType MetricType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Metric' {MetricType
type' :: MetricType
$sel:type':Metric' :: Metric -> MetricType
type'} -> MetricType
type') (\s :: Metric
s@Metric' {} MetricType
a -> Metric
s {$sel:type':Metric' :: MetricType
type' = MetricType
a} :: Metric)
instance Core.FromJSON Metric where
parseJSON :: Value -> Parser Metric
parseJSON =
String -> (Object -> Parser Metric) -> Value -> Parser Metric
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Metric"
( \Object
x ->
Text -> [Text] -> MetricType -> Metric
Metric'
(Text -> [Text] -> MetricType -> Metric)
-> Parser Text -> Parser ([Text] -> MetricType -> Metric)
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
"frameName")
Parser ([Text] -> MetricType -> Metric)
-> Parser [Text] -> Parser (MetricType -> Metric)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"threadStates" Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Text]
forall a. Monoid a => a
Prelude.mempty)
Parser (MetricType -> Metric) -> Parser MetricType -> Parser Metric
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser MetricType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"type")
)
instance Prelude.Hashable Metric
instance Prelude.NFData Metric