ePIC API in Python
Project description
epic-py package
This is the Python client for ePIC API version >= 3.0.0
.
Features
Get a PID
To get a PID and its values, simply call the get
method. It returns a Pid
object which contains prefix
, suffix
,
and its values in data
variable. Note that if username
and password
are not provided, the client can only get the
PID and its public readable values.
Create a PID
To create a PID, a Pid
object must first be created with proper data
, which is a list of PidData
(handle values).
Please see the example usage below for more details.
There are 2 ways to create a PID:
- Call the
create
method: this method will throw an error in case the PID has already existed. - Call the
create_or_update
method: as the name suggested, if the PID has already existed, it will be updated instead. This update overwrites the PID with new data.
Update a PID
To update a PID, a Pid
object must first be created with proper prefix
, suffix
, and data
. data
is a list
of PidData
(handle values).
Same as create, there are 2 ways to update a PID:
- Call the
update
method: this method will throw an error in case the PID does not exist. - Call the
create_or_update
method: if the PID already exists, it will be updated. This update overwrites the PID with new data.
Delete a PID
To delete a PID, simply call the delete
method and pass the PID string as a parameter. This command does not guarantee
that the PID will be deleted. It depends on the policies of each prefix. Usually, the no-delete
policy is enforced. If
that is the case, trying to delete a PID will lead to an error.
Example usage
Suppose one wants to create a PID with its content as follows:
[
{
"parsed_data": "Test Publisher",
"type": "publisher"
},
{
"parsed_data": "2021",
"type": "publicationYear",
"privs": "rw--"
},
{
"parsed_data": {
"identifier-Attribute": "DOI",
"identifier-Value": "10.123.456/789"
},
"type": "identifier"
},
{
"parsed_data": {
"resourceType-Value": "test"
},
"type": "resourceType"
},
{
"parsed_data": {
"creator": {
"creatorName": "Triet Doan"
}
},
"type": "creators"
},
{
"parsed_data": {
"title": {
"title-Value": "Test title"
}
},
"type": "titles"
}
]
The following example code can be used:
from epic_py import EpicAPI, PidData, Pid
publisher = PidData(type='publisher', parsed_data='Test Publisher')
publication_year = PidData(type='publicationYear', parsed_data='2021', privs='rw--')
identifier = PidData(type='identifier',
parsed_data={"identifier-Attribute": "DOI", "identifier-Value": "10.123.456/789"})
resource_type = PidData(type='resourceType', parsed_data={"resourceType-Value": "test"})
creators = PidData(type='creators', parsed_data={"creator": {"creatorName": "Triet Doan"}})
titles = PidData(type='titles', parsed_data={"title": {"title-Value": "Test title"}})
# Create the PID object
prefix = 'my_prefix'
pid = Pid(prefix=prefix, data=[publisher, publication_year, identifier, resource_type, creators, titles])
# Create the client
epic_api = EpicAPI('<host>', '<username>', '<password>')
# Create the PID
pid = epic_api.create(pid)
# Get the PID
pid_response = epic_api.get(pid.pid_str)
# Delete the PID
epic_api.delete(pid.pid_str)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file epic_py-0.1.2.tar.gz
.
File metadata
- Download URL: epic_py-0.1.2.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.4 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc821e83efbfac352a88d6970980b50d48176923eb64fe0277927dc4be7dc896 |
|
MD5 | d208fd481f025c4fbd5fadf9162d394e |
|
BLAKE2b-256 | cde089f9783cc33d837ccd7865806a1a24699c3e6215463dc19a844340754ad0 |
File details
Details for the file epic_py-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: epic_py-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.4 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 985e61a5d0c5f093aa2c50e8e2975b5f22121ce487207f770ea2c7b3fbd2f845 |
|
MD5 | 4d03219af780fe1e0da3a0cfa4582d8b |
|
BLAKE2b-256 | f872cd41c3d014a22b399ca7eea7b46b4f925855c50e1436af77580854b9a362 |