hdx.data.user

[view_source]

User class containing all logic for creating, checking, and updating users.

User Objects

class User(HDXObject)

[view_source]

User class containing all logic for creating, checking, and updating users.

Arguments:

  • initial_data Optional[Dict] - Initial user 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_user_static.yml")) -> None

[view_source]

Update user metadata with static metadata from YAML file

Arguments:

  • path Optional[str] - Path to YAML dataset metadata. Defaults to config/hdx_user_static.yml.

Returns:

None

update_from_json

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

[view_source]

Update user metadata with static metadata from JSON file

Arguments:

  • path Optional[str] - Path to JSON dataset metadata. Defaults to config/hdx_user_static.json.

Returns:

None

read_from_hdx

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

[view_source]

Reads the user given by identifier from HDX and returns User object

Arguments:

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

Returns:

  • Optional[User] - User 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 user 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 user exists in HDX and if so, update user

Returns:

None

create_in_hdx

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

[view_source]

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

Returns:

None

delete_from_hdx

def delete_from_hdx() -> None

[view_source]

Deletes a user from HDX.

Returns:

None

email

def email(subject: str, text_body: str, html_body: Optional[str] = None, sender: Optional[str] = None, **kwargs: Any, ,) -> None

[view_source]

Emails a user.

Arguments:

  • subject str - Email subject
  • text_body str - Plain text email body
  • html_body str - HTML email body
  • sender Optional[str] - Email sender. Defaults to SMTP username.
  • **kwargs - See below
  • mail_options List - Mail options (see smtplib documentation)
  • rcpt_options List - Recipient options (see smtplib documentation)

Returns:

None

get_all_users

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

[view_source]

Get all users in HDX

Arguments:

  • configuration Optional[Configuration] - HDX configuration. Defaults to global configuration.
  • **kwargs - See below
  • q str - Restrict to names containing a string. Defaults to all users.
  • order_by str - Field by which to sort - any user field or edits (number_of_edits). Defaults to 'name'.

Returns:

  • List[User] - List of all users in HDX

email_users

@staticmethod
def email_users(users: ListTuple["User"], subject: str, text_body: str, html_body: Optional[str] = None, sender: Optional[str] = None, cc: Optional[ListTuple["User"]] = None, bcc: Optional[ListTuple["User"]] = None, configuration: Optional[Configuration] = None, **kwargs: Any, ,) -> None

[view_source]

Email a list of users

Arguments:

  • users ListTuple[User] - List of users in To address
  • subject str - Email subject
  • text_body str - Plain text email body
  • html_body str - HTML email body
  • sender Optional[str] - Email sender. Defaults to SMTP username. cc (Optional[ListTuple[User]]: List of users to cc. Defaults to None. bcc (Optional[ListTuple[User]]: List of users to bcc. Defaults to None.
  • configuration Optional[Configuration] - HDX configuration. Defaults to configuration of first user in list.
  • **kwargs - See below
  • mail_options List - Mail options (see smtplib documentation)
  • rcpt_options List - Recipient options (see smtplib documentation)

Returns:

None

get_organizations

def get_organizations(permission: str = "read") -> List["Organization"]

[view_source]

Get organizations in HDX that this user is a member of.

Arguments:

  • permission str - Permission to check for. Defaults to 'read'.

Returns:

  • List[Organization] - List of organizations in HDX that this user is a member of

autocomplete

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

[view_source]

Autocomplete a user 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