diff --git a/changelog.d/20251127_095825_arnaud.lustrat_fix_pagination_parameters.md b/changelog.d/20251127_095825_arnaud.lustrat_fix_pagination_parameters.md new file mode 100644 index 00000000..08c2acef --- /dev/null +++ b/changelog.d/20251127_095825_arnaud.lustrat_fix_pagination_parameters.md @@ -0,0 +1,41 @@ + + + + + + + +### Fixed + +- MembersParameters, TeamInvitationParameters, and TeamMembershipParameters now properly apply pagination and search queries. + + diff --git a/pygitguardian/models.py b/pygitguardian/models.py index 34ff1b08..4c1af9b2 100644 --- a/pygitguardian/models.py +++ b/pygitguardian/models.py @@ -30,7 +30,9 @@ FromDictMixin, FromDictWithBase, PaginationParameter, + PaginationParameterSchema, SearchParameter, + SearchParameterSchema, ToDictMixin, ) @@ -1113,7 +1115,10 @@ class MembersParameters(PaginationParameter, SearchParameter, ToDictMixin): ] = None -class MembersParametersSchema(BaseSchema): +class MembersParametersSchema( + PaginationParameterSchema, + SearchParameterSchema, # pyright: ignore[reportGeneralTypeIssues] +): access_level = fields.Enum(AccessLevel, by_value=True, allow_none=True) active = fields.Bool(allow_none=True) ordering = fields.Str(allow_none=True) @@ -1298,7 +1303,10 @@ class TeamInvitationParameters(PaginationParameter, ToDictMixin): incident_permission: Optional[IncidentPermission] = None -class TeamInvitationParameterSchema(BaseSchema): +class TeamInvitationParameterSchema( + PaginationParameterSchema, + SearchParameterSchema, # pyright: ignore[reportGeneralTypeIssues] +): invitation_id = fields.Int(allow_none=True) is_team_leader = fields.Bool(allow_none=True) incident_permission = fields.Enum( @@ -1374,7 +1382,10 @@ class TeamMemberParameters(PaginationParameter, SearchParameter, ToDictMixin): member_id: Optional[int] = None -class TeamMembershipParameterSchema(BaseSchema): +class TeamMembershipParameterSchema( + PaginationParameterSchema, + SearchParameterSchema, # pyright: ignore[reportGeneralTypeIssues] +): is_team_leader = fields.Bool(allow_none=True) incident_permission = fields.Enum( IncidentPermission, by_value=True, allow_none=True diff --git a/tests/cassettes/test_delete_member.yaml b/tests/cassettes/test_delete_member.yaml index a23650d4..fb066c69 100644 --- a/tests/cassettes/test_delete_member.yaml +++ b/tests/cassettes/test_delete_member.yaml @@ -11,7 +11,7 @@ interactions: User-Agent: - pygitguardian/1.18.0 (Darwin;py3.11.8) method: GET - uri: https://api.gitguardian.com/v1/members?access_level=member + uri: https://api.gitguardian.com/v1/members?cursor=&per_page=20&access_level=member response: body: string: diff --git a/tests/cassettes/test_delete_team_member.yaml b/tests/cassettes/test_delete_team_member.yaml index 024b065b..ee0b3adf 100644 --- a/tests/cassettes/test_delete_team_member.yaml +++ b/tests/cassettes/test_delete_team_member.yaml @@ -125,7 +125,7 @@ interactions: User-Agent: - pygitguardian/1.18.0 (Darwin;py3.11.8) method: GET - uri: https://api.gitguardian.com/v1/teams/19/team_memberships?is_team_leader=False + uri: https://api.gitguardian.com/v1/teams/19/team_memberships?cursor=&per_page=20&is_team_leader=False response: body: string: '[{"id":29,"team_id":19,"member_id":17,"is_team_leader":false,"team_permission":"cannot_manage","incident_permission":"can_view"}]' diff --git a/tests/cassettes/test_list_members_parameters.yaml b/tests/cassettes/test_list_members_parameters.yaml index e01731b7..11c5dc4c 100644 --- a/tests/cassettes/test_list_members_parameters.yaml +++ b/tests/cassettes/test_list_members_parameters.yaml @@ -11,7 +11,7 @@ interactions: User-Agent: - pygitguardian/1.18.0 (Darwin;py3.11.8) method: GET - uri: https://api.gitguardian.com/v1/members?access_level=manager + uri: https://api.gitguardian.com/v1/members?cursor=&per_page=20&access_level=manager response: body: string: '[]' diff --git a/tests/cassettes/test_search_team_invitations.yaml b/tests/cassettes/test_search_team_invitations.yaml index cc7e7ed6..fd9a4d4e 100644 --- a/tests/cassettes/test_search_team_invitations.yaml +++ b/tests/cassettes/test_search_team_invitations.yaml @@ -68,7 +68,7 @@ interactions: User-Agent: - pygitguardian/1.18.0 (Darwin;py3.11.8) method: GET - uri: https://api.gitguardian.com/v1/teams/19/team_invitations?incident_permission=can_view + uri: https://api.gitguardian.com/v1/teams/19/team_invitations?cursor=&per_page=20&incident_permission=can_view response: body: string: '[{"id":7,"team_id":19,"invitation_id":13,"is_team_leader":true,"team_permission":"can_manage","incident_permission":"can_view"}]' diff --git a/tests/cassettes/test_search_team_members.yaml b/tests/cassettes/test_search_team_members.yaml index a873183a..f28daf8a 100644 --- a/tests/cassettes/test_search_team_members.yaml +++ b/tests/cassettes/test_search_team_members.yaml @@ -68,7 +68,7 @@ interactions: User-Agent: - pygitguardian/1.18.0 (Darwin;py3.11.8) method: GET - uri: https://api.gitguardian.com/v1/teams/19/team_memberships?is_team_leader=True + uri: https://api.gitguardian.com/v1/teams/19/team_memberships?cursor=&per_page=20&is_team_leader=True response: body: string: '[{"id":23,"team_id":19,"member_id":6,"is_team_leader":true,"team_permission":"can_manage","incident_permission":"full_access"}]' diff --git a/tests/cassettes/test_update_member.yaml b/tests/cassettes/test_update_member.yaml index 1125709f..d640bd97 100644 --- a/tests/cassettes/test_update_member.yaml +++ b/tests/cassettes/test_update_member.yaml @@ -11,7 +11,7 @@ interactions: User-Agent: - pygitguardian/1.18.0 (Darwin;py3.11.8) method: GET - uri: https://api.gitguardian.com/v1/members?access_level=manager + uri: https://api.gitguardian.com/v1/members?cursor=&per_page=20&access_level=manager response: body: string: