Skip to content

Commit 333311a

Browse files
feat(api): add pagination and query parameter to runners.list_scm_organizations
1 parent c318e03 commit 333311a

7 files changed

Lines changed: 182 additions & 32 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 193
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gitpod%2Fgitpod-2e21ce480356fd18cc413421d9d85ef46d7ebd7961518933cfb5b469799c57d7.yml
3-
openapi_spec_hash: f558f68f695c3c21bf10252e3505fdf1
4-
config_hash: 52dce9b7b86eca30b5b126335592f962
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gitpod%2Fgitpod-162fdc304a6f1f8e282b49c7cde2e2aa282e58045ac814869491340f932982d4.yml
3+
openapi_spec_hash: 017607fc78184b5a49249ed134e1ad7c
4+
config_hash: 4447d1e1149a80d1bec70d353fb8acbf

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ Methods:
710710
- <code title="post /gitpod.v1.RunnerService/CheckRepositoryAccess">client.runners.<a href="./src/gitpod/resources/runners/runners.py">check_repository_access</a>(\*\*<a href="src/gitpod/types/runner_check_repository_access_params.py">params</a>) -> <a href="./src/gitpod/types/runner_check_repository_access_response.py">RunnerCheckRepositoryAccessResponse</a></code>
711711
- <code title="post /gitpod.v1.RunnerService/CreateRunnerLogsToken">client.runners.<a href="./src/gitpod/resources/runners/runners.py">create_logs_token</a>(\*\*<a href="src/gitpod/types/runner_create_logs_token_params.py">params</a>) -> <a href="./src/gitpod/types/runner_create_logs_token_response.py">RunnerCreateLogsTokenResponse</a></code>
712712
- <code title="post /gitpod.v1.RunnerService/CreateRunnerToken">client.runners.<a href="./src/gitpod/resources/runners/runners.py">create_runner_token</a>(\*\*<a href="src/gitpod/types/runner_create_runner_token_params.py">params</a>) -> <a href="./src/gitpod/types/runner_create_runner_token_response.py">RunnerCreateRunnerTokenResponse</a></code>
713-
- <code title="post /gitpod.v1.RunnerService/ListSCMOrganizations">client.runners.<a href="./src/gitpod/resources/runners/runners.py">list_scm_organizations</a>(\*\*<a href="src/gitpod/types/runner_list_scm_organizations_params.py">params</a>) -> <a href="./src/gitpod/types/runner_list_scm_organizations_response.py">RunnerListScmOrganizationsResponse</a></code>
713+
- <code title="post /gitpod.v1.RunnerService/ListSCMOrganizations">client.runners.<a href="./src/gitpod/resources/runners/runners.py">list_scm_organizations</a>(\*\*<a href="src/gitpod/types/runner_list_scm_organizations_params.py">params</a>) -> <a href="./src/gitpod/types/runner_list_scm_organizations_response.py">SyncOrganizationsPage[RunnerListScmOrganizationsResponse]</a></code>
714714
- <code title="post /gitpod.v1.RunnerService/ParseContextURL">client.runners.<a href="./src/gitpod/resources/runners/runners.py">parse_context_url</a>(\*\*<a href="src/gitpod/types/runner_parse_context_url_params.py">params</a>) -> <a href="./src/gitpod/types/runner_parse_context_url_response.py">RunnerParseContextURLResponse</a></code>
715715
- <code title="post /gitpod.v1.RunnerService/SearchRepositories">client.runners.<a href="./src/gitpod/resources/runners/runners.py">search_repositories</a>(\*\*<a href="src/gitpod/types/runner_search_repositories_params.py">params</a>) -> <a href="./src/gitpod/types/runner_search_repositories_response.py">RunnerSearchRepositoriesResponse</a></code>
716716

