From fc8a71ef22dd5fd4edcbf39b355677b88f5ba9ed Mon Sep 17 00:00:00 2001 From: omegaup-bot Date: Fri, 27 Sep 2024 17:45:19 +0000 Subject: [PATCH] omegaUp API change for "Unify languages with `languages.json` (#7819)" API changes from https://github.com/omegaup/omegaup/commit/bbb7b200b809a6f8175b795ebba59e3d6ad57c51 --- omegaup/api.py | 324 ++++++++++++++++++++++++++++--------------------- 1 file changed, 185 insertions(+), 139 deletions(-) diff --git a/omegaup/api.py b/omegaup/api.py index 71d3a55..a5ae8e2 100644 --- a/omegaup/api.py +++ b/omegaup/api.py @@ -2853,27 +2853,21 @@ def __init__( @dataclasses.dataclass class _ContestListPayload: """_ContestListPayload""" - contests: Dict[str, Sequence['_ContestListItem']] - countContests: Dict[str, int] - isLogged: bool + contests: Sequence['_ContestListItem'] + countContests: int query: Optional[str] def __init__( self, *, - contests: Dict[str, Sequence[Dict[str, Any]]], - countContests: Dict[str, int], - isLogged: bool, + contests: Sequence[Dict[str, Any]], + countContests: int, query: Optional[str] = None, # Ignore any unknown arguments **_kwargs: Any, ): - self.contests = { - k: [_ContestListItem(**v) for v in v] - for k, v in contests.items() - } - self.countContests = {k: v for k, v in countContests.items()} - self.isLogged = isLogged + self.contests = [_ContestListItem(**v) for v in contests] + self.countContests = countContests if query is not None: self.query = query else: @@ -4772,6 +4766,27 @@ def __init__( self.start_time = datetime.datetime.fromtimestamp(start_time) +@dataclasses.dataclass +class _FullIDEPayload: + """_FullIDEPayload""" + acceptedLanguages: Sequence[str] + preferredLanguage: Optional[str] + + def __init__( + self, + *, + acceptedLanguages: Sequence[str], + preferredLanguage: Optional[str] = None, + # Ignore any unknown arguments + **_kwargs: Any, + ): + self.acceptedLanguages = [v for v in acceptedLanguages] + if preferredLanguage is not None: + self.preferredLanguage = preferredLanguage + else: + self.preferredLanguage = None + + @dataclasses.dataclass class _GraderStatus: """_GraderStatus""" @@ -9233,7 +9248,9 @@ def __init__( class _OmegaUp_Controllers_User__apiExtraInformation: """_OmegaUp_Controllers_User__apiExtraInformation""" birth_date: Optional[datetime.datetime] + email: Optional[str] last_login: Optional[datetime.datetime] + roles: Sequence[str] username: str verified: bool within_last_day: bool @@ -9241,10 +9258,12 @@ class _OmegaUp_Controllers_User__apiExtraInformation: def __init__( self, *, + roles: Sequence[str], username: str, verified: bool, within_last_day: bool, birth_date: Optional[int] = None, + email: Optional[str] = None, last_login: Optional[int] = None, # Ignore any unknown arguments **_kwargs: Any, @@ -9253,10 +9272,15 @@ def __init__( self.birth_date = datetime.datetime.fromtimestamp(birth_date) else: self.birth_date = None + if email is not None: + self.email = email + else: + self.email = None if last_login is not None: self.last_login = datetime.datetime.fromtimestamp(last_login) else: self.last_login = None + self.roles = [v for v in roles] self.username = username self.verified = verified self.within_last_day = within_last_day @@ -13365,17 +13389,40 @@ class _SubmissionsListPayload: """_SubmissionsListPayload""" includeUser: bool submissions: Sequence['_Submission'] + username: Optional[str] def __init__( self, *, includeUser: bool, submissions: Sequence[Dict[str, Any]], + username: Optional[str] = None, # Ignore any unknown arguments **_kwargs: Any, ): self.includeUser = includeUser self.submissions = [_Submission(**v) for v in submissions] + if username is not None: + self.username = username + else: + self.username = None + + +@dataclasses.dataclass +class _SupportDetailsPayload: + """_SupportDetailsPayload""" + roleNamesWithDescription: Sequence['_UserRole'] + + def __init__( + self, + *, + roleNamesWithDescription: Sequence[Dict[str, Any]], + # Ignore any unknown arguments + **_kwargs: Any, + ): + self.roleNamesWithDescription = [ + _UserRole(**v) for v in roleNamesWithDescription + ] @dataclasses.dataclass @@ -14256,15 +14303,21 @@ def __init__( @dataclasses.dataclass class _UserRole: """_UserRole""" + description: Optional[str] name: str def __init__( self, *, name: str, + description: Optional[str] = None, # Ignore any unknown arguments **_kwargs: Any, ): + if description is not None: + self.description = description + else: + self.description = None self.name = name @@ -15398,29 +15451,29 @@ def createVirtual( def create( self, *, - admission_mode: Optional[Any] = None, - alias: Optional[Any] = None, + finish_time: int, + start_time: int, + submissions_gap: int, + window_length: int, + admission_mode: Optional[str] = None, + alias: Optional[str] = None, check_plagiarism: Optional[bool] = None, contest_for_teams: Optional[bool] = None, - description: Optional[Any] = None, - feedback: Optional[Any] = None, - finish_time: Optional[Any] = None, - languages: Optional[Any] = None, + description: Optional[str] = None, + feedback: Optional[str] = None, + languages: Optional[str] = None, needs_basic_information: Optional[bool] = None, - penalty: Optional[Any] = None, - penalty_calc_policy: Optional[Any] = None, - penalty_type: Optional[Any] = None, - points_decay_factor: Optional[Any] = None, + penalty: Optional[int] = None, + penalty_calc_policy: Optional[str] = None, + penalty_type: Optional[str] = None, + points_decay_factor: Optional[float] = None, problems: Optional[str] = None, - requests_user_information: Optional[Any] = None, + requests_user_information: Optional[bool] = None, score_mode: Optional[str] = None, - scoreboard: Optional[Any] = None, - show_scoreboard_after: Optional[Any] = None, - start_time: Optional[Any] = None, - submissions_gap: Optional[Any] = None, + scoreboard: Optional[float] = None, + show_scoreboard_after: Optional[bool] = None, teams_group_alias: Optional[str] = None, - title: Optional[Any] = None, - window_length: Optional[int] = None, + title: Optional[str] = None, # Out-of-band parameters: files_: Optional[Mapping[str, BinaryIO]] = None, check_: bool = True, @@ -15428,13 +15481,16 @@ def create( r"""Creates a new contest Args: + finish_time: + start_time: + submissions_gap: + window_length: admission_mode: alias: check_plagiarism: contest_for_teams: description: feedback: - finish_time: languages: needs_basic_information: penalty: @@ -15446,41 +15502,41 @@ def create( score_mode: scoreboard: show_scoreboard_after: - start_time: - submissions_gap: teams_group_alias: title: - window_length: Returns: The API result object. """ - parameters: Dict[str, str] = {} + parameters: Dict[str, str] = { + 'finish_time': str(finish_time), + 'start_time': str(start_time), + 'submissions_gap': str(submissions_gap), + 'window_length': str(window_length), + } if admission_mode is not None: - parameters['admission_mode'] = str(admission_mode) + parameters['admission_mode'] = admission_mode if alias is not None: - parameters['alias'] = str(alias) + parameters['alias'] = alias if check_plagiarism is not None: parameters['check_plagiarism'] = str(check_plagiarism) if contest_for_teams is not None: parameters['contest_for_teams'] = str(contest_for_teams) if description is not None: - parameters['description'] = str(description) + parameters['description'] = description if feedback is not None: - parameters['feedback'] = str(feedback) - if finish_time is not None: - parameters['finish_time'] = str(finish_time) + parameters['feedback'] = feedback if languages is not None: - parameters['languages'] = str(languages) + parameters['languages'] = languages if needs_basic_information is not None: parameters['needs_basic_information'] = str( needs_basic_information) if penalty is not None: parameters['penalty'] = str(penalty) if penalty_calc_policy is not None: - parameters['penalty_calc_policy'] = str(penalty_calc_policy) + parameters['penalty_calc_policy'] = penalty_calc_policy if penalty_type is not None: - parameters['penalty_type'] = str(penalty_type) + parameters['penalty_type'] = penalty_type if points_decay_factor is not None: parameters['points_decay_factor'] = str(points_decay_factor) if problems is not None: @@ -15494,16 +15550,10 @@ def create( parameters['scoreboard'] = str(scoreboard) if show_scoreboard_after is not None: parameters['show_scoreboard_after'] = str(show_scoreboard_after) - if start_time is not None: - parameters['start_time'] = str(start_time) - if submissions_gap is not None: - parameters['submissions_gap'] = str(submissions_gap) if teams_group_alias is not None: parameters['teams_group_alias'] = teams_group_alias if title is not None: - parameters['title'] = str(title) - if window_length is not None: - parameters['window_length'] = str(window_length) + parameters['title'] = title self._client.query('/api/contest/create/', payload=parameters, files_=files_, @@ -16211,6 +16261,7 @@ def update( *, contest_alias: str, finish_time: int, + start_time: int, submissions_gap: int, window_length: int, admission_mode: Optional[str] = None, @@ -16219,19 +16270,18 @@ def update( contest_for_teams: Optional[bool] = None, default_show_all_contestants_in_scoreboard: Optional[bool] = None, description: Optional[str] = None, - feedback: Optional[Any] = None, - languages: Optional[Any] = None, + feedback: Optional[str] = None, + languages: Optional[str] = None, needs_basic_information: Optional[bool] = None, penalty: Optional[int] = None, - penalty_calc_policy: Optional[Any] = None, - penalty_type: Optional[Any] = None, + penalty_calc_policy: Optional[str] = None, + penalty_type: Optional[str] = None, points_decay_factor: Optional[float] = None, problems: Optional[str] = None, requests_user_information: Optional[str] = None, score_mode: Optional[str] = None, scoreboard: Optional[float] = None, show_scoreboard_after: Optional[bool] = None, - start_time: Optional[datetime.datetime] = None, teams_group_alias: Optional[str] = None, title: Optional[str] = None, # Out-of-band parameters: @@ -16244,6 +16294,7 @@ def update( Args: contest_alias: finish_time: + start_time: submissions_gap: window_length: admission_mode: @@ -16264,7 +16315,6 @@ def update( score_mode: scoreboard: show_scoreboard_after: - start_time: teams_group_alias: title: @@ -16274,6 +16324,7 @@ def update( parameters: Dict[str, str] = { 'contest_alias': contest_alias, 'finish_time': str(finish_time), + 'start_time': str(start_time), 'submissions_gap': str(submissions_gap), 'window_length': str(window_length), } @@ -16291,18 +16342,18 @@ def update( if description is not None: parameters['description'] = description if feedback is not None: - parameters['feedback'] = str(feedback) + parameters['feedback'] = feedback if languages is not None: - parameters['languages'] = str(languages) + parameters['languages'] = languages if needs_basic_information is not None: parameters['needs_basic_information'] = str( needs_basic_information) if penalty is not None: parameters['penalty'] = str(penalty) if penalty_calc_policy is not None: - parameters['penalty_calc_policy'] = str(penalty_calc_policy) + parameters['penalty_calc_policy'] = penalty_calc_policy if penalty_type is not None: - parameters['penalty_type'] = str(penalty_type) + parameters['penalty_type'] = penalty_type if points_decay_factor is not None: parameters['points_decay_factor'] = str(points_decay_factor) if problems is not None: @@ -16315,8 +16366,6 @@ def update( parameters['scoreboard'] = str(scoreboard) if show_scoreboard_after is not None: parameters['show_scoreboard_after'] = str(show_scoreboard_after) - if start_time is not None: - parameters['start_time'] = str(int(start_time.timestamp())) if teams_group_alias is not None: parameters['teams_group_alias'] = teams_group_alias if title is not None: @@ -16825,16 +16874,16 @@ def create( def createAssignment( self, *, + alias: str, + assignment_type: str, course_alias: str, - alias: Optional[Any] = None, - assignment_type: Optional[Any] = None, - description: Optional[Any] = None, - finish_time: Optional[Any] = None, - name: Optional[Any] = None, + description: str, + name: str, + start_time: datetime.datetime, + finish_time: Optional[datetime.datetime] = None, order: Optional[int] = None, problems: Optional[str] = None, - publish_time_delay: Optional[Any] = None, - start_time: Optional[Any] = None, + publish_time_delay: Optional[int] = None, unlimited_duration: Optional[bool] = None, # Out-of-band parameters: files_: Optional[Mapping[str, BinaryIO]] = None, @@ -16843,42 +16892,37 @@ def createAssignment( r"""API to Create an assignment Args: - course_alias: alias: assignment_type: + course_alias: description: - finish_time: name: + start_time: + finish_time: order: problems: publish_time_delay: - start_time: unlimited_duration: Returns: The API result object. """ parameters: Dict[str, str] = { + 'alias': alias, + 'assignment_type': assignment_type, 'course_alias': course_alias, + 'description': description, + 'name': name, + 'start_time': str(int(start_time.timestamp())), } - if alias is not None: - parameters['alias'] = str(alias) - if assignment_type is not None: - parameters['assignment_type'] = str(assignment_type) - if description is not None: - parameters['description'] = str(description) if finish_time is not None: - parameters['finish_time'] = str(finish_time) - if name is not None: - parameters['name'] = str(name) + parameters['finish_time'] = str(int(finish_time.timestamp())) if order is not None: parameters['order'] = str(order) if problems is not None: parameters['problems'] = problems if publish_time_delay is not None: parameters['publish_time_delay'] = str(publish_time_delay) - if start_time is not None: - parameters['start_time'] = str(start_time) if unlimited_duration is not None: parameters['unlimited_duration'] = str(unlimited_duration) self._client.query('/api/course/createAssignment/', @@ -19140,25 +19184,25 @@ def create( self, *, problem_alias: str, - visibility: str, allow_user_add_tags: Optional[bool] = None, email_clarifications: Optional[bool] = None, - extra_wall_time: Optional[Any] = None, + extra_wall_time: Optional[int] = None, group_score_policy: Optional[str] = None, - input_limit: Optional[Any] = None, - languages: Optional[Any] = None, - memory_limit: Optional[Any] = None, - output_limit: Optional[Any] = None, - overall_wall_time_limit: Optional[Any] = None, + input_limit: Optional[int] = None, + languages: Optional[str] = None, + memory_limit: Optional[int] = None, + output_limit: Optional[int] = None, + overall_wall_time_limit: Optional[int] = None, problem_level: Optional[str] = None, selected_tags: Optional[str] = None, show_diff: Optional[str] = None, source: Optional[str] = None, - time_limit: Optional[Any] = None, + time_limit: Optional[int] = None, title: Optional[str] = None, update_published: Optional[str] = None, validator: Optional[str] = None, - validator_time_limit: Optional[Any] = None, + validator_time_limit: Optional[int] = None, + visibility: Optional[str] = None, # Out-of-band parameters: files_: Optional[Mapping[str, BinaryIO]] = None, check_: bool = True, @@ -19167,7 +19211,6 @@ def create( Args: problem_alias: - visibility: allow_user_add_tags: email_clarifications: extra_wall_time: @@ -19186,13 +19229,13 @@ def create( update_published: validator: validator_time_limit: + visibility: Returns: The API result object. """ parameters: Dict[str, str] = { 'problem_alias': problem_alias, - 'visibility': visibility, } if allow_user_add_tags is not None: parameters['allow_user_add_tags'] = str(allow_user_add_tags) @@ -19205,7 +19248,7 @@ def create( if input_limit is not None: parameters['input_limit'] = str(input_limit) if languages is not None: - parameters['languages'] = str(languages) + parameters['languages'] = languages if memory_limit is not None: parameters['memory_limit'] = str(memory_limit) if output_limit is not None: @@ -19231,6 +19274,8 @@ def create( parameters['validator'] = validator if validator_time_limit is not None: parameters['validator_time_limit'] = str(validator_time_limit) + if visibility is not None: + parameters['visibility'] = visibility self._client.query('/api/problem/create/', payload=parameters, files_=files_, @@ -19553,25 +19598,25 @@ def update( *, message: str, problem_alias: str, + redirect: Union[bool, str], allow_user_add_tags: Optional[bool] = None, email_clarifications: Optional[bool] = None, - extra_wall_time: Optional[Any] = None, + extra_wall_time: Optional[int] = None, group_score_policy: Optional[str] = None, - input_limit: Optional[Any] = None, - languages: Optional[Any] = None, - memory_limit: Optional[Any] = None, - output_limit: Optional[Any] = None, - overall_wall_time_limit: Optional[Any] = None, + input_limit: Optional[int] = None, + languages: Optional[str] = None, + memory_limit: Optional[int] = None, + output_limit: Optional[int] = None, + overall_wall_time_limit: Optional[int] = None, problem_level: Optional[str] = None, - redirect: Optional[Any] = None, selected_tags: Optional[str] = None, show_diff: Optional[str] = None, source: Optional[str] = None, - time_limit: Optional[Any] = None, + time_limit: Optional[int] = None, title: Optional[str] = None, update_published: Optional[str] = None, validator: Optional[str] = None, - validator_time_limit: Optional[Any] = None, + validator_time_limit: Optional[int] = None, visibility: Optional[str] = None, # Out-of-band parameters: files_: Optional[Mapping[str, BinaryIO]] = None, @@ -19583,6 +19628,7 @@ def update( Args: message: problem_alias: + redirect: allow_user_add_tags: email_clarifications: extra_wall_time: @@ -19593,7 +19639,6 @@ def update( output_limit: overall_wall_time_limit: problem_level: - redirect: selected_tags: show_diff: source: @@ -19610,6 +19655,7 @@ def update( parameters: Dict[str, str] = { 'message': message, 'problem_alias': problem_alias, + 'redirect': str(redirect), } if allow_user_add_tags is not None: parameters['allow_user_add_tags'] = str(allow_user_add_tags) @@ -19622,7 +19668,7 @@ def update( if input_limit is not None: parameters['input_limit'] = str(input_limit) if languages is not None: - parameters['languages'] = str(languages) + parameters['languages'] = languages if memory_limit is not None: parameters['memory_limit'] = str(memory_limit) if output_limit is not None: @@ -19632,8 +19678,6 @@ def update( overall_wall_time_limit) if problem_level is not None: parameters['problem_level'] = problem_level - if redirect is not None: - parameters['redirect'] = str(redirect) if selected_tags is not None: parameters['selected_tags'] = selected_tags if show_diff is not None: @@ -19662,29 +19706,29 @@ def update( def updateStatement( self, *, + lang: str, message: str, problem_alias: str, statement: str, - visibility: str, allow_user_add_tags: Optional[bool] = None, email_clarifications: Optional[bool] = None, - extra_wall_time: Optional[Any] = None, + extra_wall_time: Optional[int] = None, group_score_policy: Optional[str] = None, - input_limit: Optional[Any] = None, - lang: Optional[Any] = None, - languages: Optional[Any] = None, - memory_limit: Optional[Any] = None, - output_limit: Optional[Any] = None, - overall_wall_time_limit: Optional[Any] = None, + input_limit: Optional[int] = None, + languages: Optional[str] = None, + memory_limit: Optional[int] = None, + output_limit: Optional[int] = None, + overall_wall_time_limit: Optional[int] = None, problem_level: Optional[str] = None, selected_tags: Optional[str] = None, show_diff: Optional[str] = None, source: Optional[str] = None, - time_limit: Optional[Any] = None, + time_limit: Optional[int] = None, title: Optional[str] = None, update_published: Optional[str] = None, validator: Optional[str] = None, - validator_time_limit: Optional[Any] = None, + validator_time_limit: Optional[int] = None, + visibility: Optional[str] = None, # Out-of-band parameters: files_: Optional[Mapping[str, BinaryIO]] = None, check_: bool = True, @@ -19692,16 +19736,15 @@ def updateStatement( r"""Updates problem statement only Args: + lang: message: problem_alias: statement: - visibility: allow_user_add_tags: email_clarifications: extra_wall_time: group_score_policy: input_limit: - lang: languages: memory_limit: output_limit: @@ -19715,15 +19758,16 @@ def updateStatement( update_published: validator: validator_time_limit: + visibility: Returns: The API result object. """ parameters: Dict[str, str] = { + 'lang': lang, 'message': message, 'problem_alias': problem_alias, 'statement': statement, - 'visibility': visibility, } if allow_user_add_tags is not None: parameters['allow_user_add_tags'] = str(allow_user_add_tags) @@ -19735,10 +19779,8 @@ def updateStatement( parameters['group_score_policy'] = group_score_policy if input_limit is not None: parameters['input_limit'] = str(input_limit) - if lang is not None: - parameters['lang'] = str(lang) if languages is not None: - parameters['languages'] = str(languages) + parameters['languages'] = languages if memory_limit is not None: parameters['memory_limit'] = str(memory_limit) if output_limit is not None: @@ -19764,6 +19806,8 @@ def updateStatement( parameters['validator'] = validator if validator_time_limit is not None: parameters['validator_time_limit'] = str(validator_time_limit) + if visibility is not None: + parameters['visibility'] = visibility self._client.query('/api/problem/updateStatement/', payload=parameters, files_=files_, @@ -19776,26 +19820,26 @@ def updateSolution( message: str, problem_alias: str, solution: str, - visibility: str, allow_user_add_tags: Optional[bool] = None, email_clarifications: Optional[bool] = None, - extra_wall_time: Optional[Any] = None, + extra_wall_time: Optional[int] = None, group_score_policy: Optional[str] = None, - input_limit: Optional[Any] = None, + input_limit: Optional[int] = None, lang: Optional[str] = None, - languages: Optional[Any] = None, - memory_limit: Optional[Any] = None, - output_limit: Optional[Any] = None, - overall_wall_time_limit: Optional[Any] = None, + languages: Optional[str] = None, + memory_limit: Optional[int] = None, + output_limit: Optional[int] = None, + overall_wall_time_limit: Optional[int] = None, problem_level: Optional[str] = None, selected_tags: Optional[str] = None, show_diff: Optional[str] = None, source: Optional[str] = None, - time_limit: Optional[Any] = None, + time_limit: Optional[int] = None, title: Optional[str] = None, update_published: Optional[str] = None, validator: Optional[str] = None, - validator_time_limit: Optional[Any] = None, + validator_time_limit: Optional[int] = None, + visibility: Optional[str] = None, # Out-of-band parameters: files_: Optional[Mapping[str, BinaryIO]] = None, check_: bool = True, @@ -19806,7 +19850,6 @@ def updateSolution( message: problem_alias: solution: - visibility: allow_user_add_tags: email_clarifications: extra_wall_time: @@ -19826,6 +19869,7 @@ def updateSolution( update_published: validator: validator_time_limit: + visibility: Returns: The API result object. @@ -19834,7 +19878,6 @@ def updateSolution( 'message': message, 'problem_alias': problem_alias, 'solution': solution, - 'visibility': visibility, } if allow_user_add_tags is not None: parameters['allow_user_add_tags'] = str(allow_user_add_tags) @@ -19849,7 +19892,7 @@ def updateSolution( if lang is not None: parameters['lang'] = lang if languages is not None: - parameters['languages'] = str(languages) + parameters['languages'] = languages if memory_limit is not None: parameters['memory_limit'] = str(memory_limit) if output_limit is not None: @@ -19875,6 +19918,8 @@ def updateSolution( parameters['validator'] = validator if validator_time_limit is not None: parameters['validator_time_limit'] = str(validator_time_limit) + if visibility is not None: + parameters['visibility'] = visibility self._client.query('/api/problem/updateSolution/', payload=parameters, files_=files_, @@ -22486,7 +22531,7 @@ def statusVerified( def extraInformation( self, *, - email: str, + usernameOrEmail: str, # Out-of-band parameters: files_: Optional[Mapping[str, BinaryIO]] = None, check_: bool = True, @@ -22496,15 +22541,16 @@ def extraInformation( - last password change request - verify status - birth date to verify the user identity + - roles assigned to user Args: - email: + usernameOrEmail: Returns: The API result object. """ parameters: Dict[str, str] = { - 'email': email, + 'usernameOrEmail': usernameOrEmail, } return _OmegaUp_Controllers_User__apiExtraInformation( **self._client.query('/api/user/extraInformation/',