Skip to content

Commit

Permalink
Rename Client in PveClient, improve Result
Browse files Browse the repository at this point in the history
Close #3
  • Loading branch information
franklupo committed Oct 8, 2019
1 parent 1effa7d commit a0b6649
Show file tree
Hide file tree
Showing 8 changed files with 886 additions and 973 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# cv4pve-api-java

ProxmoVE Client API JAVA
Proxmox VE 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) [![Donate to this project using Paypal](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=PPM9JHLQLRV2S&item_name=Open+Source+Project&currency_code=EUR&source=url)

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

# **Donations**

Expand All @@ -24,14 +24,14 @@ Corsinvest for Proxmox VE Api Client (Made in Italy)

## General

The client is generated from a JSON Api on ProxmoxVE.
The client is generated from a JSON Api on Proxmox VE.

## Result

The result is class **Result** and contain methods:

* **getResponse()** returned from ProxmoxVE (data,errors,...) JSONObject
* **responseInError** (bool) : Contains errors from ProxmoxVE.
* **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.
Expand All @@ -53,16 +53,16 @@ The result is class **Result** and contain methods:
* 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
* Return result
* Request
* Response
* Status
* Last result action
* Wait task finish task
* waitForTaskToFinish
* taskIsRunning
* getExitStatusTask
* Method directry access
* Method directly access
* get
* set
* create
Expand All @@ -75,7 +75,7 @@ The result is class **Result** and contain methods:
## Usage

```java
Client client = new Client("10.92.90.91", 8006);
PveClient client = new PveClient("10.92.90.91", 8006);
if (client.login("root", "password", "pam")) {
//version
System.out.println(client.getVersion().version().getResponse().get("data"));
Expand All @@ -88,7 +88,7 @@ if (client.login("root", "password", "pam")) {
}

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

Expand All @@ -98,7 +98,7 @@ if (client.login("root", "password", "pam")) {
System.out.println(vms.get(i));
}

//loop snashots
//loop snapshots
JSONArray snapshots = client.getNodes().get("pve1")
.getQemu().get(100).getSnapshot().snapshotList().getResponse().getJSONArray("data");
for (int i = 0; i < snapshots.length(); i++) {
Expand All @@ -115,7 +115,7 @@ if (client.login("root", "password", "pam")) {
client.waitForTaskToFinish("pve1", retCreateSnap.getString("data"), 500, 10000);

//delete snapshot
Client.Result retDeleSnap = client.getNodes().get("pve1").getQemu().get(100).getSnapshot().get("pippo").delsnapshot();
Result retDeleSnap = client.getNodes().get("pve1").getQemu().get(100).getSnapshot().get("pippo").delsnapshot();
System.out.println(retDeleSnap.getResponse().get("data"));
}
```
```
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>it.corsinvest.proxmoxve.api</groupId>
<artifactId>cv4pve-api-java</artifactId>
<version>1.1.3</version>
<version>2.0.0</version>
<packaging>jar</packaging>
<name>cv4pve-api-java</name>
<description>Corsinvest for Proxmox VE Client API JAVA</description>
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/it/corsinvest/proxmoxve/api/MethodType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* This file is part of the cv4pve-api-java https://github.com/Corsinvest/cv4pve-api-java,
* Copyright (C) 2016 Corsinvest Srl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package it.corsinvest.proxmoxve.api;

/**
* Method Type
*/
public enum MethodType {
GET, SET, CREATE, DELETE
}
Loading

0 comments on commit a0b6649

Please sign in to comment.