Coder Social home page Coder Social logo

ovh-sdk-php's Introduction

OVH SDK for PHP

PHP SDK to consume OVH web services

WARNING : This SDK is currently in development, some functions/methods are not (or not correctly) implemented. Use with care.

Before Using the SDK

Get OVH credentials

You need three keys :

  • Application Key (AK)
  • Applcation Secret (AS)
  • Consumer Key (CK)

You will find in the tools directory a script named getOvhCredentials.php. Use it to get yours credentials (read how to in the header of the script).

Requirements

You need PHP 5.3.2+ compiled with the cURL extension.

Install OVH SDK

Installing via Composer

The recommended way to install OVH SDK is through Composer.

  1. Add toorop/ovh-sdk-php as a dependency in your project's composer.json file:

     {
         "require": {
             "toorop/ovh-sdk-php": "dev-master"
         }
     }
    
  2. Download and install Composer:

     curl -s http://getcomposer.org/installer | php
    
  3. Install your dependencies:

     php composer.phar install
    
  4. Require Composer's autoloader

    Composer also prepares an autoload file that's capable of autoloading all of the classes in any of the libraries that it downloads. To use it, just add the following line to your code's bootstrap process:

     require 'vendor/autoload.php';
    

You can find out more on how to install Composer, configure autoloading, and other best-practices for defining dependencies at getcomposer.org.

Using the SDK

Quick Start

<?php
// Include the OVH SDK via composer autoload
require_once 'vendor/autoload.php';
use \Ovh\Common\Ovh;

// Populate your keyring
/** RG : APPLICATION REGION :
 * FR = eu.api.ovh.com
 * CA = ca.api.ovh.com
 * KIMSUFIFR = eu.api.kimsufi.com
 * KIMSUFICA = ca.api.kimsufi.com
 * SYSFR = eu.api.soyoustart.com
 * SYSCA = ca.api.soyoustart.com
 */
$config=array(
    'AK' => 'YOUR APPLICATION KEY',
    'AS' => 'YOUR APPLICATION SECRET',
    'CK' => 'YOUR CONSUMER KEY',
    'RG' => 'YOUR APPLICATION REGION' 
);

// Init your OVH instance
$ovh = new Ovh($config);

/**
 *
 *  Dedicated Server Part
 *
 */

// Get your Dedicated Servers
$dedicatedServerList=$ovh->getDedicatedServerList();
foreach($dedicatedServerList as $dedicatedServerDomain)
    print "$dedicatedServerDomain\n";

// Init a Dedicated Server instance
$dedicatedServer=$ovh->getDedicatedServer($dedicatedServerDomain);

// Get Dedicated Server properties
$r=$dedicatedServer->getProperties();

// Get Dedicated Server Service Infos
$r=$dedicatedServer->getServiceInfos();

// Get current task
$task=$dedicatedServer->getTasks();

// Get properties of a task
$properties = $dedicatedServer->getTaskProperties($taskId);



/**
 *
 *  VPS Part
 *
 */

// Get yours VPS
$vpsList=$ovh->getVpsList();
foreach($vpsList as $vpsDomain)
    print "$vpsDomain\n";

// Init a VPS instance
$vps=$ovh->getVps($vpsDomain);

// Get VPS properties
$r=$vps->getProperties();

// Get VPS Status
$r=$vps->getStatus();

// Get Monitoring
$r=$vps->getMonitoring('today',"cpu:max");

// Get current Monitorin
$r=$vps->getCurrentMonitoring('cpu:max');

// Stop VPS
$vps->stop();

// Start VPS
$vps->start();

// reboot VPS
$vps->reboot();

// (re)Set root password
$vps->setRootPassword();

// Get availables upgrade
$upgrades=$vps->getAvailableUpgrades();

// Get availables options
$options=$vps->getAvailableOptions();

// Get model
$models=$vps->getModels();

// Order a cPanel Licence
$r=$vps->orderCpanelLicense();

// Order a Plesk Licence
$r=$vps->orderPleskLicence(1);

// Order a FTP backup
$r=$vps->orderFtpBackup();

// Get disks
$disks=$vps->getDisks();

// Get disk properties
$properties=$vps->getDiskProperties($diskId);

// Get disk usage
$usage=$vps->getDiskUsage($diskId,'used');

// Get disk monitoring
$monit=$vps->getDiskMonitoring($diskId,'lastday','max');

// Get current task
$task=$vps->getTasks();

// Get properties of a task
$properties = $vps->getTaskProperties($taskId);

// Get VPS IPs
$ip=$vps->getIps();

// Get IP properties
$properties=$vps->getIpProperties($ip);

// Set IP properties
$vps->setIpProperties('$ip', array('reverse'=>'IP Reverse'));

// Get snapshot properties
$properties=$vps->getSnapshotProperties();

// Order a snapshot
$order=$vps->orderSnapshot();

// Get available templates
$templates=$vps->getAvailableTemplates();

// Get templates properties
$properties=$vps->getTemplateProperties($templateId);

ovh-sdk-php's People

Contributors

adrienr avatar b18s avatar claudusd avatar flosoft avatar thibautg16 avatar toorop avatar vixys avatar

Watchers

 avatar  avatar

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.