-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add policy author spec #3
Open
janedotx
wants to merge
6
commits into
dev
Choose a base branch
from
add_policy_author_spec
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e7c5faf
Moving proposed policy author changes over from EA fork to here.
janedotx cb6c96f
Minor updates to Policy and Policy Author.
janedotx 63cfca1
Adding a missing endpoint to Policy Author spec.
janedotx de084d1
Adding minor note for expected response body.
janedotx ff70d65
Removing service_areas reference and changing id to policy_id in spec.
janedotx b2440a9
updating http verb for publish endpoint
janedotx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# Policy-Author API (draft) | ||
|
||
## Background | ||
|
||
The Policy API specifies an endpoint and a JSON schema for communicating mobility policy to providers. This document describes a companion API to the provider-facing Policy endpoints for creating and editing Policy and Geography objects. | ||
|
||
[Policy PR](https://github.com/CityOfLosAngeles/mobility-data-specification/pull/322) | ||
|
||
## Endpoints | ||
|
||
The agency-facing Policy Author API consists of the following endpoints. The endpoints to list Policy and Geography objects are defined in the Policy API. The only addition is that when calling the GET /policies endpoint, append ?unpublished to get the unpublished ones, separate from the published ones. Adding ?unpublished will have no effect if your access token has a provider_id. | ||
|
||
### Policy Endpoints | ||
|
||
Responses must set the `Content-Type` header, as specified in the [Provider versioning](../provider/README.md#versioning) section. They must also specify the API version in the JSON-formatted response body, under the `version` key. | ||
|
||
#### Schema | ||
|
||
See Policy API. | ||
|
||
Metadata is free-form JSON format. | ||
|
||
### GET /policies | ||
|
||
Get a list of policies. | ||
|
||
A note: the `get_published` and `get_unpublished` parameters only make sense in the Policy Author version of this endpoint, because the Policy Author API is intended for use by Agencies and not Providers. Providers should never be able to see unpublished Policies, as those are not yet meant for public consumption. | ||
|
||
Parameters: | ||
| Name | Type | R/O | Description | | ||
| ------------ | --------- | --- | ---------------------------------------------- | | ||
| `policy_id` | UUID | Optional | If provided, returns one policy object with the matching UUID; default is to return all policy objects. | | ||
| `get_published` | string | O | If set to the string 'true', returns metadata of published policies. | | ||
| `get_unpublished` | string | O | If set to the string 'true', returns metadata of unpublished policies. | | ||
|
||
Response codes: | ||
- 200 - success | ||
- 400 - cannot return results because both params were set to true | ||
- 401 - unauthorized | ||
- 404 - not found | ||
- 500 - server error | ||
|
||
|
||
### POST /policies | ||
|
||
Create a new unpublished (mutable) Policy | ||
|
||
Payload: a new Policy object, without a `policy_id` | ||
|
||
Response codes: | ||
|
||
- 201 - Created. Returns: the Policy object on success, including a `policy_id` and a `version` indicating the current API version. | ||
- 400 - Policy does not conform to schema | ||
- 401 - Unauthorized (if any auth issue) | ||
- 500 - Server error (hopefully doesn’t happen) | ||
|
||
### PUT /policies/{policy_id} | ||
|
||
Update an existing Policy. Must be unpublished. | ||
|
||
Payload: a new Policy object | ||
|
||
Response codes: | ||
|
||
- 200 - success, returns Policy object | ||
- 400 - Policy does not conform to schema | ||
- 401 - unauthorized | ||
- 404 - not found | ||
- 409 - conflict (if immutable) | ||
- 500 - server error | ||
|
||
### PUT /policies/{policy_id}/publish | ||
|
||
Publish (make immutable) a Policy. Must be unpublished. | ||
|
||
Response codes: | ||
|
||
- 200 - success | ||
- 401 - unauthorized | ||
- 404 - not found | ||
- 409 - conflict (if already published) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should add |
||
- 500 - server error | ||
|
||
### GET /policies/meta | ||
|
||
Get a list of policy metadata. | ||
|
||
Parameters: | ||
| Name | Type | R/O | Description | | ||
| ------------ | --------- | --- | ---------------------------------------------- | | ||
| `get_published` | string | O | If set to the string 'true', returns metadata of published policies. | | ||
| `get_unpublished` | string | O | If set to the string 'true', returns metadata of unpublished policies. | | ||
|
||
Response codes: | ||
- 200 - success | ||
- 400 - cannot return results because both params were set to true | ||
- 401 - unauthorized | ||
- 404 - not found | ||
- 500 - server error | ||
|
||
|
||
### GET /policies/{policy_id}/meta | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should also have a 400 bad params error |
||
|
||
Get metadata for a specific policy. | ||
|
||
Response codes: | ||
- 200 - success | ||
- 401 - unauthorized | ||
- 404 - not found | ||
- 500 - server error | ||
|
||
|
||
### PUT /policies/{policy_id}/meta | ||
Edit metadata for a specific policy. Takes a PolicyMetadata object in the request body. | ||
|
||
Response codes: | ||
- 200 - success | ||
- 401 - unauthorized | ||
- 404 - not found | ||
- 500 - server error | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also send a 409 upon a conflict
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which I suppose doesn't make sense considering we auto-fill a policy_id, I'll remove that error handling