forked from CenterForOpenScience/osf.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
32 additions
and
0 deletions.
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,22 @@ | ||
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}' | ||
} | ||
|
||
def retrieve_all_template_ids(self): | ||
url = f'{self.host}folders/{self.home_folder_id}/contents/?resource_types=template' | ||
r = requests.get(url, headers=self.headers) | ||
resources = r.json()['resources'] | ||
return [item['@id'] for item in resources] | ||
|
||
def retreive_template_by_id(self, id): | ||
url = f'{self.host}templates/{quote_plus(id)}' | ||
r = requests.get(url, headers=self.headers) | ||
return r.json() |
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
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