gridscale / gridscale_api_client_python Goto Github PK
View Code? Open in Web Editor NEWThe official gridscale API client written in Python
License: MIT License
The official gridscale API client written in Python
License: MIT License
To make this client more in line with the official API I'd to propose a rename of the following methods:
ssh_key
is canonically without the underscore in the API. The new function names would then be
For backwards-compat we could alias the methods to their old names.
It's a small annoyance, but I still wanted to mention it. I'm ready to work an a pull request if this change finds acceptance.
We want to create a new config file that is shared across the different libraries and tools that use the gridscale API: gridscale/terraform-provider-gridscale#183
For this we need to have a function that reads that config file into an internal representation and probably also a function that writes such a config file if it does not yet exists.
See gridscale/terraform-provider-gridscale#183 for the format of the file and file paths on the different platforms.
Steps to reproduce:
Get an account with no buckets in object storage. curl the public API and verify:
$ GS_USER_ID=xyz; GS_API_TOKEN=xyz; curl https://api.gridscale.cloud/objects/objectstorages/buckets -H "X-Auth-UserID: $GS_USER_ID" -H "X-Auth-Token: $GS_API_TOKEN"
{"buckets": []}
Run test script (see below):
$ GS_USER_ID=xyz GS_API_TOKEN=xyz python test.py{'buckets': None}
So far so good. Now create a bucket in the panel, let say 'fubar' and curl again.
$ GS_USER_ID=xyz; GS_API_TOKEN=xyz; curl https://api.gridscale.cloud/objects/objectstorages/buckets -H "X-Auth-UserID: $GS_USER_ID" -H "X-Auth-Token: $GS_API_TOKEN"
{"buckets": [{"name": "fubar", "usage": {"num_objects": 0, "size_kb": 0}}]}
Looks good.
Now the API client:
$ GS_USER_ID=xyz GS_API_TOKEN=xyz python test.py
{'buckets': None}
Looks not okay.
If you add more buckets, get_buckets keeps returning none.
Test script (test.py):
import os
from pprint import pprint
from gs_api_client import Configuration, SyncGridscaleApiClient
user_id = os.getenv("GS_USER_ID")
assert user_id
api_token = os.getenv("GS_API_TOKEN")
assert api_token
config = Configuration()
config.host = "https://api.gridscale.cloud"
config.api_key["X-Auth-Token"] = api_token
config.api_key["X-Auth-UserId"] = user_id
config.debug = False
client = SyncGridscaleApiClient(configuration=config)
pprint(client.get_buckets())
Currently the synchronous API client will poll asynchronous requests every 0.5s. This makes hitting the API rate limit quite likely once you introduce concurrency.
For the API client to not feel sluggish, the poll intervall likely shouldn't simply be increased to a few seconds. It could be dynamically increased to a max and/or be request type-dependent.
In the example file it currently tries to use Debian 9 as a template.
We could just change to the newest Debian version for the example. However, this will just break whenever we depreciate Debian 11.
Another option would be to implement a default option which would always use the newest Debian version.
Since the introduction of API rate limiting, requests failed with an ApiException when hitting the limit (429).
I would propose that the client handles retries in that case.
when using the example file it does not work because by default Debian 9 is selected.
We want to switch the default branch name from master to main for all gridscale Open Source projects including this repository.
This involves:
Would be nice to do this coordinated and in "one go" so that contributors are not surprised by inconsistent naming or repositories not having switched yet. If you want to help out here contact @bkircher
Regarding to a customer's feature request, I, @bkircher , and the customers really want to have shared-credential feature in all gridscale tools (which are built on top of gridscale public API). The proposal is posted here Proposal of shared credentials across gridscale tools. Please feel free to comment.
Add GitHub Action that executes all Python test cases upon push to branch. This should be pretty simple.
Rough sketch:
Docs:
Hey there. I would like this repository to be renamed to include dashes instead of underlines, i.e. instead of "gridscale_api_client_python" we would name it "gridscale-api-client-python".
Reasons:
Any objections?
API client should support custom certificates, which will be are used by LBaaS.
Right now there is no config for any linter in this project.
Things to do:
We could use pylint or flake8. Personally, I would prefer pylint because I know it best but no hard feelings. I could gift an initial config file for pylint.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.