-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 parent
84061cc
commit df8b72e
Showing
5 changed files
with
40 additions
and
1 deletion.
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
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,2 @@ | ||
from flask_restx import Resource, fields, reqparse | ||
from contributors import get_workspace_contributors, create_workspace_contributors |
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 @@ | ||
from .contributors import (get_workspace_contributors, create_workspace_contributors) |
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,34 @@ | ||
import requests | ||
from authentication import get_access_token | ||
from utils import create_request_headers | ||
from namespaces import NamespaceEnum, get_namespace_logger | ||
from constants import PENNSIEVE_URL | ||
|
||
|
||
namespace_logger = get_namespace_logger(NamespaceEnum.MANAGE_DATASETS) | ||
|
||
def get_workspace_contributors(): | ||
try: | ||
r = requests.get(f'{PENNSIEVE_URL}/contributors') | ||
r.raise_for_status() | ||
return r.json() | ||
except Exception as e: | ||
namespace_logger.error(e) | ||
|
||
|
||
def create_workspace_contributors(contributors): | ||
try: | ||
for con in contributors: | ||
payload = { | ||
"email": con['email'], | ||
"lastName": con['last_name'], | ||
"firstName": con['first_name'], | ||
"orcid": con['orcid'] | ||
} | ||
|
||
# TODO: Handle if they contributor already exists? | ||
r = requests.post(f'{PENNSIEVE_URL}/contributors', json=payload, headers=create_request_headers(get_access_token())) | ||
r.raise_for_status() | ||
except Exception as e: | ||
namespace_logger.error(e) | ||
raise e |
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