Giter VIP home page Giter VIP logo

hetznercloud-java's People

Contributors

asaf-wizzdi avatar dajooo avatar dependabot[bot] avatar easystartup-io avatar kryp7x avatar litetex avatar n0ise9914 avatar pellepelster avatar pierreschwang avatar renovate-bot avatar renovate[bot] avatar sirthias avatar tomsiewert 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

Watchers

 avatar  avatar  avatar  avatar

hetznercloud-java's Issues

Clarify handling of optional fields.

The Hetzner Cloud API definition defines quite a few request parameters that are optional.
Currently it is unclear how one can define such a parameter as "not set".
Should it be set to null? Are there parameters where the meaning of null differs from not set?

Ideally the fact whether a parameter is optional or not would be expressed through the type system, e.g. via something like Java 8's Optional type.

Add DNS support

Hello,

Really appreciate the work done with this project, thank you!!

A useful addition to this library would be if Hetzner DNS support was added. Documentation: https://dns.hetzner.com/api-docs

Do you accept PRs? Could be done in a fork and contributed back to this project, if you wish.

Publish shade and non-shade jar

Context

Thanks for the excellent work of supporting Hetzner API with Java.

The current jar in maven central seems to be a shaded jar, which has compatibility issues with latest Spring Boot (I'm using Spring Boot 2.4.1):

2020-12-21 11:09:52.688 ERROR 82796 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.context.support.GenericApplicationContext.setApplicationStartup(GenericApplicationContext.java:165)

The following method did not exist:

    'void org.springframework.beans.factory.support.DefaultListableBeanFactory.setApplicationStartup(org.springframework.core.metrics.ApplicationStartup)'

The method's class, org.springframework.beans.factory.support.DefaultListableBeanFactory, is available from the following locations:

    jar:file:/Users/zhb/.gradle/caches/modules-2/files-2.1/me.tomsdevsn/hetznercloud-api/2.11.0/b6dc04414fc5070ad48b7c8350d5aabaa0cf6b08/hetznercloud-api-2.11.0.jar!/org/springframework/beans/factory/support/DefaultListableBeanFactory.class
    jar:file:/Users/zhb/.gradle/caches/modules-2/files-2.1/org.springframework/spring-beans/5.3.2/289d8047f7cc524d60ca0c4cc6fedb8cb003e02d/spring-beans-5.3.2.jar!/org/springframework/beans/factory/support/DefaultListableBeanFactory.class

The class hierarchy was loaded from the following locations:

    org.springframework.beans.factory.support.DefaultListableBeanFactory: file:/Users/zhb/.gradle/caches/modules-2/files-2.1/me.tomsdevsn/hetznercloud-api/2.11.0/b6dc04414fc5070ad48b7c8350d5aabaa0cf6b08/hetznercloud-api-2.11.0.jar
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory: file:/Users/zhb/.gradle/caches/modules-2/files-2.1/me.tomsdevsn/hetznercloud-api/2.11.0/b6dc04414fc5070ad48b7c8350d5aabaa0cf6b08/hetznercloud-api-2.11.0.jar
    org.springframework.beans.factory.support.AbstractBeanFactory: file:/Users/zhb/.gradle/caches/modules-2/files-2.1/me.tomsdevsn/hetznercloud-api/2.11.0/b6dc04414fc5070ad48b7c8350d5aabaa0cf6b08/hetznercloud-api-2.11.0.jar
    org.springframework.beans.factory.support.FactoryBeanRegistrySupport: file:/Users/zhb/.gradle/caches/modules-2/files-2.1/me.tomsdevsn/hetznercloud-api/2.11.0/b6dc04414fc5070ad48b7c8350d5aabaa0cf6b08/hetznercloud-api-2.11.0.jar
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry: file:/Users/zhb/.gradle/caches/modules-2/files-2.1/me.tomsdevsn/hetznercloud-api/2.11.0/b6dc04414fc5070ad48b7c8350d5aabaa0cf6b08/hetznercloud-api-2.11.0.jar
    org.springframework.core.SimpleAliasRegistry: file:/Users/zhb/.gradle/caches/modules-2/files-2.1/me.tomsdevsn/hetznercloud-api/2.11.0/b6dc04414fc5070ad48b7c8350d5aabaa0cf6b08/hetznercloud-api-2.11.0.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.beans.factory.support.DefaultListableBeanFactory

It's clear that the shaded spring packages conflicts. I can't even exclude it because it's shaded inside that jar. I assume the shaded jar is necessary in some scenario, but this makes it impossible to integrate with latest Spring Boot application.

ImagesResponse not usable

Hey, I try to use ImagesResponse Class, but as the member is private, it is unusable for forther processing (except converting to string)....
Is it possible to add a getter for the images member?

Automate your release pipeline to increase version and trigger release

I see that after every merge you have to manually make changes in 3-4 files and push manually. This can be automated. Can you try following the links to add a github workflow which automatically increments the version and commits to the repo with a message [skip-ci-version-bump] so that it does not infinitely trigger version increments. Some sample links to check.

  1. https://blog.jakelee.co.uk/incrementing-version-automatically-after-release/
  2. https://github.com/marketplace/actions/version-increment
  3. https://github.com/marketplace/actions/find-and-replace
  4. https://github.com/easystartup-io/k3s-simplified/blob/main/.github/workflows/build.yaml

Consider use of OkHttp 5 (alpha)

OkHttp 4.x has no support for Happy Eyeballs and breaks in environments with funky IPv6 however, the HC API got IPv6 support some time ago.

OkHttp 5 alpha has Happy Eyeballs support and some sort of working failover between IPv6 and IPv4.

Check what effort it'd be to migrate to OkHttp 5 and what could break. Also, do we want to use an alpha version for a production release?

Add contribution guidelines

tl;dr what it should contain:

  • Code style guideline
  • Commit message format
  • Rebasing between branches
  • Changelog

Pagination support

Current implementation seems only able to fetch the data at first page, which is 25 by default. The entire /servers response:

{
  "servers": [
    {
      "id": 9290830,
      "name": "ubuntu-2004-base",
    },
    ...
  ],
  "meta": {
    "pagination": {
      "page": 1,
      "per_page": 25,
      "previous_page": null,
      "next_page": 2,
      "last_page": 9,
      "total_entries": 205
    }
  }
}

Android compatibility

I am encountering issues while trying to use this library from an android app .
Calling HetznerCloudApi.getSSHKeys results in a RuntimeException caused by an EOFException.
Is this API not android compatible?

Unify accessibility of model class fields

Currently accessibility of model class fields is not consistent.

E.g. Servers#servers, ResponseSSHKeys#sshKeys and ResponseServerTypes#serverTypes are private, while ResponseImages#images and ResponseISOS#isos are public.

IMHO the library should pick one style and consistently use it across all types.

Additionally, and depending on the constraints of the serialization magic in use (that I am not familiar with), I would suggest that all data classes become as immutable as possible, i.e.:

  • all data classes be marked final
  • all data class fields be marked final
  • all data class fields be marked @NonNull unless null is explicitly allowed by the API (e.g. for optional fields?)

Thread-safe issue with DateDeserializer

I observed this flaky error:

Caused by: java.lang.NumberFormatException: multiple points
        at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1914)
        at java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
        at java.base/java.lang.Double.parseDouble(Double.java:543)
        at java.base/java.text.DigitList.getDouble(DigitList.java:169)
        at java.base/java.text.DecimalFormat.parse(DecimalFormat.java:2126)
        at java.base/java.text.SimpleDateFormat.subParse(SimpleDateFormat.java:1933)
        at java.base/java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1541)
        at java.base/java.text.DateFormat.parse(DateFormat.java:393)
        at me.tomsdevsn.hetznercloud.deserialize.DateDeserializer.deserialize(DateDeserializer.java:29)
        at me.tomsdevsn.hetznercloud.deserialize.DateDeserializer.deserialize(DateDeserializer.java:12)
        at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:371)

According to https://medium.com/@daveford/numberformatexception-multiple-points-when-parsing-date-650baa6829b6 , https://github.com/TomSDEVSN/hetznercloud-java/blob/ab8f9c8a9f175dc52fc3db424df220b76848b30b/src/main/java/me/tomsdevsn/hetznercloud/deserialize/DateDeserializer.java contains a private SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");, which is not thread-safe. We should either make it local variable or threadlocalized.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency org.awaitility:awaitility to v4.2.2
  • fix(deps): update dependency com.fasterxml.jackson.core:jackson-databind to v2.17.2
  • fix(deps): update dependency org.projectlombok:lombok to v1.18.34
  • chore(deps): update dependency org.apache.maven.plugins:maven-checkstyle-plugin to v3.4.0
  • chore(deps): update dependency org.apache.maven.plugins:maven-javadoc-plugin to v3.8.0
  • chore(deps): update dependency org.apache.maven.plugins:maven-release-plugin to v3.1.1
  • chore(deps): update dependency org.apache.maven.plugins:maven-surefire-plugin to v3.3.1
  • chore(deps): update dependency org.sonatype.plugins:nexus-staging-maven-plugin to v1.7.0
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/build.yml
  • actions/checkout v4
  • actions/setup-java v4
.github/workflows/codeql.yml
  • actions/checkout v4
  • github/codeql-action v3
  • github/codeql-action v3
  • github/codeql-action v3
