Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for parameters to GET requests #12

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
This class provides the building blocks for someone wanting to use PHP to talk to Proxmox 2.0.
Relatively simple piece of code, just provides a get/put/post/delete abstraction layer as methods
on top of Proxmox's REST API, while also handling the Login Ticket headers required for authentication.
# PVE2 API - PHP Client #

See http://pve.proxmox.com/wiki/Proxmox_VE_API for information about how this API works.
API spec available at http://pve.proxmox.com/pve2-api-doc/
This class provides the building blocks for someone wanting to use PHP to talk
to Proxmox 2.0+. Relatively simple piece of code, just provides a
get/put/post/delete abstraction layer as methods on top of Proxmox's REST API,
while also handling the Login Ticket headers required for authentication.

## Requirements: ##
See <http://pve.proxmox.com/wiki/Proxmox_VE_API> for information about how this
API works. API spec available at <http://pve.proxmox.com/pve2-api-doc/>

## Requirements ##

PHP 5 with cURL (including SSL) support.

## Usage: ##
## Usage ##

Example - Return status array for each Proxmox Host in this cluster.

```php
require("./pve2-api-php-client/pve2_api.class.php");

# You can try/catch exception handle the constructor here if you want.
$pve2 = new PVE2_API("hostname", "username", "realm", "password");
# realm above can be pve, pam or any other realm available.

/* Optional - enable debugging. It print()'s any results currently */
// $pve2->set_debug(true);

if ($pve2->login()) {
foreach ($pve2->get_node_list() as $node_name) {
print_r($pve2->get("/nodes/".$node_name."/status"));
Expand All @@ -30,20 +31,18 @@ Example - Return status array for each Proxmox Host in this cluster.
print("Login to Proxmox Host failed.\n");
exit;
}
```

Example - Create a new OpenVZ Container on the first host in the cluster.

```php
require("./pve2-api-php-client/pve2_api.class.php");

# You can try/catch exception handle the constructor here if you want.
$pve2 = new PVE2_API("hostname", "username", "realm", "password");
# realm above can be pve, pam or any other realm available.

/* Optional - enable debugging. It print()'s any results currently */
// $pve2->set_debug(true);

if ($pve2->login()) {

# Get first node name.
$nodes = $pve2->get_node_list();
$first_node = $nodes[0];
Expand All @@ -69,20 +68,18 @@ Example - Create a new OpenVZ Container on the first host in the cluster.
print("Login to Proxmox Host failed.\n");
exit;
}
```

Example - Modify DNS settings on an existing container on the first host.

```php
require("./pve2-api-php-client/pve2_api.class.php");

# You can try/catch exception handle the constructor here if you want.
$pve2 = new PVE2_API("hostname", "username", "realm", "password");
# realm above can be pve, pam or any other realm available.

/* Optional - enable debugging. It print()'s any results currently */
// $pve2->set_debug(true);

if ($pve2->login()) {

# Get first node name.
$nodes = $pve2->get_node_list();
$first_node = $nodes[0];
Expand All @@ -98,25 +95,25 @@ Example - Modify DNS settings on an existing container on the first host.
print("Login to Proxmox Host failed.\n");
exit;
}
```

Example - Delete an existing container.

```php
require("./pve2-api-php-client/pve2_api.class.php");

# You can try/catch exception handle the constructor here if you want.
$pve2 = new PVE2_API("hostname", "username", "realm", "password");
# realm above can be pve, pam or any other realm available.

/* Optional - enable debugging. It print()'s any results currently */
// $pve2->set_debug(true);

if ($pve2->login()) {
# NOTE - replace XXXX with node short name, and YYYY with container ID.
var_dump($pve2->delete("/nodes/XXXX/openvz/YYYY"));
} else {
print("Login to Proxmox Host failed.\n");
exit;
}
```

Licensed under the MIT License.
See LICENSE file.
3 changes: 2 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- add a new class extending PVE2_API that provides abstraction methods to common tasks, ie. create VM/container, change container settings, etc.
- add a new class extending PVE2_API that provides abstraction methods to
common tasks, ie. create VM/container, change container settings, etc.
Loading