Skip to content

Commit

Permalink
respond to CR
Browse files Browse the repository at this point in the history
  • Loading branch information
cslzchen committed Nov 29, 2023
1 parent 1ca9602 commit 7de03b4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion osf/external/cedar/client.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import requests

from urllib.parse import quote_plus

from website import settings


class CedarClient(object):

host = settings.CEDAR_API_HOST
api_key = settings.CEDAR_API_KEY
home_folder_id = quote_plus(settings.CEDAR_HOME_FOLDER_ID)
headers = {
'Authorization': f'apikey {api_key}'
'Authorization': f'apiKey {api_key}',
}

def retrieve_all_template_ids(self):
url = f'{self.host}folders/{self.home_folder_id}/contents/?resource_types=template'
# TODO: add error handling
r = requests.get(url, headers=self.headers)
resources = r.json()['resources']
return [item['@id'] for item in resources]

def retrieve_template_by_id(self, id):
url = f'{self.host}templates/{quote_plus(id)}'
# TODO: add error handling
r = requests.get(url, headers=self.headers)
return r.json()

0 comments on commit 7de03b4

Please sign in to comment.