Memberships¶
Table of Contents
Resource description¶
All endpoints adhere to the JSON API specification.
Attributes¶
Name |
Description |
Required? |
Type |
Notes |
---|---|---|---|---|
isSubscriber |
Subscription status |
Yes |
Boolean |
Indicates whether the user uses one of the utility’s Safety Manual licenses. |
isSubscriberDatetime |
Datetime of when the user’s subscription status last changed |
No |
Datetime |
Relationships¶
Name |
Description |
Required? |
Type |
Notes |
---|---|---|---|---|
utility |
Utility this Membership belongs to |
True |
Foreign key |
|
user |
User this Membership belongs to |
True |
Foreign key |
List Memberships¶
A user must have at least “spectator” authorization to list Memberships for their Utility.
- GET https://reliability.api.publicpower.org/v1/memberships/¶
Example request:
GET /v1/memberships/ HTTP/1.1 Host: reliability.api.publicpower.org Content-Type: application/vnd.api+json Authorization: Bearer myaccesstoken
- Request Headers
Authorization – Required OAuth token to authenticate. See Authentication docs.
Content-Type –
Content-Type: application/vnd.api+json
- JSON API IANA media type
- Query Parameters
page (int) – Page Number of results to request.
page_size (int) – Number of results to return per-page.
filter[utility] (int) – Return results for comma-separated Utility IDs
Example response:
HTTP/1.1 200 OK Content-Type: application/vnd.api+json { "links": { "first": "https://reliability.api.publicpower.dev/v1/memberships/?page=1", "last": "https://reliability.api.publicpower.dev/v1/memberships/?page=1", "next": "https://reliability.api.publicpower.dev/v1/memberships/?page=1", "prev": null }, "data": [ { "type": "Membership", "id": "3007", "attributes": { "isSubscriber": false }, "relationships": { "user": { "data": { "type": "User", "id": "2279" } }, "utility": { "data": { "type": "Utility", "id": "177" } } } }, { "type": "Membership", "id": "3006", "attributes": { "isSubscriber": false }, "relationships": { "user": { "data": { "type": "User", "id": "2278" } }, "utility": { "data": { "type": "Utility", "id": "177" } } } } ], "meta": { "pagination": { "page": 1, "pages": 1, "count": 2 } } }
- 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 Membership¶
A user must have “admin” authorization to create Memberships for existing Users
- POST https://reliability.api.publicpower.org/v1/memberships/¶
Example request:
POST /v1/memberships/ HTTP/1.1 Host: reliability.api.publicpower.org Content-Type: application/vnd.api+json Authorization: Bearer myaccesstoken { "data": { "type": "Membership", "attributes": { "isSubscriber": false }, "relationships": { "utility": { "data": { "type": "Utility", "id": 177 } }, "user": { "data": { "type": "User", "id": 2212 } } } } }
- Request Headers
Authorization – Required OAuth token to authenticate. See Authentication docs.
Content-Type –
Content-Type: application/vnd.api+json
- JSON API IANA media type
Example response:
HTTP/1.1 201 Created Vary: Accept Content-Type: application/vnd.api+json { "data": { "type": "Membership", "id": "3013", "attributes": { "isSubscriber": false }, "relationships": { "user": { "data": { "type": "User", "id": "2212" } }, "utility": { "data": { "type": "Utility", "id": "177" } } } } }
- Status Codes
201 Created – Substation created
401 Unauthorized – You did not provide a valid
Authorization: Bearer
token.403 Forbidden – Your user role is not authorized to access this endpoint.
Retrieve a Membership¶
A user must have at least “spectator” authorization to retrieve Memberships for their Utility.
- GET https://reliability.api.publicpower.org/v1/memberships/(int: membership_id)/¶
Example request:
GET /v1/memberships/3013/ HTTP/1.1 Host: reliability.api.publicpower.org Content-Type: application/vnd.api+json Authorization: Bearer myaccesstoken
- Request Headers
Authorization – Required OAuth token to authenticate. See Authentication docs.
Content-Type –
Content-Type: application/vnd.api+json
- JSON API IANA media type
Example response:
HTTP/1.1 200 OK Content-Type: application/vnd.api+json { "data": { "type": "Membership", "id": "3013", "attributes": { "isSubscriber": false }, "relationships": { "user": { "data": { "type": "User", "id": "2212" } }, "utility": { "data": { "type": "Utility", "id": "177" } } } } }
- 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 Membership¶
A user must have “leader” authorization to update Memberships for their Utility.
- PATCH https://reliability.api.publicpower.org/v1/memberships/(int: membership_id)/¶
Example request:
PATCH /v1/memberships/3013/ HTTP/1.1 Host: reliability.api.publicpower.org Content-Type: application/vnd.api+json Authorization: Bearer myaccesstoken { "data": { "type": "Membership", "id": "3013", "attributes": { "isSubscriber": true } } }
- Request Headers
Authorization – Required OAuth token to authenticate. See Authentication docs.
Content-Type –
Content-Type: application/vnd.api+json
- JSON API IANA media type
Example response:
HTTP/1.1 200 OK Content-Type: application/vnd.api+json { "data": { "type": "Membership", "id": "3013", "attributes": { "isSubscriber": true }, "relationships": { "user": { "data": { "type": "User", "id": "2212" } }, "utility": { "data": { "type": "Utility", "id": "177" } } } } }
- Status Codes
200 OK – Membership 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 Membership¶
A user must have “leader” authorization to delete Memberships for their Utility.
- DELETE https://reliability.api.publicpower.org/v1/memberships/(int: membership_id)/¶
Example request:
DELETE /v1/memberships/3013/ HTTP/1.1 Host: reliability.api.publicpower.org Content-Type: application/vnd.api+json Authorization: Bearer myaccesstoken
- Request Headers
Authorization – Required OAuth token to authenticate. See Authentication docs.
Content-Type –
Content-Type: application/vnd.api+json
- JSON API IANA media type
Example response:
HTTP/1.1 204 No Content Content-Type: application/vnd.api+json
- Status Codes
204 No Content – Membership deleted
401 Unauthorized – You did not provide a valid
Authorization: Bearer
token.403 Forbidden – Your user role is not authorized to access this endpoint.