henningholmde / hcloud-rust Goto Github PK
View Code? Open in Web Editor NEWUnofficial Rust crate for accessing the Hetzner Cloud API
License: Other
Unofficial Rust crate for accessing the Hetzner Cloud API
License: Other
Now that #5 is closed, clippy should be added to CI to prevent regression.
When running cargo fmt
, I get the following errors:
Warning: can't set `ignore = IgnoreList { path_set: {"src/apis", "src/models"}, rustfmt_toml_path: "" }`, unstable features are only available in nightly channel.
Warning: can't set `ignore = IgnoreList { path_set: {"src/models", "src/apis"}, rustfmt_toml_path: "" }`, unstable features are only available in nightly channel.
Warning: can't set `ignore = IgnoreList { path_set: {"src/apis", "src/models"}, rustfmt_toml_path: "" }`, unstable features are only available in nightly channel.
Warning: can't set `ignore = IgnoreList { path_set: {"src/apis", "src/models"}, rustfmt_toml_path: "" }`, unstable features are only available in nightly channel.
Warning: can't set `ignore = IgnoreList { path_set: {"src/models", "src/apis"}, rustfmt_toml_path: "" }`, unstable features are only available in nightly channel.
Is there a reason we opt to not format the generated files? Doesn't it make them easier to parse for the human eye? And since the templates don't change on every code change, it's not like every commit will update the formatting of the templates
Since Today is a new Api version online. This breaks hcloud::apis::server_types_api::list_server_types and some more stuff
https://status.hetzner.com/de/incident/682c742f-1dc0-40da-83ed-be2d89a2a43b
The default user agent for API access is currently set to:
hcloud-rust/src/apis/configuration.rs
Line 42 in 52da68e
Changing this to something like hcloud-rust/x.y.z
would make more sense.
Running cargo clippy
currently displays many warnings in the generated code. Thus clippy is of no use, even for developing tests and examples.
It should be possible to adapt the generator templates to bring the number of warnings down a bit. For those that cannot be fixed through just changing the templates, directives to disable the corresponding checks should be added.
By default, the API only returns the first 25 items (see https://docs.hetzner.cloud/#pagination).
For larger project, this means there is currently no way to access more than these 25 items.
(see also MaximilianKoestler/hcloud-openapi#5)
Currently, the Hetzner Cloud API is sadly sometimes quite flaky and will at times throw around random errors. Hetzner themselves apparently know this and have implemented retry measures in some parts of their Terraform provider and Go client library.
We hit these problems very often using your library and I think it would be a good idea to add retry support into the library directly. I'm not exactly sure how to implement this given that you use the OpenAPI generator, however.
hcloud::models::network::Network
contains pub id: i64
but
hcloud::models::create_server_request::CreateServerRequest
requires pub networks: Option<Vec<i32>>
Does the id-type-mismatch already come from the Hetzner API or is something wrong in the generator?
There are more places where ID types are inconsistent. Having to downcast at these points is extremely annoying.
I've been meaning to update one of our projects that uses hcloud to tokio 1 (1.4.0 to be specific), but while it compiles, I can run the thing anymore. As soon as I try to do any hcloud api requests the thing crashes. Does updating the reqwest
dependency require an update from the openapi generator people, or is that something you can do yourselves?
Many of the API functions take several Option<T>
parameters, e.g. servers_api::list_servers()
:
hcloud-rust/src/apis/servers_api.rs
Line 52 in 52da68e
Calling this function in your code results in somthing that is pretty hard to comprehend, as seen in the example code:
hcloud-rust/examples/list_servers.rs
Line 21 in 52da68e
Handing over a struct with all parameters would result in code that is easier to read, e.g.:
.list_servers(ListServersParams {
status: None,
sort: None,
name: None,
label_selector: None,
})
When implementing std::default::Default for the type, unused paramters could even be ommited:
.list_servers(Default::default())
We're calling hcloud::apis::servers_api::list_servers
on a project, where a server has it's image set to be "unavailable", because we restored it from a snapshot that has since been deleted. This causes serde to fail parsing it. The issue downstream is https://gitlab.com/famedly/company/devops/tools/hcloud-prom-filesd/-/issues/4, ftr. This needs patching in the unofficial OpenAPI spec (MaximilianKoestler/hcloud-openapi#14), or switching to the official OpenAPI spec, which does this correctly.
Currently there are several warnings related to the generated code when building the project. These should be fixed which is probably possible with minor changes to the templates.
Find a nice way for adding additional documentation to the generated code (without changing the generated files directly).
First idea: Adding documentation from a separate description file (e.g. JSON/YAML) using a post-processsing script when generating the code.
hi!
Reading the documentation of DeleteServerParams
it sounds like this is the i32 id field in the Server
struct, but since the type is String I went with the server name and this didn't work. Converting the i32 id field to a string did work though. This field should probably be a i32 instead (I didn't check the other structs, this is just the one I ran into).
Thanks!
Currently, prices are repesented as String
type, e.g.:
hcloud-rust/src/models/price.rs
Lines 16 to 23 in 52da68e
Using decimal representation (e.g. rust_decimal) would be more convenient for calculations.
Reported here: MaximilianKoestler/hcloud-openapi#15
Can be reproduced on 0.9.0 or earlier with the list_servers
example when a Rocky Linux server is running:
$ cargo run --example list_servers API_TOKEN
Finished dev [unoptimized + debuginfo] target(s) in 0.12s
Running `target/debug/examples/list_servers API_TOKEN`
Error: "API call to list_servers failed: Serde(Error(\"unknown variant `rocky`, expected one of `centos`, `debian`, `fedora`, `ubuntu`, `unknown`\", line: 172, column: 28))"
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.