Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Removed

- A bullet item for the Removed category.

-->
<!--
### Added

- A bullet item for the Added category.

-->
<!--
### Changed

- A bullet item for the Changed category.

-->
<!--
### Deprecated

- A bullet item for the Deprecated category.

-->

### Fixed

- MembersParameters, TeamInvitationParameters, and TeamMembershipParameters now properly apply pagination and search queries.

<!--
### Security

- A bullet item for the Security category.

-->
17 changes: 14 additions & 3 deletions pygitguardian/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
FromDictMixin,
FromDictWithBase,
PaginationParameter,
PaginationParameterSchema,
SearchParameter,
SearchParameterSchema,
ToDictMixin,
)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/cassettes/test_delete_member.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird that we have cursor still present even though exclude_none was specified in the schemas

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because the default value for this one is an empty string and not None

response:
body:
string:
Expand Down
2 changes: 1 addition & 1 deletion tests/cassettes/test_delete_team_member.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]'
Expand Down
2 changes: 1 addition & 1 deletion tests/cassettes/test_list_members_parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[]'
Expand Down
2 changes: 1 addition & 1 deletion tests/cassettes/test_search_team_invitations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]'
Expand Down
2 changes: 1 addition & 1 deletion tests/cassettes/test_search_team_members.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]'
Expand Down
2 changes: 1 addition & 1 deletion tests/cassettes/test_update_member.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading