Change Control Resources¶
Change Control Resources help manage changes to resources.
Users¶
A user represents a person or process that creates, changes, or deletes a resource.
The representation includes:
- attributes
- id (server selected) - Database ID
- username - The user’s email or ID
- created (server selected) - Time that the account was created, in ISO 8601 format.
- agreement - The version of the contribution agreement the user has accepted. “0” for not agreed, “1” for first version, etc.
- permissions - A list of permissions. Permissions include
"change-resource"
(add or change any resource except users or history resources),"delete-resource"
(delete any resource)"import-mdn"
(setup import of an MDN page)
- links
- changesets (many) - Associated changesets, in ID order, changes are ignored.
To get a single user representation:
GET /api/v1/users/1 HTTP/1.1
Host: browsercompat.org
Accept: application/vnd.api+json
A sample response is:
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json
{
"users": {
"id": "1",
"username": "user",
"created": "2015-04-20T18:06:48.567514Z",
"agreement": 0,
"permissions": [
"change-resource",
"delete-resource"
],
"links": {
"changesets": [
"1"
]
}
},
"links": {
"users.changesets": {
"type": "changesets",
"href": "https://browsercompat.org/api/v1/changesets/{users.changesets}"
}
}
}
You can also request the authenticated user’s resource:
GET /api/v1/users/me HTTP/1.1
Host: browsercompat.org
Accept: application/vnd.api+json
Authorization: Bearer xxQLNiTUFjRL5En8nBWzSDc5tLWkV2
The response is a redirect to the user’s resource:
HTTP/1.1 302 FOUND
Content-Type: text/html; charset=utf-8
Location: https://browsercompat.org/api/v1/users/1
If the request is made anonymously, then the response is an error:
HTTP/1.1 401 UNAUTHORIZED
Content-Type: application/vnd.api+json
WWW-Authenticate: Bearer realm="api"
{
"errors": [
{
"detail": "Authentication credentials were not provided.",
"status": "401"
}
]
}
Changesets¶
A changeset collects history resources into a logical unit, allowing for
faster reversions and better history display. The changeset can be
auto-created through a POST
, PUT
, or DELETE
to a resource, or it
can be created independently and specified by adding changeset=<ID>
URI
parameter (i.e., PUT /browsers/15?changeset=73
).
The representation includes:
- attributes
- id (server selected) - Database ID
- created (server selected) - When the changeset was created, in ISO 8601 format.
- modified (server selected) - When the changeset was last modified, in ISO 8601 format.
- target_resource_type (write-once, optional) - The name of the primary resource for this changeset, for example “browsers”, “versions”, etc.
- target_resource_id (write-once, optional) - The ID of the primary resource for this changeset.
- closed - True if the changeset is closed to new changes. Auto-created changesets are auto-closed, and cache invalidation is delayed until manually created changesets are closed.
- links
- user (one) - The user who initiated this changeset, can not be changed.
- historical_browsers (many) - Associated historical_browsers, in ID order, changes are ignored.
- historical_features (many) - Associated historical_features, in ID order, changes are ignored.
- historical_maturities (many) - Associated historical_maturities, in ID order, changes are ignored.
- historical_sections (many) - Associated historical_sections, in ID order, changes are ignored.
- historical_specificationss (many) - Associated historical_specificationss, in ID order, changes are ignored.
- historical_supports (many) - Associated historical_supports, in ID order, changes are ignored.
- historical_versions (many) - Associated historical_versions, in ID order, changes are ignored.
To get a single changeset representation:
GET /api/v1/changesets/2 HTTP/1.1
Host: browsercompat.org
Accept: application/vnd.api+json
A sample response is:
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json
{
"changesets": {
"id": "2",
"created": "2015-04-20T18:22:47.046692Z",
"modified": "2015-04-20T18:22:47.056433Z",
"closed": true,
"target_resource_type": null,
"target_resource_id": null,
"links": {
"user": "1",
"historical_browsers": [
"16"
],
"historical_features": [],
"historical_maturities": [],
"historical_references": [],
"historical_sections": [],
"historical_specifications": [],
"historical_supports": [],
"historical_versions": []
}
},
"links": {
"changesets.user": {
"type": "users",
"href": "https://browsercompat.org/api/v1/users/{changesets.user}"
},
"changesets.historical_browsers": {
"type": "historical_browsers",
"href": "https://browsercompat.org/api/v1/historical_browsers/{changesets.historical_browsers}"
},
"changesets.historical_features": {
"type": "historical_features",
"href": "https://browsercompat.org/api/v1/historical_features/{changesets.historical_features}"
},
"changesets.historical_maturities": {
"type": "historical_maturities",
"href": "https://browsercompat.org/api/v1/historical_maturities/{changesets.historical_maturities}"
},
"changesets.historical_references": {
"type": "historical_references",
"href": "https://browsercompat.org/api/v1/historical_references/{changesets.historical_references}"
},
"changesets.historical_sections": {
"type": "historical_sections",
"href": "https://browsercompat.org/api/v1/historical_sections/{changesets.historical_sections}"
},
"changesets.historical_specifications": {
"type": "historical_specifications",
"href": "https://browsercompat.org/api/v1/historical_specifications/{changesets.historical_specifications}"
},
"changesets.historical_supports": {
"type": "historical_supports",
"href": "https://browsercompat.org/api/v1/historical_supports/{changesets.historical_supports}"
},
"changesets.historical_versions": {
"type": "historical_versions",
"href": "https://browsercompat.org/api/v1/historical_versions/{changesets.historical_versions}"
}
}
}