Skip to content

Commit 9c8f7ea

Browse files
feat(api): add ListSCMOrganizations endpoint
1 parent ddd18c0 commit 9c8f7ea

File tree

7 files changed

+289
-4
lines changed

7 files changed

+289
-4
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 160
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gitpod%2Fgitpod-247b6e1af7faefcf2f0ad1f1a012b45fd566be64e313d92648311bac4cda8b8e.yml
3-
openapi_spec_hash: 5eb6026ee5764b077a65c26e85e4a84a
4-
config_hash: acfe8cf5d6e4b26387e4fefa3bff8409
1+
configured_endpoints: 161
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gitpod%2Fgitpod-baa13045a9492d958fc06db0dcee2fd99972435f8b9a707831cf4da8d84db194.yml
3+
openapi_spec_hash: 5e7adb5d5cdf924eb7c0e4ddf1b81260
4+
config_hash: d930f7e17a525d153b810339251607b7

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ from gitpod.types import (
568568
RunnerCheckAuthenticationForHostResponse,
569569
RunnerCreateLogsTokenResponse,
570570
RunnerCreateRunnerTokenResponse,
571+
RunnerListScmOrganizationsResponse,
571572
RunnerParseContextURLResponse,
572573
RunnerSearchRepositoriesResponse,
573574
)
@@ -583,6 +584,7 @@ Methods:
583584
- <code title="post /gitpod.v1.RunnerService/CheckAuthenticationForHost">client.runners.<a href="./src/gitpod/resources/runners/runners.py">check_authentication_for_host</a>(\*\*<a href="src/gitpod/types/runner_check_authentication_for_host_params.py">params</a>) -> <a href="./src/gitpod/types/runner_check_authentication_for_host_response.py">RunnerCheckAuthenticationForHostResponse</a></code>
584585
- <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>
585586
- <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>
587+
- <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>
586588
- <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>
587589
- <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>
588590

src/gitpod/resources/runners/runners.py

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
runner_parse_context_url_params,
2020
runner_create_runner_token_params,
2121
runner_search_repositories_params,
22+
runner_list_scm_organizations_params,
2223
runner_check_authentication_for_host_params,
2324
)
2425
from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
@@ -60,6 +61,7 @@
6061
from ...types.runner_parse_context_url_response import RunnerParseContextURLResponse
6162
from ...types.runner_create_runner_token_response import RunnerCreateRunnerTokenResponse
6263
from ...types.runner_search_repositories_response import RunnerSearchRepositoriesResponse
64+
from ...types.runner_list_scm_organizations_response import RunnerListScmOrganizationsResponse
6365
from ...types.runner_check_authentication_for_host_response import RunnerCheckAuthenticationForHostResponse
6466

6567
__all__ = ["RunnersResource", "AsyncRunnersResource"]
@@ -608,6 +610,75 @@ def create_runner_token(
608610
cast_to=RunnerCreateRunnerTokenResponse,
609611
)
610612

