hs_restclient package¶
Subpackages¶
Submodules¶
hs_restclient.compat module¶
-
hs_restclient.compat.
is_py2
= True¶ Python 2.x?
-
hs_restclient.compat.
is_py3
= False¶ Python 3.x?
hs_restclient.exceptions module¶
Bases:
exceptions.Exception
Bases:
hs_restclient.exceptions.HydroShareException
Exception used to communicate HTTP errors from HydroShare server
Arguments in tuple passed to constructor must be: (url, status_code, params). url and status_code are of type string, while the optional params argument should be a dict.
hs_restclient.generators module¶
Module contents¶
Client library for HydroShare REST API
Bases:
object
Bases:
object
Construct HydroShare object for querying HydroShare’s REST API
Parameters: - hostname – Hostname of the HydroShare server to query
- port – Integer representing the TCP port on which to connect to the HydroShare server
- use_https – Boolean, if True, HTTPS will be used (HTTP cannot be used when auth is specified)
- verify – Boolean, if True, security certificates will be verified
- auth – Concrete instance of AbstractHydroShareAuth (e.g. HydroShareAuthBasic)
- prompt_auth – Boolean, default True, prompts user/pass if no auth is given
Raises: HydroShareAuthenticationException if auth is not a known authentication type.
Raises: HydroShareAuthenticationException if auth is specified by use_https is False.
Raises: HydroShareAuthenticationException if other authentication errors occur.
Add a new file to an existing resource
Parameters: - pid – The HydroShare ID of the resource
- resource_file – a read-only binary file-like object (i.e. opened with the flag ‘rb’) or a string representing path to file to be uploaded as part of the new resource
- resource_filename – string representing the filename of the resource file. Must be specified if resource_file is a file-like object. If resource_file is a string representing a valid file path, and resource_filename is not specified, resource_filename will be equal to os.path.basename(resource_file). is a string
- progress_callback – user-defined function to provide feedback to the user about the progress of the upload of resource_file. For more information, see: http://toolbelt.readthedocs.org/en/latest/uploading-data.html#monitoring-your-streaming-multipart-upload
Returns: Dictionary containing ‘resource_id’ the ID of the resource to which the file was added, and ‘file_name’ the filename of the file added.
Raises: HydroShareNotAuthorized if user is not authorized to perform action.
Raises: HydroShareNotFound if the resource was not found.
Raises: HydroShareHTTPException if an unexpected HTTP response code is encountered.
Create a Referenced Content File (.url) :param pid: The HydroShare ID of the resource for which the file should be created :param name: Filename for the referenced file :param ref_url: url to be used in the referenced file :param path: Optional, defaults to contents directory if not provided. Folder path for the file to be created in :return: JsonResponse on success or HttpResponse with error status code on error
Raises: HydroShareNotAuthorized if user is not authorized to perform action. Raises: HydroShareNotFound if the resource or resource file was not found. Raises: HydroShareHTTPException if an unexpected HTTP response code is encountered.
Deprecated, use createReferenceURL. Create a Referenced Content File (.url)
Parameters: - pid – The HydroShare ID of the resource for which the file should be created
- path – Folder path for the file to be created in
- name – Filename for the referenced file
- ref_url – url to be used in the referenced file
Returns: JsonResponse on success or HttpResponse with error status code on error
Raises: HydroShareNotAuthorized if user is not authorized to perform action.
Raises: HydroShareNotFound if the resource or resource file was not found.
Raises: HydroShareHTTPException if an unexpected HTTP response code is encountered.
Create a new resource.
Parameters: - resource_type – string representing the a HydroShare resource type recognized by this server.
- title – string representing the title of the new resource
- resource_file – a read-only binary file-like object (i.e. opened with the flag ‘rb’) or a string representing path to file to be uploaded as part of the new resource
- resource_filename – string representing the filename of the resource file. Must be specified if resource_file is a file-like object. If resource_file is a string representing a valid file path, and resource_filename is not specified, resource_filename will be equal to os.path.basename(resource_file). is a string
- abstract – string representing abstract of resource
- keywords – list of strings representing keywords to associate with the resource
- edit_users – list of HydroShare usernames who will be given edit permissions
- view_users – list of HydroShare usernames who will be given view permissions
- edit_groups – list of HydroShare group names that will be given edit permissions
- view_groups – list of HydroShare group names that will be given view permissions
- metadata – json string data for each of the metadata elements
- extra_metadata – json string data for key/value pair metadata elements defined by user
- progress_callback – user-defined function to provide feedback to the user about the progress of the upload of resource_file. For more information, see: http://toolbelt.readthedocs.org/en/latest/uploading-data.html#monitoring-your-streaming-multipart-upload
Returns: string representing ID of newly created resource.
Raises: HydroShareArgumentException if any parameters are invalid.
Raises: HydroShareNotAuthorized if user is not authorized to perform action.
Raises: HydroShareHTTPException if an unexpected HTTP response code is encountered.
Create folder as specified by pathname for a given resource
Parameters: - pid – The HydroShare ID of the resource for which folder to be created
- pathname – Folder path/name for the folder to be created
Returns: A JSON object representing the resource id and path of the folder that was created
Raises: HydroShareNotAuthorized if user is not authorized to perform action.
Raises: HydroShareNotFound if the resource or resource file was not found.
Raises: HydroShareHTTPException if an unexpected HTTP response code is encountered.
Example of JSON data returned: {
“resource_id”: “32a08bc23a86e471282a832143491b49”, “path”: “model/initial”}
Delete a resource.
Parameters: pid – The HydroShare ID of the resource
Delete a resource file
Parameters: - pid – The HydroShare ID of the resource
- filename – String representing the name of the resource file to delete
Returns: Dictionary containing ‘resource_id’ the ID of the resource from which the file was deleted, and ‘file_name’ the filename of the file deleted.
Raises: HydroShareNotAuthorized if user is not authorized to perform action.
Raises: HydroShareNotFound if the resource or resource file was not found.
Raises: HydroShareHTTPException if an unexpected HTTP response code is encountered.
Delete a folder as specified by pathname for a given resource
Parameters: - pid – The HydroShare ID of the resource for which folder to be deleted
- pathname – Folder path/name for the folder to be deleted
Returns: A JSON object representing the resource id and path of the folder that was deleted
Raises: HydroShareNotAuthorized if user is not authorized to perform action.
Raises: HydroShareNotFound if the resource or resource file was not found.
Raises: HydroShareHTTPException if an unexpected HTTP response code is encountered.
Example of JSON data returned: {
‘resource_id’: “32a08bc23a86e471282a832143491b49”, ‘path’: “model/initial”}
Get a resource in BagIt format
Parameters: - pid – The HydroShare ID of the resource
- destination – String representing the directory to save bag to. Bag will be saved to file named $(PID).zip in destination; existing file of the same name will be overwritten. If None, a stream to the zipped bag will be returned instead.
- unzip – True if the bag should be unzipped when saved to destination. Bag contents to be saved to directory named $(PID) residing in destination. Only applies when destination is not None.
- wait_for_bag_creation – True if to wait to download the bag in case the bag is not ready (bag needs to be recreated before it can be downloaded).
Raises: HydroShareArgumentException if any arguments are invalid.
Raises: HydroShareNotAuthorized if the user is not authorized to access the resource.
Raises: HydroShareNotFound if the resource was not found.
Raises: HydroShareHTTPException to signal an HTTP error
Raise: HydroShareBagNotReady if the bag is not ready to be downloaded and wait_for_bag_creation is False
Returns: None if the bag was saved directly to disk. Or a generator representing a buffered stream of the bytes comprising the bag returned by the REST end point.
Get a file within a resource.
Parameters: - pid – The HydroShare ID of the resource
- filename – String representing the name of the resource file to get.
- destination – String representing the directory to save the resource file to. If None, a stream to the resource file will be returned instead.
Returns: The path of the downloaded file (if destination was specified), or a stream to the resource file.
Raises: HydroShareArgumentException if any parameters are invalid.
Raises: HydroShareNotAuthorized if user is not authorized to perform action.
Raises: HydroShareNotFound if the resource was not found.
Raises: HydroShareHTTPException if an unexpected HTTP response code is encountered.
Get a listing of files within a resource.
Parameters: pid – The HydroShare ID of the resource whose resource files are to be listed. Raises: HydroShareArgumentException if any parameters are invalid. Raises: HydroShareNotAuthorized if user is not authorized to perform action. Raises: HydroShareNotFound if the resource was not found. Raises: HydroShareHTTPException if an unexpected HTTP response code is encountered. Returns: A generator that can be used to fetch dict objects, each dict representing the JSON object representation of the resource returned by the REST end point. For example: - {
“count”: 95, “next”: “https://www.hydroshare.org/hsapi/resource/32a08bc23a86e471282a832143491b49/file_list/?page=2”, “previous”: null, “results”: [
- {
- “url”: “http://www.hydroshare.org/django_irods/download/32a08bc23a86e471282a832143491b49/data/contents/foo/bar.txt”, “size”: 23550, “content_type”: “text/plain”
}, {
“url”: “http://www.hydroshare.org/django_irods/download/32a08bc23a86e471282a832143491b49/data/contents/dem.tif”, “size”: 107545, “content_type”: “image/tiff”}, {
“url”: “http://www.hydroshare.org/django_irods/download/32a08bc23a86e471282a832143491b49/data/contents/data.csv”, “size”: 148, “content_type”: “text/csv”}, {
“url”: “http://www.hydroshare.org/django_irods/download/32a08bc23a86e471282a832143491b49/data/contents/data.sqlite”, “size”: 267118, “content_type”: “application/x-sqlite3”}, {
“url”: “http://www.hydroshare.org/django_irods/download/32a08bc23a86e471282a832143491b49/data/contents/viz.png”, “size”: 128, “content_type”: “image/png”}
]
}
Get a listing of files and folders for a resource at the specified path (pathname)
Parameters: - pid – The HydroShare ID of the resource whose folder contents to be listed
- pathname – Folder path for which contents (files and folders) need to be listed
Returns: A JSON object representing the contents of the specified folder
Raises: HydroShareNotAuthorized if user is not authorized to perform action.
Raises: HydroShareNotFound if the resource or resource file was not found.
Raises: HydroShareHTTPException if an unexpected HTTP response code is encountered.
Example of JSON data returned: {
“resource_id”: “32a08bc23a86e471282a832143491b49”, “path”: “model/initial”, “files”: [“model.exe”, “param.txt”], “folders”: [“run/1”, “run/2”]}
Get resource map metadata for a resource
Parameters: pid – The HydroShare ID of the resource Raises: HydroShareNotAuthorized if the user is not authorized to view the metadata. Raises: HydroShareNotFound if the resource was not found. Raises: HydroShareHTTPException to signal an HTTP error. Returns: A string representing the XML+RDF serialization of resource map metadata. Example of data returned:
<?xml version=”1.0” encoding=”UTF-8”?> <rdf:RDF
xmlns:citoterms=”http://purl.org/spar/cito/” xmlns:dc=”http://purl.org/dc/elements/1.1/” xmlns:dcterms=”http://purl.org/dc/terms/” xmlns:foaf=”http://xmlns.com/foaf/0.1/” xmlns:ore=”http://www.openarchives.org/ore/terms/” xmlns:rdf=”http://www.w3.org/1999/02/22-rdf-syntax-ns#” xmlns:rdfs1=”http://www.w3.org/2001/01/rdf-schema#”- >
- <rdf:Description rdf:about=”http://foresite-toolkit.googlecode.com/#pythonAgent”>
- <foaf:name>Foresite Toolkit (Python)</foaf:name> <foaf:mbox>foresite@googlegroups.com</foaf:mbox>
</rdf:Description> <rdf:Description rdf:about=”http://www.hydroshare.org/terms/GenericResource”>
<rdfs1:label>Generic</rdfs1:label> <rdfs1:isDefinedBy>http://www.hydroshare.org/terms</rdfs1:isDefinedBy></rdf:Description> <rdf:Description rdf:about=”http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/contents/test.txt”>
<ore:isAggregatedBy>http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemap.xml#aggregation</ore:isAggregatedBy> <dc:format>text/plain</dc:format></rdf:Description> <rdf:Description rdf:about=”http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemap.xml”>
<dc:identifier>03c862ccf17b4853ac4288d63ab2d766</dc:identifier> <ore:describes rdf:resource=”http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemap.xml#aggregation”/> <rdf:type rdf:resource=”http://www.openarchives.org/ore/terms/ResourceMap”/> <dc:format>application/rdf+xml</dc:format> <dc:creator rdf:resource=”http://foresite-toolkit.googlecode.com/#pythonAgent”/> <dcterms:created>2016-11-29T16:17:52Z</dcterms:created> <dcterms:modified>2016-11-29T16:17:52Z</dcterms:modified></rdf:Description> <rdf:Description rdf:about=”http://www.openarchives.org/ore/terms/ResourceMap”>
<rdfs1:isDefinedBy>http://www.openarchives.org/ore/terms/</rdfs1:isDefinedBy> <rdfs1:label>ResourceMap</rdfs1:label></rdf:Description> <rdf:Description rdf:about=”http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemap.xml#aggregation”>
<citoterms:isDocumentedBy>http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemetadata.xml</citoterms:isDocumentedBy> <dc:title>Gen Res-1</dc:title> <dcterms:type rdf:resource=”http://www.hydroshare.org/terms/GenericResource”/> <ore:isDescribedBy>http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemap.xml</ore:isDescribedBy> <ore:aggregates rdf:resource=”http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemetadata.xml”/> <ore:aggregates rdf:resource=”http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/contents/test.txt”/> <rdf:type rdf:resource=”http://www.openarchives.org/ore/terms/Aggregation”/>
</rdf:Description>- <rdf:Description rdf:about=”http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemetadata.xml”>
- <ore:isAggregatedBy>http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemap.xml#aggregation</ore:isAggregatedBy> <citoterms:documents>http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemap.xml#aggregation</citoterms:documents> <dc:title>Dublin Core science metadata document describing the HydroShare resource</dc:title> <dc:format>application/rdf+xml</dc:format>
</rdf:Description> <rdf:Description rdf:about=”http://www.openarchives.org/ore/terms/Aggregation”>
<rdfs1:label>Aggregation</rdfs1:label> <rdfs1:isDefinedBy>http://www.openarchives.org/ore/terms/</rdfs1:isDefinedBy></rdf:Description>
</rdf:RDF>
Get the list of resource types supported by the HydroShare server
Returns: A set of strings representing the HydroShare resource types Raises: HydroShareHTTPException to signal an HTTP error
Get science metadata for a resource in JSON format Note: Dublin core metadata as well as any resource specific metadata is retrieved.
Parameters: pid – The HydroShare ID of the resource Raises: HydroShareNotAuthorized if the user is not authorized to view the metadata. Raises: HydroShareNotFound if the resource was not found. Raises: HydroShareHTTPException to signal an HTTP error. Returns: A string representing JSON serialization of science metadata. Example of data JSON returned (this example shows only Dublin core metadata):
- {
“title”:”Great Salt Lake Level and Volume”, “creators”:[
{“name”:”John Smith”,”description”:”/user/24/”,”organization”:”USU”,”email”:”john.smith@usu.edu”,”address”:”Engineering Building, USU, Logan, Utah”,”phone”:”435-789-9087”,”homepage”:null,”order”:1}, {“name”:”Lisa Miller”,”description”:null,”organization”:null,”email”:null,”address”:null,”phone”:null,”homepage”:null,”order”:2}],
- “contributors”:[
- {“name”:”Jenny Parker”,”description”:”“,”organization”:”Univesity of Utah”,”email”:”jenny_parker@hotmail.com”,”address”:”“,”phone”:”“,”homepage”:”“}
],
- “coverages”:[
- {“type”:”period”,”value”:{“start”:”01/01/2000”,”end”:”12/12/2010”}}
],
- “dates”:[
- {“type”:”created”,”start_date”:”2017-01-03T17:06:18.932217Z”,”end_date”:null}, {“type”:”modified”,”start_date”:”2017-01-03T17:06:19.162694Z”,”end_date”:null}
],
“description”:”Time series of level, area and volume in the Great Salt Lake. Volume and area of the Great Salt Lake are derived from recorded levels”, “formats”:[
{“value”:”image/tiff”}],
- “funding_agencies”:[
- {“agency_name”:”National Science Foundation”,”award_title”:”Model Execution Cyberinfrastructure “,”award_number”:”NSF_9087658_2017”,”agency_url”:”http://www.nsf.gov”}
],
- “identifiers”:[
- {“name”:”hydroShareIdentifier”,”url”:”http://www.hydroshare.org/resource/87ffb608900e407ab4b67d30c93b329e”}
],
“language”:”eng”, “rights”:”This resource is shared under the Creative Commons Attribution CC BY. http://creativecommons.org/licenses/by/4.0/”, “type”:”http://www.hydroshare.org/terms/GenericResource”, “publisher”:null, “sources”:[], “subjects”:[
{“value”:”NSF”}, {“value”:”Modeling”}],
“relations”:[]
}
Get science metadata for a resource in XML+RDF format
Parameters: pid – The HydroShare ID of the resource Raises: HydroShareNotAuthorized if the user is not authorized to view the metadata. Raises: HydroShareNotFound if the resource was not found. Raises: HydroShareHTTPException to signal an HTTP error. Returns: A string representing the XML+RDF serialization of science metadata. Example of data XML+RDF returned:
<?xml version=”1.0”?> <!DOCTYPE rdf:RDF PUBLIC “-//DUBLIN CORE//DCMES DTD 2002/07/31//EN” “http://dublincore.org/documents/2002/07/31/dcmes-xml/dcmes-xml-dtd.dtd”> <rdf:RDF xmlns:dc=”http://purl.org/dc/elements/1.1/” xmlns:dcterms=”http://purl.org/dc/terms/” xmlns:hsterms=”http://hydroshare.org/terms/” xmlns:rdf=”http://www.w3.org/1999/02/22-rdf-syntax-ns#” xmlns:rdfs1=”http://www.w3.org/2001/01/rdf-schema#”>
- <rdf:Description rdf:about=”http://www.hydroshare.org/resource/87ffb608900e407ab4b67d30c93b329e”>
<dc:title>Great Salt Lake Level and Volume</dc:title> <dc:type rdf:resource=”http://www.hydroshare.org/terms/GenericResource”/> <dc:description>
- <rdf:Description>
- <dcterms:abstract>Time series of level, area and volume in the Great Salt Lake. Volume and area of the Great Salt Lake are derived from recorded levels</dcterms:abstract>
</rdf:Description>
</dc:description> <hsterms:awardInfo>
- <rdf:Description rdf:about=”http://www.nsf.gov”>
- <hsterms:fundingAgencyName>National Science Foundation</hsterms:fundingAgencyName> <hsterms:awardTitle>Model Execution Cyberinfrastructure </hsterms:awardTitle> <hsterms:awardNumber>NSF_9087658_2017</hsterms:awardNumber>
</rdf:Description>
</hsterms:awardInfo> <dc:creator>
- <rdf:Description>
- <hsterms:name>John Smith</hsterms:name> <hsterms:creatorOrder>1</hsterms:creatorOrder> <hsterms:organization>Utah State University</hsterms:organization> <hsterms:email>john.smith@gmail.com</hsterms:email> <hsterms:address>Engineering Building, USU, Logan, Utah</hsterms:address> <hsterms:phone rdf:resource=”tel:435-797-8967”/>
</rdf:Description>
</dc:creator> <dc:creator>
- <rdf:Description>
- <hsterms:name>Lisa Miller</hsterms:name> <hsterms:creatorOrder>2</hsterms:creatorOrder>
</rdf:Description>
</dc:creator> <dc:contributor>
- <rdf:Description>
- <hsterms:name>Jenny Parker</hsterms:name> <hsterms:organization>Univesity of Utah</hsterms:organization> <hsterms:email>jenny_parker@hotmail.com</hsterms:email>
</rdf:Description>
</dc:contributor> <dc:coverage>
- <dcterms:period>
- <rdf:value>start=2000-01-01T00:00:00; end=2010-12-12T00:00:00; scheme=W3C-DTF</rdf:value>
</dcterms:period>
</dc:coverage> <dc:date>
- <dcterms:created>
- <rdf:value>2017-01-03T17:06:18.932217+00:00</rdf:value>
</dcterms:created>
</dc:date> <dc:date>
- <dcterms:modified>
- <rdf:value>2017-01-03T17:35:34.067279+00:00</rdf:value>
</dcterms:modified>
</dc:date> <dc:format>image/tiff</dc:format> <dc:identifier>
- <rdf:Description>
- <hsterms:hydroShareIdentifier>http://www.hydroshare.org/resource/87ffb608900e407ab4b67d30c93b329e</hsterms:hydroShareIdentifier>
</rdf:Description>
</dc:identifier> <dc:language>eng</dc:language> <dc:rights>
- <rdf:Description>
- <hsterms:rightsStatement>This resource is shared under the Creative Commons Attribution CC BY.</hsterms:rightsStatement> <hsterms:URL rdf:resource=”http://creativecommons.org/licenses/by/4.0/”/>
</rdf:Description>
</dc:rights> <dc:subject>NSF</dc:subject> <dc:subject>Model</dc:subject> <dc:subject>Cyberinfrastructure</dc:subject> <hsterms:extendedMetadata>
- <rdf:Description>
- <hsterms:key>model</hsterms:key> <hsterms:value>ueb</hsterms:value>
</rdf:Description>
</hsterms:extendedMetadata> <hsterms:extendedMetadata>
- <rdf:Description>
- <hsterms:key>os</hsterms:key> <hsterms:value>windows</hsterms:value>
</rdf:Description>
</hsterms:extendedMetadata>
</rdf:Description> <rdf:Description rdf:about=”http://www.hydroshare.org/terms/GenericResource”>
<rdfs1:label>Generic</rdfs1:label> <rdfs1:isDefinedBy>http://www.hydroshare.org/terms</rdfs1:isDefinedBy></rdf:Description>
</rdf:RDF>
Get system metadata for a resource
Parameters: pid – The HydroShare ID of the resource Raises: HydroShareHTTPException to signal an HTTP error Returns: A dict representing the JSON object representation of the resource returned by the REST end point. Example of data returned:
- {u’bag_url’: u’http://www.hydroshare.org/static/media/bags/hr3hy35y5ht4y54hhthrtg43w.zip’,
- u’creator’: u’B Miles’, u’date_created’: u‘01-02-2015’, u’date_last_updated’: u‘05-13-2015’, u’resource_id’: u’hr3hy35y5ht4y54hhthrtg43w’, u’resource_title’: u’Other raster’, u’resource_type’: u’RasterResource’, u’science_metadata_url’: u’http://www.hydroshare.org/hsapi/scimeta/hr3hy35y5ht4y54hhthrtg43w/’, u’public’: True}
Query the GET /hsapi/userInfo/ REST end point of the HydroShare server.
Raises: HydroShareHTTPException to signal an HTTP error Returns: A JSON object representing user info, for example: - {
- “username”: “username”, “first_name”: “First”, “last_name”: “Last”, “email”: “user@domain.com”
}
Set access rules for a resource. Current only allows for setting the public or private setting.
Parameters: - pid – The HydroShare ID of the resource
- public – True if the resource should be made public.
Update a Referenced Content File (.url)
Parameters: - pid – The HydroShare ID of the resource for which the file should be updated
- name – Filename for the referenced file
- ref_url – url to be updated in the referenced file
- path – Optional, defaults to contents directory if not provided. Folder path for the file to be updated in
Returns: JsonResponse on success or HttpResponse with error status code on error
Raises: HydroShareNotAuthorized if user is not authorized to perform action.
Raises: HydroShareNotFound if the resource or resource file was not found.
Raises: HydroShareHTTPException if an unexpected HTTP response code is encountered.
Deprecated, use updateReferenceURL. Update a Referenced Content File (.url)
Parameters: - pid – The HydroShare ID of the resource for which the file should be updated
- path – Folder path for the file to be updated in
- name – Filename for the referenced file
- ref_url – url to be updated in the referenced file
Returns: JsonResponse on success or HttpResponse with error status code on error
Raises: HydroShareNotAuthorized if user is not authorized to perform action.
Raises: HydroShareNotFound if the resource or resource file was not found.
Raises: HydroShareHTTPException if an unexpected HTTP response code is encountered.
Update Dublin core metadata as well as resource specific metadata for a resource
Parameters: - pid – The HydroShare ID of the resource for which science metadata needs to be updated
- metadata – A dict containing data for each of the dublin core metadata elements that needs to be updated
Raises: HydroShareNotAuthorized if the user is not authorized to view the metadata.
Raises: HydroShareNotFound if the resource was not found.
Raises: HydroShareHTTPException to signal an HTTP error.
Returns: A string representing the JSON serialization of resource science metadata.
Example of data JSON returned (this example shows only Dublin core metadata):
- {
“title”:”Great Salt Lake Level and Volume”, “creators”:[
{“name”:”John Smith”,”description”:”/user/24/”,”organization”:”USU”,”email”:”john.smith@usu.edu”,”address”:”Engineering Building, USU, Logan, Utah”,”phone”:”435-789-9087”,”homepage”:null,”order”:1}, {“name”:”Lisa Miller”,”description”:null,”organization”:null,”email”:null,”address”:null,”phone”:null,”homepage”:null,”order”:2}],
- “contributors”:[
- {“name”:”Jenny Parker”,”description”:”“,”organization”:”University of Utah”,”email”:”jenny_parker@hotmail.com”,”address”:”“,”phone”:”“,”homepage”:”“}
],
- “coverages”:[
- {“type”:”period”,”value”:{“start”:”01/01/2000”,”end”:”12/12/2010”}}
],
- “dates”:[
- {“type”:”created”,”start_date”:”2017-01-03T17:06:18.932217Z”,”end_date”:null}, {“type”:”modified”,”start_date”:”2017-01-03T17:06:19.162694Z”,”end_date”:null}
],
“description”:”Time series of level, area and volume in the Great Salt Lake. Volume and area of the Great Salt Lake are derived from recorded levels”, “formats”:[
{“value”:”image/tiff”}],
- “funding_agencies”:[
- {“agency_name”:”National Science Foundation”,”award_title”:”Model Execution Cyberinfrastructure “,”award_number”:”NSF_9087658_2017”,”agency_url”:”http://www.nsf.gov”}
],
- “identifiers”:[
- {“name”:”hydroShareIdentifier”,”url”:”http://www.hydroshare.org/resource/87ffb608900e407ab4b67d30c93b329e”}
],
“language”:”eng”, “rights”: {“statement”: “This resource is shared under the Creative Commons Attribution CC BY.” “url”: “http://creativecommons.org/licenses/by/4.0/”}, “type”:”http://www.hydroshare.org/terms/GenericResource”, “publisher”:null, “sources”:[], “subjects”:[
{“value”:”NSF”}, {“value”:”Modeling”}],
“relations”:[]
}