{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Network.AWS.CloudWatchEvents.PutEvents
(
putEvents
, PutEvents
, peEntries
, putEventsResponse
, PutEventsResponse
, persFailedEntryCount
, persEntries
, persResponseStatus
) where
import Network.AWS.CloudWatchEvents.Types
import Network.AWS.CloudWatchEvents.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
newtype PutEvents = PutEvents'
{ _peEntries :: List1 PutEventsRequestEntry
} deriving (Eq, Read, Show, Data, Typeable, Generic)
putEvents
:: NonEmpty PutEventsRequestEntry
-> PutEvents
putEvents pEntries_ = PutEvents' {_peEntries = _List1 # pEntries_}
peEntries :: Lens' PutEvents (NonEmpty PutEventsRequestEntry)
peEntries = lens _peEntries (\ s a -> s{_peEntries = a}) . _List1
instance AWSRequest PutEvents where
type Rs PutEvents = PutEventsResponse
request = postJSON cloudWatchEvents
response
= receiveJSON
(\ s h x ->
PutEventsResponse' <$>
(x .?> "FailedEntryCount") <*>
(x .?> "Entries" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable PutEvents where
instance NFData PutEvents where
instance ToHeaders PutEvents where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSEvents.PutEvents" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON PutEvents where
toJSON PutEvents'{..}
= object (catMaybes [Just ("Entries" .= _peEntries)])
instance ToPath PutEvents where
toPath = const "/"
instance ToQuery PutEvents where
toQuery = const mempty
data PutEventsResponse = PutEventsResponse'
{ _persFailedEntryCount :: !(Maybe Int)
, _persEntries :: !(Maybe [PutEventsResultEntry])
, _persResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
putEventsResponse
:: Int
-> PutEventsResponse
putEventsResponse pResponseStatus_ =
PutEventsResponse'
{ _persFailedEntryCount = Nothing
, _persEntries = Nothing
, _persResponseStatus = pResponseStatus_
}
persFailedEntryCount :: Lens' PutEventsResponse (Maybe Int)
persFailedEntryCount = lens _persFailedEntryCount (\ s a -> s{_persFailedEntryCount = a})
persEntries :: Lens' PutEventsResponse [PutEventsResultEntry]
persEntries = lens _persEntries (\ s a -> s{_persEntries = a}) . _Default . _Coerce
persResponseStatus :: Lens' PutEventsResponse Int
persResponseStatus = lens _persResponseStatus (\ s a -> s{_persResponseStatus = a})
instance NFData PutEventsResponse where