{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.CloudWatchEvents.PutTargets
(
PutTargets (..),
newPutTargets,
putTargets_eventBusName,
putTargets_rule,
putTargets_targets,
PutTargetsResponse (..),
newPutTargetsResponse,
putTargetsResponse_failedEntryCount,
putTargetsResponse_failedEntries,
putTargetsResponse_httpStatus,
)
where
import Amazonka.CloudWatchEvents.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data PutTargets = PutTargets'
{
PutTargets -> Maybe Text
eventBusName :: Prelude.Maybe Prelude.Text,
PutTargets -> Text
rule :: Prelude.Text,
PutTargets -> NonEmpty Target
targets :: Prelude.NonEmpty Target
}
deriving (PutTargets -> PutTargets -> Bool
(PutTargets -> PutTargets -> Bool)
-> (PutTargets -> PutTargets -> Bool) -> Eq PutTargets
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutTargets -> PutTargets -> Bool
$c/= :: PutTargets -> PutTargets -> Bool
== :: PutTargets -> PutTargets -> Bool
$c== :: PutTargets -> PutTargets -> Bool
Prelude.Eq, ReadPrec [PutTargets]
ReadPrec PutTargets
Int -> ReadS PutTargets
ReadS [PutTargets]
(Int -> ReadS PutTargets)
-> ReadS [PutTargets]
-> ReadPrec PutTargets
-> ReadPrec [PutTargets]
-> Read PutTargets
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutTargets]
$creadListPrec :: ReadPrec [PutTargets]
readPrec :: ReadPrec PutTargets
$creadPrec :: ReadPrec PutTargets
readList :: ReadS [PutTargets]
$creadList :: ReadS [PutTargets]
readsPrec :: Int -> ReadS PutTargets
$creadsPrec :: Int -> ReadS PutTargets
Prelude.Read, Int -> PutTargets -> ShowS
[PutTargets] -> ShowS
PutTargets -> String
(Int -> PutTargets -> ShowS)
-> (PutTargets -> String)
-> ([PutTargets] -> ShowS)
-> Show PutTargets
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutTargets] -> ShowS
$cshowList :: [PutTargets] -> ShowS
show :: PutTargets -> String
$cshow :: PutTargets -> String
showsPrec :: Int -> PutTargets -> ShowS
$cshowsPrec :: Int -> PutTargets -> ShowS
Prelude.Show, (forall x. PutTargets -> Rep PutTargets x)
-> (forall x. Rep PutTargets x -> PutTargets) -> Generic PutTargets
forall x. Rep PutTargets x -> PutTargets
forall x. PutTargets -> Rep PutTargets x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutTargets x -> PutTargets
$cfrom :: forall x. PutTargets -> Rep PutTargets x
Prelude.Generic)
newPutTargets ::
Prelude.Text ->
Prelude.NonEmpty Target ->
PutTargets
newPutTargets :: Text -> NonEmpty Target -> PutTargets
newPutTargets Text
pRule_ NonEmpty Target
pTargets_ =
PutTargets' :: Maybe Text -> Text -> NonEmpty Target -> PutTargets
PutTargets'
{ $sel:eventBusName:PutTargets' :: Maybe Text
eventBusName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:rule:PutTargets' :: Text
rule = Text
pRule_,
$sel:targets:PutTargets' :: NonEmpty Target
targets = Tagged (NonEmpty Target) (Identity (NonEmpty Target))
-> Tagged (NonEmpty Target) (Identity (NonEmpty Target))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Target) (Identity (NonEmpty Target))
-> Tagged (NonEmpty Target) (Identity (NonEmpty Target)))
-> NonEmpty Target -> NonEmpty Target
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Target
pTargets_
}
putTargets_eventBusName :: Lens.Lens' PutTargets (Prelude.Maybe Prelude.Text)
putTargets_eventBusName :: (Maybe Text -> f (Maybe Text)) -> PutTargets -> f PutTargets
putTargets_eventBusName = (PutTargets -> Maybe Text)
-> (PutTargets -> Maybe Text -> PutTargets)
-> Lens PutTargets PutTargets (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTargets' {Maybe Text
eventBusName :: Maybe Text
$sel:eventBusName:PutTargets' :: PutTargets -> Maybe Text
eventBusName} -> Maybe Text
eventBusName) (\s :: PutTargets
s@PutTargets' {} Maybe Text
a -> PutTargets
s {$sel:eventBusName:PutTargets' :: Maybe Text
eventBusName = Maybe Text
a} :: PutTargets)
putTargets_rule :: Lens.Lens' PutTargets Prelude.Text
putTargets_rule :: (Text -> f Text) -> PutTargets -> f PutTargets
putTargets_rule = (PutTargets -> Text)
-> (PutTargets -> Text -> PutTargets)
-> Lens PutTargets PutTargets Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTargets' {Text
rule :: Text
$sel:rule:PutTargets' :: PutTargets -> Text
rule} -> Text
rule) (\s :: PutTargets
s@PutTargets' {} Text
a -> PutTargets
s {$sel:rule:PutTargets' :: Text
rule = Text
a} :: PutTargets)
putTargets_targets :: Lens.Lens' PutTargets (Prelude.NonEmpty Target)
putTargets_targets :: (NonEmpty Target -> f (NonEmpty Target))
-> PutTargets -> f PutTargets
putTargets_targets = (PutTargets -> NonEmpty Target)
-> (PutTargets -> NonEmpty Target -> PutTargets)
-> Lens PutTargets PutTargets (NonEmpty Target) (NonEmpty Target)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTargets' {NonEmpty Target
targets :: NonEmpty Target
$sel:targets:PutTargets' :: PutTargets -> NonEmpty Target
targets} -> NonEmpty Target
targets) (\s :: PutTargets
s@PutTargets' {} NonEmpty Target
a -> PutTargets
s {$sel:targets:PutTargets' :: NonEmpty Target
targets = NonEmpty Target
a} :: PutTargets) ((NonEmpty Target -> f (NonEmpty Target))
-> PutTargets -> f PutTargets)
-> ((NonEmpty Target -> f (NonEmpty Target))
-> NonEmpty Target -> f (NonEmpty Target))
-> (NonEmpty Target -> f (NonEmpty Target))
-> PutTargets
-> f PutTargets
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Target -> f (NonEmpty Target))
-> NonEmpty Target -> f (NonEmpty Target)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest PutTargets where
type AWSResponse PutTargets = PutTargetsResponse
request :: PutTargets -> Request PutTargets
request = Service -> PutTargets -> Request PutTargets
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy PutTargets
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutTargets)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse PutTargets))
-> Logger
-> Service
-> Proxy PutTargets
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutTargets)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Int
-> Maybe [PutTargetsResultEntry] -> Int -> PutTargetsResponse
PutTargetsResponse'
(Maybe Int
-> Maybe [PutTargetsResultEntry] -> Int -> PutTargetsResponse)
-> Either String (Maybe Int)
-> Either
String (Maybe [PutTargetsResultEntry] -> Int -> PutTargetsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Int)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"FailedEntryCount")
Either
String (Maybe [PutTargetsResultEntry] -> Int -> PutTargetsResponse)
-> Either String (Maybe [PutTargetsResultEntry])
-> Either String (Int -> PutTargetsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Either String (Maybe (Maybe [PutTargetsResultEntry]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"FailedEntries" Either String (Maybe (Maybe [PutTargetsResultEntry]))
-> Maybe [PutTargetsResultEntry]
-> Either String (Maybe [PutTargetsResultEntry])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [PutTargetsResultEntry]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> PutTargetsResponse)
-> Either String Int -> Either String PutTargetsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable PutTargets
instance Prelude.NFData PutTargets
instance Core.ToHeaders PutTargets where
toHeaders :: PutTargets -> ResponseHeaders
toHeaders =
ResponseHeaders -> PutTargets -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"AWSEvents.PutTargets" :: Prelude.ByteString),
HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON PutTargets where
toJSON :: PutTargets -> Value
toJSON PutTargets' {Maybe Text
NonEmpty Target
Text
targets :: NonEmpty Target
rule :: Text
eventBusName :: Maybe Text
$sel:targets:PutTargets' :: PutTargets -> NonEmpty Target
$sel:rule:PutTargets' :: PutTargets -> Text
$sel:eventBusName:PutTargets' :: PutTargets -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"EventBusName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
eventBusName,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Rule" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
rule),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Targets" Text -> NonEmpty Target -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Target
targets)
]
)
instance Core.ToPath PutTargets where
toPath :: PutTargets -> ByteString
toPath = ByteString -> PutTargets -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery PutTargets where
toQuery :: PutTargets -> QueryString
toQuery = QueryString -> PutTargets -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data PutTargetsResponse = PutTargetsResponse'
{
PutTargetsResponse -> Maybe Int
failedEntryCount :: Prelude.Maybe Prelude.Int,
PutTargetsResponse -> Maybe [PutTargetsResultEntry]
failedEntries :: Prelude.Maybe [PutTargetsResultEntry],
PutTargetsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (PutTargetsResponse -> PutTargetsResponse -> Bool
(PutTargetsResponse -> PutTargetsResponse -> Bool)
-> (PutTargetsResponse -> PutTargetsResponse -> Bool)
-> Eq PutTargetsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutTargetsResponse -> PutTargetsResponse -> Bool
$c/= :: PutTargetsResponse -> PutTargetsResponse -> Bool
== :: PutTargetsResponse -> PutTargetsResponse -> Bool
$c== :: PutTargetsResponse -> PutTargetsResponse -> Bool
Prelude.Eq, ReadPrec [PutTargetsResponse]
ReadPrec PutTargetsResponse
Int -> ReadS PutTargetsResponse
ReadS [PutTargetsResponse]
(Int -> ReadS PutTargetsResponse)
-> ReadS [PutTargetsResponse]
-> ReadPrec PutTargetsResponse
-> ReadPrec [PutTargetsResponse]
-> Read PutTargetsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutTargetsResponse]
$creadListPrec :: ReadPrec [PutTargetsResponse]
readPrec :: ReadPrec PutTargetsResponse
$creadPrec :: ReadPrec PutTargetsResponse
readList :: ReadS [PutTargetsResponse]
$creadList :: ReadS [PutTargetsResponse]
readsPrec :: Int -> ReadS PutTargetsResponse
$creadsPrec :: Int -> ReadS PutTargetsResponse
Prelude.Read, Int -> PutTargetsResponse -> ShowS
[PutTargetsResponse] -> ShowS
PutTargetsResponse -> String
(Int -> PutTargetsResponse -> ShowS)
-> (PutTargetsResponse -> String)
-> ([PutTargetsResponse] -> ShowS)
-> Show PutTargetsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutTargetsResponse] -> ShowS
$cshowList :: [PutTargetsResponse] -> ShowS
show :: PutTargetsResponse -> String
$cshow :: PutTargetsResponse -> String
showsPrec :: Int -> PutTargetsResponse -> ShowS
$cshowsPrec :: Int -> PutTargetsResponse -> ShowS
Prelude.Show, (forall x. PutTargetsResponse -> Rep PutTargetsResponse x)
-> (forall x. Rep PutTargetsResponse x -> PutTargetsResponse)
-> Generic PutTargetsResponse
forall x. Rep PutTargetsResponse x -> PutTargetsResponse
forall x. PutTargetsResponse -> Rep PutTargetsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutTargetsResponse x -> PutTargetsResponse
$cfrom :: forall x. PutTargetsResponse -> Rep PutTargetsResponse x
Prelude.Generic)
newPutTargetsResponse ::
Prelude.Int ->
PutTargetsResponse
newPutTargetsResponse :: Int -> PutTargetsResponse
newPutTargetsResponse Int
pHttpStatus_ =
PutTargetsResponse' :: Maybe Int
-> Maybe [PutTargetsResultEntry] -> Int -> PutTargetsResponse
PutTargetsResponse'
{ $sel:failedEntryCount:PutTargetsResponse' :: Maybe Int
failedEntryCount =
Maybe Int
forall a. Maybe a
Prelude.Nothing,
$sel:failedEntries:PutTargetsResponse' :: Maybe [PutTargetsResultEntry]
failedEntries = Maybe [PutTargetsResultEntry]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:PutTargetsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
putTargetsResponse_failedEntryCount :: Lens.Lens' PutTargetsResponse (Prelude.Maybe Prelude.Int)
putTargetsResponse_failedEntryCount :: (Maybe Int -> f (Maybe Int))
-> PutTargetsResponse -> f PutTargetsResponse
putTargetsResponse_failedEntryCount = (PutTargetsResponse -> Maybe Int)
-> (PutTargetsResponse -> Maybe Int -> PutTargetsResponse)
-> Lens
PutTargetsResponse PutTargetsResponse (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTargetsResponse' {Maybe Int
failedEntryCount :: Maybe Int
$sel:failedEntryCount:PutTargetsResponse' :: PutTargetsResponse -> Maybe Int
failedEntryCount} -> Maybe Int
failedEntryCount) (\s :: PutTargetsResponse
s@PutTargetsResponse' {} Maybe Int
a -> PutTargetsResponse
s {$sel:failedEntryCount:PutTargetsResponse' :: Maybe Int
failedEntryCount = Maybe Int
a} :: PutTargetsResponse)
putTargetsResponse_failedEntries :: Lens.Lens' PutTargetsResponse (Prelude.Maybe [PutTargetsResultEntry])
putTargetsResponse_failedEntries :: (Maybe [PutTargetsResultEntry]
-> f (Maybe [PutTargetsResultEntry]))
-> PutTargetsResponse -> f PutTargetsResponse
putTargetsResponse_failedEntries = (PutTargetsResponse -> Maybe [PutTargetsResultEntry])
-> (PutTargetsResponse
-> Maybe [PutTargetsResultEntry] -> PutTargetsResponse)
-> Lens
PutTargetsResponse
PutTargetsResponse
(Maybe [PutTargetsResultEntry])
(Maybe [PutTargetsResultEntry])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTargetsResponse' {Maybe [PutTargetsResultEntry]
failedEntries :: Maybe [PutTargetsResultEntry]
$sel:failedEntries:PutTargetsResponse' :: PutTargetsResponse -> Maybe [PutTargetsResultEntry]
failedEntries} -> Maybe [PutTargetsResultEntry]
failedEntries) (\s :: PutTargetsResponse
s@PutTargetsResponse' {} Maybe [PutTargetsResultEntry]
a -> PutTargetsResponse
s {$sel:failedEntries:PutTargetsResponse' :: Maybe [PutTargetsResultEntry]
failedEntries = Maybe [PutTargetsResultEntry]
a} :: PutTargetsResponse) ((Maybe [PutTargetsResultEntry]
-> f (Maybe [PutTargetsResultEntry]))
-> PutTargetsResponse -> f PutTargetsResponse)
-> ((Maybe [PutTargetsResultEntry]
-> f (Maybe [PutTargetsResultEntry]))
-> Maybe [PutTargetsResultEntry]
-> f (Maybe [PutTargetsResultEntry]))
-> (Maybe [PutTargetsResultEntry]
-> f (Maybe [PutTargetsResultEntry]))
-> PutTargetsResponse
-> f PutTargetsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[PutTargetsResultEntry]
[PutTargetsResultEntry]
[PutTargetsResultEntry]
[PutTargetsResultEntry]
-> Iso
(Maybe [PutTargetsResultEntry])
(Maybe [PutTargetsResultEntry])
(Maybe [PutTargetsResultEntry])
(Maybe [PutTargetsResultEntry])
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
[PutTargetsResultEntry]
[PutTargetsResultEntry]
[PutTargetsResultEntry]
[PutTargetsResultEntry]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
putTargetsResponse_httpStatus :: Lens.Lens' PutTargetsResponse Prelude.Int
putTargetsResponse_httpStatus :: (Int -> f Int) -> PutTargetsResponse -> f PutTargetsResponse
putTargetsResponse_httpStatus = (PutTargetsResponse -> Int)
-> (PutTargetsResponse -> Int -> PutTargetsResponse)
-> Lens PutTargetsResponse PutTargetsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTargetsResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutTargetsResponse' :: PutTargetsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutTargetsResponse
s@PutTargetsResponse' {} Int
a -> PutTargetsResponse
s {$sel:httpStatus:PutTargetsResponse' :: Int
httpStatus = Int
a} :: PutTargetsResponse)
instance Prelude.NFData PutTargetsResponse