hdx.data.resource_view
module hdx.data.resource_view
Resource view class containing all logic for creating, checking, and updating resource views.
Classes
-
ResourceView — ResourceView class containing all logic for creating, checking, and updating resource views.
class ResourceView(initial_data: dict | None = None, configuration: Configuration | None = None)
Bases : HDXObject
ResourceView class containing all logic for creating, checking, and updating resource views.
Parameters
-
initial_data : dict | None — Initial resource view metadata dictionary. Defaults to None.
-
configuration : Configuration | None — HDX configuration. Defaults to global configuration.
Methods
-
actions — Dictionary of actions that can be performed on object
-
update_from_yaml — Update resource view metadata with static metadata from YAML file
-
update_from_json — Update resource view metadata with static metadata from JSON file
-
read_from_hdx — Reads the resource view given by identifier from HDX and returns ResourceView object
-
get_all_for_resource — Read all resource views for a resource given by identifier from HDX and returns list of ResourceView objects
-
check_required_fields — Check that metadata for resource view is complete. The parameter ignore_fields should be set if required to any fields that should be ignored for the particular operation.
-
update_in_hdx — Check if resource view exists in HDX and if so, update resource view
-
create_in_hdx — Check if resource view exists in HDX and if so, update it, otherwise create resource view
-
delete_from_hdx — Deletes a resource view from HDX.
-
copy — Copies all fields except id, resource_id and package_id from another resource view.
staticmethod ResourceView.actions() → dict[str, str]
Dictionary of actions that can be performed on object
Returns
-
dict[str, str] — Dictionary of actions that can be performed on object
method ResourceView.update_from_yaml(path: Path | str = Path('config', 'hdx_resource_view_static.yaml')) → None
Update resource view metadata with static metadata from YAML file
Parameters
-
path : Path | str — Path to YAML resource view metadata. Defaults to config/hdx_resource_view_static.yaml.
Returns
-
None — None
method ResourceView.update_from_json(path: Path | str = Path('config', 'hdx_resource_view_static.json')) → None
Update resource view metadata with static metadata from JSON file
Parameters
-
path : Path | str — Path to JSON dataset metadata. Defaults to config/hdx_resource_view_static.json.
Returns
-
None — None
classmethod ResourceView.read_from_hdx(identifier: str, configuration: Configuration | None = None) → Optional['ResourceView']
Reads the resource view given by identifier from HDX and returns ResourceView object
Parameters
-
identifier : str — Identifier of resource view
-
configuration : Configuration | None — HDX configuration. Defaults to global configuration.
Returns
-
Optional['ResourceView'] — ResourceView object if successful read, None if not
staticmethod ResourceView.get_all_for_resource(identifier: str, configuration: Configuration | None = None) → list['ResourceView']
Read all resource views for a resource given by identifier from HDX and returns list of ResourceView objects
Parameters
-
identifier : str — Identifier of resource
-
configuration : Configuration | None — HDX configuration. Defaults to global configuration.
Returns
-
list['ResourceView'] — List of ResourceView objects
method ResourceView.check_required_fields(ignore_fields: Sequence[str] = ()) → None
Check that metadata for resource view is complete. The parameter ignore_fields should be set if required to any fields that should be ignored for the particular operation.
Parameters
-
ignore_fields : Sequence[str] — Fields to ignore. Default is ().
Returns
-
None — None
method ResourceView.update_in_hdx(**kwargs: Any) → None
Check if resource view exists in HDX and if so, update resource view
Returns
-
None — None
Raises
-
HDXError
method ResourceView.create_in_hdx(**kwargs: Any) → None
Check if resource view exists in HDX and if so, update it, otherwise create resource view
Returns
-
None — None
method ResourceView.delete_from_hdx() → None
Deletes a resource view from HDX.
Returns
-
None — None
method ResourceView.copy(resource_view: Union['ResourceView', dict, str]) → None
Copies all fields except id, resource_id and package_id from another resource view.
Parameters
-
resource_view : Union['ResourceView', dict, str] — Either a resource view id or resource view metadata either from a ResourceView object or a dictionary
Returns
-
None — None
Raises
-
HDXError