src/gitpod/pagination.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
"MembersPagePagination",
5252
"SyncMembersPage",
5353
"AsyncMembersPage",
54+
"OrganizationsPagePagination",
55+
"SyncOrganizationsPage",
56+
"AsyncOrganizationsPage",
5457
"OutputsPagePagination",
5558
"SyncOutputsPage",
5659
"AsyncOutputsPage",
@@ -819,6 +822,56 @@ def next_page_info(self) -> Optional[PageInfo]:
819822
return PageInfo(params={"token": next_token})
820823

821824

825+
class OrganizationsPagePagination(BaseModel):
826+
next_token: Optional[str] = FieldInfo(alias="nextToken", default=None)
827+
828+
829+
class SyncOrganizationsPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
830+
organizations: List[_T]
831+
pagination: Optional[OrganizationsPagePagination] = None
832+
833+
@override
834+
def _get_page_items(self) -> List[_T]:
835+
organizations = self.organizations
836+
if not organizations:
837+
return []
838+
return organizations
839+
840+
@override
841+
def next_page_info(self) -> Optional[PageInfo]:
842+
next_token = None
843+
if self.pagination is not None:
844+
if self.pagination.next_token is not None:
845+
next_token = self.pagination.next_token
846+
if not next_token:
847+
return None
848+
849+
return PageInfo(params={"token": next_token})
850+
851+
852+
class AsyncOrganizationsPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
853+
organizations: List[_T]
854+
pagination: Optional[OrganizationsPagePagination] = None
855+
856+
@override
857+
def _get_page_items(self) -> List[_T]:
858+
organizations = self.organizations
859+
if not organizations:
860+
return []
861+
return organizations
862+
863+
@override
864+
def next_page_info(self) -> Optional[PageInfo]:
865+
next_token = None
866+
if self.pagination is not None:
867+
if self.pagination.next_token is not None:
868+
next_token = self.pagination.next_token
869+
if not next_token:
870+
return None
871+
872+
return PageInfo(params={"token": next_token})
873+
874+
822875
class OutputsPagePagination(BaseModel):
823876
next_token: Optional[str] = FieldInfo(alias="nextToken", default=None)
824877

