Causes

Resource description

All endpoints adhere to the JSON API specification.

Attributes

Name

Description

Required?

Type

Notes

name

Display name for the Cause

True

string

isScheduled

Indicates whether this is a scheduled or unscheduled cause

False

bool

Calculated read-only

Relationships

Name

Description

Required?

Type

parent

Self-referencing key used to create a Cause hierarchy

True

Foreign key

List Causes

A user must have at least “member” authorization to read Causes.

GET https://reliability.api.publicpower.org/v1/causes/

Example request:

GET /v1/causes/ HTTP/1.1
Host: reliability.api.publicpower.org
Content-Type: application/vnd.api+json
Authorization: Bearer myaccesstoken
Request Headers
Query Parameters
  • page (int) – Page Number of results to request.

  • page_size (int) – Number of results to return per-page.

Example response:

HTTP/1.1 200 OK
Content-Type: application/vnd.api+json

{
  "links": {
    "first": "https://reliability.api.publicpower.dev/v1/causes/?page=1&page_size=2",
    "last": "https://reliability.api.publicpower.dev/v1/causes/?page=29&page_size=2",
    "next": "https://reliability.api.publicpower.dev/v1/causes/?page=2&page_size=2",
    "prev": null
  },
  "data": [
  {
    "type": "Cause",
    "id": "1",
    "attributes": {
      "name": "Scheduled",
      "isScheduled": true
    },
    "relationships": {
      "parent": {
        "data": null
      }
    }
  },
  {
    "type": "Cause",
    "id": "2",
    "attributes": {
      "name": "Non-Utility Construction",
      "isScheduled": true
    },
    "relationships": {
      "parent": {
        "data": {
          "type": "Cause",
          "id": "1"
        }
      }
    }
  }
  ],
  "meta": {
    "pagination": {
      "page": 1,
      "pages": 29,
      "count": 58
    }
  }
}
Status Codes
  • 200 OK – Successful response

  • 401 Unauthorized – You did not provide a valid Authorization: Bearer token.

  • 403 Forbidden – Your user role is not authorized to access this endpoint.

Create a Cause

A user must have “admin” authorization to create Causes.

POST https://reliability.api.publicpower.org/v1/causes/

Example request:

POST /v1/causes/ HTTP/1.1
Host: reliability.api.publicpower.org
Content-Type: application/vnd.api+json
Authorization: Bearer myaccesstoken

{
  "data": {
    "type": "Cause",
    "attributes": {
      "name": "New Cause"
    },
    "relationships": {
      "parent": {
        "data": {
          "type": "Cause",
          "id": "1"
        }
      }
    }
  }
}
Request Headers

Example response:

HTTP/1.1 201 Created
Vary: Accept
Content-Type: application/vnd.api+json

{
  "data": {
    "type": "Cause",
    "id": "66",
    "attributes": {
      "name": "New Cause",
      "isScheduled": true
    },
    "relationships": {
      "parent": {
        "data": {
          "type": "Cause",
          "id": "1"
        }
      }
    }
  }
}
Status Codes

Retrieve a Cause

A user must at least have “member” authorization to retrieve Causes.

GET https://reliability.api.publicpower.org/v1/causes/(int: cause_id)/

Example request:

GET /v1/causes/66/ HTTP/1.1
Host: reliability.api.publicpower.org
Content-Type: application/vnd.api+json
Authorization: Bearer myaccesstoken
Request Headers

Example response:

HTTP/1.1 200 OK
Content-Type: application/vnd.api+json

{
  "data": {
    "type": "Cause",
    "id": "66",
    "attributes": {
      "name": "New Cause",
      "isScheduled": true
    },
    "relationships": {
      "parent": {
        "data": {
          "type": "Cause",
          "id": "1"
        }
      }
    }
  }
}
Status Codes
  • 200 OK – Successful response

  • 401 Unauthorized – You did not provide a valid Authorization: Bearer token.

  • 403 Forbidden – Your user role is not authorized to access this endpoint.

Update a Cause

A user must have “admin” authorization to update Causes.

PATCH https://reliability.api.publicpower.org/v1/causes/(int: cause_id)/

Example request:

PATCH /v1/causes/66/ HTTP/1.1
Host: reliability.api.publicpower.org
Content-Type: application/vnd.api+json
Authorization: Bearer myaccesstoken

{
  "data": {
    "id": 66,
    "type": "Cause",
    "attributes": {
      "name": "Modified Cause"
    }
  }
}
Request Headers

Example response:

HTTP/1.1 200 OK
Content-Type: application/vnd.api+json

{
  "data": {
    "type": "Cause",
    "id": "66",
    "attributes": {
      "name": "Modified Cause",
      "isScheduled": true
    },
    "relationships": {
      "parent": {
        "data": {
          "type": "Cause",
          "id": "1"
        }
      }
    }
  }
}
Status Codes
  • 200 OK – Cause updated

  • 401 Unauthorized – You did not provide a valid Authorization: Bearer token.

  • 403 Forbidden – Your user role is not authorized to access this endpoint.

Delete a Cause

A user must have “admin” authorization to delete Causes.

DELETE https://reliability.api.publicpower.org/v1/causes/(int: cause_id)/

Example request:

DELETE /v1/causes/66/ HTTP/1.1
Host: reliability.api.publicpower.org
Content-Type: application/vnd.api+json
Authorization: Bearer myaccesstoken
Request Headers

Example response:

HTTP/1.1 204 No Content
Content-Type: application/vnd.api+json
Status Codes