Corsinvest / cv4pve-api-dotnet

Proxmox VE Client API .Net C#
https://www.corsinvest.it/cv4pve
GNU General Public License v3.0
58 stars 15 forks source link
api api-client api-gateway api-rest dotnet dotnet-core dotnet-standard enterprise lxc nuget proxmox proxmox-apis proxmox-cluster proxmox-ve proxmoxve pve qemu web-api

Corsinvest.ProxmoxVE.Api

Nuget Nuget Nuget Nuget Nuget

Proxmox VE Client API .Net

Proxmox VE Api

   ______                _                      __
  / ____/___  __________(_)___ _   _____  _____/ /_
 / /   / __ \/ ___/ ___/ / __ \ | / / _ \/ ___/ __/
/ /___/ /_/ / /  (__  ) / / / / |/ /  __(__  ) /_
\____/\____/_/  /____/_/_/ /_/|___/\___/____/\__/

Corsinvest for Proxmox VE Api Client  (Made in Italy)

Copyright and License

Copyright: Corsinvest Srl For licensing details please visit LICENSE

Commercial Support

This software is part of a suite of tools called cv4pve-tools. If you want commercial support, visit the site

General

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

Main features

Api token

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

Result

The result is class Result and contain properties:

Example result:

{
  "data": {
    "smbios1": "uuid=9246585e-0c8b-4d02-8fe2-f48fd0da3975",
    "ide2": "none,media=cdrom",
    "onboot": 1,
    "boot": "cdn",
    "cores": 2,
    "agent": 1,
    "memory": 4096,
    "numa": 0,
    "bootdisk": "virtio0",
    "sockets": 1,
    "net0": "virtio=3A:39:38:30:36:31,bridge=vmbr0",
    "parent": "auto4hours170904080002",
    "digest": "acafde32daab50bce801fef2e029440c54ebe2f7",
    "vga": "qxl",
    "virtio0": "local-zfs:vm-100-disk-1,cache=writeback,size=50G",
    "ostype": "win8",
    "name": "phenometa"
  }
}

Usage

//if you want use lite version only get/set/create/delete use PveClientBase

var client = new PveClient("10.92.90.91");
if (await client.Login("root", "password"))
{
    var vm = await client.Nodes["pve1"].Qemu[100];

    //config vm
    var config = await vm.Config.VmConfig();
    Console.WriteLine(JsonConvert.SerializeObject(config.Response,Formatting.Indented));

    //create snapshot
    var response = await vm.Snapshot.Snapshot("pippo2311");

    //update snapshot description
    await vm.Snapshot["pippo2311"].Config.UpdateSnapshotConfig("description");

    //delete snapshot
    await vm.Snapshot["pippo2311"].Delsnapshot();

    //list of snapshot
    foreach (var snapshot in (await vm.Snapshot.SnapshotList()).Response.data)
    {
        Console.WriteLine(JsonConvert.SerializeObject(snapshot,Formatting.Indented));
        Console.WriteLine(snapshot.name);
    }

    //change response type from json to png
    client.ResponseType = "png";
    var dataImg = client.Nodes["pve1"].Rrd.Rrd("cpu", "day").Response;
    Console.WriteLine("<img src=\"{dataImg}\" \>");
}

//using Api Token
var client = new PveClient("10.92.100.33");
client.ApiToken = "root@pam!qqqqqq=8a8c1cd4-d373-43f1-b366-05ce4cb8061f";
var version = await client.Version.Version();
Console.WriteLine(JsonConvert.SerializeObject(version.Response.data, Formatting.Indented));

Corsinvest.ProxmoxVE.Extension

Extension add functionality on Api.

Corsinvest.ProxmoxVE.Shared

Contain model for Json conversion and utility.

Corsinvest.ProxmoxVE.Metadata

Read documentation ProxmoxVE API and extract structure.

Corsinvest.ProxmoxVE.Shell

Utility for console application.