Skip to content
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

Refine API wrapper for "Plugins" once more #115

Merged
merged 1 commit into from
Sep 21, 2023
Merged

Refine API wrapper for "Plugins" once more #115

merged 1 commit into from
Sep 21, 2023

Conversation

amotl
Copy link
Contributor

@amotl amotl commented Sep 21, 2023

About

After GH-110 and GH-114, this patch streamlines the API wrapper about "plugins" a bit more.

Details

  1. The patch is needed to make Add subcommands plugins {list,status}, to inquire plugins grafana-wtf#91 work.

  2. While at it, it also adjusts/trims the method names a bit. I hope it will not cause too much harm, because the feature has only been released recently. I don't think we need to bump to 4.0.0 to properly signal that "breaking" change. I would just run a 3.9.0 release to ship it. Please let me know if you think differently.

/cc @bhks

@codecov
Copy link

codecov bot commented Sep 21, 2023

Codecov Report

Merging #115 (402cb5e) into main (05759df) will decrease coverage by 0.75%.
Report is 3 commits behind head on main.
The diff coverage is 54.54%.

@@            Coverage Diff             @@
##             main     #115      +/-   ##
==========================================
- Coverage   94.85%   94.11%   -0.75%     
==========================================
  Files          25       25              
  Lines        1594     1613      +19     
==========================================
+ Hits         1512     1518       +6     
- Misses         82       95      +13     
Files Changed Coverage Δ
grafana_client/elements/plugin.py 58.18% <54.16%> (-9.27%) ⬇️
grafana_client/client.py 95.69% <55.55%> (-4.31%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

"""
:return:
Return list of all installed plugins.
"""
path = "/plugins?embedded=0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we allow user to pass the filters like embedded=0&core=0 ? Can be a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, why not. Can you point us to corresponding documentation or code, where all the possible filtering parameters are enumerated? Maybe there are even more, about sorting or paging?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, see GH-117.

path = "/plugins/%s/install" % plugin_id
# Unfortunately, this endpoint may respond with an empty JSON,
# which needs compensation, because it does not decode well.
r = self.client.POST(path, json={"version": version}, accept_empty_json=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for handling this , I was not sure on how to handle the exceptions I was getting.

return r
except GrafanaClientError as ex:
# Ignore `Client Error 409: Plugin already installed`.
if "409" not in str(ex):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I figured after I merged my PR.

@amotl amotl merged commit d5b30d4 into main Sep 21, 2023
7 checks passed
@amotl amotl deleted the plugins-refine-2 branch September 21, 2023 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants