straussmann/proxmoxmg-api-client

一个简单的PHP 5.5+ Proxmox Mail Gateway API客户端。

dev-master 2020-12-13 23:30 UTC

README

这个 PHP 5.5+ 库允许您通过API与Proxmox服务器交互。

Coverage Build Status Latest Stable Version Daily Downloads Monthly Downloads Total Downloads Latest Unstable Version License

如果您发现任何错误、错别字或检测到某些内容未按预期工作,请打开一个 问题 或发推文给我 @ZzAntares。我将尽快发布修复程序。

寻找PHP 5.3版本库?发行版 中搜索适合您需求的版本,我推荐使用 2.1.1 版本。

安装

建议使用 Composer 进行安装,如果您还没有 Composer,您在等什么?

在您项目的根目录中执行以下操作

$ composer require zzantares/proxmoxve ~4.0

或者将其添加到您的 composer.json 文件中

{
    "require": {
        "zzantares/proxmoxve": "~4.0"
    }
}

然后执行安装

$ composer install --no-dev

用法

<?php

// Require the autoloader
require_once 'vendor/autoload.php';

// Use the library namespace
use ProxmoxVE\Proxmox;

// 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 = [
    'hostname' => 'proxmox.server.com',
    'username' => 'root',
    'password' => 'secret',
    'realm' => 'pve',
    'port' => '9009',
];

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

$allNodes = $proxmox->get('/nodes');

print_r($allNodes);

示例输出

Array
(
    [data] => Array
        (
            [0] => Array
                (
                    [disk] => 2539465464
                    [cpu] => 0.031314446882002
                    [maxdisk] => 30805066770
                    [maxmem] => 175168446464
                    [node] => mynode1
                    [maxcpu] => 24
                    [level] =>
                    [uptime] => 139376
                    [id] => node/mynode1
                    [type] => node
                    [mem] => 20601992182
                )

        )

)

想了解更多技巧吗?

查看我们的 wiki

文档

在您的Proxmox客户端对象上,您可以使用 get()create()set()delete() 函数操作在 PVE2 API文档 中指定的所有资源,参数作为关联数组中的第二个参数传递。

我可以交互哪些资源或路径以及如何交互?

在您的Proxmox服务器上,您可以使用 pvesh CLI工具 管理所有pve资源,您可以像使用pvesh工具一样使用此库。例如,您可以运行 pvesh,然后,如屏幕信息所示,您可以输入 help [path] [--verbose] 来查看如何使用路径以及应传递给它的参数。请务必在 Proxmox wiki 上了解有关 pvesh CLI工具 的信息。

Proxmox API是如何工作的?

请参阅 ProxmoxVE API 文章,位于 Proxmox wiki

我觉得你在隐藏一些酷炫的技巧!我需要更多的文档!

请参阅项目的 wiki 以获取更详细的文档,那里都有,我发誓... 我想。

许可证

本项目采用MIT许可证发布。有关详细信息,请参阅附带的 LICENSE 文件。

想要贡献吗?

谢谢!请查看 CONTRIBUTING,您可以轻松设置开发环境,以便快速开始。