.github/workflows/release.yml
  • actions/checkout v4
  • actions/setup-java v4
  • crazy-max/ghaction-import-gpg v6
  • softprops/action-gh-release v2
  • actions/checkout v4
  • actions/setup-java v4
  • JamesIves/github-pages-deploy-action v4.5.0
.github/workflows/test.yml
  • actions/checkout v4
  • actions/setup-java v4
maven
pom.xml
  • com.squareup.okhttp3:okhttp 4.12.0
  • com.fasterxml.jackson.core:jackson-databind 2.17.0
  • org.projectlombok:lombok 1.18.32
  • org.assertj:assertj-core 3.25.3
  • org.junit.jupiter:junit-jupiter 5.10.2
  • org.slf4j:slf4j-simple 2.0.12
  • org.awaitility:awaitility 4.2.1
  • org.apache.jclouds:jclouds-compute 2.6.0
  • org.bouncycastle:bcpkix-jdk15on 1.70
  • org.apache.maven.plugins:maven-compiler-plugin 3.12.1
  • org.apache.maven.plugins:maven-surefire-plugin 3.2.5
  • org.apache.maven.plugins:maven-source-plugin 3.2.1
  • org.apache.maven.plugins:maven-javadoc-plugin 3.6.3
  • org.apache.maven.plugins:maven-deploy-plugin 3.1.1
  • org.apache.maven.plugins:maven-release-plugin 3.0.1
  • org.apache.maven.scm:maven-scm-provider-gitexe 2.0.1
  • org.sonatype.plugins:nexus-staging-maven-plugin 1.6.13
  • org.apache.maven.plugins:maven-gpg-plugin 3.1.0
  • org.apache.maven.plugins:maven-checkstyle-plugin 3.3.1
  • com.puppycrawl.tools:checkstyle 10.14.2

  • Check this box to trigger a request for Renovate to run again on this repository

Publish to maven central

It'd be great if hetznercloud-java was available through maven central and thus did not require local building and publishing...

Incorrect data type of Image.createFrom

Got exceptions when creating new servers:

