module Network.Google.Script.Types.Product where
import Network.Google.Prelude
import Network.Google.Script.Types.Sum
data Status = Status'
{ _sDetails :: !(Maybe [StatusDetailsItem])
, _sCode :: !(Maybe (Textual Int32))
, _sMessage :: !(Maybe Text)
} deriving (Eq,Show,Data,Typeable,Generic)
status
:: Status
status =
Status'
{ _sDetails = Nothing
, _sCode = Nothing
, _sMessage = Nothing
}
sDetails :: Lens' Status [StatusDetailsItem]
sDetails
= lens _sDetails (\ s a -> s{_sDetails = a}) .
_Default
. _Coerce
sCode :: Lens' Status (Maybe Int32)
sCode
= lens _sCode (\ s a -> s{_sCode = a}) .
mapping _Coerce
sMessage :: Lens' Status (Maybe Text)
sMessage = lens _sMessage (\ s a -> s{_sMessage = a})
instance FromJSON Status where
parseJSON
= withObject "Status"
(\ o ->
Status' <$>
(o .:? "details" .!= mempty) <*> (o .:? "code") <*>
(o .:? "message"))
instance ToJSON Status where
toJSON Status'{..}
= object
(catMaybes
[("details" .=) <$> _sDetails,
("code" .=) <$> _sCode,
("message" .=) <$> _sMessage])
data Operation = Operation'
{ _oDone :: !(Maybe Bool)
, _oError :: !(Maybe Status)
, _oResponse :: !(Maybe OperationResponse)
, _oName :: !(Maybe Text)
, _oMetadata :: !(Maybe OperationMetadata)
} deriving (Eq,Show,Data,Typeable,Generic)
operation
:: Operation
operation =
Operation'
{ _oDone = Nothing
, _oError = Nothing
, _oResponse = Nothing
, _oName = Nothing
, _oMetadata = Nothing
}
oDone :: Lens' Operation (Maybe Bool)
oDone = lens _oDone (\ s a -> s{_oDone = a})
oError :: Lens' Operation (Maybe Status)
oError = lens _oError (\ s a -> s{_oError = a})
oResponse :: Lens' Operation (Maybe OperationResponse)
oResponse
= lens _oResponse (\ s a -> s{_oResponse = a})
oName :: Lens' Operation (Maybe Text)
oName = lens _oName (\ s a -> s{_oName = a})
oMetadata :: Lens' Operation (Maybe OperationMetadata)
oMetadata
= lens _oMetadata (\ s a -> s{_oMetadata = a})
instance FromJSON Operation where
parseJSON
= withObject "Operation"
(\ o ->
Operation' <$>
(o .:? "done") <*> (o .:? "error") <*>
(o .:? "response")
<*> (o .:? "name")
<*> (o .:? "metadata"))
instance ToJSON Operation where
toJSON Operation'{..}
= object
(catMaybes
[("done" .=) <$> _oDone, ("error" .=) <$> _oError,
("response" .=) <$> _oResponse,
("name" .=) <$> _oName,
("metadata" .=) <$> _oMetadata])
data ExecutionRequest = ExecutionRequest'
{ _erFunction :: !(Maybe Text)
, _erSessionState :: !(Maybe Text)
, _erDevMode :: !(Maybe Bool)
, _erParameters :: !(Maybe [JSONValue])
} deriving (Eq,Show,Data,Typeable,Generic)
executionRequest
:: ExecutionRequest
executionRequest =
ExecutionRequest'
{ _erFunction = Nothing
, _erSessionState = Nothing
, _erDevMode = Nothing
, _erParameters = Nothing
}
erFunction :: Lens' ExecutionRequest (Maybe Text)
erFunction
= lens _erFunction (\ s a -> s{_erFunction = a})
erSessionState :: Lens' ExecutionRequest (Maybe Text)
erSessionState
= lens _erSessionState
(\ s a -> s{_erSessionState = a})
erDevMode :: Lens' ExecutionRequest (Maybe Bool)
erDevMode
= lens _erDevMode (\ s a -> s{_erDevMode = a})
erParameters :: Lens' ExecutionRequest [JSONValue]
erParameters
= lens _erParameters (\ s a -> s{_erParameters = a})
. _Default
. _Coerce
instance FromJSON ExecutionRequest where
parseJSON
= withObject "ExecutionRequest"
(\ o ->
ExecutionRequest' <$>
(o .:? "function") <*> (o .:? "sessionState") <*>
(o .:? "devMode")
<*> (o .:? "parameters" .!= mempty))
instance ToJSON ExecutionRequest where
toJSON ExecutionRequest'{..}
= object
(catMaybes
[("function" .=) <$> _erFunction,
("sessionState" .=) <$> _erSessionState,
("devMode" .=) <$> _erDevMode,
("parameters" .=) <$> _erParameters])
newtype StatusDetailsItem = StatusDetailsItem'
{ _sdiAddtional :: HashMap Text JSONValue
} deriving (Eq,Show,Data,Typeable,Generic)
statusDetailsItem
:: HashMap Text JSONValue
-> StatusDetailsItem
statusDetailsItem pSdiAddtional_ =
StatusDetailsItem'
{ _sdiAddtional = _Coerce # pSdiAddtional_
}
sdiAddtional :: Lens' StatusDetailsItem (HashMap Text JSONValue)
sdiAddtional
= lens _sdiAddtional (\ s a -> s{_sdiAddtional = a})
. _Coerce
instance FromJSON StatusDetailsItem where
parseJSON
= withObject "StatusDetailsItem"
(\ o -> StatusDetailsItem' <$> (parseJSONObject o))
instance ToJSON StatusDetailsItem where
toJSON = toJSON . _sdiAddtional
data ScriptStackTraceElement = ScriptStackTraceElement'
{ _ssteFunction :: !(Maybe Text)
, _ssteLineNumber :: !(Maybe (Textual Int32))
} deriving (Eq,Show,Data,Typeable,Generic)
scriptStackTraceElement
:: ScriptStackTraceElement
scriptStackTraceElement =
ScriptStackTraceElement'
{ _ssteFunction = Nothing
, _ssteLineNumber = Nothing
}
ssteFunction :: Lens' ScriptStackTraceElement (Maybe Text)
ssteFunction
= lens _ssteFunction (\ s a -> s{_ssteFunction = a})
ssteLineNumber :: Lens' ScriptStackTraceElement (Maybe Int32)
ssteLineNumber
= lens _ssteLineNumber
(\ s a -> s{_ssteLineNumber = a})
. mapping _Coerce
instance FromJSON ScriptStackTraceElement where
parseJSON
= withObject "ScriptStackTraceElement"
(\ o ->
ScriptStackTraceElement' <$>
(o .:? "function") <*> (o .:? "lineNumber"))
instance ToJSON ScriptStackTraceElement where
toJSON ScriptStackTraceElement'{..}
= object
(catMaybes
[("function" .=) <$> _ssteFunction,
("lineNumber" .=) <$> _ssteLineNumber])
data ExecutionError = ExecutionError'
{ _eeScriptStackTraceElements :: !(Maybe [ScriptStackTraceElement])
, _eeErrorType :: !(Maybe Text)
, _eeErrorMessage :: !(Maybe Text)
} deriving (Eq,Show,Data,Typeable,Generic)
executionError
:: ExecutionError
executionError =
ExecutionError'
{ _eeScriptStackTraceElements = Nothing
, _eeErrorType = Nothing
, _eeErrorMessage = Nothing
}
eeScriptStackTraceElements :: Lens' ExecutionError [ScriptStackTraceElement]
eeScriptStackTraceElements
= lens _eeScriptStackTraceElements
(\ s a -> s{_eeScriptStackTraceElements = a})
. _Default
. _Coerce
eeErrorType :: Lens' ExecutionError (Maybe Text)
eeErrorType
= lens _eeErrorType (\ s a -> s{_eeErrorType = a})
eeErrorMessage :: Lens' ExecutionError (Maybe Text)
eeErrorMessage
= lens _eeErrorMessage
(\ s a -> s{_eeErrorMessage = a})
instance FromJSON ExecutionError where
parseJSON
= withObject "ExecutionError"
(\ o ->
ExecutionError' <$>
(o .:? "scriptStackTraceElements" .!= mempty) <*>
(o .:? "errorType")
<*> (o .:? "errorMessage"))
instance ToJSON ExecutionError where
toJSON ExecutionError'{..}
= object
(catMaybes
[("scriptStackTraceElements" .=) <$>
_eeScriptStackTraceElements,
("errorType" .=) <$> _eeErrorType,
("errorMessage" .=) <$> _eeErrorMessage])
newtype OperationMetadata = OperationMetadata'
{ _omAddtional :: HashMap Text JSONValue
} deriving (Eq,Show,Data,Typeable,Generic)
operationMetadata
:: HashMap Text JSONValue
-> OperationMetadata
operationMetadata pOmAddtional_ =
OperationMetadata'
{ _omAddtional = _Coerce # pOmAddtional_
}
omAddtional :: Lens' OperationMetadata (HashMap Text JSONValue)
omAddtional
= lens _omAddtional (\ s a -> s{_omAddtional = a}) .
_Coerce
instance FromJSON OperationMetadata where
parseJSON
= withObject "OperationMetadata"
(\ o -> OperationMetadata' <$> (parseJSONObject o))
instance ToJSON OperationMetadata where
toJSON = toJSON . _omAddtional
newtype OperationResponse = OperationResponse'
{ _orAddtional :: HashMap Text JSONValue
} deriving (Eq,Show,Data,Typeable,Generic)
operationResponse
:: HashMap Text JSONValue
-> OperationResponse
operationResponse pOrAddtional_ =
OperationResponse'
{ _orAddtional = _Coerce # pOrAddtional_
}
orAddtional :: Lens' OperationResponse (HashMap Text JSONValue)
orAddtional
= lens _orAddtional (\ s a -> s{_orAddtional = a}) .
_Coerce
instance FromJSON OperationResponse where
parseJSON
= withObject "OperationResponse"
(\ o -> OperationResponse' <$> (parseJSONObject o))
instance ToJSON OperationResponse where
toJSON = toJSON . _orAddtional
data ExecutionResponse = ExecutionResponse'
{ _erStatus :: !(Maybe Text)
, _erResult :: !(Maybe JSONValue)
} deriving (Eq,Show,Data,Typeable,Generic)
executionResponse
:: ExecutionResponse
executionResponse =
ExecutionResponse'
{ _erStatus = Nothing
, _erResult = Nothing
}
erStatus :: Lens' ExecutionResponse (Maybe Text)
erStatus = lens _erStatus (\ s a -> s{_erStatus = a})
erResult :: Lens' ExecutionResponse (Maybe JSONValue)
erResult = lens _erResult (\ s a -> s{_erResult = a})
instance FromJSON ExecutionResponse where
parseJSON
= withObject "ExecutionResponse"
(\ o ->
ExecutionResponse' <$>
(o .:? "status") <*> (o .:? "result"))
instance ToJSON ExecutionResponse where
toJSON ExecutionResponse'{..}
= object
(catMaybes
[("status" .=) <$> _erStatus,
("result" .=) <$> _erResult])