diff --git a/README.md b/README.md
index f7799be8..494033fd 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ Hetzner Cloud API for Java
Simple Java client for the Hetzner Cloud API.
-The current version is **2.0.0**.
+The current version is **2.1.0**.
It would be nice, if you submit pull requests.
@@ -37,7 +37,7 @@ Dependency:
me.tomsdevsnhetznercloud-api
- 2.0.0
+ 2.1.0compile
@@ -55,7 +55,7 @@ repositories({
})
dependencies({
- compile "me.tomsdevsn:hetznercloud-api:2.0.0"
+ compile "me.tomsdevsn:hetznercloud-api:2.1.0"
})
```
diff --git a/pom.xml b/pom.xml
index f6d7d9ca..b58ec49d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.tomsdevsnhetznercloud-api
- 2.0.0
+ 2.1.0HetznerCloud-APIJava-client for the Hetzner Cloud
diff --git a/src/main/java/me/tomsdevsn/hetznercloud/HetznerCloudAPI.java b/src/main/java/me/tomsdevsn/hetznercloud/HetznerCloudAPI.java
index 9df86a0b..75a6e22f 100644
--- a/src/main/java/me/tomsdevsn/hetznercloud/HetznerCloudAPI.java
+++ b/src/main/java/me/tomsdevsn/hetznercloud/HetznerCloudAPI.java
@@ -1,5 +1,6 @@
package me.tomsdevsn.hetznercloud;
+import me.tomsdevsn.hetznercloud.exception.InvalidParametersException;
import me.tomsdevsn.hetznercloud.objects.request.*;
import me.tomsdevsn.hetznercloud.objects.response.*;
import org.springframework.http.HttpEntity;
@@ -87,6 +88,9 @@ public GetServerResponse getServerById(long id) {
* @return response of the API
*/
public ServerResponse createServer(ServerRequest serverRequest) {
+ serverRequest.getSshKeys().forEach(object -> {
+ if (!(object instanceof Long || object instanceof String)) throw new InvalidParametersException("Object not Long or String");
+ });
return restTemplate.postForEntity(API_URL + "/servers", new HttpEntity<>(serverRequest, httpHeaders), ServerResponse.class).getBody();
}
@@ -112,7 +116,7 @@ public ServernameChangeResponse changeServerName(long id, ServernameChangeReques
}
/**
- * Request a VNC over websocket Console
+ * Request a VNC over Websocket-console
*
* @param id ID of the server
* @return ConsoleResponse object
@@ -571,6 +575,16 @@ public SSHKeysResponse getSSHKeyByName(String name) {
return restTemplate.exchange(API_URL + "/ssh_keys?" + name, HttpMethod.GET, httpEntity, SSHKeysResponse.class).getBody();
}
+ /**
+ * Get a SSH key by the fingerprint.
+ *
+ * @param fingerprint Fingerprint of the SSH key
+ * @return SSHKeysResponse object
+ */
+ public SSHKeysResponse getSSHKeyByFingerprint(String fingerprint) {
+ return restTemplate.exchange(API_URL + "/ssh_keys?" + fingerprint, HttpMethod.GET, httpEntity, SSHKeysResponse.class).getBody();
+ }
+
/**
* Create a SSH key.
*
diff --git a/src/main/java/me/tomsdevsn/hetznercloud/exception/InvalidParametersException.java b/src/main/java/me/tomsdevsn/hetznercloud/exception/InvalidParametersException.java
new file mode 100644
index 00000000..50d9c636
--- /dev/null
+++ b/src/main/java/me/tomsdevsn/hetznercloud/exception/InvalidParametersException.java
@@ -0,0 +1,13 @@
+package me.tomsdevsn.hetznercloud.exception;
+
+/**
+ * The Exception will be called, if you use invalid parameters.
+ */
+public class InvalidParametersException extends RuntimeException {
+
+ private static final long serialVersionUID = 7465859521263546503L;
+
+ public InvalidParametersException(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/me/tomsdevsn/hetznercloud/objects/request/ServerRequest.java b/src/main/java/me/tomsdevsn/hetznercloud/objects/request/ServerRequest.java
index 7d79db2f..d156418d 100644
--- a/src/main/java/me/tomsdevsn/hetznercloud/objects/request/ServerRequest.java
+++ b/src/main/java/me/tomsdevsn/hetznercloud/objects/request/ServerRequest.java
@@ -23,8 +23,11 @@ public class ServerRequest {
@JsonProperty("start_after_create")
private boolean startAfterCreate;
+ /**
+ * The objects in the list have to be a Long or a String, or it will throw an Exception {@link me.tomsdevsn.hetznercloud.exception.InvalidParametersException}
+ */
@JsonProperty("ssh_keys")
- private List sshKeys;
+ private List