hdx.data.organization

[view_source]

Organization class containing all logic for creating, checking, and updating organizations.

Organization Objects

class Organization(HDXObject)

[view_source]

Organization class containing all logic for creating, checking, and updating organizations.

Arguments:

  • initial_data Optional[Dict] - Initial organization metadata dictionary. Defaults to None.
  • configuration Optional[Configuration] - HDX configuration. Defaults to global configuration.

actions

@staticmethod
def actions() -> Dict[str, str]

[view_source]

Dictionary of actions that can be performed on object

Returns:

Dict[str, str]: Dictionary of actions that can be performed on object

update_from_yaml

def update_from_yaml(path: str = join("config", "hdx_organization_static.yml")) -> None

[view_source]

Update organization metadata with static metadata from YAML file

Arguments:

  • path str - Path to YAML dataset metadata. Defaults to config/hdx_organization_static.yml.

Returns:

None

update_from_json

def update_from_json(path: str = join("config", "hdx_organization_static.json")) -> None

[view_source]

Update organization metadata with static metadata from JSON file

Arguments:

  • path str - Path to JSON dataset metadata. Defaults to config/hdx_organization_static.json.

Returns:

None

read_from_hdx

@classmethod
def read_from_hdx(cls, identifier: str, configuration: Optional[Configuration] = None) -> Optional["Organization"]

[view_source]

Reads the organization given by identifier from HDX and returns Organization object

Arguments:

  • identifier str - Identifier of organization
  • configuration Optional[Configuration] - HDX configuration. Defaults to global configuration.

Returns:

  • Optional[Organization] - Organization object if successful read, None if not

check_required_fields

def check_required_fields(ignore_fields: ListTuple[str] = tuple()) -> None

[view_source]

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.

Arguments:

  • ignore_fields ListTuple[str] - Fields to ignore. Default is tuple().

Returns:

None

update_in_hdx

def update_in_hdx(**kwargs: Any) -> None

[view_source]

Check if organization exists in HDX and if so, update organization

Returns:

None

create_in_hdx

def create_in_hdx(**kwargs: Any) -> None

[view_source]

Check if organization exists in HDX and if so, update it, otherwise create organization

Returns:

None

delete_from_hdx

def delete_from_hdx() -> None

[view_source]

Deletes a organization from HDX.

Returns:

None

get_users

def get_users(capacity: Optional[str] = None) -> List["User"]

[view_source]

Returns the organization's users.

Arguments:

  • capacity Optional[str] - Filter by capacity eg. member, admin. Defaults to None.

Returns:

  • List[User] - Organization's users.

add_update_user

def add_update_user(user: Union["User", Dict, str], capacity: Optional[str] = None) -> None

[view_source]

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).

Arguments:

  • user Union[User,Dict,str] - Either a user id or user metadata either from a User object or a dictionary
  • capacity Optional[str] - Capacity of user eg. member, admin. Defaults to None.

Returns:

None

add_update_users

def add_update_users(users: ListTuple[Union["User", Dict, str]], capacity: Optional[str] = None) -> None

[view_source]

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).

Arguments:

  • users ListTuple[Union[User,Dict,str]] - A list of either user ids or users metadata from User objects or dictionaries
  • capacity Optional[str] - Capacity of users eg. member, admin. Defaults to None.

Returns:

None

remove_user

def remove_user(user: Union["User", Dict, str]) -> bool

[view_source]

Remove a user from the organization

Arguments:

  • 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

get_datasets

def get_datasets(query: str = "*:*", **kwargs: Any) -> List["Dataset"]

[view_source]

Get list of datasets in organization

Arguments:

  • query str - Restrict datasets returned to this query (in Solr format). Defaults to ':'.
  • **kwargs - 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

get_all_organization_names

@staticmethod
def get_all_organization_names(configuration: Optional[Configuration] = None, **kwargs: Any) -> List[str]

[view_source]

Get all organization names in HDX

Arguments:

  • configuration Optional[Configuration] - HDX configuration. Defaults to global configuration.
  • **kwargs - 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 - 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

autocomplete

@classmethod
def autocomplete(cls, name: str, limit: int = 20, configuration: Optional[Configuration] = None) -> List

[view_source]

Autocomplete an organization name and return matches

Arguments:

  • name str - Name to autocomplete
  • limit int - Maximum number of matches to return
  • configuration Optional[Configuration] - HDX configuration. Defaults to global configuration.

Returns:

  • List - Autocomplete matches