-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added documentation for exporting saved Metric Explorer charts with the XDMoD API #1907
base: xdmod11.0
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just need to add that the user needs to also pip install requests
and it'll be good to go.
@aaronweeden Updated per your feedback. You can now export either a single chart or all your saved charts to a specified path. |
chart_name = f"{chart['name']}.{image_format}" if ('name' in chart) else f"xdmod_API_export_{idx}.{image_format}" | ||
|
||
with open(export_dir + '/' + chart_name, "wb") as f: | ||
f.write(chart_response.content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f.write(chart_response.content) | |
f.write(chart_response.content) | |
print('Wrote ' + export_dir + '/' + chart_name) |
docs/howto-api-image-export.md
Outdated
chart_json['operation'] = "get_data" | ||
chart_json['controller_module'] = "metric_explorer" | ||
chart_json['show_title'] = "y" | ||
chart_json['format'] = image_format | ||
chart_json['width'] = width | ||
chart_json['height'] = height | ||
|
||
chart_response = session.post(f'{site_address}/controllers/metric_explorer.php', data=chart_json, headers=header) | ||
chart_name = f"{chart['name']}.{image_format}" if ('name' in chart) else f"xdmod_API_export_{idx}.{image_format}" | ||
|
||
with open(export_dir + '/' + chart_name, "wb") as f: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chart_json['operation'] = "get_data" | |
chart_json['controller_module'] = "metric_explorer" | |
chart_json['show_title'] = "y" | |
chart_json['format'] = image_format | |
chart_json['width'] = width | |
chart_json['height'] = height | |
chart_response = session.post(f'{site_address}/controllers/metric_explorer.php', data=chart_json, headers=header) | |
chart_name = f"{chart['name']}.{image_format}" if ('name' in chart) else f"xdmod_API_export_{idx}.{image_format}" | |
with open(export_dir + '/' + chart_name, "wb") as f: | |
chart_json['operation'] = 'get_data' | |
chart_json['controller_module'] = 'metric_explorer' | |
chart_json['show_title'] = 'y' | |
chart_json['format'] = image_format | |
chart_json['width'] = width | |
chart_json['height'] = height | |
chart_response = session.post(f'{site_address}/controllers/metric_explorer.php', data=chart_json, headers=header) | |
chart_name = f"{chart['name']}.{image_format}" if ('name' in chart) else f'xdmod_API_export_{idx}.{image_format}' | |
with open(export_dir + '/' + chart_name, 'wb') as f: |
Description
This documentation contains a Python script that uses the XDMoD API to authenticate with a local XDMoD account for the given credentials and site URL. Then the script will export the saved Metric Explorer charts into the current working directory. This documentation also describes how to edit certain parts of the script and where to find more information about the request schema for the request that exports the images.
Motivation and Context
We received a ticket asking about using the XDMoD API to export saved images for an Open XDMoD - Open OnDemand integration. This documentation will be used with the response and for future tickets that refer to issues about exporting images with the XDMoD API.
Tests performed
Tested script locally.
Checklist: