Web Technologies/2021-2022/Laboratory 10

Representational state transfer (REST) is a software architectural style that describes a uniform interface between physically separate components, often across the Internet in a client-server architecture.[1]

Readings

edit

Exercise

edit

Create a REST API that has the role of an artifact repository. An artifact is defined as any file which can be stored onto a disk (i.e. image, document, source code etc.). The REST API should be able to:

  • Have a directory structure which contains the artifacts:
    • Each artifact could be stored in a directory which indicates its purpose (you can think of it as grouping artifact of a project)
    • It should have a resources that allows the listing of all directories and the artifact currently contained in a directory
  • Resource for fetching, adding and deleting artifact

Examples using Flask can be found here and here.

Example

edit

Here is an example structure of the REST API:

GET /artifacts/

  • returns list of available directories

GET /artifacts/<directory>

  • returns list of all artifacts from directory

POST /artifacts/<directory>/<artifact_id>

  • push artifact in repository

GET /artifact/<directory>/<artifact_id>

  • get artifact by id from directory

DELETE /artifact/<directory>

  • delete entire directory and artifacts

DELTE /artifact/<directory>/<artifact_id>

  • delete artifact

PUT /artifact/<directory>/<artifact_id>

  • replace artifact (deleting the old one)

After you have finished consider how you can add support for more advanced features such as versioning of artifacts.

See Also

edit

References

edit