The idea here is to write a function that accepts a URL Endpoint, Input Parameters (dictionary), and a descriptor of Output Parameters (what the endpoint is expected to return).
Example:
- URL: https://api.helioviewer.org/v2/getJP2Image
- Input Parameters: [date, sourceId, jpip, json]
(Should this be data types? [datetime, int, string, dictionary])
(Can python generate a help string based on this?)
(Likely we will still need to create wrappers i.e. def getJp2Image(date, sourceId, jpip, json))
(How to specify optional vs. required parameters?)
- Output Parameters: either dictionary, file, string, (maybe other)
Example 1:
result = execute_api_call("https://api.helioviewer.org/v2/getJP2Image", {date: "2014-01-01T23:59:59Z", sourceId: 14}, ReturnType.Binary)
# result is a binary blob containing the jp2 image
Example 2:
result = execute_api_call("https://api.helioviewer.org/v2/getJP2Image", {date: "2014-01-01T23:59:59Z", sourceId: 14, jpip: True}, ReturnType.Dict)
# {
# "uri": "jpip://api.helioviewer.org:8090/AIA/2014/01/02/335/2014_01_02__00_00_02_62__SDO_AIA_AIA_335.jp2"
# }
The idea here is to write a function that accepts a URL Endpoint, Input Parameters (dictionary), and a descriptor of Output Parameters (what the endpoint is expected to return).
Example:
(Should this be data types? [datetime, int, string, dictionary])
(Can python generate a help string based on this?)
(Likely we will still need to create wrappers i.e. def getJp2Image(date, sourceId, jpip, json))
(How to specify optional vs. required parameters?)
Example 1:
Example 2: