hdx.data.organization
module hdx.data.organization
Organization class containing all logic for creating, checking, and updating organizations.
Classes
-
Organization — Organization class containing all logic for creating, checking, and updating organizations.
class Organization(initial_data: dict | None = None, configuration: Configuration | None = None)
Bases : HDXObject
Organization class containing all logic for creating, checking, and updating organizations.
Parameters
-
initial_data : dict | None — Initial organization 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 organization metadata with static metadata from YAML file
-
update_from_json — Update organization metadata with static metadata from JSON file
-
read_from_hdx — Reads the organization given by identifier from HDX and returns Organization object
-
check_required_fields — Check that metadata for organization 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 organization exists in HDX and if so, update organization
-
create_in_hdx — Check if organization exists in HDX and if so, update it, otherwise create organization
-
delete_from_hdx — Deletes a organization from HDX.
-
get_users — Returns the organization's users.
-
add_update_user — Add new or update existing user in organization with new metadata. Capacity eg. member, admin must be supplied either within the User object or dictionary or using the capacity argument (which takes precedence).
-
add_update_users — Add new or update existing users in organization with new metadata. Capacity eg. member, admin must be supplied either within the User object or dictionary or using the capacity argument (which takes precedence).
-
remove_user — Remove a user from the organization
-
get_datasets — Get list of datasets in organization
-
get_all_organization_names — Get all organization names in HDX
-
autocomplete — Autocomplete an organization name and return matches
staticmethod Organization.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 Organization.update_from_yaml(path: Path | str = Path('config', 'hdx_organization_static.yaml')) → None
Update organization metadata with static metadata from YAML file
Parameters
-
path : Path | str — Path to YAML dataset metadata. Defaults to config/hdx_organization_static.yaml.
Returns
-
None — None
method Organization.update_from_json(path: Path | str = Path('config', 'hdx_organization_static.json')) → None
Update organization metadata with static metadata from JSON file
Parameters
-
path : Path | str — Path to JSON dataset metadata. Defaults to config/hdx_organization_static.json.
Returns
-
None — None
classmethod Organization.read_from_hdx(identifier: str, configuration: Configuration | None = None) → Optional['Organization']
Reads the organization given by identifier from HDX and returns Organization object
Parameters
-
identifier : str — Identifier of organization
-
configuration : Configuration | None — HDX configuration. Defaults to global configuration.
Returns
-
Optional['Organization'] — Organization object if successful read, None if not
method Organization.check_required_fields(ignore_fields: Sequence[str] = ()) → None
Check that metadata for organization 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 Organization.update_in_hdx(**kwargs: Any) → None
Check if organization exists in HDX and if so, update organization
Returns
-
None — None
method Organization.create_in_hdx(**kwargs: Any) → None
Check if organization exists in HDX and if so, update it, otherwise create organization
Returns
-
None — None
method Organization.delete_from_hdx() → None
Deletes a organization from HDX.
Returns
-
None — None
method Organization.get_users(capacity: str | None = None) → list['User']
Returns the organization's users.
Parameters
-
capacity : str | None — Filter by capacity eg. member, admin. Defaults to None.
-
Returns — Organization's users.
method Organization.add_update_user(user: Union['User', dict, str], capacity: str | None = None) → None
Add new or update existing user in organization with new metadata. Capacity eg. member, admin must be supplied either within the User object or dictionary or using the capacity argument (which takes precedence).
Parameters
-
user : Union['User', dict, str] — Either a user id or user metadata either from a User object or a dictionary
-
capacity : str | None — Capacity of user eg. member, admin. Defaults to None.
Returns
-
None — None
Raises
-
HDXError
method Organization.add_update_users(users: Sequence[Union['User', dict, str]], capacity: str | None = None) → None
Add new or update existing users in organization with new metadata. Capacity eg. member, admin must be supplied either within the User object or dictionary or using the capacity argument (which takes precedence).
Parameters
-
users : Sequence[Union['User', dict, str]] — A list of either user ids or users metadata from User objects or dictionaries
-
capacity : str | None — Capacity of users eg. member, admin. Defaults to None.
Returns
-
None — None
method Organization.remove_user(user: Union['User', dict, str]) → bool
Remove a user from the organization
Parameters
-
user : Union['User', dict, str] — Either a user id or user metadata either from a User object or a dictionary
Returns
-
bool — True if user removed or False if not
method Organization.get_datasets(query: str = ':', **kwargs: Any) → list['Dataset']
Get list of datasets in organization
Parameters
-
query : str — Restrict datasets returned to this query (in Solr format). Defaults to ':'.
-
**kwargs : Any — See below
-
sort : string — Sorting of the search results. Defaults to 'relevance asc, metadata_modified desc'.
-
rows : int — Number of matching rows to return. Defaults to all datasets (sys.maxsize).
-
start : int — Offset in the complete result for where the set of returned datasets should begin
-
facet : string — Whether to enable faceted results. Default to True.
-
facet.mincount : int — Minimum counts for facet fields should be included in the results
-
facet.limit : int — Maximum number of values the facet fields return (- = unlimited). Defaults to 50.
-
facet.field : list[str] — Fields to facet upon. Default is empty.
-
use_default_schema : bool — Use default package schema instead of custom schema. Defaults to False.
Returns
-
list['Dataset'] — List of datasets in organization
staticmethod Organization.get_all_organization_names(configuration: Configuration | None = None, **kwargs: Any) → list[str]
Get all organization names in HDX
Parameters
-
configuration : Configuration | None — HDX configuration. Defaults to global configuration.
-
**kwargs : Any — See below
-
sort : str — Sort the search results according to field name and sort-order. Allowed fields are ‘name’, ‘package_count’ and ‘title’. Defaults to 'name asc'.
-
organizations : list[str] — List of names of the groups to return.
-
all_fields : bool — Return group dictionaries instead of just names. Only core fields are returned - get some more using the include_* options. Defaults to False.
-
include_extras : bool — If all_fields, include the group extra fields. Defaults to False.
-
include_tags : bool — If all_fields, include the group tags. Defaults to False.
-
include_groups : bool — If all_fields, include the groups the groups are in. Defaults to False.
-
include_users : bool — If all_fields, include the organization users. Defaults to False.
Returns
-
list[str] — List of all organization names in HDX
classmethod Organization.autocomplete(name: str, limit: int = 20, configuration: Configuration | None = None) → list
Autocomplete an organization name and return matches
Parameters
-
name : str — Name to autocomplete
-
limit : int — Maximum number of matches to return
-
configuration : Configuration | None — HDX configuration. Defaults to global configuration.
Returns
-
list — Autocomplete matches