Skip to content

Commit

Permalink
records: add data_model parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
utnapischtim committed Jul 31, 2023
1 parent f79fa50 commit 9a8f22f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions repository_cli/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,15 @@ def delete_record(pid: str) -> None:

@group_records.command("delete-draft")
@option_pid
@option_data_model
@with_appcontext
def delete_draft(pid: str) -> None:
def delete_draft(pid: str, data_model: str) -> None:
"""Delete draft.
example call:
invenio repository records delete-draft -p "fcze8-4vx33"
"""
service = get_records_service()
service = get_records_service(data_model)
identity = get_identity(permission_name="system_process", role_name="admin")

if not exists_record(service, pid, identity):
Expand All @@ -270,14 +271,15 @@ def group_pids() -> None:

@group_pids.command("list")
@option_pid
@option_data_model
@with_appcontext
def list_pids(pid: str) -> None:
def list_pids(pid: str, data_model: str) -> None:
"""List record's pids.
example call:
invenio repository records pids list -p <pid>
"""
service = get_records_service()
service = get_records_service(data_model)
identity = get_identity()

if not exists_record(service, pid, identity):
Expand All @@ -297,16 +299,17 @@ def list_pids(pid: str) -> None:
@group_pids.command("replace")
@option_pid
@option_pid_identifier
@option_data_model
@with_appcontext
def replace_pid(pid: str, pid_identifier: str) -> None:
def replace_pid(pid: str, pid_identifier: str, data_model: str) -> None:
"""Update pid doi to unmanaged.
example call:
invenio repository records pids replace -p "fcze8-4vx33"
--pid-identifier '{"doi": {
"identifier": "10.48436/fcze8-4vx33", "provider": "unmanaged"}}'
"""
service = get_records_service()
service = get_records_service(data_model)
identity = get_identity(permission_name="system_process", role_name="admin")

if not exists_record(service, pid, identity):
Expand Down

0 comments on commit 9a8f22f

Please sign in to comment.