Skip to content

Commit

Permalink
Transfer ownership
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniele Corsini committed Jul 4, 2019
1 parent 00f2649 commit ace434f
Show file tree
Hide file tree
Showing 4 changed files with 1,624 additions and 798 deletions.
110 changes: 57 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# eve2pve-api-java
# cv4pve-api-java

ProxmoVE Client API JAVA

[![License](https://img.shields.io/github/license/Corsinvest/cv4pve-api-java.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html)
![GitHub release](https://img.shields.io/github/release/Corsinvest/cv4pve-api-java.svg)

[ProxmoxVE Api](https://pve.proxmox.com/pve-docs/api-viewer/)

```text
______ __ _ _ ________
/ ____/___ / /____ _________ _____(_)_______ | | / / ____/
/ __/ / __ \/ __/ _ \/ ___/ __ \/ ___/ / ___/ _ \ | | / / __/
/ /___/ / / / /_/ __/ / / /_/ / / / (__ ) __/ | |/ / /___
/_____/_/ /_/\__/\___/_/ / .___/_/ /_/____/\___/ |___/_____/
/_/
(Made in Italy)
______ _ __
/ ____/___ __________(_)___ _ _____ _____/ /_
/ / / __ \/ ___/ ___/ / __ \ | / / _ \/ ___/ __/
/ /___/ /_/ / / (__ ) / / / / |/ / __(__ ) /_
\____/\____/_/ /____/_/_/ /_/|___/\___/____/\__/
Corsinvest for Proxmox VE Api Client (Made in Italy)
```

## General
Expand Down Expand Up @@ -45,66 +47,68 @@ The result is class **Result** and contain methods:
* Tree structure
* client.getNodes().get("pve1").getQemu().vmlist().getResponse().getJSONArray("data")
* Return data Proxmox VE
* Debug Level show to console information
* Return result status
* getStatusCode
* getReasonPhrase
* isSuccessStatusCode
* Wait task finish task
* waitForTaskToFinish
* taskIsRunning
* getExitStatusTask
* Method directry access
* get
* set
* create
* delete
* Login return bool if access
* Return Result class more information
* Minimal dependency library

## Usage

```java

Client client = new Client("192.168.22", 8006);
client.login("root", "password", "pam");

System.out.println(client->get('/version'));
// same for put/post/delete

//loop nodes for
JSONArray nodes = client.getNodes().index().getResponse().getJSONArray("data");
for (int i = 0; i < nodes.length(); i++) {
System.out.println(nodes.get(i));
}

//loop nodes for each
for (JSONObject node : Client.<JSONObject>JSONArrayToList(client.getNodes().index().getResponse().getJSONArray("data"))) {
System.out.println(node);
Client client = new Client("10.92.90.91", 8006);
if (client.login("root", "password", "pam")) {
//version
System.out.println(client.getVersion().version().getResponse().get("data"));

// same for put/post/delete
//loop nodes for
JSONArray nodes = client.getNodes().index().getResponse().getJSONArray("data");
for (int i = 0; i < nodes.length(); i++) {
System.out.println(nodes.get(i));
}

//loop nodes for each
Client.<JSONObject>JSONArrayToList(client.getNodes().index().getResponse().getJSONArray("data")).forEach((node) -> {
System.out.println(node);
});

//loops vms qemu
JSONArray vms = client.getNodes().get("pve1").getQemu().vmlist().getResponse().getJSONArray("data");
for (int i = 0; i < vms.length(); i++) {
System.out.println(vms.get(i));
}

//loop snashots
JSONArray snapshots = client.getNodes().get("pve1")
.getQemu().get(100).getSnapshot().snapshotList().getResponse().getJSONArray("data");
for (int i = 0; i < snapshots.length(); i++) {
System.out.println(snapshots.get(i));
}

//create snapshot
JSONObject retCreateSnap = client.getNodes().get("pve1").getQemu().get(100).getSnapshot().snapshot("pippo").getResponse();

//print UPID
System.out.println(retCreateSnap.get("data"));

//wait creation
client.waitForTaskToFinish("pve1", retCreateSnap.getString("data"), 500, 10000);

//delete snapshot
Client.Result retDeleSnap = client.getNodes().get("pve1").getQemu().get(100).getSnapshot().get("pippo").delsnapshot();
System.out.println(retDeleSnap.getResponse().get("data"));
}

//loops vms qemu
JSONArray vms = client.getNodes().get("pve1").getQemu().vmlist().getResponse().getJSONArray("data");
for (int i = 0; i < vms.length(); i++) {
System.out.println(vms.get(i));
}

//loop snashots
JSONArray snapshots = client.getNodes().get("pve1")
.getQemu().get(100).getSnapshot().snapshotList().getResponse().getJSONArray("data");
for (int i = 0; i < snapshots.length(); i++) {
System.out.println(snapshots.get(i));
}

//create snapshot
JSONObject retCreateSnap = client.getNodes().get("pve1")
.getQemu().get(100).getSnapshot().snapshot("pippo").getResponse();

//print UPID
System.out.println(retCreateSnap.get("data"));

//wait creation
client.waitForTaskToFinish("pve1", retCreateSnap.getString("data"), 500, 10000);

//delete snapshot
Client.Result retDeleSnap = client.getNodes().get("pve1")
.getQemu().get(100).getSnapshot().get("pippo").delsnapshot();
System.out.println(retDeleSnap.getResponse().get("data"));
```
38 changes: 20 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.enterpriseve.proxmoxve.api</groupId>
<artifactId>eve2pve-api-java</artifactId>
<version>1.0.7</version>
<groupId>it.corsinvest.proxmoxve.api</groupId>
<artifactId>cv4pve-api-java</artifactId>
<version>1.1.0</version>
<packaging>jar</packaging>
<name>cv4pve-api-java</name>
<description>Corsinvest for Proxmox VE Client API JAVA</description>
<url>http://www.corsinvest.it</url>
<developers>
<developer>
<id>dc</id>
<name>Daniele Corsini</name>
<email>daniele.corsini@corsinvest.it</email>
<roles>
<role>Project Manager</role>
<role>Architect</role>
</roles>
<organization>Corsinvest Srl</organization>
<timezone>0</timezone>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.5</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<version>20180813</version>
<type>jar</type>
</dependency>
</dependencies>
Expand All @@ -30,6 +34,4 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<name>eve2pve-api-java</name>
<description>ProxmoVE Client API JAVA </description>
</project>
Loading

0 comments on commit ace434f

Please sign in to comment.