# 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:
1. Call the `create` method: this method will throw an error in case the PID has already existed.
1. 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:
1. Call the `update` method: this method will throw an error in case the PID does not exist.
1. 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:
```json
[
{
"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:
```python
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)
```
Raw data
{
"_id": null,
"home_page": "https://gitlab.gwdg.de/epic/epic-python-library",
"name": "epic-py",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": null,
"keywords": "pid, handle, persistent-identifier, epic",
"author": "Triet Doan",
"author_email": "triet.doan@gwdg.de",
"download_url": "https://files.pythonhosted.org/packages/cd/e0/89f9783cc33d837ccd7865806a1a24699c3e6215463dc19a844340754ad0/epic_py-0.1.2.tar.gz",
"platform": null,
"description": "# epic-py package\n\nThis is the Python client for ePIC API `version >= 3.0.0`.\n\n## Features\n\n### Get a PID\n\nTo get a PID and its values, simply call the `get` method. It returns a `Pid` object which contains `prefix`, `suffix`,\nand its values in `data` variable. Note that if `username` and `password` are not provided, the client can only get the\nPID and its public readable values.\n\n### Create a PID\n\nTo create a PID, a `Pid` object must first be created with proper `data`, which is a list of `PidData` (handle values).\nPlease see the example usage below for more details.\n\nThere are 2 ways to create a PID:\n\n1. Call the `create` method: this method will throw an error in case the PID has already existed.\n1. Call the `create_or_update` method: as the name suggested, if the PID has already existed, it will be updated\n instead. This update overwrites the PID with new data.\n\n### Update a PID\n\nTo update a PID, a `Pid` object must first be created with proper `prefix`, `suffix`, and `data`. `data` is a list\nof `PidData` (handle values).\n\nSame as create, there are 2 ways to update a PID:\n\n1. Call the `update` method: this method will throw an error in case the PID does not exist.\n1. Call the `create_or_update` method: if the PID already exists, it will be updated. This update overwrites the PID\n with new data.\n\n### Delete a PID\n\nTo delete a PID, simply call the `delete` method and pass the PID string as a parameter. This command does not guarantee\nthat the PID will be deleted. It depends on the policies of each prefix. Usually, the `no-delete` policy is enforced. If\nthat is the case, trying to delete a PID will lead to an error.\n\n## Example usage\n\nSuppose one wants to create a PID with its content as follows:\n\n```json\n[\n {\n \"parsed_data\": \"Test Publisher\",\n \"type\": \"publisher\"\n },\n {\n \"parsed_data\": \"2021\",\n \"type\": \"publicationYear\",\n \"privs\": \"rw--\"\n },\n {\n \"parsed_data\": {\n \"identifier-Attribute\": \"DOI\",\n \"identifier-Value\": \"10.123.456/789\"\n },\n \"type\": \"identifier\"\n },\n {\n \"parsed_data\": {\n \"resourceType-Value\": \"test\"\n },\n \"type\": \"resourceType\"\n },\n {\n \"parsed_data\": {\n \"creator\": {\n \"creatorName\": \"Triet Doan\"\n }\n },\n \"type\": \"creators\"\n },\n {\n \"parsed_data\": {\n \"title\": {\n \"title-Value\": \"Test title\"\n }\n },\n \"type\": \"titles\"\n }\n]\n```\n\nThe following example code can be used:\n\n```python\nfrom epic_py import EpicAPI, PidData, Pid\n\npublisher = PidData(type='publisher', parsed_data='Test Publisher')\npublication_year = PidData(type='publicationYear', parsed_data='2021', privs='rw--')\nidentifier = PidData(type='identifier',\n parsed_data={\"identifier-Attribute\": \"DOI\", \"identifier-Value\": \"10.123.456/789\"})\nresource_type = PidData(type='resourceType', parsed_data={\"resourceType-Value\": \"test\"})\ncreators = PidData(type='creators', parsed_data={\"creator\": {\"creatorName\": \"Triet Doan\"}})\ntitles = PidData(type='titles', parsed_data={\"title\": {\"title-Value\": \"Test title\"}})\n\n# Create the PID object\nprefix = 'my_prefix'\npid = Pid(prefix=prefix, data=[publisher, publication_year, identifier, resource_type, creators, titles])\n\n# Create the client\nepic_api = EpicAPI('<host>', '<username>', '<password>')\n\n# Create the PID\npid = epic_api.create(pid)\n\n# Get the PID\npid_response = epic_api.get(pid.pid_str)\n\n# Delete the PID\nepic_api.delete(pid.pid_str)\n```",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "ePIC API in Python",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://gitlab.gwdg.de/epic/epic-python-library",
"Repository": "https://gitlab.gwdg.de/epic/epic-python-library"
},
"split_keywords": [
"pid",
" handle",
" persistent-identifier",
" epic"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f872cd41c3d014a22b399ca7eea7b46b4f925855c50e1436af77580854b9a362",
"md5": "4d03219af780fe1e0da3a0cfa4582d8b",
"sha256": "985e61a5d0c5f093aa2c50e8e2975b5f22121ce487207f770ea2c7b3fbd2f845"
},
"downloads": -1,
"filename": "epic_py-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4d03219af780fe1e0da3a0cfa4582d8b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 4599,
"upload_time": "2024-08-01T09:47:55",
"upload_time_iso_8601": "2024-08-01T09:47:55.956760Z",
"url": "https://files.pythonhosted.org/packages/f8/72/cd41c3d014a22b399ca7eea7b46b4f925855c50e1436af77580854b9a362/epic_py-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cde089f9783cc33d837ccd7865806a1a24699c3e6215463dc19a844340754ad0",
"md5": "d208fd481f025c4fbd5fadf9162d394e",
"sha256": "bc821e83efbfac352a88d6970980b50d48176923eb64fe0277927dc4be7dc896"
},
"downloads": -1,
"filename": "epic_py-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "d208fd481f025c4fbd5fadf9162d394e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 3837,
"upload_time": "2024-08-01T09:47:59",
"upload_time_iso_8601": "2024-08-01T09:47:59.009540Z",
"url": "https://files.pythonhosted.org/packages/cd/e0/89f9783cc33d837ccd7865806a1a24699c3e6215463dc19a844340754ad0/epic_py-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-01 09:47:59",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "epic-py"
}