hdx.data.user
User class containing all logic for creating, checking, and updating users.
User Objects
class User(HDXObject)
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]
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.yaml")) -> None
Update user metadata with static metadata from YAML file
Arguments:
path
Optional[str] - Path to YAML dataset metadata. Defaults to config/hdx_user_static.yaml.
Returns:
None
update_from_json
def update_from_json(path: str = join("config",
"hdx_user_static.json")) -> None
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"]
Reads the user given by identifier from HDX and returns User object
Arguments:
identifier
str - Identifier of userconfiguration
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
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
Check if user exists in HDX and if so, update user
Returns:
None
create_in_hdx
def create_in_hdx(**kwargs: Any) -> None
Check if user exists in HDX and if so, update it, otherwise create user
Returns:
None
delete_from_hdx
def delete_from_hdx() -> None
Deletes a user from HDX.
Returns:
None
def email(subject: str,
text_body: str,
html_body: Optional[str] = None,
sender: Optional[str] = None,
**kwargs: Any) -> None
Emails a user.
Arguments:
subject
str - Email subjecttext_body
str - Plain text email bodyhtml_body
str - HTML email bodysender
Optional[str] - Email sender. Defaults to SMTP username.**kwargs
- See belowmail_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"]
Get all users in HDX
Arguments:
configuration
Optional[Configuration] - HDX configuration. Defaults to global configuration.**kwargs
- See belowq
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
Email a list of users
Arguments:
users
ListTuple[User] - List of users in To addresssubject
str - Email subjecttext_body
str - Plain text email bodyhtml_body
str - HTML email bodysender
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 belowmail_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"]
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
Autocomplete a user name and return matches
Arguments:
name
str - Name to autocompletelimit
int - Maximum number of matches to returnconfiguration
Optional[Configuration] - HDX configuration. Defaults to global configuration.
Returns:
List
- Autocomplete matches