Search Results

Search found 4 results on 1 pages for 'dafmetal'.

Page 1/1 | 1 

  • Should I allow sending complete structures when using PUT for updates in a REST API or not?

    - by dafmetal
    I am designing a REST API and I wonder what the recommended way to handle updates to resources would be. More specifically, I would allow updates through a PUT on the resource, but what should I allow in the body of the PUT request? Always the complete structure of the resource? Always the subpart (that changed) of the structure of the resource? A combination of both? For example, take the resource http://example.org/api/v1/dogs/packs/p1. A GET on this resource would give the following: Request: GET http://example.org/api/v1/dogs/packs/p1 Accept: application/xml Response: <pack> <owner>David</owner> <dogs> <dog> <name>Woofer</name> <breed>Basset Hound</breed> </dog> <dog> <name>Mr. Bones</name> <breed>Basset Hound</breed> </dog> </dogs> </pack> Suppose I want to add a dog (Sniffers the Basset Hound) to the pack, would I support either: Request: PUT http://example.org/api/v1/dogs/packs/p1 <dog> <name>Sniffers</name> <breed>Basset Hound</breed> </dog> Response: HTTP/1.1 200 OK or Request: PUT http://example.org/api/v1/dogs/packs/p1 <pack> <owner>David</owner> <dogs> <dog> <name>Woofer</name> <breed>Basset Hound</breed> </dog> <dog> <name>Mr. Bones</name> <breed>Basset Hound</breed> </dog> <dog> <name>Sniffers</name> <breed>Basset Hound</breed> </dog> </dogs> </pack> Response: HTTP/1.1 200 OK or both? If supporting updates through subsections of the structure is recommended, how would I handle deletes (such as when a dog dies)? Through query parameters?

    Read the article

  • Best practices on using URIs as parameter value in REST calls.

    - by dafmetal
    I am designing a REST API where some resources can be filtered through query parameters. In some cases, these filter values would be resources from the same REST API. This makes for longish and pretty unreadable URIs. While this is not too much of a problem in itself because the URIs are meant to be created and manipulated programmatically, it makes for some painful debugging. I was thinking of allowing shortcuts to URIs used as filter values and I wonder if this is allowed according to the REST architecture and if there are any best practices. For example: I have a resource that gets me Java classes. Then the following request would give me all Java classes: GET http://example.org/api/v1/class Suppose I want all subclasses of the Collection Java class, then I would use the following request: GET http://example.org/api/v1/class?has-supertype=http://example.org/api/v1/class/collection That request would return me Vector, ArrayList and all other subclasses of the Collection Java class. That URI is quite long though. I could already shorten it by allowing hs as an alias for has-supertype. This would give me: GET http://example.org/api/v1/class?hs=http://example.org/api/v1/class/collection Another way to allow shorter URIs would be to allow aliases for URI prefixes. For example, I could define class as an alias for the URI prefix http://example.org/api/v1/class/. Which would give me the following possibility: GET http://example.org/api/v1/class?hs=class:collection Another possibility would be to remove the class alias entirely and always prefix the parameter value with http://example.org/api/v1/class/ as this is the only thing I would support. This would turn the request for all subtypes of Collection into: GET http://example.org/api/v1/class?hs=collection Do these "simplifications" of the original request URI still conform to the principles of a REST architecture? Or did I just go off the deep end?

    Read the article

  • Prepending to a multi-gigabyte file.

    - by dafmetal
    What would be the most performant way to prepend a single character to a multi-gigabyte file (in my practical case, a 40GB file). There is no limitation on the implementation to do this. Meaning it can be through a tool, a shell script, a program in any programming language, ...

    Read the article

  • How to expose a function that takes two input files as a REST resource?

    - by dafmetal
    I need to expose a function, let's say compute that takes two input files: a plan file and a system file. The compute function uses to system file to see whether the plan in the plan file can be executed or not. It produces an output file containing the result of this check including recommendations for the plan. I need to expose this functionality in a REST architecture and have no influence on the compute function itself (it is being developed by another organization). I can control the interface through which it is accessed. What would be a recommended way to expose this functionality in a REST architecture?

    Read the article

1