UserService#

class UserService[source]#

Methods

patch

Update the attributes of a user.

get_coupon_usages

Get all the coupons used for the specified user.

get_transactions

Get all transactions for the specified user.

get

Get the info of the currently logged in user.

login

Login using your username and password.

register

Create a new user.

logout

Revoke a given token.

search

Search for a user by name and username.

patch(json_body, *, user_id, extra_parameters=None)[source]#

Update the attributes of a user.

Parameters:
Returns:

The updated user.

Return type:

ExtendedUser

get_coupon_usages(*, user_id, extra_parameters=None)[source]#

Get all the coupons used for the specified user.

Parameters:
Returns:

All coupons used for the given user.

Return type:

Sequence[TenantCouponUsage | CourseCouponUsage]

get_transactions(*, user_id, extra_parameters=None)[source]#

Get all transactions for the specified user.

Parameters:
Returns:

All transactions for the given user.

Return type:

Sequence[ExtendedTransaction]

get(*, type='default', extended=False, with_permissions=False, extra_parameters=None)[source]#

Get the info of the currently logged in user.

Parameters:
  • type (Literal['default', 'extended', 'roles']) – If this is roles a mapping between course_id and role name will be returned, if this is extended an ExtendedUser instead of a User will be returned.

  • extended (bool) – If true this has the same effect as setting type to extended.

  • with_permissions (bool) – Setting this to true will add the key permissions to the user. The value will be a mapping indicating which global permissions this user has.

  • extra_parameters (Optional[Mapping[str, Union[str, bool, int, float]]]) – The extra query parameters you might want to add. By default no extra query parameters are added.

  • self (UserService[AuthenticatedClient]) –

Returns:

A response containing the JSON serialized user

Return type:

ExtendedUser | User | Mapping[str, str]

login(json_body, *, with_permissions=False, extra_parameters=None)[source]#

Login using your username and password.

permissions to the user. The value will be a mapping indicating which global permissions this user has.

Parameters:
  • json_body (Union[dict, list, LoginUserData_1, LoginUserData_1_2]) – The body of the request. See LoginUserData for information about the possible fields. You can provide this data as a LoginUserData or as a dictionary.

  • with_permissions (bool) – Return the global permissions of the newly logged in user.

  • extra_parameters (Optional[Mapping[str, Union[str, bool, int, float]]]) – The extra query parameters you might want to add. By default no extra query parameters are added.

Returns:

A response containing the JSON serialized user

Return type:

ResultDataPostUserLogin

register(json_body, *, extra_parameters=None)[source]#

Create a new user.

Parameters:
Returns:

The registered user and an access_token that can be used to perform requests as this new user.

Return type:

ResultDataPostUserRegister

logout(multipart_data, *, extra_parameters=None)[source]#

Revoke a given token.

Parameters:
Returns:

An empty 200 response.

Return type:

LogoutResponse

search(*, q, exclude_course=Nothing, extra_parameters=None)[source]#

Search for a user by name and username.

Parameters:
  • q (str) – The string to search for, all SQL wildcard are escaped and spaces are replaced by wildcards.

  • exclude_course (Union[Just[int], _Nothing[int]]) – Exclude all users that are in the given course from the search results. You need the permission can_list_course_users on this course to use this parameter.

  • extra_parameters (Optional[Mapping[str, Union[str, bool, int, float]]]) – The extra query parameters you might want to add. By default no extra query parameters are added.

  • self (UserService[AuthenticatedClient]) –

Returns:

The users that match the given query string.

Return type:

Sequence[User]