sentora / sentora-core

Sentora is a web hosting control panel written in PHP for *NIX
GNU General Public License v3.0
648 stars 446 forks source link

Implementation of new API/Webservice to replace XMWS #70

Open allebb opened 9 years ago

allebb commented 9 years ago

I intend of completely overhauling the current XML based API to a more standardised format. - I'm sure everyone agrees that this is probably wayyyy overdue! lol

The new solution will be a RESTful based web-service (which can talk both JSON and XML based on user preference - Simply by requesting the desire content-ype in the header) I will also complete the implementation of the remaining functionality for all core modules as at present only about 20% of the core functionality is covered by the core at present..

I intend to use a standard 'Resource' type design and utilising RESTful practice to CREATE (POST), READ (GET), UPDATE (PUT) and DELETE (DELETE).

MBlagui commented 9 years ago

Great ! to see rest API!! Do you need help ? Testing? Feedback?

allebb commented 9 years ago

Don't need any help at the moment buddy as I'm going to lay down the API framework code first, I personally want to get the main API base classes down first though (so authorisation etc. is taken care of) and then would be good if you would like to give me a hand getting the remaining API endpoints done for the existing core modules in Sentora :) - Give me a few weeks though and I'll hook up with you again and we can get started :)

On 24 October 2014 17:58, MBlagui notifications@github.com wrote:

Great ! to see rest API!! Do you need help ? Testing? Feedback?

— Reply to this email directly or view it on GitHub https://github.com/sentora/sentora-core/issues/70#issuecomment-60416568.

MBlagui commented 9 years ago

My pleasure... Try to think about the api in it's own Vhost/port ;-) So we can firewall it even with iptables.

allebb commented 9 years ago

Thats a good idea, I'll completely decouple the API from the control panel interface to enable the ability to host it on a separate port etc.

On 26 October 2014 11:06, MBlagui notifications@github.com wrote:

My pleasure... Try to think about the api in it's own Vhost/port ;-) So we can firewall it even with iptables.

— Reply to this email directly or view it on GitHub https://github.com/sentora/sentora-core/issues/70#issuecomment-60513898.

MBlagui commented 9 years ago

Api is first layer before we can think multiserver panel. But implementation is not so hard in DB.

We need to add serverID in all packages/ressources ( web/ftp/email) so we know where the ressource will be setup. We can easily move into that model.

alpha1125 commented 9 years ago

Bobby, If you want, I'd love to help out with this.

I've been looking to see how I could bootstrap zpanel, so I could use the functions. I was then informed of XMWS, the API. Upon looking at the code, I was like... huh? A lack of examples put me off from walking through the code with xdebug.

Rest is best. :)

What rest walkable tree structure are you thinking of? Are we using some best practises?

Some better rest classes I've used have included:

The below is just a sample, I grabbed from another RESTful API (http://rallydev.com). It's a sample query for say a user.

{
  QueryResult: {
    _versionAPIMajor: "2",
    _versionAPIMinor: "0",
    Errors: [ ],
    Warnings: [ ],
    TotalResultCount: 1,
    StartIndex: 1,
    PageSize: 20,
    Results: [
      {
        _rallyAPIMajor: "2",
        _rallyAPIMinor: "0",
        _ref: "http://localhost/api/webservice/v2.0/user/19223487150",
        _refObjectUUID: "some UUID",
        _refObjectName: "Alpha1125",
        _type: "User"
      }
    ]
  }
}

Where underscored prefixes, are system values.