API

EcasShare.__init__(url=None, token_file=None)[source]

Initialize the client.

Parameters:url – URL of the B2SHARE instance. One of the following

hostnames can be used to identify the B2SHARE instance:

  • b2share.eudat.eu - the hostname of the production site.
  • trng-b2share.eudat.eu - the base url of the training

site. Use this URL for testing.

Parameters:token_file – B2SHARE API ACCESS token
EcasShare.retrieve_access_token()[source]

Read the token from a given file named ‘token’

EcasShare.list_communities(token=None)[source]

List all the communities, without any filtering.

Parameters:token – Optional: B2SHARE API ACCESS token
Returns:list of communities in json
EcasShare.retrieve_community_specific_records(community_id)[source]

List all records of a specific community.

Parameters:community_id – community id. Can be retrieved from the list of

communities list_communities :return: the list of records (in JSON format) or an exception message

EcasShare.get_community_schema(community_id)[source]

Retrieves the JSON schema of records approved by a specific community.

Parameters:community_id – community id. Can be found from the list of
communities
list_communities
Returns:community schema in json format.
EcasShare.list_all_records(size=None)[source]

List all the records, without any filtering TODO add pagination :param size: Optional :return: list of records in json format.

EcasShare.get_specific_record(record_id, draft=True)[source]

List the metadata of the record specified by RECORD_ID.

Parameters:
  • record_id – record id.
  • draft – True/False to specify which type of record to search for. Default: True.
Returns:

list of records.

EcasShare.get_record_pid(record_id)[source]

Get the pid from the record metadata (published).

Parameters:record_id – record id
Returns:epicPID, prefix/suffix
EcasShare.create_draft_record(community_id, title)[source]

Create a new record with minimal metadata, in the draft state.

Parameters:
  • community_id
  • title – title for the record
Returns:

record_id, filebucket_id

EcasShare.create_draft_record_with_pid(title=None, original_pid=None, metadata_json=None)[source]

Create a draft record and specifying the original pid. Adapted from DataCite schema:

  • relatedIdentifierType: Handle
  • relationType: isDerivedFrom
Parameters:
  • title – title for the record.
  • original_pid – PID (prefix/suffix) of the input Dataset.
Returns:

record_id and filebucket_id

EcasShare.submit_draft_for_publication(record_id)[source]
Parameters:record_id – record id
Returns:request status (HTTP response)
EcasShare.delete_draft_record(record_id)[source]
Parameters:record_id – record id
Returns:request status
EcasShare.search_records()[source]

List all the records, without any filtering

EcasShare.get_filebucketid_from_record(record_id)[source]

TODO add exception when record not found

Parameters:record_id – identifier for a specific record, which can be in draft or published state
Returns:filebucket id.
EcasShare.search_drafts()[source]

Search for all drafts (unpublished records) that are accessible by the requestor. Usually this means own records only.

Returns:the list of matching drafts (in JSON format).
EcasShare.search_specific_record(search_value)[source]
EcasShare.add_file_to_draft_record(file_path, filebucket_id)[source]
Parameters:
  • file_path – path to the file to be uploaded.
  • filebucket_id – identifier for a set of files. Each record has its own file set, usually found in the links -> files section
Returns:

request status

EcasShare.list_files_in_bucket(filebucket_id)[source]

List the files uploaded into a record object.

Parameters:filebucket_id – identifier for a set of files. Each record has its own file set, usually found in the links -> files section
Returns:information about all the files in the record object