Resource module

class rohub.Resource.Resource.Resource(ro_id=None, source=None, resource_type=None, input_url=None, file_path=None, title=None, folder=None, description=None, identifier=None, post_request=True)

Bases: object

Class Representation of Rohub’s resource.

Note

editable attributes:
- resource_type
- title
- folder
- description
read-only attributes:
- ros
- identifier
- name
- filename
- size
- download_url
- created
- creator
- modificator
- modified
- created_on
- created_by
- modified_on
- modified_by
- original_created_on
- original_created_by
- original_creator_name
- authors_credits
- contributors_credits
- shared
- doi
- read_only
- api_link
add_keywords(keywords)

Function that adds set of keywords to the resource.

Parameters

keywords (list) – list of keywords

Returns

response content from the API

Return type

dict

assign_doi(external_doi=None)

Function that assigns doi to the resource.

Note

If external_doi value was provided it will be used as doi, otherwise the system will automatically generate and assign doi!

Parameters

external_doi (str) – value for the external, existing doi, optional

Returns

doi

Return type

str

delete()

Function that deletes resource.

Warning

The resource will be deleted from the service and will no longer appear in the API. This doesn’t mean that object created in your local scope will be removed!

Returns

response content from the API

Return type

dict

delete_keywords()

Function that deletes all keywords associated with the resource.

Returns

None

Return type

None

delete_license()

Function that deletes association between license and resource.

Returns

response content from the API

Return type

dict

download(resource_filename, path=None)

Function that acquires the resource to the local file storage.

Parameters
  • resource_filename (str) – resource’s full filename (with extension)

  • path (str) – path where file should be downloaded, optional - current working dir is the default!

Returns

full path to the acquired resource

Return type

str

list_keywords()

Function that shows list of keywords for associated with the resource.

Returns

response containing keywords details

Return type

dict

list_license()

Function that lists license associated with the resource.

Returns

response containing license details

Return type

dict

set_keywords(keywords)

Function that sets list of keywords to the resource.

Parameters

keywords (list) – list of keywords

Returns

response content from the API

Return type

dict

set_license(license_id)

Function that sets license information to the resource.

See also

list_available_licenses() list_custom_licenses() add_custom_license()

Parameters

license_id (str) – license’s identifier

Returns

response content from the API

Return type

dict

show_full_metadata()

Function that shows all metadata associated with the resource.

Returns

response content from the API

Return type

dict

show_metadata()

Function that shows selected (most relevant) information regarding resource.

Returns

resource’s most relevant metadata

Return type

dict

update_content(input_url=None, file_path=None)

Function that updates resource’s content.

Note

After executing update_content the resource will be updated in the service with accordance to the changes that were made to the python object in your local scope. In order to update content for internal resource please provide resource through file_path argument. In case of external resource an input_url argument should be provided.

Note

input_url is required for updating external resource, and file_path is in case of internal one. At least one of them has to be provided!

Warning

The resource content will be overwritten!

Parameters
  • input_url (str) – url to the external resource

  • file_path (str) – path to the internal resource

Returns

response content from the API

Return type

dict

update_metadata(ro_id=None)

Function that updates resource’s metadata.

Note

After executing update_metadata the resource will be updated in the service with accordance to the changes that were made to the python object in your local scope.

Note

to move back a resource to the “Home” directory set folder = “/”

Parameters

ro_id (str) – research object’s identifier, optional

Returns

response content from the API

Return type

dict