{-# 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.SageMakerRuntime.InvokeEndpoint
(
invokeEndpoint
, InvokeEndpoint
, ieAccept
, ieContentType
, ieEndpointName
, ieBody
, invokeEndpointResponse
, InvokeEndpointResponse
, iersInvokedProductionVariant
, iersContentType
, iersResponseStatus
, iersBody
) where
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.SageMakerRuntime.Types
import Network.AWS.SageMakerRuntime.Types.Product
data InvokeEndpoint = InvokeEndpoint'
{ _ieAccept :: !(Maybe Text)
, _ieContentType :: !(Maybe Text)
, _ieEndpointName :: !Text
, _ieBody :: !ByteString
} deriving (Eq, Read, Show, Data, Typeable, Generic)
invokeEndpoint
:: Text
-> ByteString
-> InvokeEndpoint
invokeEndpoint pEndpointName_ pBody_ =
InvokeEndpoint'
{ _ieAccept = Nothing
, _ieContentType = Nothing
, _ieEndpointName = pEndpointName_
, _ieBody = pBody_
}
ieAccept :: Lens' InvokeEndpoint (Maybe Text)
ieAccept = lens _ieAccept (\ s a -> s{_ieAccept = a})
ieContentType :: Lens' InvokeEndpoint (Maybe Text)
ieContentType = lens _ieContentType (\ s a -> s{_ieContentType = a})
ieEndpointName :: Lens' InvokeEndpoint Text
ieEndpointName = lens _ieEndpointName (\ s a -> s{_ieEndpointName = a})
ieBody :: Lens' InvokeEndpoint ByteString
ieBody = lens _ieBody (\ s a -> s{_ieBody = a})
instance AWSRequest InvokeEndpoint where
type Rs InvokeEndpoint = InvokeEndpointResponse
request = postBody sageMakerRuntime
response
= receiveBytes
(\ s h x ->
InvokeEndpointResponse' <$>
(h .#? "x-Amzn-Invoked-Production-Variant") <*>
(h .#? "Content-Type")
<*> (pure (fromEnum s))
<*> (pure x))
instance Hashable InvokeEndpoint where
instance NFData InvokeEndpoint where
instance ToBody InvokeEndpoint where
toBody = toBody . _ieBody
instance ToHeaders InvokeEndpoint where
toHeaders InvokeEndpoint'{..}
= mconcat
["Accept" =# _ieAccept,
"Content-Type" =# _ieContentType]
instance ToPath InvokeEndpoint where
toPath InvokeEndpoint'{..}
= mconcat
["/endpoints/", toBS _ieEndpointName, "/invocations"]
instance ToQuery InvokeEndpoint where
toQuery = const mempty
data InvokeEndpointResponse = InvokeEndpointResponse'
{ _iersInvokedProductionVariant :: !(Maybe Text)
, _iersContentType :: !(Maybe Text)
, _iersResponseStatus :: !Int
, _iersBody :: !ByteString
} deriving (Eq, Read, Show, Data, Typeable, Generic)
invokeEndpointResponse
:: Int
-> ByteString
-> InvokeEndpointResponse
invokeEndpointResponse pResponseStatus_ pBody_ =
InvokeEndpointResponse'
{ _iersInvokedProductionVariant = Nothing
, _iersContentType = Nothing
, _iersResponseStatus = pResponseStatus_
, _iersBody = pBody_
}
iersInvokedProductionVariant :: Lens' InvokeEndpointResponse (Maybe Text)
iersInvokedProductionVariant = lens _iersInvokedProductionVariant (\ s a -> s{_iersInvokedProductionVariant = a})
iersContentType :: Lens' InvokeEndpointResponse (Maybe Text)
iersContentType = lens _iersContentType (\ s a -> s{_iersContentType = a})
iersResponseStatus :: Lens' InvokeEndpointResponse Int
iersResponseStatus = lens _iersResponseStatus (\ s a -> s{_iersResponseStatus = a})
iersBody :: Lens' InvokeEndpointResponse ByteString
iersBody = lens _iersBody (\ s a -> s{_iersBody = a})
instance NFData InvokeEndpointResponse where