Proxmox VE Client API Java
______ _ __
/ ____/___ __________(_)___ _ _____ _____/ /_
/ / / __ \/ ___/ ___/ / __ \ | / / _ \/ ___/ __/
/ /___/ /_/ / / (__ ) / / / / |/ / __(__ ) /_
\____/\____/_/ /____/_/_/ /_/|___/\___/____/\__/
Corsinvest for Proxmox VE Api Client (Made in Italy)
Copyright: Corsinvest Srl For licensing details please visit LICENSE.md
This software is part of a suite of tools called cv4pve-tools. If you want commercial support, visit the site
The client is generated from a JSON Api on Proxmox VE.
The result is class Result and contain methods:
- getResponse() returned from Proxmox VE (data,errors,...) JSONObject
- responseInError (bool) : Contains errors from Proxmox VE.
- getStatusCode() (int) : Status code of the HTTP response.
- getReasonPhrase() (string): The reason phrase which typically is sent by servers together with the status code.
- isSuccessStatusCode() (bool) : Gets a value that indicates if the HTTP response was successful.
- getError() (string) : Get error.
- Easy to learn
- Method named
- Full method generated from documentation
- Comment any method and parameters
- Parameters indexed eg [n] is structured in array index and value
- Tree structure
- client.getNodes().get("pve1").getQemu().vmlist().getResponse().getJSONArray("data")
- Return data Proxmox VE
- Debug Level show to console information
- Return result
- Request
- Response
- Status
- Last result action
- Wait task finish task
- waitForTaskToFinish
- taskIsRunning
- getExitStatusTask
- Method directly access
- get
- set
- create
- delete
- Login return bool if access
- Return Result class more information
- Minimal dependency library
- ClientBase lite function
- Form Proxmox VE 6.2 support Api Token for user
From version 6.2 of Proxmox VE is possible to use Api token. This feature permit execute Api without using user and password. If using Privilege Separation when create api token remember specify in permission. Format USER@REALM!TOKENID=UUID
//if you want use lite version only get/set/create/delete use PveClientBasePveClientclient = newPveClient("10.92.90.91", 8006);
if (client.login("root", "password", "pam")) {
//versionSystem.out.println(client.getVersion().version().getResponse().get("data"));
// same for put/post/delete//loop nodes forJSONArraynodes = client.getNodes().index().getResponse().getJSONArray("data");
for (inti = 0; i < nodes.length(); i++) {
System.out.println(nodes.get(i));
}
//loop nodes for eachPveClient.<JSONObject>JSONArrayToList(client.getNodes().index().getResponse().getJSONArray("data")).forEach((node) -> {
System.out.println(node);
});
//loops vms qemuJSONArrayvms = client.getNodes().get("pve1").getQemu().vmlist().getResponse().getJSONArray("data");
for (inti = 0; i < vms.length(); i++) {
System.out.println(vms.get(i));
}
//loop snapshotsJSONArraysnapshots = client.getNodes().get("pve1")
.getQemu().get(100).getSnapshot().snapshotList().getResponse().getJSONArray("data");
for (inti = 0; i < snapshots.length(); i++) {
System.out.println(snapshots.get(i));
}
//create snapshotJSONObjectretCreateSnap = client.getNodes().get("pve1").getQemu().get(100).getSnapshot().snapshot("pippo").getResponse();
//print UPIDSystem.out.println(retCreateSnap.get("data"));
//wait creationclient.waitForTaskToFinish("pve1", retCreateSnap.getString("data"), 500, 10000);
//delete snapshotResultretDeleSnap = client.getNodes().get("pve1").getQemu().get(100).getSnapshot().get("pippo").delsnapshot();
System.out.println(retDeleSnap.getResponse().get("data"));
}For escape string use URLEncoder.encode
Map<Integer, String> netN = newHashMap<>();
netN.put(1, URLEncoder.encode("name=eth0,rate=15,bridge=vmbr0,firewall=1,gw=xx.xx.xx.xx,ip=xx.xx.xx.xx/24,hwaddr=02:00:be:0f:f2:63",StandardCharsets.UTF_8));