diff --git a/docker-compose.yml b/docker-compose.yml index 7f2da485..db42c341 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: ./ diff --git a/landoapi/api/revisions.py b/landoapi/api/revisions.py index b8885339..1f9c4eb4 100644 --- a/landoapi/api/revisions.py +++ b/landoapi/api/revisions.py @@ -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) diff --git a/landoapi/phabricator_client.py b/landoapi/phabricator_client.py index fbd8f8c3..f8cf8b95 100644 --- a/landoapi/phabricator_client.py +++ b/landoapi/phabricator_client.py @@ -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. diff --git a/landoapi/spec/swagger.yml b/landoapi/spec/swagger.yml index e06b0937..c0d7e255 100644 --- a/landoapi/spec/swagger.yml +++ b/landoapi/spec/swagger.yml @@ -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