I made changes so that Stratos REST API adhere to the HTTP specification. Given below are some of the examples.
*GET * Header 200 with response body containing the data. Return 204 if no content found with the given url. *POST * POST - 201 Return 201 when the resource is created and URL to the newly created resource is sent as location header. Ex: Deploying a auto scaling policy successfully. Status code : 201 with location header *< HTTP/1.1 201 Created* *< Location: https://localhost:9443/stratos/admin/policy/autoscale/simpleAutoscalePolicy2 <https://localhost:9443/stratos/admin/policy/autoscale/simpleAutoscalePolicy2>* POST - 204 Return 204 when the request is handled successfully, but server has no response to send back. Ex: Unsubcribe does not return any content. So, POST /cartridge/unsubscribe/alias On success : 204 Accepted *DELETE* Return 404 if the resource not found. For instance DELETE /tenant/udara.com return 404 in case there is no tenant found with the domain udara.com. Yes there is a debate [1] in whether sending 404 is good or bad in DELETE. There are mix arguments. I chose to send 404 :-). Return 204 For instance DELETE /tenant/udara.com return 204 if the tenant udara.com is deleted successfully. *PUT* PUT tenant/udara.com Return 404 in case there is no tenant with udara.com as the domain Return 204 when tenant is updated successfully. *Common Error format* { "Error": { "errorCode": " 400", "errorMessage": " Specified policy [simpleAutoscalePolicyuuu] already exists" } } Changes are commited to the master branch. Please have a look and suggest improvements. [1] http://stackoverflow.com/questions/2342579/http-status-code-for-update-and-delete On Tue, Jul 8, 2014 at 12:59 PM, Isuru Haththotuwa <isu...@apache.org> wrote: > +1 for this change. We can use a standard way to do this, such as > returning a 'Response' type [1]. > > [1]. http://docs.oracle.com/javaee/6/api/javax/ws/rs/core/Response.html > > > On Tue, Jul 8, 2014 at 10:10 AM, Dakshika Jayathilaka <daksh...@wso2.com> > wrote: > >> +1 for having proper back end error mechanism for end users, but when we >> are designing it has to adhere some proper standard, coz this is community >> project and many contributors may take part on this. If we loosed the >> concepts on starting point that will deviate whole concept of having >> standardization. >> >> WDYT? >> >> *Dakshika Jayathilaka* >> Software Engineer >> WSO2, Inc. >> lean.enterprise.middleware >> 0771100911 >> >> >> On Mon, Jul 7, 2014 at 2:46 PM, Udara Liyanage <ud...@wso2.com> wrote: >> >>> Hi Dakshita, >>> >>> I am really worried about the structure of the response rather than what >>> values it should output. What I wanted to tell is every API call should >>> send response adhering to that format regardless of the fields it has. >>> >>> For a REST client for Stratos, http status code is important in very few >>> occasions, rather client is more interested in the back end error message. >>> >>> >>> On Mon, Jul 7, 2014 at 5:37 PM, Dakshika Jayathilaka <daksh...@wso2.com> >>> wrote: >>> >>>> There are some instances we need to have HTTP status + attribute >>>> details on body. >>>> >>>> ex: >>>> >>>> *409 conflict: *can return in different scenarios, so we need to >>>> implement some differentiation mechanism >>>> >>>> if you check HTTP/1.1[1] spec its clearly mention this: >>>> >>>> The response body SHOULD include enough information for the user to >>>> recognize the source of the conflict. >>>> >>>> [1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html >>>> >>>> >>>> >>>> *Dakshika Jayathilaka* >>>> Software Engineer >>>> WSO2, Inc. >>>> lean.enterprise.middleware >>>> 0771100911 >>>> >>>> >>>> On Mon, Jul 7, 2014 at 10:54 AM, Imesh Gunaratne <im...@apache.org> >>>> wrote: >>>> >>>>> Udara, there are few other important points: >>>>> * Introduce versioning to the API and preserve v1.0 released with >>>>> Stratos 4.0.0 for a certain time period. >>>>> * introduce token based authentication. >>>>> >>>>> May be we could do these with separate tasks. >>>>> >>>>> Thanks >>>>> >>>>> >>>>> On Monday, July 7, 2014, Imesh Gunaratne <im...@apache.org> wrote: >>>>> >>>>>> +1 Definitely, we need to do this. Jsend spec looks good, but I >>>>>> wonder whether we need a status attribute since HTTP status code already >>>>>> does that. >>>>>> >>>>>> One other important fact is that we need to document the API >>>>>> definition very well with samples. >>>>>> >>>>>> Thanks >>>>>> >>>>>> On Monday, July 7, 2014, Udara Liyanage <ud...@wso2.com> wrote: >>>>>> >>>>>>> HI, >>>>>>> >>>>>>> Currently different REST API methods sends response in different >>>>>>> formats. Some API methods have Response as the return type and some have >>>>>>> Response. IMO it is better if all the API methods fallow the same >>>>>>> format. >>>>>>> For instance [1] discuss a simple response format. >>>>>>> >>>>>>> [1] http://labs.omniti.com/labs/jsend >>>>>>> >>>>>>> -- >>>>>>> >>>>>>> Udara Liyanage >>>>>>> Software Engineer >>>>>>> WSO2, Inc.: http://wso2.com >>>>>>> lean. enterprise. middleware >>>>>>> >>>>>>> web: http://udaraliyanage.wordpress.com >>>>>>> phone: +94 71 443 6897 >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Imesh Gunaratne >>>>>> >>>>>> Technical Lead, WSO2 >>>>>> Committer & PPMC Member, Apache Stratos >>>>>> >>>>>> >>>>> >>>>> -- >>>>> Imesh Gunaratne >>>>> >>>>> Technical Lead, WSO2 >>>>> Committer & PPMC Member, Apache Stratos >>>>> >>>>> >>>> >>> >>> >>> -- >>> >>> Udara Liyanage >>> Software Engineer >>> WSO2, Inc.: http://wso2.com >>> lean. enterprise. middleware >>> >>> web: http://udaraliyanage.wordpress.com >>> phone: >>> +94 71 443 6897 >>> >>> -- >>> Thanks and Regards, >>> >>> Isuru H. >>> +94 716 358 048* <http://wso2.com/>* >>> >>> >>> * <http://wso2.com/>* >>> >>> >>> -- Udara Liyanage Software Engineer WSO2, Inc.: http://wso2.com lean. enterprise. middleware web: http://udaraliyanage.wordpress.com phone: +94 71 443 6897