613+
def list_scm_organizations(
614+
self,
615+
*,
616+
token: str | Omit = omit,
617+
page_size: int | Omit = omit,
618+
runner_id: str | Omit = omit,
619+
scm_host: str | Omit = omit,
620+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
621+
# The extra values given here take precedence over values defined on the client or passed to this method.
622+
extra_headers: Headers | None = None,
623+
extra_query: Query | None = None,
624+
extra_body: Body | None = None,
625+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
626+
) -> RunnerListScmOrganizationsResponse:
627+
"""
628+
Lists SCM organizations the user belongs to.
629+
630+
Use this method to:
631+
632+
- Get all organizations for a user on a specific SCM host
633+
- Check organization admin permissions for webhook creation
634+
635+
### Examples
636+
637+
- List GitHub organizations:
638+
639+
Lists all organizations the user belongs to on GitHub.
640+
641+
```yaml
642+
runnerId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
643+
scmHost: "github.com"
644+
```
645+
646+
Args:
647+
scm_host: The SCM host to list organizations from (e.g., "github.com", "gitlab.com")
648+
649+
extra_headers: Send extra headers
650+
651+
extra_query: Add additional query parameters to the request
652+
653+
extra_body: Add additional JSON properties to the request
654+
655+
timeout: Override the client-level default timeout for this request, in seconds
656+
"""
657+
return self._post(
658+
"/gitpod.v1.RunnerService/ListSCMOrganizations",
659+
body=maybe_transform(
660+
{
661+
"runner_id": runner_id,
662+
"scm_host": scm_host,
663+
},
664+
runner_list_scm_organizations_params.RunnerListScmOrganizationsParams,
665+
),
666+
options=make_request_options(
667+
extra_headers=extra_headers,
668+
extra_query=extra_query,
669+
extra_body=extra_body,
670+
timeout=timeout,
671+
query=maybe_transform(
672+
{
673+
"token": token,
674+
"page_size": page_size,
675+
},
676+
runner_list_scm_organizations_params.RunnerListScmOrganizationsParams,
677+
),
678+
),
679+
cast_to=RunnerListScmOrganizationsResponse,
680+
)
681+
611682
def parse_context_url(
612683
self,
613684
*,
@@ -1304,6 +1375,75 @@ async def create_runner_token(
13041375
cast_to=RunnerCreateRunnerTokenResponse,
13051376
)
13061377

1378+
async def list_scm_organizations(
1379+
self,
1380+
*,
1381+
token: str | Omit = omit,
1382+
page_size: int | Omit = omit,
1383+
runner_id: str | Omit = omit,
1384+
scm_host: str | Omit = omit,
1385+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1386+
# The extra values given here take precedence over values defined on the client or passed to this method.
1387+
extra_headers: Headers | None = None,
1388+
extra_query: Query | None = None,
1389+
extra_body: Body | None = None,
1390+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
1391+
) -> RunnerListScmOrganizationsResponse:
1392+
"""
1393+
Lists SCM organizations the user belongs to.
1394+
1395+
Use this method to:
1396+
1397+
- Get all organizations for a user on a specific SCM host
1398+
- Check organization admin permissions for webhook creation
1399+
1400+
### Examples
1401+
1402+
- List GitHub organizations:
1403+
1404+
Lists all organizations the user belongs to on GitHub.
1405+
1406+
```yaml
1407+
runnerId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
1408+
scmHost: "github.com"
1409+
```
1410+
1411+
Args:
1412+
scm_host: The SCM host to list organizations from (e.g., "github.com", "gitlab.com")
1413+
1414+
extra_headers: Send extra headers
1415+
1416+
extra_query: Add additional query parameters to the request
1417+
1418+
extra_body: Add additional JSON properties to the request
1419+
1420+
timeout: Override the client-level default timeout for this request, in seconds
1421+
"""
1422+
return await self._post(
1423+
"/gitpod.v1.RunnerService/ListSCMOrganizations",
1424+
body=await async_maybe_transform(
1425+
{
1426+
"runner_id": runner_id,
1427+
"scm_host": scm_host,
1428+
},
1429+
runner_list_scm_organizations_params.RunnerListScmOrganizationsParams,
1430+
),
1431+
options=make_request_options(
1432+
extra_headers=extra_headers,
1433+
extra_query=extra_query,
1434+
extra_body=extra_body,
1435+
timeout=timeout,
1436+
query=await async_maybe_transform(
1437+
{
1438+
"token": token,
1439+
"page_size": page_size,
1440+
},
1441+
runner_list_scm_organizations_params.RunnerListScmOrganizationsParams,
1442+
),
1443+
),
1444+
cast_to=RunnerListScmOrganizationsResponse,
1445+
)
1446+
13071447
async def parse_context_url(
13081448
self,
13091449
*,
@@ -1483,6 +1623,9 @@ def __init__(self, runners: RunnersResource) -> None:
14831623
self.create_runner_token = to_raw_response_wrapper(
14841624
runners.create_runner_token,
14851625
)
1626+
self.list_scm_organizations = to_raw_response_wrapper(
1627+
runners.list_scm_organizations,
1628+
)
14861629
self.parse_context_url = to_raw_response_wrapper(
14871630
runners.parse_context_url,
14881631
)
@@ -1527,6 +1670,9 @@ def __init__(self, runners: AsyncRunnersResource) -> None:
15271670
self.create_runner_token = async_to_raw_response_wrapper(
15281671
runners.create_runner_token,
15291672
)
1673+
self.list_scm_organizations = async_to_raw_response_wrapper(
1674+
runners.list_scm_organizations,
1675+
)
15301676
self.parse_context_url = async_to_raw_response_wrapper(
15311677
runners.parse_context_url,
15321678
)
@@ -1571,6 +1717,9 @@ def __init__(self, runners: RunnersResource) -> None:
15711717
self.create_runner_token = to_streamed_response_wrapper(
15721718
runners.create_runner_token,
15731719
)
1720+
self.list_scm_organizations = to_streamed_response_wrapper(
1721+
runners.list_scm_organizations,
1722+
)
15741723
self.parse_context_url = to_streamed_response_wrapper(
15751724
runners.parse_context_url,
15761725
)
@@ -1615,6 +1764,9 @@ def __init__(self, runners: AsyncRunnersResource) -> None:
16151764
self.create_runner_token = async_to_streamed_response_wrapper(
16161765
runners.create_runner_token,
16171766
)
1767+
self.list_scm_organizations = async_to_streamed_response_wrapper(
1768+
runners.list_scm_organizations,
1769+
)
16181770
self.parse_context_url = async_to_streamed_response_wrapper(
16191771
runners.parse_context_url,
16201772
)

src/gitpod/types/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@
221221
from .runner_search_repositories_response import RunnerSearchRepositoriesResponse as RunnerSearchRepositoriesResponse
222222
from .environment_create_logs_token_params import EnvironmentCreateLogsTokenParams as EnvironmentCreateLogsTokenParams
223223
from .project_prebuild_configuration_param import ProjectPrebuildConfigurationParam as ProjectPrebuildConfigurationParam
224+
from .runner_list_scm_organizations_params import RunnerListScmOrganizationsParams as RunnerListScmOrganizationsParams
224225
from .user_get_authenticated_user_response import UserGetAuthenticatedUserResponse as UserGetAuthenticatedUserResponse
225226
from .environment_create_from_project_params import (
226227
EnvironmentCreateFromProjectParams as EnvironmentCreateFromProjectParams,
@@ -231,6 +232,9 @@
231232
from .project_create_from_environment_params import (
232233
ProjectCreateFromEnvironmentParams as ProjectCreateFromEnvironmentParams,
233234
)
235+
from .runner_list_scm_organizations_response import (
236+
RunnerListScmOrganizationsResponse as RunnerListScmOrganizationsResponse,
237+
)
234238
from .environment_create_from_project_response import (
235239
EnvironmentCreateFromProjectResponse as EnvironmentCreateFromProjectResponse,
236240
)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing_extensions import Annotated, TypedDict
6+
7+
from .._utils import PropertyInfo
8+
9+
__all__ = ["RunnerListScmOrganizationsParams"]
10+
11+
12+
class RunnerListScmOrganizationsParams(TypedDict, total=False):
13+
token: str
14+
15+
page_size: Annotated[int, PropertyInfo(alias="pageSize")]
16+
17+
runner_id: Annotated[str, PropertyInfo(alias="runnerId")]
18+
19+
scm_host: Annotated[str, PropertyInfo(alias="scmHost")]
20+
"""The SCM host to list organizations from (e.g., "github.com", "gitlab.com")"""
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List, Optional
4+
5+
from pydantic import Field as FieldInfo
6+
7+
from .._models import BaseModel
8+
9+
__all__ = ["RunnerListScmOrganizationsResponse", "Organization"]
10+
11+
12+
class Organization(BaseModel):
13+
is_admin: Optional[bool] = FieldInfo(alias="isAdmin", default=None)
14+
"""
15+
Whether the user has admin permissions in this organization. Admin permissions
16+
typically allow creating organization-level webhooks.
17+
"""
18+
19+
name: Optional[str] = None
20+
"""Organization name/slug (e.g., "gitpod-io")"""
21+
22+
url: Optional[str] = None
23+
"""Organization URL (e.g., "https://github.com/gitpod-io")"""
24+
25+
26+
class RunnerListScmOrganizationsResponse(BaseModel):
27+
organizations: Optional[List[Organization]] = None
28+
"""List of organizations the user belongs to"""

0 commit comments

Comments
 (0)