{-# 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.MediaStore.Types.MetricPolicy where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaStore.Types.ContainerLevelMetrics
import Amazonka.MediaStore.Types.MetricPolicyRule
import qualified Amazonka.Prelude as Prelude
data MetricPolicy = MetricPolicy'
{
MetricPolicy -> Maybe (NonEmpty MetricPolicyRule)
metricPolicyRules :: Prelude.Maybe (Prelude.NonEmpty MetricPolicyRule),
MetricPolicy -> ContainerLevelMetrics
containerLevelMetrics :: ContainerLevelMetrics
}
deriving (MetricPolicy -> MetricPolicy -> Bool
(MetricPolicy -> MetricPolicy -> Bool)
-> (MetricPolicy -> MetricPolicy -> Bool) -> Eq MetricPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricPolicy -> MetricPolicy -> Bool
$c/= :: MetricPolicy -> MetricPolicy -> Bool
== :: MetricPolicy -> MetricPolicy -> Bool
$c== :: MetricPolicy -> MetricPolicy -> Bool
Prelude.Eq, ReadPrec [MetricPolicy]
ReadPrec MetricPolicy
Int -> ReadS MetricPolicy
ReadS [MetricPolicy]
(Int -> ReadS MetricPolicy)
-> ReadS [MetricPolicy]
-> ReadPrec MetricPolicy
-> ReadPrec [MetricPolicy]
-> Read MetricPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricPolicy]
$creadListPrec :: ReadPrec [MetricPolicy]
readPrec :: ReadPrec MetricPolicy
$creadPrec :: ReadPrec MetricPolicy
readList :: ReadS [MetricPolicy]
$creadList :: ReadS [MetricPolicy]
readsPrec :: Int -> ReadS MetricPolicy
$creadsPrec :: Int -> ReadS MetricPolicy
Prelude.Read, Int -> MetricPolicy -> ShowS
[MetricPolicy] -> ShowS
MetricPolicy -> String
(Int -> MetricPolicy -> ShowS)
-> (MetricPolicy -> String)
-> ([MetricPolicy] -> ShowS)
-> Show MetricPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricPolicy] -> ShowS
$cshowList :: [MetricPolicy] -> ShowS
show :: MetricPolicy -> String
$cshow :: MetricPolicy -> String
showsPrec :: Int -> MetricPolicy -> ShowS
$cshowsPrec :: Int -> MetricPolicy -> ShowS
Prelude.Show, (forall x. MetricPolicy -> Rep MetricPolicy x)
-> (forall x. Rep MetricPolicy x -> MetricPolicy)
-> Generic MetricPolicy
forall x. Rep MetricPolicy x -> MetricPolicy
forall x. MetricPolicy -> Rep MetricPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricPolicy x -> MetricPolicy
$cfrom :: forall x. MetricPolicy -> Rep MetricPolicy x
Prelude.Generic)
newMetricPolicy ::
ContainerLevelMetrics ->
MetricPolicy
newMetricPolicy :: ContainerLevelMetrics -> MetricPolicy
newMetricPolicy ContainerLevelMetrics
pContainerLevelMetrics_ =
MetricPolicy' :: Maybe (NonEmpty MetricPolicyRule)
-> ContainerLevelMetrics -> MetricPolicy
MetricPolicy'
{ $sel:metricPolicyRules:MetricPolicy' :: Maybe (NonEmpty MetricPolicyRule)
metricPolicyRules = Maybe (NonEmpty MetricPolicyRule)
forall a. Maybe a
Prelude.Nothing,
$sel:containerLevelMetrics:MetricPolicy' :: ContainerLevelMetrics
containerLevelMetrics = ContainerLevelMetrics
pContainerLevelMetrics_
}
metricPolicy_metricPolicyRules :: Lens.Lens' MetricPolicy (Prelude.Maybe (Prelude.NonEmpty MetricPolicyRule))
metricPolicy_metricPolicyRules :: (Maybe (NonEmpty MetricPolicyRule)
-> f (Maybe (NonEmpty MetricPolicyRule)))
-> MetricPolicy -> f MetricPolicy
metricPolicy_metricPolicyRules = (MetricPolicy -> Maybe (NonEmpty MetricPolicyRule))
-> (MetricPolicy
-> Maybe (NonEmpty MetricPolicyRule) -> MetricPolicy)
-> Lens
MetricPolicy
MetricPolicy
(Maybe (NonEmpty MetricPolicyRule))
(Maybe (NonEmpty MetricPolicyRule))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricPolicy' {Maybe (NonEmpty MetricPolicyRule)
metricPolicyRules :: Maybe (NonEmpty MetricPolicyRule)
$sel:metricPolicyRules:MetricPolicy' :: MetricPolicy -> Maybe (NonEmpty MetricPolicyRule)
metricPolicyRules} -> Maybe (NonEmpty MetricPolicyRule)
metricPolicyRules) (\s :: MetricPolicy
s@MetricPolicy' {} Maybe (NonEmpty MetricPolicyRule)
a -> MetricPolicy
s {$sel:metricPolicyRules:MetricPolicy' :: Maybe (NonEmpty MetricPolicyRule)
metricPolicyRules = Maybe (NonEmpty MetricPolicyRule)
a} :: MetricPolicy) ((Maybe (NonEmpty MetricPolicyRule)
-> f (Maybe (NonEmpty MetricPolicyRule)))
-> MetricPolicy -> f MetricPolicy)
-> ((Maybe (NonEmpty MetricPolicyRule)
-> f (Maybe (NonEmpty MetricPolicyRule)))
-> Maybe (NonEmpty MetricPolicyRule)
-> f (Maybe (NonEmpty MetricPolicyRule)))
-> (Maybe (NonEmpty MetricPolicyRule)
-> f (Maybe (NonEmpty MetricPolicyRule)))
-> MetricPolicy
-> f MetricPolicy
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(NonEmpty MetricPolicyRule)
(NonEmpty MetricPolicyRule)
(NonEmpty MetricPolicyRule)
(NonEmpty MetricPolicyRule)
-> Iso
(Maybe (NonEmpty MetricPolicyRule))
(Maybe (NonEmpty MetricPolicyRule))
(Maybe (NonEmpty MetricPolicyRule))
(Maybe (NonEmpty MetricPolicyRule))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
(NonEmpty MetricPolicyRule)
(NonEmpty MetricPolicyRule)
(NonEmpty MetricPolicyRule)
(NonEmpty MetricPolicyRule)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
metricPolicy_containerLevelMetrics :: Lens.Lens' MetricPolicy ContainerLevelMetrics
metricPolicy_containerLevelMetrics :: (ContainerLevelMetrics -> f ContainerLevelMetrics)
-> MetricPolicy -> f MetricPolicy
metricPolicy_containerLevelMetrics = (MetricPolicy -> ContainerLevelMetrics)
-> (MetricPolicy -> ContainerLevelMetrics -> MetricPolicy)
-> Lens
MetricPolicy
MetricPolicy
ContainerLevelMetrics
ContainerLevelMetrics
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricPolicy' {ContainerLevelMetrics
containerLevelMetrics :: ContainerLevelMetrics
$sel:containerLevelMetrics:MetricPolicy' :: MetricPolicy -> ContainerLevelMetrics
containerLevelMetrics} -> ContainerLevelMetrics
containerLevelMetrics) (\s :: MetricPolicy
s@MetricPolicy' {} ContainerLevelMetrics
a -> MetricPolicy
s {$sel:containerLevelMetrics:MetricPolicy' :: ContainerLevelMetrics
containerLevelMetrics = ContainerLevelMetrics
a} :: MetricPolicy)
instance Core.FromJSON MetricPolicy where
parseJSON :: Value -> Parser MetricPolicy
parseJSON =
String
-> (Object -> Parser MetricPolicy) -> Value -> Parser MetricPolicy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"MetricPolicy"
( \Object
x ->
Maybe (NonEmpty MetricPolicyRule)
-> ContainerLevelMetrics -> MetricPolicy
MetricPolicy'
(Maybe (NonEmpty MetricPolicyRule)
-> ContainerLevelMetrics -> MetricPolicy)
-> Parser (Maybe (NonEmpty MetricPolicyRule))
-> Parser (ContainerLevelMetrics -> MetricPolicy)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty MetricPolicyRule))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MetricPolicyRules")
Parser (ContainerLevelMetrics -> MetricPolicy)
-> Parser ContainerLevelMetrics -> Parser MetricPolicy
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ContainerLevelMetrics
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ContainerLevelMetrics")
)
instance Prelude.Hashable MetricPolicy
instance Prelude.NFData MetricPolicy
instance Core.ToJSON MetricPolicy where
toJSON :: MetricPolicy -> Value
toJSON MetricPolicy' {Maybe (NonEmpty MetricPolicyRule)
ContainerLevelMetrics
containerLevelMetrics :: ContainerLevelMetrics
metricPolicyRules :: Maybe (NonEmpty MetricPolicyRule)
$sel:containerLevelMetrics:MetricPolicy' :: MetricPolicy -> ContainerLevelMetrics
$sel:metricPolicyRules:MetricPolicy' :: MetricPolicy -> Maybe (NonEmpty MetricPolicyRule)
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"MetricPolicyRules" Text -> NonEmpty MetricPolicyRule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(NonEmpty MetricPolicyRule -> Pair)
-> Maybe (NonEmpty MetricPolicyRule) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty MetricPolicyRule)
metricPolicyRules,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
( Text
"ContainerLevelMetrics"
Text -> ContainerLevelMetrics -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ContainerLevelMetrics
containerLevelMetrics
)
]
)