-- | Constructs the compound payload for image events
getImagePayload :: Metric -> IO (Maybe Word64)
getImagePayload m@Metric{..} = do
    verb <- case T.splitOn "." <$> getEventType m of
        Just (_:verb:_) -> case parseImageVerb verb of
            Just x  -> return $ Just x
            Nothing -> do
                alertM "Ceilometer.Process.getImagePayload" $
                    "Invalid verb for image event: " <> show verb
                return Nothing
        Just x -> do
            alertM "Ceilometer.Process.getImagePayload"
                 $ "Invalid parse of verb for image event" <> show x
            return Nothing
        Nothing -> do
            alertM "Ceilometer.Process.getImagePayload"
                   "event_type field missing from image event"
            return Nothing
    status <- case H.lookup "status" metricMetadata of
        Just (String status) -> case parseImageStatus status of
            Just x  -> return $ Just x
            Nothing -> do
                alertM "Ceilometer.Process.getImagePayload" $
                       "Invalid status for image event: " <> show status
                return Nothing
        Just x -> do
            alertM "Ceilometer.Process.getImagePayload"
                 $ "Invalid parse of status for image event" <> show x
            return Nothing
        Nothing -> do
            alertM "Ceilometer.Process.getImagePayload"
                   "Status field missing from image event"
            return Nothing
    return $ do
        s <- status
        v <- verb
        let e = Instant
        p <- fromIntegral <$> metricPayload
        return $ review (prCompoundEvent . pdImage) $ PDImage s v e p
getImagePayload :: Metric -> IO (Maybe Word64)
getImagePayload m@Metric{..} = do
    verb <- case T.splitOn "." <$> getEventType m of
        Just (_:verb:_) -> case parseImageVerb verb of
            Just x  -> return $ Just x
            Nothing -> do
                alertM "Ceilometer.Process.getImagePayload" $
                    "Invalid verb for image event: " <> show verb
                return Nothing
        Just x -> do
            alertM "Ceilometer.Process.getImagePayload"
                 $ "Invalid parse of verb for image event" <> show x
            return Nothing
        Nothing -> do
            alertM "Ceilometer.Process.getImagePayload"
                   "event_type field missing from image event"
            return Nothing
    status <- case H.lookup "status" metricMetadata of
        Just (String status) -> case parseImageStatus status of
            Just x  -> return $ Just x
            Nothing -> do
                alertM "Ceilometer.Process.getImagePayload" $
                       "Invalid status for image event: " <> show status
                return Nothing
        Just x -> do
            alertM "Ceilometer.Process.getImagePayload"
                 $ "Invalid parse of status for image event" <> show x
            return Nothing
        Nothing -> do
            alertM "Ceilometer.Process.getImagePayload"
                   "Status field missing from image event"
            return Nothing
    return $ do
        s <- status
        v <- verb
        let e = Instant
        p <- fromIntegral <$> metricPayload
        return $ review (prCompoundEvent . pdImage) $ PDImage s v e p
getImagePayload m@Metric{..} = do
    verb <- case T.splitOn "." <$> getEventType m of
        Just (_:verb:_) -> case parseImageVerb verb of
            Just x  -> return $ Just x
            Nothing -> do
                alertM "Ceilometer.Process.getImagePayload" $
                    "Invalid verb for image event: " <> show verb
                return Nothing
        Just x -> do
            alertM "Ceilometer.Process.getImagePayload"
                 $ "Invalid parse of verb for image event" <> show x
            return Nothing
        Nothing -> do
            alertM "Ceilometer.Process.getImagePayload"
                   "event_type field missing from image event"
            return Nothing
    status <- case H.lookup "status" metricMetadata of
        Just (String status) -> case parseImageStatus status of
            Just x  -> return $ Just x
            Nothing -> do
                alertM "Ceilometer.Process.getImagePayload" $
                       "Invalid status for image event: " <> show status
                return Nothing
        Just x -> do
            alertM "Ceilometer.Process.getImagePayload"
                 $ "Invalid parse of status for image event" <> show x
            return Nothing
        Nothing -> do
            alertM "Ceilometer.Process.getImagePayload"
                   "Status field missing from image event"
            return Nothing
    return $ do
        s <- status
        v <- verb
        let e = Instant
        p <- fromIntegral <$> metricPayload
        return $ review (prCompoundEvent . pdImage) $ PDImage s v e p