Skip to content
This repository was archived by the owner on May 7, 2021. It is now read-only.

API: Procedures

Joshua Kalpin edited this page Mar 5, 2016 · 8 revisions

Procedure

A Procedure is the root document that the protocol builder creates. In a sense, it is the protocol itself. It contains information about the document and is made up of a series of pages.

Path

/api/procedures

Permissions

Only the user that owns the procedure may access or modify it.

Fields

Field Name Type Required? Default Value Read Only? Description
Title String Yes No The name for this procedure
Author String No owner.first_name + ' ' + owner.last_name No The creator of this procedure
Owner User Yes No The user that owns this procedure. This is inferred from the authorization token.
UUID UUID Yes Yes A unique identifier for this procedure. This value is auto-generated
Created Datetime Yes Yes The time that this object was created. This value is auto-generated
Last Modified Datetime Yes Yes The last time that this object was updated. This value is auto-generated.
Pages List<Page> No [] No The pages that are contained within this procedure. This is auto-updated when a page is created that belongs to this procedure.

Creating

To create a procedure POST to /api/procedures.

Status Codes

201: Object Created Successfully

400: Bad value in the request body. Check the response for errors

401: Invalid Request Token

Example Request

POST /api/procedures
Host: sanaprotocolbuilder.me
Authorization: Token <token>
{
  "title":"Untitled Procedure"
}

Example Response

{
  "id":7,
  "title":"Untitled Procedure",
  "author":"John Smith",
  "uuid":"bed18172-1723-4072-85b8-798616097667",
  "owner":6,
  "pages":[],
  "last_modified":"2016-03-05T18:44:51.230744Z",
  "created":"2016-03-05T18:44:51.230806Z"
}

Updating

To update a procedure UPDATE to /api/procedures/{id}, where id is the id of the procedure. You only need to send the fields that are to be updated in the body of the request. Sending up other fields that are not modified, will not do anything.

Status Codes

200: Object Updated Successfully

400: Bad value in the request body. Check the response for errors

401: Invalid Request Token

404: Procedure does not exist

Example Request

UPDATE /api/procedures/7
Host: sanaprotocolbuilder.me
Authorization: Token <token>
{
  "title":"My Procedure"
}

Example Response

{
  "id":7,
  "title":"My Procedure",
  "author":"John Smith",
  "uuid":"bed18172-1723-4072-85b8-798616097667",
  "owner":6,
  "pages":[],
  "last_modified":"2016-03-05T18:48:37.515686Z",
  "created":"2016-03-05T18:44:51.230806Z"
}

Deleting

To delete a procedure send a DELETE request to /api/procedures/{id} where the id is the id of the procedure to be deleted.

Status Codes

203: Object successfully deleted

401: Invalid Request Token

404: Procedure does not exist

Example Request

DELETE /api/procedures/7
Host: sanaprotocolbuilder.me
Authorization: Token <token>

Example Response

No response body

Getting All

To get all procedures that you own GET to /api/procedures.

Status Codes

200: Success

401: Invalid Request Token

Example Request

GET /api/procedures
Host: sanaprotocolbuilder.me
Authorization: Token <token>

Example Response

[
  {
    "id":5,
    "title":"Untitled Procedure",
    "author":"No author specified",
    "uuid":"6841a13e-275d-4b17-a6f3-b0c2e8512d49",
    "owner":6,
    "pages":[
      {
        "id":12,
        "display_index":0,
        "last_modified":"2016-03-05T00:42:38.880071Z",
        "created":"2016-03-05T00:41:54.141476Z",
        "procedure":5
      },
      {
        "id":13,
        "display_index":1,
        "last_modified":"2016-03-05T00:42:53.808247Z",
        "created":"2016-03-05T00:42:53.808288Z",
        "procedure":5
      },
      {
        "id":14,
        "display_index":2,
        "last_modified":"2016-03-05T00:42:54.518141Z",
        "created":"2016-03-05T00:42:54.518178Z",
        "procedure":5
      }
    ],
    "last_modified":"2016-03-05T00:43:02.622411Z",
    "created":"2016-03-04T18:18:21.549666Z"
  },
  {
    "id":6,
    "title":"Untitled Procedure",
    "author":"a",
    "uuid":"3d66f932-9c43-4cb1-8c2d-3fb6eb23aa56",
    "owner":6,
    "pages":[

    ],
    "last_modified":"2016-03-05T18:44:20.723130Z",
    "created":"2016-03-05T18:37:58.466792Z"
  },
  {
    "id":7,
    "title":"My Procedure",
    "author":"John Smith",
    "uuid":"bed18172-1723-4072-85b8-798616097667",
    "owner":6,
    "pages":[

    ],
    "last_modified":"2016-03-05T18:48:37.515686Z",
    "created":"2016-03-05T18:44:51.230806Z"
  }
]

Get one

To get all procedures that you own GET to /api/procedures/{id}, Where id is the procedure's id.

Status Codes

200: Success

401: Invalid Request Token

404: Procedure does not exist

Example Request

GET /api/procedures/7
Host: sanaprotocolbuilder.me
Authorization: Token <token>

Example Response

{
    "id":7,
    "title":"My Procedure",
    "author":"John Smith",
    "uuid":"bed18172-1723-4072-85b8-798616097667",
    "owner":6,
    "pages":[],
    "last_modified":"2016-03-05T18:48:37.515686Z",
    "created":"2016-03-05T18:44:51.230806Z"
  }

Clone this wiki locally