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
2 changes: 1 addition & 1 deletion codegen/templates/rest/_request.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ if self._github.config.rest_api_validate_body:
"{{ endpoint.method | upper }}",
url,
{% if endpoint.query_params %}
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
{% endif %}
{% if endpoint.request_body %}
{% set name = TYPE_MAPPING[endpoint.request_body.type] %}
Expand Down
2 changes: 1 addition & 1 deletion codegen/templates/rest/client.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ from typing import TYPE_CHECKING, Literal, Optional, Annotated, overload
from pydantic import BaseModel, Field

from githubkit.typing import Missing, UnsetType
from githubkit.utils import exclude_unset, UNSET
from githubkit.utils import UNSET, exclude_unset, parse_query_params
from githubkit.compat import model_dump, type_validate_python

if TYPE_CHECKING:
Expand Down
13 changes: 13 additions & 0 deletions githubkit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ def is_async(obj: Any) -> bool:
return inspect.iscoroutinefunction(func_)


def parse_query_params(params: dict[str, Any]) -> dict[str, Any]:
"""GitHub query params use `name[]` format to send an array.

See also: https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api?apiVersion=2022-11-28
"""
new_params: dict[str, Any] = {}
for key, value in params.items():
if isinstance(value, list):
key = f"{key}[]"
new_params[key] = value
return new_params


class TaggedUnion(Generic[T]):
__slots__ = ("discriminator", "tag", "type_")

Expand Down
130 changes: 65 additions & 65 deletions githubkit/versions/ghec_v2022_11_28/rest/actions.py

Large diffs are not rendered by default.

70 changes: 35 additions & 35 deletions githubkit/versions/ghec_v2022_11_28/rest/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from githubkit.compat import model_dump, type_validate_python
from githubkit.typing import Missing, UnsetType
from githubkit.utils import UNSET, exclude_unset
from githubkit.utils import UNSET, exclude_unset, parse_query_params

if TYPE_CHECKING:
from datetime import datetime
Expand Down Expand Up @@ -113,7 +113,7 @@ def list_public_events(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -159,7 +159,7 @@ async def async_list_public_events(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -287,7 +287,7 @@ def list_public_events_for_repo_network(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -331,7 +331,7 @@ async def async_list_public_events_for_repo_network(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -380,7 +380,7 @@ def list_notifications_for_authenticated_user(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Thread],
Expand Down Expand Up @@ -430,7 +430,7 @@ async def async_list_notifications_for_authenticated_user(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Thread],
Expand Down Expand Up @@ -1090,7 +1090,7 @@ def list_public_org_events(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -1129,7 +1129,7 @@ async def async_list_public_org_events(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -1169,7 +1169,7 @@ def list_repo_events(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -1209,7 +1209,7 @@ async def async_list_repo_events(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -1256,7 +1256,7 @@ def list_repo_notifications_for_authenticated_user(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Thread],
Expand Down Expand Up @@ -1303,7 +1303,7 @@ async def async_list_repo_notifications_for_authenticated_user(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Thread],
Expand Down Expand Up @@ -1507,7 +1507,7 @@ def list_stargazers_for_repo(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=Union[list[SimpleUser], list[Stargazer]],
Expand Down Expand Up @@ -1558,7 +1558,7 @@ async def async_list_stargazers_for_repo(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=Union[list[SimpleUser], list[Stargazer]],
Expand Down Expand Up @@ -1600,7 +1600,7 @@ def list_watchers_for_repo(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[SimpleUser],
Expand Down Expand Up @@ -1639,7 +1639,7 @@ async def async_list_watchers_for_repo(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[SimpleUser],
Expand Down Expand Up @@ -1942,7 +1942,7 @@ def list_repos_starred_by_authenticated_user(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Repository],
Expand Down Expand Up @@ -1991,7 +1991,7 @@ async def async_list_repos_starred_by_authenticated_user(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Repository],
Expand Down Expand Up @@ -2242,7 +2242,7 @@ def list_watched_repos_for_authenticated_user(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[MinimalRepository],
Expand Down Expand Up @@ -2283,7 +2283,7 @@ async def async_list_watched_repos_for_authenticated_user(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[MinimalRepository],
Expand Down Expand Up @@ -2328,7 +2328,7 @@ def list_events_for_authenticated_user(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -2369,7 +2369,7 @@ async def async_list_events_for_authenticated_user(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -2411,7 +2411,7 @@ def list_org_events_for_authenticated_user(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -2453,7 +2453,7 @@ async def async_list_org_events_for_authenticated_user(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -2492,7 +2492,7 @@ def list_public_events_for_user(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -2531,7 +2531,7 @@ async def async_list_public_events_for_user(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -2573,7 +2573,7 @@ def list_received_events_for_user(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -2615,7 +2615,7 @@ async def async_list_received_events_for_user(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -2654,7 +2654,7 @@ def list_received_public_events_for_user(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -2693,7 +2693,7 @@ async def async_list_received_public_events_for_user(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[Event],
Expand Down Expand Up @@ -2744,7 +2744,7 @@ def list_repos_starred_by_user(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=Union[list[StarredRepository], list[Repository]],
Expand Down Expand Up @@ -2795,7 +2795,7 @@ async def async_list_repos_starred_by_user(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=Union[list[StarredRepository], list[Repository]],
Expand Down Expand Up @@ -2833,7 +2833,7 @@ def list_repos_watched_by_user(
return self._github.request(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[MinimalRepository],
Expand Down Expand Up @@ -2871,7 +2871,7 @@ async def async_list_repos_watched_by_user(
return await self._github.arequest(
"GET",
url,
params=exclude_unset(params),
params=exclude_unset(parse_query_params(params)),
headers=exclude_unset(headers),
stream=stream,
response_model=list[MinimalRepository],
Expand Down
Loading