Locks API

This endpoint allows for manipulation of mutex locks on resources that should be modified by only one Bridge user at a time (currently only implemented for CourseTemplate objects).

Interfaces

Object Synopses

Lockable

  • id String

    A UUID to uniquely identify this exact lock object

  • lockable_type String

    Entity type of the object being locked (currently only CourseTemplate)

  • lockable_id String

    Database ID of the resource referred to by this lock

  • holder_id String

    Reference to Bridge user_id who created/holds this lock

  • expires_in Integer

    Time (in seconds) until this lock will automatically expire

  • updated_at DateTime

    DateTime at which the object being locked was last updated on the server

Get lock status of a lockable resource

GET /api/author/course_templates/:id/lock
GET /api/author/tasks/:id/lock

Response Codes

  • 200 OK
  • 403 Forbidden
  • 404 Not Found

Parameters

  • id Integer Required

    Query parameter. This is the id of the course template resource you are trying to view the lock status of.

Example Response

{
  "lock": {
    "lockable_id": 10,
    "lockable_type": "CourseTemplate",
    "holder_id": "1",
    "expires_in": 900
  }
}

Create a new lock on a resource

POST /api/author/course_templates/:id/lock
POST /api/author/tasks/:id/lock

Response Codes

  • 200 OK
  • 403 Forbidden
  • 409 Conflict
  • 422 Unprocessable Entity

Parameters

  • id Integer Required

    Query parameter. This is the id of the course template resource you are creating a lock for.

Example Response

{
  "lock": {
    "id": "bf45ef52-b1a7-46a1-b96d-27a9c8dd43ef",
    "lockable_id": 10,
    "lockable_type": "CourseTemplate",
    "holder_id": "1",
    "updated_at": "2016-06-17T12:41:82.000-06:00"
  }
}

Renew a new lock on a resource (resets the expires_at time)

PUT /api/author/course_templates/:id/lock
PUT /api/author/tasks/:id/lock

Note: The UUID (unique ID of the existing lock) must be provided as an HTTP header X-Lock-Id:

Response Codes

  • 204 No Content
  • 403 Forbidden
  • 409 Conflict
  • 422 Unprocessable Entity

Parameters

  • id Integer Required

    Query parameter. This is the id of the course template resource you are renewing the lock for.

Release a lock on a resource

DELETE /api/author/course_templates/:id/lock
DELETE /api/author/tasks/:id/lock

Note: The UUID (unique ID of the existing lock) must be provided as an HTTP header X-Lock-Id:

Response Codes

  • 204 No Content
  • 403 Forbidden
  • 409 Conflict
  • 422 Unprocessable Entity

Parameters

  • id Integer Required

    Query parameter. This is the id of the course template resource you are releasing the lock for.