java.util.concurrent.ExecutionException: org.springframework.web.client.RestClientException: Error while extracting response for type [class me.tomsdevsn.hetznercloud.objects.response.ServerResponse] and content type [application/json]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: For input string: "202002E.4202002E4"; nested exception is com.fasterxml.jackson.databind.JsonMappingException: For input string: "202002E.4202002E4" (through reference chain: me.tomsdevsn.hetznercloud.objects.response.ServerResponse["server"]->me.tomsdevsn.hetznercloud.objects.general.Server["image"]->me.tomsdevsn.hetznercloud.objects.general.Image["created"])
        at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
        at org.gradle.hetznerautoscaler.TestDistributionAgentPool.startMachines(HetznerAutoscalerApplication.kt:101)
        at org.gradle.hetznerautoscaler.TestDistributionAgentPool.makeSureAgentPoolMatchesWorkload(HetznerAutoscalerApplication.kt:70)
        at org.gradle.hetznerautoscaler.EveryMinuteTask.minuteTask(HetznerAutoscalerApplication.kt:47)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
        at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
        at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:95)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.springframework.web.client.RestClientException: Error while extracting response for type [class me.tomsdevsn.hetznercloud.objects.response.ServerResponse] and content type [application/json]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: For input string: "202002E.4202002E4"; nested exception is com.fasterxml.jackson.databind.JsonMappingException: For input string: "202002E.4202002E4" (through reference chain: me.tomsdevsn.hetznercloud.objects.response.ServerResponse["server"]->me.tomsdevsn.hetznercloud.objects.general.Server["image"]->me.tomsdevsn.hetznercloud.objects.general.Image["created"])
        at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:120)
        at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:1034)
        at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:1017)
        at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:777)
        at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:710)
        at org.springframework.web.client.RestTemplate.postForEntity(RestTemplate.java:467)
        at me.tomsdevsn.hetznercloud.HetznerCloudAPI.createServer(HetznerCloudAPI.java:113)
        at org.gradle.hetznerautoscaler.DefaultHetznerCloudClient.startServer(HetznerCloudClient.kt:37)
        at org.gradle.hetznerautoscaler.TestDistributionAgentPool$startMachines$$inlined$List$lambda$1.run(HetznerAutoscalerApplication.kt:97)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        ... 3 common frames omitted

It seems like that Image.CreatedFrom.id should be String instead of Long: https://github.com/blindpirate/hetznercloud-java/blob/8edd4c91bd01e770875b93e0bedb50a1a14c5a07/src/main/java/me/tomsdevsn/hetznercloud/objects/general/Image.java#L44

Future of this project

Most of you have already seen from the commits, as well as from the time I needed for the issues, that the project here is relatively unmaintained from my side. I would like to explain why this is so, as the client is used more than I thought.

I started the project when I was still in school and had a lot of free time. I spent this free time, besides friends and family, almost exclusively with Java.
Since I started my apprenticeship at Hetzner, the contact with Java has decreased, because we don't use this language internally, as well as my available free time. I concentrate more on my work and the training itself, as well as I try to use my little free time as much as possible, but with friends and family instead of with an IDE.

However, when I do some programming, I do it in languages like Golang or Ruby. Java is rarely used here, mostly only through vocational school.

I would not like to drop this project, as it is (apparently) the only Java client that is largely well maintained (even if everything takes some time to implement).

I would also like to point out that I am happy to accept help from anyone, be it as PR or as a simple issue.

Thank you for your understanding.

Replace Spring with a more lightweight HTTP library

Hey, would you be ok with replacing Spring with a more lightweight HTTP only library (e.g. OkHttp)?

Currently only the Resttemplate is used from Spring, which in my opinion drags in a lot of complexity and dependencies just to execute some basic HTTP requests. Spring, being a fairly complex piece of software with a lot of dependencies also greatly increases the attack surface (see CVEs for currently used version) and makes usage in a Spring application potentially harder.

Originally posted by @pellepelster in #45 (comment)

remove shade plugin as it does not allow overriding dependencies

shade plugin should not be used to compile libraries used by other maven projects ,
not shading the library allows excluding the library dependencies if required , for example if the library is using Jackson version 2.9.10.5
another project using the library may exclude the library's Jackson dependency and use its own.

Align data model type names with Java convention

Currently the request and response model types are named as RequestXXX and ResponseXXX which is not in line with Java naming conventions.

Usually type names end with the basic name and are prefixed with qualifiers.
E.g. a ServerRequest is a first and foremost a request. The prefix Server qualifies it and says that is a Request for a Server. The same logic applies to responses.

Therefore all the types should really be named the other way around, i.e. XXXRequest and XXXResponse.

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.