module Network.AWS.MachineLearning.Predict
(
predict
, Predict
, pMLModelId
, pRecord
, pPredictEndpoint
, predictResponse
, PredictResponse
, prsPrediction
, prsStatus
) where
import Network.AWS.MachineLearning.Types
import Network.AWS.MachineLearning.Types.Product
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data Predict = Predict'
{ _pMLModelId :: !Text
, _pRecord :: !(Map Text Text)
, _pPredictEndpoint :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
predict
:: Text
-> Text
-> Predict
predict pMLModelId_ pPredictEndpoint_ =
Predict'
{ _pMLModelId = pMLModelId_
, _pRecord = mempty
, _pPredictEndpoint = pPredictEndpoint_
}
pMLModelId :: Lens' Predict Text
pMLModelId = lens _pMLModelId (\ s a -> s{_pMLModelId = a});
pRecord :: Lens' Predict (HashMap Text Text)
pRecord = lens _pRecord (\ s a -> s{_pRecord = a}) . _Map;
pPredictEndpoint :: Lens' Predict Text
pPredictEndpoint = lens _pPredictEndpoint (\ s a -> s{_pPredictEndpoint = a});
instance AWSRequest Predict where
type Rs Predict = PredictResponse
request = postJSON machineLearning
response
= receiveJSON
(\ s h x ->
PredictResponse' <$>
(x .?> "Prediction") <*> (pure (fromEnum s)))
instance ToHeaders Predict where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AmazonML_20141212.Predict" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON Predict where
toJSON Predict'{..}
= object
(catMaybes
[Just ("MLModelId" .= _pMLModelId),
Just ("Record" .= _pRecord),
Just ("PredictEndpoint" .= _pPredictEndpoint)])
instance ToPath Predict where
toPath = const "/"
instance ToQuery Predict where
toQuery = const mempty
data PredictResponse = PredictResponse'
{ _prsPrediction :: !(Maybe Prediction)
, _prsStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
predictResponse
:: Int
-> PredictResponse
predictResponse pStatus_ =
PredictResponse'
{ _prsPrediction = Nothing
, _prsStatus = pStatus_
}
prsPrediction :: Lens' PredictResponse (Maybe Prediction)
prsPrediction = lens _prsPrediction (\ s a -> s{_prsPrediction = a});
prsStatus :: Lens' PredictResponse Int
prsStatus = lens _prsStatus (\ s a -> s{_prsStatus = a});