module Network.AWS.CloudWatchLogs.PutLogEvents
    (
    
      putLogEvents
    , PutLogEvents
    
    , pleSequenceToken
    , pleLogGroupName
    , pleLogStreamName
    , pleLogEvents
    
    , putLogEventsResponse
    , PutLogEventsResponse
    
    , plersRejectedLogEventsInfo
    , plersNextSequenceToken
    , plersStatus
    ) where
import           Network.AWS.CloudWatchLogs.Types
import           Network.AWS.CloudWatchLogs.Types.Product
import           Network.AWS.Prelude
import           Network.AWS.Request
import           Network.AWS.Response
data PutLogEvents = PutLogEvents'
    { _pleSequenceToken :: !(Maybe Text)
    , _pleLogGroupName  :: !Text
    , _pleLogStreamName :: !Text
    , _pleLogEvents     :: !(List1 InputLogEvent)
    } deriving (Eq,Read,Show,Data,Typeable,Generic)
putLogEvents
    :: Text 
    -> Text 
    -> NonEmpty InputLogEvent 
    -> PutLogEvents
putLogEvents pLogGroupName_ pLogStreamName_ pLogEvents_ =
    PutLogEvents'
    { _pleSequenceToken = Nothing
    , _pleLogGroupName = pLogGroupName_
    , _pleLogStreamName = pLogStreamName_
    , _pleLogEvents = _List1 # pLogEvents_
    }
pleSequenceToken :: Lens' PutLogEvents (Maybe Text)
pleSequenceToken = lens _pleSequenceToken (\ s a -> s{_pleSequenceToken = a});
pleLogGroupName :: Lens' PutLogEvents Text
pleLogGroupName = lens _pleLogGroupName (\ s a -> s{_pleLogGroupName = a});
pleLogStreamName :: Lens' PutLogEvents Text
pleLogStreamName = lens _pleLogStreamName (\ s a -> s{_pleLogStreamName = a});
pleLogEvents :: Lens' PutLogEvents (NonEmpty InputLogEvent)
pleLogEvents = lens _pleLogEvents (\ s a -> s{_pleLogEvents = a}) . _List1;
instance AWSRequest PutLogEvents where
        type Rs PutLogEvents = PutLogEventsResponse
        request = postJSON cloudWatchLogs
        response
          = receiveJSON
              (\ s h x ->
                 PutLogEventsResponse' <$>
                   (x .?> "rejectedLogEventsInfo") <*>
                     (x .?> "nextSequenceToken")
                     <*> (pure (fromEnum s)))
instance ToHeaders PutLogEvents where
        toHeaders
          = const
              (mconcat
                 ["X-Amz-Target" =#
                    ("Logs_20140328.PutLogEvents" :: ByteString),
                  "Content-Type" =#
                    ("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON PutLogEvents where
        toJSON PutLogEvents'{..}
          = object
              (catMaybes
                 [("sequenceToken" .=) <$> _pleSequenceToken,
                  Just ("logGroupName" .= _pleLogGroupName),
                  Just ("logStreamName" .= _pleLogStreamName),
                  Just ("logEvents" .= _pleLogEvents)])
instance ToPath PutLogEvents where
        toPath = const "/"
instance ToQuery PutLogEvents where
        toQuery = const mempty
data PutLogEventsResponse = PutLogEventsResponse'
    { _plersRejectedLogEventsInfo :: !(Maybe RejectedLogEventsInfo)
    , _plersNextSequenceToken     :: !(Maybe Text)
    , _plersStatus                :: !Int
    } deriving (Eq,Read,Show,Data,Typeable,Generic)
putLogEventsResponse
    :: Int 
    -> PutLogEventsResponse
putLogEventsResponse pStatus_ =
    PutLogEventsResponse'
    { _plersRejectedLogEventsInfo = Nothing
    , _plersNextSequenceToken = Nothing
    , _plersStatus = pStatus_
    }
plersRejectedLogEventsInfo :: Lens' PutLogEventsResponse (Maybe RejectedLogEventsInfo)
plersRejectedLogEventsInfo = lens _plersRejectedLogEventsInfo (\ s a -> s{_plersRejectedLogEventsInfo = a});
plersNextSequenceToken :: Lens' PutLogEventsResponse (Maybe Text)
plersNextSequenceToken = lens _plersNextSequenceToken (\ s a -> s{_plersNextSequenceToken = a});
plersStatus :: Lens' PutLogEventsResponse Int
plersStatus = lens _plersStatus (\ s a -> s{_plersStatus = a});