{-# 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.CloudWatchEvents.Types.RunCommandTarget where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data RunCommandTarget = RunCommandTarget'
{
RunCommandTarget -> Text
key :: Prelude.Text,
RunCommandTarget -> NonEmpty Text
values :: Prelude.NonEmpty Prelude.Text
}
deriving (RunCommandTarget -> RunCommandTarget -> Bool
(RunCommandTarget -> RunCommandTarget -> Bool)
-> (RunCommandTarget -> RunCommandTarget -> Bool)
-> Eq RunCommandTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RunCommandTarget -> RunCommandTarget -> Bool
$c/= :: RunCommandTarget -> RunCommandTarget -> Bool
== :: RunCommandTarget -> RunCommandTarget -> Bool
$c== :: RunCommandTarget -> RunCommandTarget -> Bool
Prelude.Eq, ReadPrec [RunCommandTarget]
ReadPrec RunCommandTarget
Int -> ReadS RunCommandTarget
ReadS [RunCommandTarget]
(Int -> ReadS RunCommandTarget)
-> ReadS [RunCommandTarget]
-> ReadPrec RunCommandTarget
-> ReadPrec [RunCommandTarget]
-> Read RunCommandTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RunCommandTarget]
$creadListPrec :: ReadPrec [RunCommandTarget]
readPrec :: ReadPrec RunCommandTarget
$creadPrec :: ReadPrec RunCommandTarget
readList :: ReadS [RunCommandTarget]
$creadList :: ReadS [RunCommandTarget]
readsPrec :: Int -> ReadS RunCommandTarget
$creadsPrec :: Int -> ReadS RunCommandTarget
Prelude.Read, Int -> RunCommandTarget -> ShowS
[RunCommandTarget] -> ShowS
RunCommandTarget -> String
(Int -> RunCommandTarget -> ShowS)
-> (RunCommandTarget -> String)
-> ([RunCommandTarget] -> ShowS)
-> Show RunCommandTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RunCommandTarget] -> ShowS
$cshowList :: [RunCommandTarget] -> ShowS
show :: RunCommandTarget -> String
$cshow :: RunCommandTarget -> String
showsPrec :: Int -> RunCommandTarget -> ShowS
$cshowsPrec :: Int -> RunCommandTarget -> ShowS
Prelude.Show, (forall x. RunCommandTarget -> Rep RunCommandTarget x)
-> (forall x. Rep RunCommandTarget x -> RunCommandTarget)
-> Generic RunCommandTarget
forall x. Rep RunCommandTarget x -> RunCommandTarget
forall x. RunCommandTarget -> Rep RunCommandTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RunCommandTarget x -> RunCommandTarget
$cfrom :: forall x. RunCommandTarget -> Rep RunCommandTarget x
Prelude.Generic)
newRunCommandTarget ::
Prelude.Text ->
Prelude.NonEmpty Prelude.Text ->
RunCommandTarget
newRunCommandTarget :: Text -> NonEmpty Text -> RunCommandTarget
newRunCommandTarget Text
pKey_ NonEmpty Text
pValues_ =
RunCommandTarget' :: Text -> NonEmpty Text -> RunCommandTarget
RunCommandTarget'
{ $sel:key:RunCommandTarget' :: Text
key = Text
pKey_,
$sel:values:RunCommandTarget' :: NonEmpty Text
values = 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
pValues_
}
runCommandTarget_key :: Lens.Lens' RunCommandTarget Prelude.Text
runCommandTarget_key :: (Text -> f Text) -> RunCommandTarget -> f RunCommandTarget
runCommandTarget_key = (RunCommandTarget -> Text)
-> (RunCommandTarget -> Text -> RunCommandTarget)
-> Lens RunCommandTarget RunCommandTarget Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RunCommandTarget' {Text
key :: Text
$sel:key:RunCommandTarget' :: RunCommandTarget -> Text
key} -> Text
key) (\s :: RunCommandTarget
s@RunCommandTarget' {} Text
a -> RunCommandTarget
s {$sel:key:RunCommandTarget' :: Text
key = Text
a} :: RunCommandTarget)
runCommandTarget_values :: Lens.Lens' RunCommandTarget (Prelude.NonEmpty Prelude.Text)
runCommandTarget_values :: (NonEmpty Text -> f (NonEmpty Text))
-> RunCommandTarget -> f RunCommandTarget
runCommandTarget_values = (RunCommandTarget -> NonEmpty Text)
-> (RunCommandTarget -> NonEmpty Text -> RunCommandTarget)
-> Lens
RunCommandTarget RunCommandTarget (NonEmpty Text) (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RunCommandTarget' {NonEmpty Text
values :: NonEmpty Text
$sel:values:RunCommandTarget' :: RunCommandTarget -> NonEmpty Text
values} -> NonEmpty Text
values) (\s :: RunCommandTarget
s@RunCommandTarget' {} NonEmpty Text
a -> RunCommandTarget
s {$sel:values:RunCommandTarget' :: NonEmpty Text
values = NonEmpty Text
a} :: RunCommandTarget) ((NonEmpty Text -> f (NonEmpty Text))
-> RunCommandTarget -> f RunCommandTarget)
-> ((NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> RunCommandTarget
-> f RunCommandTarget
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 RunCommandTarget where
parseJSON :: Value -> Parser RunCommandTarget
parseJSON =
String
-> (Object -> Parser RunCommandTarget)
-> Value
-> Parser RunCommandTarget
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"RunCommandTarget"
( \Object
x ->
Text -> NonEmpty Text -> RunCommandTarget
RunCommandTarget'
(Text -> NonEmpty Text -> RunCommandTarget)
-> Parser Text -> Parser (NonEmpty Text -> RunCommandTarget)
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
"Key") Parser (NonEmpty Text -> RunCommandTarget)
-> Parser (NonEmpty Text) -> Parser RunCommandTarget
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
"Values")
)
instance Prelude.Hashable RunCommandTarget
instance Prelude.NFData RunCommandTarget
instance Core.ToJSON RunCommandTarget where
toJSON :: RunCommandTarget -> Value
toJSON RunCommandTarget' {NonEmpty Text
Text
values :: NonEmpty Text
key :: Text
$sel:values:RunCommandTarget' :: RunCommandTarget -> NonEmpty Text
$sel:key:RunCommandTarget' :: RunCommandTarget -> 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
"Key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
key),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Values" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
values)
]
)