sentora-core icon indicating copy to clipboard operation
sentora-core copied to clipboard

Implementation of new API/Webservice to replace XMWS

Open allebb opened this issue 11 years ago • 6 comments

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

allebb avatar Oct 18 '14 23:10 allebb

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

Mehdi-Bl avatar Oct 24 '14 16:10 Mehdi-Bl

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 [email protected] 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.

allebb avatar Oct 26 '14 10:10 allebb

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

Mehdi-Bl avatar Oct 26 '14 11:10 Mehdi-Bl

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 [email protected] 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.

allebb avatar Oct 26 '14 12:10 allebb

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.

Mehdi-Bl avatar Oct 26 '14 13:10 Mehdi-Bl

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:

  • Versioning in the url.
  • Standardized wrapper in json, which included error, result count, pagesize, result

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.

alpha1125 avatar Oct 26 '14 18:10 alpha1125