Skip to content

Commit

Permalink
Preparing next release, fixing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zzantares committed Aug 11, 2014
1 parent dd76844 commit d230532
Show file tree
Hide file tree
Showing 21 changed files with 335 additions and 327 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ php:
- 5.6
- 5.5
- 5.4
- 5.3
- hhvm

matrix:
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
v3.0.0
------

- PHP 5.4 required.
- Proxmox API client logic rewritten (but the usage is pretty much the same).
- GuzzleHttp used for sending HTTP requests.
- Credentials default form is now an array not an object (read the docs).
- Better docs (compliant with this new release).


v2.1.1
------

Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Welcome developers!
==================
===================

Before making any contribution you should now:

- All code contribution should follow PSR-1 and PSR-2 coding style standards. (Thanks to [Alexey Ashurok](https://github.com/aotd1))
- You should code the tests for any function you add, some times is not possible but try doing it.
- You should code the tests for any function you add, some times is not possible but try doing it. Personally I like more the *black box* testing approach.
- All functions need to be properly documented, all comments, variable names, function names only on english language.
- Variables and functions names should be self descriptive.

Expand All @@ -15,7 +15,7 @@ Installation
Of course you should [fork the repo](https://github.com/ZzAntares/ProxmoxVE/fork), then after cloning your forked repo:

```sh
$ composer install --dev # run cmd inside the project folder
$ composer install --dev # Run command inside the project folder
```

What needs to be done?
Expand Down
83 changes: 51 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ProxmoxVE API Client
====================

This **PHP 5.3+** library allows you to interact with your Proxmox server via API.
This **PHP 5.4+** library allows you to interact with your Proxmox server via API.

[![Build Status](https://travis-ci.org/ZzAntares/ProxmoxVE.svg?branch=master)](https://travis-ci.org/ZzAntares/ProxmoxVE)
[![Latest Stable Version](https://poser.pugx.org/zzantares/proxmoxve/v/stable.svg)](https://packagist.org/packages/zzantares/proxmoxve)
Expand All @@ -11,7 +11,9 @@ This **PHP 5.3+** library allows you to interact with your Proxmox server via AP
[![Latest Unstable Version](https://poser.pugx.org/zzantares/proxmoxve/v/unstable.svg)](https://packagist.org/packages/zzantares/proxmoxve)
[![License](https://poser.pugx.org/zzantares/proxmoxve/license.svg)](https://packagist.org/packages/zzantares/proxmoxve)

> If you find any errors or you detect that something is not working as expected please open an [issue](https://github.com/ZzAntares/ProxmoxVE/issues/new) or tweetme [@ZzAntares](https://twitter.com/ZzAntares). I'll try to release a fix asap.
> If you find any errors, typos or you detect that something is not working as expected please open an [issue](https://github.com/ZzAntares/ProxmoxVE/issues/new) or tweetme [@ZzAntares](https://twitter.com/ZzAntares). I'll try to release a fix asap.
**looking for a PHP 5.3 library version?** Search through the [releases](https://github.com/ZzAntares/ProxmoxVE/releases) one that fits your needs, I recommend using the [2.1.1](https://github.com/ZzAntares/ProxmoxVE/releases/tag/v2.1.1) version.

Installation
------------
Expand All @@ -21,15 +23,15 @@ Recomended installation is using [Composer], if you do not have [Composer] what
In the root of your project execute the following:

```sh
$ composer require zzantares/proxmoxve ~2.0
$ composer require zzantares/proxmoxve ~3.0
```

Or add this to your `composer.json` file:

```json
{
"require": {
"zzantares/proxmoxve": "~2.0"
"zzantares/proxmoxve": "~3.0"
}
}
```
Expand All @@ -48,21 +50,26 @@ Usage
// Require the autoloader
require_once 'vendor/autoload.php';

// Use the library namespaces
use ProxmoxVE\Credentials;
// Use the library namespace
use ProxmoxVE\Proxmox;

$server = 'your.server.tld';
$user = 'root';
$pass = 'secret';

// Create your Credentials object
$credentials = new Credentials($server, $user, $pass);
// Create your credentials array
$credentials = [
'hostname' => 'proxmox.server.com', // Also can be an IP
'username' => 'root',
'password' => 'secret',
];

// realm and port defaults to 'pam' and '8006' but you can specify them like so
$credentials = new Credentials($server, $user, $pass, 'pve', '9009');
$credentials = [
'hostname' => 'proxmox.server.com',
'username' => 'root',
'password' => 'secret',
'realm' => 'pve',
'port' => '9009',
];

// Then simply pass your Credentials object when creating the API client object.
// Then simply pass your credentials when creating the API client object.
$proxmox = new Proxmox($credentials);

$allNodes = $proxmox->get('/nodes');
Expand Down Expand Up @@ -98,33 +105,39 @@ Array
)
```

For the lazy ones it's possible to create a ProxmoxVE instance passing an associative array but you need to specify all fields including realm and port:
Using custom credentials object
-------------------------------

Also is possible to create a ProxmoxVE instance passing a custom object that has all related data needed to connect to the Proxmox server:

```php
<?php
// Once again require the autoloader
require_once 'vendor/autoload.php';

// You can define your credentials using an array
$credentials = array(
'hostname' => 'your.server.tld',
'username' => 'root',
'password' => 'secret',
'realm' => 'pam',
'port' => '8006',
);
// Sample custom credentials class
class CustomCredentials
{
public function __construct($host, $user, $pass)
{
$this->hostname = $host;
$this->username = $user;
$this->password = $pass;
}
}

// Create ProxmoxVE instance by passing the $credentials array
// Create ProxmoxVE instance by passing your custom credentials object
$credentials = new CustomCredentials('proxmox.server.com', 'root', 'secret');
$proxmox = new ProxmoxVE\Proxmox($credentials);

// Then you can use it, for example create a new user.

// Define params
$params = array(
$params = [
'userid' => 'new_user@pve', // Proxmox requires to specify the realm (see the docs)
'comment' => 'Creating a new user',
'password' => 'canyoukeepasecret?',
);
];

// Send request passing params
$result = $proxmox->create('/access/users', $params);
Expand All @@ -140,6 +153,8 @@ if (isset($result['errors'])) {
}
```

Using a custom credentials object is useful when your application uses some *ORM models* with the connecting data inside them, so you can pass for example an *Eloquent* model that holds the credentials inside.


Docs
----
Expand All @@ -154,9 +169,9 @@ In your proxmox server you can use the [pvesh CLI Tool](http://pve.proxmox.com/w

Consult the [ProxmoxVE API] article at the [Proxmox wiki].

**I need more docs!**
**I feel you're hiding some cool tricks! I need more docs!**

See the [doc](https://github.com/ZzAntares/ProxmoxVE/tree/master/doc) directory for more detailed documentation.
See the [doc](https://github.com/ZzAntares/ProxmoxVE/tree/master/doc) directory for more detailed documentation, it's all in there I swear it... I think.


License
Expand Down Expand Up @@ -190,15 +205,19 @@ If you feel guilty by using this open source software library for free, you can
> Fork and code! There is no better donation that your code contribution ;)

TODO
[![@ZzAntares](https://lh4.googleusercontent.com/-y60LB84GXNk/U-gGlzNHUGI/AAAAAAAACDs/cuhszQOezYE/s50-no/twitter-logo.png)](https://twitter.com/ZzAntares)

> Or just cheer me up [@ZzAntares](https://twitter.com/ZzAntares).
Upcoming features
----
- Notify the user when a CNAME DNS record is provided as a hostname, Proxmox API seems to not work in this case.
- Add SSL support.

- SSL support.
- Save AuthToken data in serialized form to avoid ticket creation per request.
- Use an abstracted OOP layer to access all Proxmox resources.
- Code useful tests ¬_¬!

[LICENSE]:https://github.com/ZzAntares/ProxmoxVE/blob/master/LICENSE
[LICENSE]:./LICENSE
[PVE2 API Documentation]:http://pve.proxmox.com/pve2-api-doc/
[ProxmoxVE API]:http://pve.proxmox.com/wiki/Proxmox_VE_API
[Proxmox wiki]:http://pve.proxmox.com/wiki
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zzantares/proxmoxve",
"type": "library",
"description": "A simple PHP 5.3+ Proxmox API client.",
"description": "A simple PHP 5.4+ Proxmox API client.",
"keywords": ["Proxmox", "API", "KVM", "OpenVZ", "Virtualization"],
"homepage": "https://github.com/ZzAntares/ProxmoxVE",
"license": "MIT",
Expand Down
Loading

0 comments on commit d230532

Please sign in to comment.