Skip to content

Commit dfee19e

Browse files
feat(api): RBAC APIs
1 parent 1e67eff commit dfee19e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+8907
-514
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: 119
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gitpod%2Fgitpod-ca9a49ac7fbb63f55611fd7cd48a22a3ff8b38a797125c8513e891d9b7345550.yml
3-
openapi_spec_hash: fd6ffbdfaefcc555e61ca1c565e05214
4-
config_hash: 7fb76543ceafd4a116473f647f8d63b1
1+
configured_endpoints: 159
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gitpod%2Fgitpod-d62ef4b9187c1f3d36f428abc4b31d8a09ffd36e93d39b8136c60c8f463c838e.yml
3+
openapi_spec_hash: d7f01b6f24e88eb46d744ecd28061f26
4+
config_hash: 26e4a10dfc6ec809322e60d889d15414

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<a href="https://pkg.go.dev/github.com/gitpod-io/gitpod-sdk-go"><img src="https://pkg.go.dev/badge/github.com/gitpod-io/gitpod-sdk-go.svg" alt="Go Reference"></a>
44

5-
The Gitpod Go library provides convenient access to the [Gitpod REST API](https://docs.ona.com)
5+
The Gitpod Go library provides convenient access to the [Gitpod REST API](https://docs.gitpod.io)
66
from applications written in Go.
77

88
It is generated with [Stainless](https://www.stainless.com/).

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ or products provided by Gitpod, please follow the respective company's security
2020

2121
### Gitpod Terms and Policies
2222

23-
Please contact dev-feedback@ona.com for any questions or concerns regarding the security of our services.
23+
Please contact dev-feedback@gitpod.com for any questions or concerns regarding the security of our services.
2424

2525
---
2626

account.go

Lines changed: 131 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,42 @@ func (r *AccountService) GetSSOLoginURL(ctx context.Context, body AccountGetSSOL
138138
// ```yaml
139139
// {}
140140
// ```
141-
func (r *AccountService) ListJoinableOrganizations(ctx context.Context, params AccountListJoinableOrganizationsParams, opts ...option.RequestOption) (res *AccountListJoinableOrganizationsResponse, err error) {
141+
func (r *AccountService) ListJoinableOrganizations(ctx context.Context, params AccountListJoinableOrganizationsParams, opts ...option.RequestOption) (res *pagination.JoinableOrganizationsPage[JoinableOrganization], err error) {
142+
var raw *http.Response
142143
opts = slices.Concat(r.Options, opts)
144+
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
143145
path := "gitpod.v1.AccountService/ListJoinableOrganizations"
144-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
145-
return
146+
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, params, &res, opts...)
147+
if err != nil {
148+
return nil, err
149+
}
150+
err = cfg.Execute()
151+
if err != nil {
152+
return nil, err
153+
}
154+
res.SetPageConfig(cfg, raw)
155+
return res, nil
156+
}
157+
158+
// Lists organizations that the currently authenticated account can join.
159+
//
160+
// Use this method to:
161+
//
162+
// - Discover organizations associated with the account's email domain.
163+
// - Allow users to join existing organizations.
164+
// - Display potential organizations during onboarding.
165+
//
166+
// ### Examples
167+
//
168+
// - List joinable organizations:
169+
//
170+
// Retrieves a list of organizations the account can join.
171+
//
172+
// ```yaml
173+
// {}
174+
// ```
175+
func (r *AccountService) ListJoinableOrganizationsAutoPaging(ctx context.Context, params AccountListJoinableOrganizationsParams, opts ...option.RequestOption) *pagination.JoinableOrganizationsPageAutoPager[JoinableOrganization] {
176+
return pagination.NewJoinableOrganizationsPageAutoPager(r.ListJoinableOrganizations(ctx, params, opts...))
146177
}
147178

148179
// Lists available login providers with optional filtering.
@@ -224,6 +255,29 @@ func (r *AccountService) ListLoginProvidersAutoPaging(ctx context.Context, param
224255
return pagination.NewLoginProvidersPageAutoPager(r.ListLoginProviders(ctx, params, opts...))
225256
}
226257

258+
// ListSSOLogins
259+
func (r *AccountService) ListSSOLogins(ctx context.Context, params AccountListSSOLoginsParams, opts ...option.RequestOption) (res *pagination.LoginsPage[AccountListSSOLoginsResponse], err error) {
260+
var raw *http.Response
261+
opts = slices.Concat(r.Options, opts)
262+
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
263+
path := "gitpod.v1.AccountService/ListSSOLogins"
264+
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, params, &res, opts...)
265+
if err != nil {
266+
return nil, err
267+
}
268+
err = cfg.Execute()
269+
if err != nil {
270+
return nil, err
271+
}
272+
res.SetPageConfig(cfg, raw)
273+
return res, nil
274+
}
275+
276+
// ListSSOLogins
277+
func (r *AccountService) ListSSOLoginsAutoPaging(ctx context.Context, params AccountListSSOLoginsParams, opts ...option.RequestOption) *pagination.LoginsPageAutoPager[AccountListSSOLoginsResponse] {
278+
return pagination.NewLoginsPageAutoPager(r.ListSSOLogins(ctx, params, opts...))
279+
}
280+
227281
type Account struct {
228282
ID string `json:"id,required" format:"uuid"`
229283
// A Timestamp represents a point in time independent of any time zone or local
@@ -580,24 +634,29 @@ func (r accountGetSSOLoginURLResponseJSON) RawJSON() string {
580634
return r.raw
581635
}
582636

583-
type AccountListJoinableOrganizationsResponse struct {
584-
JoinableOrganizations []JoinableOrganization `json:"joinableOrganizations"`
585-
JSON accountListJoinableOrganizationsResponseJSON `json:"-"`
637+
type AccountListSSOLoginsResponse struct {
638+
// provider is the provider used by this login method, e.g. "github", "google",
639+
// "custom"
640+
DisplayName string `json:"displayName,required"`
641+
// login_url is the URL to redirect the user to for SSO login
642+
LoginURL string `json:"loginUrl,required"`
643+
JSON accountListSSOLoginsResponseJSON `json:"-"`
586644
}
587645

588-
// accountListJoinableOrganizationsResponseJSON contains the JSON metadata for the
589-
// struct [AccountListJoinableOrganizationsResponse]
590-
type accountListJoinableOrganizationsResponseJSON struct {
591-
JoinableOrganizations apijson.Field
592-
raw string
593-
ExtraFields map[string]apijson.Field
646+
// accountListSSOLoginsResponseJSON contains the JSON metadata for the struct
647+
// [AccountListSSOLoginsResponse]
648+
type accountListSSOLoginsResponseJSON struct {
649+
DisplayName apijson.Field
650+
LoginURL apijson.Field
651+
raw string
652+
ExtraFields map[string]apijson.Field
594653
}
595654

596-
func (r *AccountListJoinableOrganizationsResponse) UnmarshalJSON(data []byte) (err error) {
655+
func (r *AccountListSSOLoginsResponse) UnmarshalJSON(data []byte) (err error) {
597656
return apijson.UnmarshalRoot(data, r)
598657
}
599658

600-
func (r accountListJoinableOrganizationsResponseJSON) RawJSON() string {
659+
func (r accountListSSOLoginsResponseJSON) RawJSON() string {
601660
return r.raw
602661
}
603662

@@ -611,6 +670,8 @@ func (r AccountGetParams) MarshalJSON() (data []byte, err error) {
611670

612671
type AccountDeleteParams struct {
613672
AccountID param.Field[string] `json:"accountId,required" format:"uuid"`
673+
// reason is an optional field for the reason for account deletion
674+
Reason param.Field[string] `json:"reason"`
614675
}
615676

616677
func (r AccountDeleteParams) MarshalJSON() (data []byte, err error) {
@@ -631,7 +692,8 @@ func (r AccountGetSSOLoginURLParams) MarshalJSON() (data []byte, err error) {
631692
type AccountListJoinableOrganizationsParams struct {
632693
Token param.Field[string] `query:"token"`
633694
PageSize param.Field[int64] `query:"pageSize"`
634-
Empty param.Field[bool] `json:"empty"`
695+
// pagination contains the pagination options for listing joinable organizations
696+
Pagination param.Field[AccountListJoinableOrganizationsParamsPagination] `json:"pagination"`
635697
}
636698

637699
func (r AccountListJoinableOrganizationsParams) MarshalJSON() (data []byte, err error) {
@@ -647,6 +709,20 @@ func (r AccountListJoinableOrganizationsParams) URLQuery() (v url.Values) {
647709
})
648710
}
649711

712+
// pagination contains the pagination options for listing joinable organizations
713+
type AccountListJoinableOrganizationsParamsPagination struct {
714+
// Token for the next set of results that was returned as next_token of a
715+
// PaginationResponse
716+
Token param.Field[string] `json:"token"`
717+
// Page size is the maximum number of results to retrieve per page. Defaults to 25.
718+
// Maximum 100.
719+
PageSize param.Field[int64] `json:"pageSize"`
720+
}
721+
722+
func (r AccountListJoinableOrganizationsParamsPagination) MarshalJSON() (data []byte, err error) {
723+
return apijson.MarshalRoot(r)
724+
}
725+
650726
type AccountListLoginProvidersParams struct {
651727
Token param.Field[string] `query:"token"`
652728
PageSize param.Field[int64] `query:"pageSize"`
@@ -671,6 +747,8 @@ func (r AccountListLoginProvidersParams) URLQuery() (v url.Values) {
671747

672748
// filter contains the filter options for listing login methods
673749
type AccountListLoginProvidersParamsFilter struct {
750+
// email is the email address to filter SSO providers by
751+
Email param.Field[string] `json:"email"`
674752
// invite_id is the ID of the invite URL the user wants to login with
675753
InviteID param.Field[string] `json:"inviteId" format:"uuid"`
676754
}
@@ -692,3 +770,41 @@ type AccountListLoginProvidersParamsPagination struct {
692770
func (r AccountListLoginProvidersParamsPagination) MarshalJSON() (data []byte, err error) {
693771
return apijson.MarshalRoot(r)
694772
}
773+
774+
type AccountListSSOLoginsParams struct {
775+
// email is the email the user wants to login with
776+
Email param.Field[string] `json:"email,required" format:"email"`
777+
Token param.Field[string] `query:"token"`
778+
PageSize param.Field[int64] `query:"pageSize"`
779+
// pagination contains the pagination options for listing SSO logins
780+
Pagination param.Field[AccountListSSOLoginsParamsPagination] `json:"pagination"`
781+
// return_to is the URL the user will be redirected to after login
782+
ReturnTo param.Field[string] `json:"returnTo" format:"uri"`
783+
}
784+
785+
func (r AccountListSSOLoginsParams) MarshalJSON() (data []byte, err error) {
786+
return apijson.MarshalRoot(r)
787+
}
788+
789+
// URLQuery serializes [AccountListSSOLoginsParams]'s query parameters as
790+
// `url.Values`.
791+
func (r AccountListSSOLoginsParams) URLQuery() (v url.Values) {
792+
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
793+
ArrayFormat: apiquery.ArrayQueryFormatComma,
794+
NestedFormat: apiquery.NestedQueryFormatBrackets,
795+
})
796+
}
797+
798+
// pagination contains the pagination options for listing SSO logins
799+
type AccountListSSOLoginsParamsPagination struct {
800+
// Token for the next set of results that was returned as next_token of a
801+
// PaginationResponse
802+
Token param.Field[string] `json:"token"`
803+
// Page size is the maximum number of results to retrieve per page. Defaults to 25.
804+
// Maximum 100.
805+
PageSize param.Field[int64] `json:"pageSize"`
806+
}
807+
808+
func (r AccountListSSOLoginsParamsPagination) MarshalJSON() (data []byte, err error) {
809+
return apijson.MarshalRoot(r)
810+
}

account_test.go

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestAccountGetWithOptionalParams(t *testing.T) {
3838
}
3939
}
4040

41-
func TestAccountDelete(t *testing.T) {
41+
func TestAccountDeleteWithOptionalParams(t *testing.T) {
4242
t.Skip("Prism tests are disabled")
4343
baseURL := "http://localhost:4010"
4444
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -53,6 +53,7 @@ func TestAccountDelete(t *testing.T) {
5353
)
5454
_, err := client.Accounts.Delete(context.TODO(), gitpod.AccountDeleteParams{
5555
AccountID: gitpod.F("f53d2330-3795-4c5d-a1f3-453121af9c60"),
56+
Reason: gitpod.F("reason"),
5657
})
5758
if err != nil {
5859
var apierr *gitpod.Error
@@ -105,7 +106,10 @@ func TestAccountListJoinableOrganizationsWithOptionalParams(t *testing.T) {
105106
_, err := client.Accounts.ListJoinableOrganizations(context.TODO(), gitpod.AccountListJoinableOrganizationsParams{
106107
Token: gitpod.F("token"),
107108
PageSize: gitpod.F(int64(0)),
108-
Empty: gitpod.F(true),
109+
Pagination: gitpod.F(gitpod.AccountListJoinableOrganizationsParamsPagination{
110+
Token: gitpod.F("token"),
111+
PageSize: gitpod.F(int64(100)),
112+
}),
109113
})
110114
if err != nil {
111115
var apierr *gitpod.Error
@@ -133,6 +137,7 @@ func TestAccountListLoginProvidersWithOptionalParams(t *testing.T) {
133137
Token: gitpod.F("token"),
134138
PageSize: gitpod.F(int64(0)),
135139
Filter: gitpod.F(gitpod.AccountListLoginProvidersParamsFilter{
140+
Email: gitpod.F("email"),
136141
InviteID: gitpod.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
137142
}),
138143
Pagination: gitpod.F(gitpod.AccountListLoginProvidersParamsPagination{
@@ -148,3 +153,35 @@ func TestAccountListLoginProvidersWithOptionalParams(t *testing.T) {
148153
t.Fatalf("err should be nil: %s", err.Error())
149154
}
150155
}
156+
157+
func TestAccountListSSOLoginsWithOptionalParams(t *testing.T) {
158+
t.Skip("Prism tests are disabled")
159+
baseURL := "http://localhost:4010"
160+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
161+
baseURL = envURL
162+
}
163+
if !testutil.CheckTestServer(t, baseURL) {
164+
return
165+
}
166+
client := gitpod.NewClient(
167+
option.WithBaseURL(baseURL),
168+
option.WithBearerToken("My Bearer Token"),
169+
)
170+
_, err := client.Accounts.ListSSOLogins(context.TODO(), gitpod.AccountListSSOLoginsParams{
171+
Email: gitpod.F("dev@stainless.com"),
172+
Token: gitpod.F("token"),
173+
PageSize: gitpod.F(int64(0)),
174+
Pagination: gitpod.F(gitpod.AccountListSSOLoginsParamsPagination{
175+
Token: gitpod.F("token"),
176+
PageSize: gitpod.F(int64(100)),
177+
}),
178+
ReturnTo: gitpod.F("https://example.com"),
179+
})
180+
if err != nil {
181+
var apierr *gitpod.Error
182+
if errors.As(err, &apierr) {
183+
t.Log(string(apierr.DumpRequest(true)))
184+
}
185+
t.Fatalf("err should be nil: %s", err.Error())
186+
}
187+
}

0 commit comments

Comments
 (0)