src/gitpod/resources/runners/runners.py

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
async_to_raw_response_wrapper,
4242
async_to_streamed_response_wrapper,
4343
)
44-
from ...pagination import SyncRunnersPage, AsyncRunnersPage
44+
from ...pagination import SyncRunnersPage, AsyncRunnersPage, SyncOrganizationsPage, AsyncOrganizationsPage
4545
from ..._base_client import AsyncPaginator, make_request_options
4646
from ...types.runner import Runner
4747
from ...types.runner_kind import RunnerKind
@@ -681,6 +681,8 @@ def list_scm_organizations(
681681
*,
682682
token: str | Omit = omit,
683683
page_size: int | Omit = omit,
684+
pagination: runner_list_scm_organizations_params.Pagination | Omit = omit,
685+
query: str | Omit = omit,
684686
runner_id: str | Omit = omit,
685687
scm_host: str | Omit = omit,
686688
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -689,7 +691,7 @@ def list_scm_organizations(
689691
extra_query: Query | None = None,
690692
extra_body: Body | None = None,
691693
timeout: float | httpx.Timeout | None | NotGiven = not_given,
692-
) -> RunnerListScmOrganizationsResponse:
694+
) -> SyncOrganizationsPage[RunnerListScmOrganizationsResponse]:
693695
"""
694696
Lists SCM organizations the user belongs to.
695697
@@ -709,7 +711,29 @@ def list_scm_organizations(
709711
scmHost: "github.com"
710712
```
711713
714+
- Search GitLab groups:
715+
716+
Returns the first page of GitLab groups matching the substring.
717+
718+
```yaml
719+
runnerId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
720+
scmHost: "gitlab.com"
721+
query: "platform"
722+
pagination:
723+
pageSize: 25
724+
```
725+
712726
Args:
727+
pagination: Pagination parameters. When unset, defaults to the standard PaginationRequest
728+
defaults (page_size 25, max 100). Tokens are opaque and provider-specific.
729+
730+
query: Optional substring filter applied to the organization name.
731+
732+
- GitLab: forwarded to the upstream `search` parameter (server-side,
733+
case-insensitive substring on name/path).
734+
- GitHub and Bitbucket: not implemented as they don't support searching Empty
735+
value means no filter.
736+
713737
scm_host: The SCM host to list organizations from (e.g., "github.com", "gitlab.com")
714738
715739
extra_headers: Send extra headers
@@ -720,10 +744,13 @@ def list_scm_organizations(
720744
721745
timeout: Override the client-level default timeout for this request, in seconds
722746
"""
723-
return self._post(
747+
return self._get_api_list(
724748
"/gitpod.v1.RunnerService/ListSCMOrganizations",
749+
page=SyncOrganizationsPage[RunnerListScmOrganizationsResponse],
725750
body=maybe_transform(
726751
{
752+
"pagination": pagination,
753+
"query": query,
727754
"runner_id": runner_id,
728755
"scm_host": scm_host,
729756
},
@@ -742,7 +769,8 @@ def list_scm_organizations(
742769
runner_list_scm_organizations_params.RunnerListScmOrganizationsParams,
743770
),
744771
),
745-
cast_to=RunnerListScmOrganizationsResponse,
772+
model=RunnerListScmOrganizationsResponse,
773+
method="post",
746774
)
747775

748776
def parse_context_url(
@@ -1505,11 +1533,13 @@ async def create_runner_token(
15051533
cast_to=RunnerCreateRunnerTokenResponse,
15061534
)
15071535

1508-
async def list_scm_organizations(
1536+
def list_scm_organizations(
15091537
self,
15101538
*,
15111539
token: str | Omit = omit,
15121540
page_size: int | Omit = omit,
1541+
pagination: runner_list_scm_organizations_params.Pagination | Omit = omit,
1542+
query: str | Omit = omit,
15131543
runner_id: str | Omit = omit,
15141544
scm_host: str | Omit = omit,
15151545
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -1518,7 +1548,7 @@ async def list_scm_organizations(
15181548
extra_query: Query | None = None,
15191549
extra_body: Body | None = None,
15201550
timeout: float | httpx.Timeout | None | NotGiven = not_given,
1521-
) -> RunnerListScmOrganizationsResponse:
1551+
) -> AsyncPaginator[RunnerListScmOrganizationsResponse, AsyncOrganizationsPage[RunnerListScmOrganizationsResponse]]:
15221552
"""
15231553
Lists SCM organizations the user belongs to.
15241554
@@ -1538,7 +1568,29 @@ async def list_scm_organizations(
15381568
scmHost: "github.com"
15391569
```
15401570
1571+
- Search GitLab groups:
1572+
1573+
Returns the first page of GitLab groups matching the substring.
1574+
1575+
```yaml
1576+
runnerId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
1577+
scmHost: "gitlab.com"
1578+
query: "platform"
1579+
pagination:
1580+
pageSize: 25
1581+
```
1582+
15411583
Args:
1584+
pagination: Pagination parameters. When unset, defaults to the standard PaginationRequest
1585+
defaults (page_size 25, max 100). Tokens are opaque and provider-specific.
1586+
1587+
query: Optional substring filter applied to the organization name.
1588+
1589+
- GitLab: forwarded to the upstream `search` parameter (server-side,
1590+
case-insensitive substring on name/path).
1591+
- GitHub and Bitbucket: not implemented as they don't support searching Empty
1592+
value means no filter.
1593+
15421594
scm_host: The SCM host to list organizations from (e.g., "github.com", "gitlab.com")
15431595
15441596
extra_headers: Send extra headers
@@ -1549,10 +1601,13 @@ async def list_scm_organizations(
15491601
15501602
timeout: Override the client-level default timeout for this request, in seconds
15511603
"""
1552-
return await self._post(
1604+
return self._get_api_list(
15531605
"/gitpod.v1.RunnerService/ListSCMOrganizations",
1554-
body=await async_maybe_transform(
1606+
page=AsyncOrganizationsPage[RunnerListScmOrganizationsResponse],
1607+
body=maybe_transform(
15551608
{
1609+
"pagination": pagination,
1610+
"query": query,
15561611
"runner_id": runner_id,
15571612
"scm_host": scm_host,
15581613
},
@@ -1563,15 +1618,16 @@ async def list_scm_organizations(
15631618
extra_query=extra_query,
15641619
extra_body=extra_body,
15651620
timeout=timeout,
1566-
query=await async_maybe_transform(
1621+
query=maybe_transform(
15671622
{
15681623
"token": token,
15691624
"page_size": page_size,
15701625
},
15711626
runner_list_scm_organizations_params.RunnerListScmOrganizationsParams,
15721627
),
15731628
),
1574-
cast_to=RunnerListScmOrganizationsResponse,
1629+
model=RunnerListScmOrganizationsResponse,
1630+
method="post",
15751631
)
15761632

15771633
async def parse_context_url(

src/gitpod/types/runner_list_scm_organizations_params.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,51 @@
66

77
from .._utils import PropertyInfo
88

9-
__all__ = ["RunnerListScmOrganizationsParams"]
9+
__all__ = ["RunnerListScmOrganizationsParams", "Pagination"]
1010

1111

1212
class RunnerListScmOrganizationsParams(TypedDict, total=False):
1313
token: str
1414

1515
page_size: Annotated[int, PropertyInfo(alias="pageSize")]
1616

17+
pagination: Pagination
18+
"""Pagination parameters.
19+
20+
When unset, defaults to the standard PaginationRequest defaults (page_size 25,
21+
max 100). Tokens are opaque and provider-specific.
22+
"""
23+
24+
query: str
25+
"""Optional substring filter applied to the organization name.
26+
27+
- GitLab: forwarded to the upstream `search` parameter (server-side,
28+
case-insensitive substring on name/path).
29+
- GitHub and Bitbucket: not implemented as they don't support searching Empty
30+
value means no filter.
31+
"""
32+
1733
runner_id: Annotated[str, PropertyInfo(alias="runnerId")]
1834

1935
scm_host: Annotated[str, PropertyInfo(alias="scmHost")]
2036
"""The SCM host to list organizations from (e.g., "github.com", "gitlab.com")"""
37+
38+
39+
class Pagination(TypedDict, total=False):
40+
"""Pagination parameters.
41+
42+
When unset, defaults to the standard PaginationRequest defaults
43+
(page_size 25, max 100). Tokens are opaque and provider-specific.
44+
"""
45+
46+
token: str
47+
"""
48+
Token for the next set of results that was returned as next_token of a
49+
PaginationResponse
50+
"""
51+
52+
page_size: Annotated[int, PropertyInfo(alias="pageSize")]
53+
"""Page size is the maximum number of results to retrieve per page. Defaults to 25.
54+
55+
Maximum 100.
56+
"""

src/gitpod/types/runner_list_scm_organizations_response.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import List, Optional
3+
from typing import Optional
44

55
from pydantic import Field as FieldInfo
66

77
from .._models import BaseModel
88

9-
__all__ = ["RunnerListScmOrganizationsResponse", "Organization"]
9+
__all__ = ["RunnerListScmOrganizationsResponse"]
1010

1111

12-
class Organization(BaseModel):
12+
class RunnerListScmOrganizationsResponse(BaseModel):
1313
is_admin: Optional[bool] = FieldInfo(alias="isAdmin", default=None)
1414
"""
1515
Deprecated: this field is unused by all known consumers and is scheduled for
@@ -26,8 +26,3 @@ class Organization(BaseModel):
2626

2727
url: Optional[str] = None
2828
"""Organization URL (e.g., "https://github.com/gitpod-io")"""
29-
30-
31-
class RunnerListScmOrganizationsResponse(BaseModel):
32-
organizations: Optional[List[Organization]] = None
33-
"""List of organizations the user belongs to"""

0 commit comments

Comments
 (0)