|
| 1 | +This page outlines the general usage patterns and organization of the COMS API. This article is intended for a technical audience, and for people who are planning on using the API endpoints. |
| 2 | + |
| 3 | +**The COMS API is documented using the [Open API Specification](https://coms.api.gov.bc.ca/api/v1/docs)** |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Bucket](#bucket) |
| 8 | +- [Object](#object) |
| 9 | + - [Metadata](#metadata) |
| 10 | + - [Tag](#tag) |
| 11 | + - [Versions](#versions) |
| 12 | +- [Permission](#permission) |
| 13 | +- [Sync](#sync) |
| 14 | +- [User](#user) |
| 15 | + |
| 16 | +## Bucket |
| 17 | + |
| 18 | +Bucket operations offer the usual CRUD operations for bucket resource management. For example: |
| 19 | + |
| 20 | +- `CREATE /bucket` and `PATCH /bucket/{bucketId}` will pre-emptively check to see if the proposed credential changes represent a network-accessible bucket. These endpoints will yield an error if it is unable to validate the bucket. |
| 21 | + |
| 22 | +## Object |
| 23 | + |
| 24 | +Object endpoints directly influence and manipulate S3 objects and information inherent to them. These endpoints serve as the main core of COMS, focusing on CRUD operations for the objects themselves. |
| 25 | + |
| 26 | +- Uploading (`POST /object`) or updating an object ( `POST /object/{objectId}`) accepts a file in a multipart/form-data body. You can include metadata (via headers) and tags (using query params) in this request. |
| 27 | +- `GET /object/{objectId}` is the main endpoint for users to directly access and download a single object. |
| 28 | +- `HEAD /object/{objectId}` should be used for situations where you need to get information about the object, but do not want the binary stream of the object itself. |
| 29 | +- `DELETE /object/{objectId}` deletes either the object or a specific version of the object. COMS follows the S3 standard for [deleting versioned objects](https://docs.aws.amazon.com/AmazonS3/latest/userguide/DeletingObjectVersions.html) |
| 30 | + - If versioning is enabled, calling `/object/{objectId}` is a soft-delete, adding a 'delete-marker' version. To restore this object, remove the delete-marker with `/object/{objectId}?versionId={VersionId of delete-marker}`. To hard-delete a versioned object, you must delete the last version `/object/{objectId}?versionId={last version}`. |
| 31 | + - Calling in the Delete endpoint on a bucket without versioning is a hard-delete. |
| 32 | +- The `GET /object` search and `PATCH /object/{objectId}/public` public toggle require a backing database in order to function. |
| 33 | + |
| 34 | +### Metadata |
| 35 | + |
| 36 | +Metadata operation endpoints directly focus on the manipulation of metadata of S3 Objects. Each endpoint will create a copy of the object with the modified metadata attached. |
| 37 | + |
| 38 | +More details found here: [Metadata and Tags](Metadata-Tag) |
| 39 | + |
| 40 | +### Tag |
| 41 | + |
| 42 | +Tag operation endpoints directly focus on the manipulation of tags of S3 Objects. Unlike Metadata, Tags can be modified without the need to create new versions of the object. |
| 43 | + |
| 44 | +More details found here: [Metadata and Tags](Metadata-Tag) |
| 45 | + |
| 46 | +### Versions |
| 47 | + |
| 48 | +Version specific operations focus on listing and discovering versioning information known by COMS. While the majority of version-specific operations are available as query parameters in the Objects endpoints, the `GET /object/{objectId}/version` endpoint focuses on letting users discover and list what versions are available to work with. |
| 49 | + |
| 50 | +## Permission |
| 51 | + |
| 52 | +Permission operation endpoints directly focus on associating users to objects with specific permissions. All of these endpoints require a database to function. Existing permissions can be searched for using `GET /permission/object` and `GET /permission/bucket`, and standard create, read and delete operations for permissions exist to allow users to modify access control for specific objects they have management permissions over. |
| 53 | + |
| 54 | +More details found here: [Permissions](Permissions) |
| 55 | + |
| 56 | +## Sync |
| 57 | + |
| 58 | +*Available in COMS v0.7+* |
| 59 | + |
| 60 | +Sync endpoints allow synchronizing COMS' internal state with that of the actual S3 bucket/object. This can be useful for setting up a S3 bucket with preexisting files for use with COMS without having to re-upload everything through the COMS API, or for synchronizing changes made through an external S3 client (e.g. S3 Browser, Cyberduck etc) to an object already managed by COMS. |
| 61 | + |
| 62 | +API calls to the sync endpoints do not immediately add all detected changes to COMS' internal database; instead, they are added to a queue where they are eventually processed. The endpoint `GET /sync/status` returns the number of items that are currently sitting in this queue. |
| 63 | + |
| 64 | +At the time of writing, synchronization is not done automatically, so the sync endpoints must be used in order for COMS to know of any changes to the bucket/object. |
| 65 | + |
| 66 | +## User |
| 67 | + |
| 68 | +User operation endpoints focus on exposing known tracked users and identity providers. These endpoints serve as a reference point for finding the right user and identity to manipulate in the Permission endpoints. As COMS is relatively agnostic to how a user logs in (it only cares that you exist), the onus of determining which identity provider a user uses falls onto the line of business to handle, should that be something that needs monitoring. |
0 commit comments