UserService#
- class UserService[source]#
Methods
Update the attributes of a user.
Get all the coupons used for the specified user.
Get all transactions for the specified user.
Get the info of the currently logged in user.
Login using your username and password.
Create a new user.
Revoke a given token.
Search for a user by name and username.
- patch(json_body, *, user_id, extra_parameters=None)[source]#
Update the attributes of a user.
- Parameters:
json_body (
Union
[dict
,list
,PatchUserData
]) – The body of the request. SeePatchUserData
for information about the possible fields. You can provide this data as aPatchUserData
or as a dictionary.user_id (
int
) – The id of the user you want to change. Currently this can only be your own user id.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 updated user.
- Return type:
- 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:
- 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:
- 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. SeeLoginUserData
for information about the possible fields. You can provide this data as aLoginUserData
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:
- register(json_body, *, extra_parameters=None)[source]#
Create a new user.
- Parameters:
json_body (
Union
[dict
,list
,RegisterUserData
]) – The body of the request. SeeRegisterUserData
for information about the possible fields. You can provide this data as aRegisterUserData
or as a dictionary.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:
The registered user and an access_token that can be used to perform requests as this new user.
- Return type:
- logout(multipart_data, *, extra_parameters=None)[source]#
Revoke a given token.
- Parameters:
multipart_data (
Union
[dict
,list
,LogoutUserData
]) – The data that should form the body of the request. SeeLogoutUserData
for information about the possible fields.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:
An empty 200 response.
- Return type:
- 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: