Giter VIP home page Giter VIP logo

proxmox-api's Introduction

proxmox-api

Build Status Gem Version

What is it?

ProxmoxAPI is Ruby wrapper for Proxmox REST API. It simply send your requests to Proxmox REST API server without verifying them.

Usage

Installation

You can add this gem to your Gemfile and use bundler:

gem 'proxmox-api'

Or install gem manually:

gem install proxmox

Authorization

Creating connection is as simple as giving all needed info to ProxmoxAPI constructor:

First parameter is node we are going to connect to. Second parameter is options hash. Possible options are:

  1. Ticket creation options :username, :password, :realm, :otp (see /access/ticket request description)

    require 'proxmox_api'
    
    client = ProxmoxAPI.new(
      'proxmox-host.example.org',
      username: 'root', password: 'password', realm: 'pam', verify_ssl: false
    )
  2. Token options :token, :secret (see API documentation for details)

    require 'proxmox_api'
    
    client = ProxmoxAPI.new(
      'proxmox-host.example.org',
      token: 'root@pam!tokenid', secret: 'cdbb8fce-c068-4a9b-ade1-a00043db818a', verify_ssl: false
    )
  3. SSL options, supported by rest-client. See it's documentation for full list.

ProxmoxAPI constructor will automatically try to get access ticket with given credentials and will raise an exception if this will fail.

Making requests

To build REST API url just chain it to client object. Calling .get, .put, .post or .delete will result in sending appropriate request to Proxmox node.

ProxmoxAPI::ApiException will be raised if server will return error status code.

# Get current status of container with id 101 on pve1 node
client.nodes['pve1'].lxc[101].status.current.get

# Same request. You can use brackets or methods in any valid combination.
client.nodes.pve1.lxc[101].status[:current].get

# Same request again. Full api path can be given with brackets too.
client['nodes/pve1/lxc/101/status/current'].get

# Create user 'user' with password 'password' in 'pve' realm
client.access.users.post(userid: 'user@pve', password: 'password')

# Give user PVEAdmin role on server with vmid 101 
proxmox.access.acl.put(path: 'vms/101', users: 'user@pve', roles: 'PVEAdmin')

If you want to ignore server status codes, you can use dangerous methods:

# Here we use dangerous method to check if user exists
proxmox.access.users['user@pve'].get!.nil?

Contributing

Feel free to create issue or propose pull request on GitHub.

proxmox-api's People

Contributors

h0tw1r3 avatar l-eugene avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

h0tw1r3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.