-
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.
adding
d1_python.cnclient
operations (#26)
- Loading branch information
1 parent
6b7f7a1
commit e457c0f
Showing
3 changed files
with
55 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
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,46 @@ | ||
from os import environ | ||
from d1_client.cnclient import CoordinatingNodeClient | ||
from d1_common.types.dataoneTypes import Subject, person | ||
|
||
from . import defs | ||
|
||
def init_client(cn_url: str, auth_token: str): | ||
""" | ||
Initialize a d1_client.cnclient.CoordinatingNodeClient instance. | ||
:param str cn_url: The URL | ||
""" | ||
options: dict = {"headers": {"Authorization": "Bearer " + auth_token}} | ||
return CoordinatingNodeClient(cn_url, **options) | ||
|
||
def get_subjects(client: CoordinatingNodeClient, orcid: str): | ||
""" | ||
""" | ||
return client.getSubjectInfo(orcid) | ||
|
||
def get_first_subject(client: CoordinatingNodeClient, orcid: str): | ||
""" | ||
""" | ||
try: | ||
return get_subjects(client=client, orcid=orcid)[0] | ||
except IndexError: | ||
return None | ||
|
||
def get_subject_name(subject: Subject): | ||
""" | ||
""" | ||
first, last = subject.content()[0].content()[1], subject.content()[0].content()[2] | ||
return "%s %s" % (first, last) | ||
|
||
def node_list(client: CoordinatingNodeClient): | ||
""" | ||
""" | ||
nodes = client.listNodes() | ||
for node in nodes.content(): | ||
print(node.name) | ||
return nodes | ||
|
||
def register_user(client: CoordinatingNodeClient, orcid: str, name: str, email: str=None): | ||
""" | ||
""" | ||
|
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