Coder Social home page Coder Social logo

directadmin-rails-plugin's Introduction

DirectAdmin Rails Plugin (by Josh Delsman)

The DirectAdmin Rails plugin provides you with a communication class for interfacing directly with your DirectAdmin Web Control Panel.

NOTE: I would recommend that until DA decides to move to an XML- based system, that you only use the commands which start with “CMD_API”, most of which are updated here:

Installation

Installation is simple:

script/plugin install git://github.com/voxxit/directadmin-rails-plugin.git

Example Usage

First, you must initialise a DirectAdmin::Base object to use. This requires the DirectAdmin hostname, port, username and password, as well as a failure email for commands:

@da = DirectAdmin::Base.new(
  :username       => "admin",
  :password       => "password",
  :host           => "http://host.com:2222/",
  :port           => "2222",
  :failure_email  => "[email protected]"
)

If the API command requires POST and additional form data, such as username or password, you’ll need to insert some form data. Here is an example from the CMD_API_ACCOUNT_USER command:

form_data = {
  :action    => 'create',
  :add       => 'Submit',
  :username  => 'sampleuser',
  :email     => '[email protected]',
  :passwd    => 'sample_Password',
  :passwd2   => 'sample_Password',
  :domain    => 'sample.com',
  :package   => 'packagename',
  :ip        => '127.0.0.1',
  :notify    => 'yes'
}

If the API command requires GET (like CMD_API_SHOW_USER_DOMAINS does), you’ll need to add the option :method => ‘get’ to your call and whatever GET parameters are required.

Now, you can simply make the call! You will need to invoke the “do” method, which will communicate with the server, perform the function, and then report back with a URL encoded array/string:

*Example with POST-enabled API call:*

@show_users = @da.do(
  :command => "CMD_API_SHOW_USERS"
)

*Example with GET-enabled API call:*

@show_user_domains = @da.do(
  :command => "CMD_API_SHOW_USER_DOMAINS", 
  :method => 'get',
  :user => user
)

You can optionally elect to parse the data into a usable and pretty handy hash, too:

@hash = @da.parse(@show_users.body)

Bugs/Issues

Please report all issues using the GitHub issue tracker at:

github.com/voxxit/directadmin-rails-plugin/issues

Credit

Author: Josh Delsman (voxxit.github.com)

License

See the MIT-LICENSE file.

directadmin-rails-plugin's People

Stargazers

 avatar  avatar  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.