{-# 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.FrameMetric 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 FrameMetric = FrameMetric'
{
FrameMetric -> Text
frameName :: Prelude.Text,
FrameMetric -> [Text]
threadStates :: [Prelude.Text],
FrameMetric -> MetricType
type' :: MetricType
}
deriving (FrameMetric -> FrameMetric -> Bool
(FrameMetric -> FrameMetric -> Bool)
-> (FrameMetric -> FrameMetric -> Bool) -> Eq FrameMetric
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FrameMetric -> FrameMetric -> Bool
$c/= :: FrameMetric -> FrameMetric -> Bool
== :: FrameMetric -> FrameMetric -> Bool
$c== :: FrameMetric -> FrameMetric -> Bool
Prelude.Eq, ReadPrec [FrameMetric]
ReadPrec FrameMetric
Int -> ReadS FrameMetric
ReadS [FrameMetric]
(Int -> ReadS FrameMetric)
-> ReadS [FrameMetric]
-> ReadPrec FrameMetric
-> ReadPrec [FrameMetric]
-> Read FrameMetric
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FrameMetric]
$creadListPrec :: ReadPrec [FrameMetric]
readPrec :: ReadPrec FrameMetric
$creadPrec :: ReadPrec FrameMetric
readList :: ReadS [FrameMetric]
$creadList :: ReadS [FrameMetric]
readsPrec :: Int -> ReadS FrameMetric
$creadsPrec :: Int -> ReadS FrameMetric
Prelude.Read, Int -> FrameMetric -> ShowS
[FrameMetric] -> ShowS
FrameMetric -> String
(Int -> FrameMetric -> ShowS)
-> (FrameMetric -> String)
-> ([FrameMetric] -> ShowS)
-> Show FrameMetric
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FrameMetric] -> ShowS
$cshowList :: [FrameMetric] -> ShowS
show :: FrameMetric -> String
$cshow :: FrameMetric -> String
showsPrec :: Int -> FrameMetric -> ShowS
$cshowsPrec :: Int -> FrameMetric -> ShowS
Prelude.Show, (forall x. FrameMetric -> Rep FrameMetric x)
-> (forall x. Rep FrameMetric x -> FrameMetric)
-> Generic FrameMetric
forall x. Rep FrameMetric x -> FrameMetric
forall x. FrameMetric -> Rep FrameMetric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FrameMetric x -> FrameMetric
$cfrom :: forall x. FrameMetric -> Rep FrameMetric x
Prelude.Generic)
newFrameMetric ::
Prelude.Text ->
MetricType ->
FrameMetric
newFrameMetric :: Text -> MetricType -> FrameMetric
newFrameMetric Text
pFrameName_ MetricType
pType_ =
FrameMetric' :: Text -> [Text] -> MetricType -> FrameMetric
FrameMetric'
{ $sel:frameName:FrameMetric' :: Text
frameName = Text
pFrameName_,
$sel:threadStates:FrameMetric' :: [Text]
threadStates = [Text]
forall a. Monoid a => a
Prelude.mempty,
$sel:type':FrameMetric' :: MetricType
type' = MetricType
pType_
}
frameMetric_frameName :: Lens.Lens' FrameMetric Prelude.Text
frameMetric_frameName :: (Text -> f Text) -> FrameMetric -> f FrameMetric
frameMetric_frameName = (FrameMetric -> Text)
-> (FrameMetric -> Text -> FrameMetric)
-> Lens FrameMetric FrameMetric Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FrameMetric' {Text
frameName :: Text
$sel:frameName:FrameMetric' :: FrameMetric -> Text
frameName} -> Text
frameName) (\s :: FrameMetric
s@FrameMetric' {} Text
a -> FrameMetric
s {$sel:frameName:FrameMetric' :: Text
frameName = Text
a} :: FrameMetric)
frameMetric_threadStates :: Lens.Lens' FrameMetric [Prelude.Text]
frameMetric_threadStates :: ([Text] -> f [Text]) -> FrameMetric -> f FrameMetric
frameMetric_threadStates = (FrameMetric -> [Text])
-> (FrameMetric -> [Text] -> FrameMetric)
-> Lens FrameMetric FrameMetric [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FrameMetric' {[Text]
threadStates :: [Text]
$sel:threadStates:FrameMetric' :: FrameMetric -> [Text]
threadStates} -> [Text]
threadStates) (\s :: FrameMetric
s@FrameMetric' {} [Text]
a -> FrameMetric
s {$sel:threadStates:FrameMetric' :: [Text]
threadStates = [Text]
a} :: FrameMetric) (([Text] -> f [Text]) -> FrameMetric -> f FrameMetric)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> FrameMetric
-> f FrameMetric
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
frameMetric_type :: Lens.Lens' FrameMetric MetricType
frameMetric_type :: (MetricType -> f MetricType) -> FrameMetric -> f FrameMetric
frameMetric_type = (FrameMetric -> MetricType)
-> (FrameMetric -> MetricType -> FrameMetric)
-> Lens FrameMetric FrameMetric MetricType MetricType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FrameMetric' {MetricType
type' :: MetricType
$sel:type':FrameMetric' :: FrameMetric -> MetricType
type'} -> MetricType
type') (\s :: FrameMetric
s@FrameMetric' {} MetricType
a -> FrameMetric
s {$sel:type':FrameMetric' :: MetricType
type' = MetricType
a} :: FrameMetric)
instance Core.FromJSON FrameMetric where
parseJSON :: Value -> Parser FrameMetric
parseJSON =
String
-> (Object -> Parser FrameMetric) -> Value -> Parser FrameMetric
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"FrameMetric"
( \Object
x ->
Text -> [Text] -> MetricType -> FrameMetric
FrameMetric'
(Text -> [Text] -> MetricType -> FrameMetric)
-> Parser Text -> Parser ([Text] -> MetricType -> FrameMetric)
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 -> FrameMetric)
-> Parser [Text] -> Parser (MetricType -> FrameMetric)
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 -> FrameMetric)
-> Parser MetricType -> Parser FrameMetric
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 FrameMetric
instance Prelude.NFData FrameMetric
instance Core.ToJSON FrameMetric where
toJSON :: FrameMetric -> Value
toJSON FrameMetric' {[Text]
Text
MetricType
type' :: MetricType
threadStates :: [Text]
frameName :: Text
$sel:type':FrameMetric' :: FrameMetric -> MetricType
$sel:threadStates:FrameMetric' :: FrameMetric -> [Text]
$sel:frameName:FrameMetric' :: FrameMetric -> Text
..} =
[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
"frameName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
frameName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"threadStates" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
threadStates),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> MetricType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= MetricType
type')
]
)