联 系 我 们
售前咨询
售后咨询
微信关注:星环科技服务号
更多联系方式 >
8.10 ACL Related Operations
更新时间:12/16/2024, 3:28:36 PM

Create User

user_created = hc.create_user(
    user_name = "test_user",
    pwd = "password123"
)
复制

Result:

This method returns a Boolean value to represent whether this operation is successful. If the error pops up when creating user, “ValueError” exception will be raised.

Parameter description:

Table 123. Create User (Python API)
Parameters Description Options

user_name (str)

New username

Yes

password (str)

New password

Yes

is_super (bool)

Whether this user is superuser

No, defaults to False

can_create_role (bool)

Whether this user can create role

No, defaults to False

can_create_db (bool)

Whether this user can create database

No, defaults to False

Check User

user_info = hc.get_user_info("user_name")
复制

Result:

This method returns a Dictionary containing the user information.

Parameter description:

Table 124. Check User (Python API)
Parameters Description Options

user_name (str)

Name of user to get information

Yes

Delete User

user_deleted = hc.delete_user("user_name")
复制

Result:

This method returns a Boolean value to represent whether this operation is successful. If the error pops up when deleting user, “ValueError” exception will be raised.

Parameter description:

Table 125. Delete User (Python API)
Parameters Description Required

user_name (str)

Username to be deleted

Yes

Alter User

changed = hc.change_user_info(user_name = "test_user", pwd = "password123", is_super = True)
复制

Result:

This method returns a Boolean value to represent whether this operation is successful. If the error pops up when altering user, “ValueError” exception will be raised.

Parameter description:

Table 126. Alter User (Python API)
Parameters Description Required

user_name (str)

Username to be changed

Yes

pwd (str)

New password

Yes

change_meta (bool)

Whether to change metadata

No, defaults to False

is_super (bool)

Whether this user is superuser

No, defaults to False

can_create_role (bool)

Whether this user can create role

No, defaults to False

can_create_db (bool)

Whether this user can create database

No, defaults to False

Change User Password
changed = hc.change_password(new_password = "another_new_password123", user_name = "test_user")
复制

Result:

This method returns a Boolean value to represent whether this operation is successful. If the error pops up when changing password, “ValueError” exception will be raised.

Parameter description:

Table 127. Change User Password (Python API)
Parameters Description Required

new_password (str)

New password of the specified user

Yes

user_name (str)

Name of user to change password, if not specified, the password of current user will be changed

No

Grant Privilege

granted = hc.grant_user_permission("user_name", ["all"], "table_name", "database_name")
复制

Result:

This method returns a Boolean value to represent whether this operation is successful. If the error pops up when granting privilege, “ValueError” exception will be raised.

Parameter description:

Table 128. Grant Privilege (Python API)
Parameters Description Required

user_name (str)

User to whom will be granted privileges

Yes

privileges (list[str])

Privilege list, including “create”, “access”, “all”

Yes

table_name (str)

Table name

No, grants privileges on "default" database if not specified. If user does not have privilege on "default" database, “ValueError” exception will be raised

database_name (str)

Database where the table is created

No, defaults to "default" database

Revoke Privilege

delete_grant = hc.delete_user_permission("test_user", ["all"], "my_test_rename", "my_database")
复制

Result:

This method returns a Boolean value to represent whether this operation is successful. If the error pops up when revoking privilege, “ValueError” exception will be raised.

Parameter description:

Table 129. Revoke Privilege (Python API)
Parameters Description Required

user_name (str)

User to whom will be revoked privileges

Yes

privileges (list[str])

Privilege list, including “create”, “access”, “all”

Yes

table_name (str)

Table name

No, revokes privileges on "default" database if not specified. If user does not have privilege on "default" database, “ValueError” exception will be raised

database_name (str)

Database where the table is created

No, defaults to "default" database

Check User Privilege

user_permission = hc.view_user_permission("user_name")
复制

Result:

This method returns a Dictionary containing user privilege information.

Parameter description:

Table 130. Check User Privilege (Python API)
Parameters Description Required

user_name (str)

User to check privilege

Yes

Check Table Privilege

table_permission = view_table_permission("table_name", "database_name")
复制

Result:

This method returns a Dictionary containing user privilege information.

Parameter description:

Table 131. Check Table Privilege (Python API)
Parameters Description Required

table_name (str)

Table to check privilege

Yes

database_name

Database where the table is located

No, defaults to "default" database