Giter VIP home page Giter VIP logo

hcloud-rust's People

Contributors

good-praxis avatar henningholmde avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hcloud-rust's Issues

Add clippy to CI

Now that #5 is closed, clippy should be added to CI to prevent regression.

Can't ignore paths in rustfmt without Nightly

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

Make clippy happy

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.

Add retry to routes

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.

ID-type mismatch

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.

Update for tokio 1

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?

Use structs for specifying API call parameters

Many of the API functions take several Option<T> parameters, e.g. servers_api::list_servers():

fn list_servers(&self, status: Option<&str>, sort: Option<&str>, name: Option<&str>, label_selector: Option<&str>) -> Result<crate::models::ListServersResponse, Error>;

Calling this function in your code results in somthing that is pretty hard to comprehend, as seen in the example code:

.list_servers(None, None, None, None)

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())

Unavailable images cause listing servers to fail

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.

How to add documentation to the generated code?

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.

id in DeleteServerParams should be i32

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!

Missing os_flavor `rocky` causes `list_servers` to fail on Rocky Linux servers

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))"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.