{-# 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.Budgets.Types.ScpActionDefinition where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data ScpActionDefinition = ScpActionDefinition'
{
ScpActionDefinition -> Text
policyId :: Prelude.Text,
ScpActionDefinition -> NonEmpty Text
targetIds :: Prelude.NonEmpty Prelude.Text
}
deriving (ScpActionDefinition -> ScpActionDefinition -> Bool
(ScpActionDefinition -> ScpActionDefinition -> Bool)
-> (ScpActionDefinition -> ScpActionDefinition -> Bool)
-> Eq ScpActionDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScpActionDefinition -> ScpActionDefinition -> Bool
$c/= :: ScpActionDefinition -> ScpActionDefinition -> Bool
== :: ScpActionDefinition -> ScpActionDefinition -> Bool
$c== :: ScpActionDefinition -> ScpActionDefinition -> Bool
Prelude.Eq, ReadPrec [ScpActionDefinition]
ReadPrec ScpActionDefinition
Int -> ReadS ScpActionDefinition
ReadS [ScpActionDefinition]
(Int -> ReadS ScpActionDefinition)
-> ReadS [ScpActionDefinition]
-> ReadPrec ScpActionDefinition
-> ReadPrec [ScpActionDefinition]
-> Read ScpActionDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScpActionDefinition]
$creadListPrec :: ReadPrec [ScpActionDefinition]
readPrec :: ReadPrec ScpActionDefinition
$creadPrec :: ReadPrec ScpActionDefinition
readList :: ReadS [ScpActionDefinition]
$creadList :: ReadS [ScpActionDefinition]
readsPrec :: Int -> ReadS ScpActionDefinition
$creadsPrec :: Int -> ReadS ScpActionDefinition
Prelude.Read, Int -> ScpActionDefinition -> ShowS
[ScpActionDefinition] -> ShowS
ScpActionDefinition -> String
(Int -> ScpActionDefinition -> ShowS)
-> (ScpActionDefinition -> String)
-> ([ScpActionDefinition] -> ShowS)
-> Show ScpActionDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScpActionDefinition] -> ShowS
$cshowList :: [ScpActionDefinition] -> ShowS
show :: ScpActionDefinition -> String
$cshow :: ScpActionDefinition -> String
showsPrec :: Int -> ScpActionDefinition -> ShowS
$cshowsPrec :: Int -> ScpActionDefinition -> ShowS
Prelude.Show, (forall x. ScpActionDefinition -> Rep ScpActionDefinition x)
-> (forall x. Rep ScpActionDefinition x -> ScpActionDefinition)
-> Generic ScpActionDefinition
forall x. Rep ScpActionDefinition x -> ScpActionDefinition
forall x. ScpActionDefinition -> Rep ScpActionDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScpActionDefinition x -> ScpActionDefinition
$cfrom :: forall x. ScpActionDefinition -> Rep ScpActionDefinition x
Prelude.Generic)
newScpActionDefinition ::
Prelude.Text ->
Prelude.NonEmpty Prelude.Text ->
ScpActionDefinition
newScpActionDefinition :: Text -> NonEmpty Text -> ScpActionDefinition
newScpActionDefinition Text
pPolicyId_ NonEmpty Text
pTargetIds_ =
ScpActionDefinition' :: Text -> NonEmpty Text -> ScpActionDefinition
ScpActionDefinition'
{ $sel:policyId:ScpActionDefinition' :: Text
policyId = Text
pPolicyId_,
$sel:targetIds:ScpActionDefinition' :: NonEmpty Text
targetIds = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pTargetIds_
}
scpActionDefinition_policyId :: Lens.Lens' ScpActionDefinition Prelude.Text
scpActionDefinition_policyId :: (Text -> f Text) -> ScpActionDefinition -> f ScpActionDefinition
scpActionDefinition_policyId = (ScpActionDefinition -> Text)
-> (ScpActionDefinition -> Text -> ScpActionDefinition)
-> Lens ScpActionDefinition ScpActionDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScpActionDefinition' {Text
policyId :: Text
$sel:policyId:ScpActionDefinition' :: ScpActionDefinition -> Text
policyId} -> Text
policyId) (\s :: ScpActionDefinition
s@ScpActionDefinition' {} Text
a -> ScpActionDefinition
s {$sel:policyId:ScpActionDefinition' :: Text
policyId = Text
a} :: ScpActionDefinition)
scpActionDefinition_targetIds :: Lens.Lens' ScpActionDefinition (Prelude.NonEmpty Prelude.Text)
scpActionDefinition_targetIds :: (NonEmpty Text -> f (NonEmpty Text))
-> ScpActionDefinition -> f ScpActionDefinition
scpActionDefinition_targetIds = (ScpActionDefinition -> NonEmpty Text)
-> (ScpActionDefinition -> NonEmpty Text -> ScpActionDefinition)
-> Lens
ScpActionDefinition
ScpActionDefinition
(NonEmpty Text)
(NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScpActionDefinition' {NonEmpty Text
targetIds :: NonEmpty Text
$sel:targetIds:ScpActionDefinition' :: ScpActionDefinition -> NonEmpty Text
targetIds} -> NonEmpty Text
targetIds) (\s :: ScpActionDefinition
s@ScpActionDefinition' {} NonEmpty Text
a -> ScpActionDefinition
s {$sel:targetIds:ScpActionDefinition' :: NonEmpty Text
targetIds = NonEmpty Text
a} :: ScpActionDefinition) ((NonEmpty Text -> f (NonEmpty Text))
-> ScpActionDefinition -> f ScpActionDefinition)
-> ((NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> ScpActionDefinition
-> f ScpActionDefinition
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON ScpActionDefinition where
parseJSON :: Value -> Parser ScpActionDefinition
parseJSON =
String
-> (Object -> Parser ScpActionDefinition)
-> Value
-> Parser ScpActionDefinition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"ScpActionDefinition"
( \Object
x ->
Text -> NonEmpty Text -> ScpActionDefinition
ScpActionDefinition'
(Text -> NonEmpty Text -> ScpActionDefinition)
-> Parser Text -> Parser (NonEmpty Text -> ScpActionDefinition)
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
"PolicyId")
Parser (NonEmpty Text -> ScpActionDefinition)
-> Parser (NonEmpty Text) -> Parser ScpActionDefinition
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TargetIds")
)
instance Prelude.Hashable ScpActionDefinition
instance Prelude.NFData ScpActionDefinition
instance Core.ToJSON ScpActionDefinition where
toJSON :: ScpActionDefinition -> Value
toJSON ScpActionDefinition' {NonEmpty Text
Text
targetIds :: NonEmpty Text
policyId :: Text
$sel:targetIds:ScpActionDefinition' :: ScpActionDefinition -> NonEmpty Text
$sel:policyId:ScpActionDefinition' :: ScpActionDefinition -> 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
"PolicyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
policyId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TargetIds" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
targetIds)
]
)