Skip to content
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

Use default phabricator api key to query public revisions #6

Merged
merged 1 commit into from
Jun 7, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ services:
- PORT=80
- VERSION_PATH=/version.json
- PHABRICATOR_URL=https://mozphab.dev.mozaws.net
- PHABRICATOR_UNPRIVILEGED_API_KEY=api-123456789
py3-linter:
build:
context: ./
2 changes: 1 addition & 1 deletion landoapi/api/revisions.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
from landoapi.phabricator_client import PhabricatorClient


def get(api_key, revision_id):
def get(revision_id, api_key=None):
""" API endpoint at /revisions/{id} to get revision data. """
phab = PhabricatorClient(api_key)
revision = phab.get_revision(id=revision_id)
5 changes: 4 additions & 1 deletion landoapi/phabricator_client.py
Original file line number Diff line number Diff line change
@@ -18,7 +18,10 @@ class PhabricatorClient:

def __init__(self, api_key):
self.api_url = os.getenv('PHABRICATOR_URL') + '/api'
self.api_key = api_key
if api_key:
self.api_key = api_key
else:
self.api_key = os.getenv('PHABRICATOR_UNPRIVILEGED_API_KEY')

def get_revision(self, id=None, phid=None):
""" Gets a revision as defined by the Phabricator API.
6 changes: 4 additions & 2 deletions landoapi/spec/swagger.yml
Original file line number Diff line number Diff line change
@@ -33,8 +33,10 @@ paths:
in: query
type: string
description: |
A Phabricator Conduit API key to use to get the revision.
required: true
A Phabricator Conduit API key to use to get the revision. If not
provided, then a default api key capable of getting public revisions
only will be used instead.
required: false
responses:
200:
description: OK