{-# 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.SageMaker.Types.MetricDefinition where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data MetricDefinition = MetricDefinition'
{
MetricDefinition -> Text
name :: Prelude.Text,
MetricDefinition -> Text
regex :: Prelude.Text
}
deriving (MetricDefinition -> MetricDefinition -> Bool
(MetricDefinition -> MetricDefinition -> Bool)
-> (MetricDefinition -> MetricDefinition -> Bool)
-> Eq MetricDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricDefinition -> MetricDefinition -> Bool
$c/= :: MetricDefinition -> MetricDefinition -> Bool
== :: MetricDefinition -> MetricDefinition -> Bool
$c== :: MetricDefinition -> MetricDefinition -> Bool
Prelude.Eq, ReadPrec [MetricDefinition]
ReadPrec MetricDefinition
Int -> ReadS MetricDefinition
ReadS [MetricDefinition]
(Int -> ReadS MetricDefinition)
-> ReadS [MetricDefinition]
-> ReadPrec MetricDefinition
-> ReadPrec [MetricDefinition]
-> Read MetricDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricDefinition]
$creadListPrec :: ReadPrec [MetricDefinition]
readPrec :: ReadPrec MetricDefinition
$creadPrec :: ReadPrec MetricDefinition
readList :: ReadS [MetricDefinition]
$creadList :: ReadS [MetricDefinition]
readsPrec :: Int -> ReadS MetricDefinition
$creadsPrec :: Int -> ReadS MetricDefinition
Prelude.Read, Int -> MetricDefinition -> ShowS
[MetricDefinition] -> ShowS
MetricDefinition -> String
(Int -> MetricDefinition -> ShowS)
-> (MetricDefinition -> String)
-> ([MetricDefinition] -> ShowS)
-> Show MetricDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricDefinition] -> ShowS
$cshowList :: [MetricDefinition] -> ShowS
show :: MetricDefinition -> String
$cshow :: MetricDefinition -> String
showsPrec :: Int -> MetricDefinition -> ShowS
$cshowsPrec :: Int -> MetricDefinition -> ShowS
Prelude.Show, (forall x. MetricDefinition -> Rep MetricDefinition x)
-> (forall x. Rep MetricDefinition x -> MetricDefinition)
-> Generic MetricDefinition
forall x. Rep MetricDefinition x -> MetricDefinition
forall x. MetricDefinition -> Rep MetricDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricDefinition x -> MetricDefinition
$cfrom :: forall x. MetricDefinition -> Rep MetricDefinition x
Prelude.Generic)
newMetricDefinition ::
Prelude.Text ->
Prelude.Text ->
MetricDefinition
newMetricDefinition :: Text -> Text -> MetricDefinition
newMetricDefinition Text
pName_ Text
pRegex_ =
MetricDefinition' :: Text -> Text -> MetricDefinition
MetricDefinition' {$sel:name:MetricDefinition' :: Text
name = Text
pName_, $sel:regex:MetricDefinition' :: Text
regex = Text
pRegex_}
metricDefinition_name :: Lens.Lens' MetricDefinition Prelude.Text
metricDefinition_name :: (Text -> f Text) -> MetricDefinition -> f MetricDefinition
metricDefinition_name = (MetricDefinition -> Text)
-> (MetricDefinition -> Text -> MetricDefinition)
-> Lens MetricDefinition MetricDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDefinition' {Text
name :: Text
$sel:name:MetricDefinition' :: MetricDefinition -> Text
name} -> Text
name) (\s :: MetricDefinition
s@MetricDefinition' {} Text
a -> MetricDefinition
s {$sel:name:MetricDefinition' :: Text
name = Text
a} :: MetricDefinition)
metricDefinition_regex :: Lens.Lens' MetricDefinition Prelude.Text
metricDefinition_regex :: (Text -> f Text) -> MetricDefinition -> f MetricDefinition
metricDefinition_regex = (MetricDefinition -> Text)
-> (MetricDefinition -> Text -> MetricDefinition)
-> Lens MetricDefinition MetricDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDefinition' {Text
regex :: Text
$sel:regex:MetricDefinition' :: MetricDefinition -> Text
regex} -> Text
regex) (\s :: MetricDefinition
s@MetricDefinition' {} Text
a -> MetricDefinition
s {$sel:regex:MetricDefinition' :: Text
regex = Text
a} :: MetricDefinition)
instance Core.FromJSON MetricDefinition where
parseJSON :: Value -> Parser MetricDefinition
parseJSON =
String
-> (Object -> Parser MetricDefinition)
-> Value
-> Parser MetricDefinition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"MetricDefinition"
( \Object
x ->
Text -> Text -> MetricDefinition
MetricDefinition'
(Text -> Text -> MetricDefinition)
-> Parser Text -> Parser (Text -> MetricDefinition)
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
"Name") Parser (Text -> MetricDefinition)
-> Parser Text -> Parser MetricDefinition
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Regex")
)
instance Prelude.Hashable MetricDefinition
instance Prelude.NFData MetricDefinition
instance Core.ToJSON MetricDefinition where
toJSON :: MetricDefinition -> Value
toJSON MetricDefinition' {Text
regex :: Text
name :: Text
$sel:regex:MetricDefinition' :: MetricDefinition -> Text
$sel:name:MetricDefinition' :: MetricDefinition -> 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
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Regex" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
regex)
]
)