Skip to content

Commit 77f5109

Browse files
feat(api): manual updates
1 parent 8853449 commit 77f5109

27 files changed

+1116
-376
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: 111
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gitpod%2Fgitpod-3655d5ad0ac3e228c1519af70dbf3d0bfa3c47a2d06d4cac92a650da051b49a6.yml
3-
openapi_spec_hash: 5dbb5577e6a7cae7db615b1b06c9d23e
4-
config_hash: 719ad411c0ec7402a7a4c1f95515280c
1+
configured_endpoints: 115
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gitpod%2Fgitpod-d854bc81e0a99171716893e6790a87ba350bb6fc778f8e3244abdd47d5c252c3.yml
3+
openapi_spec_hash: 5189220e4712a7b0cdd35beba2ebb47d
4+
config_hash: 981e43e8b1e3ddabd435d350aeeed417

api.md

Lines changed: 42 additions & 2 deletions
Large diffs are not rendered by default.

editor.go

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ func (r *EditorService) Get(ctx context.Context, body EditorGetParams, opts ...o
5757
return
5858
}
5959

60-
// Lists all available code editors.
60+
// Lists all available code editors, optionally filtered to those allowed in an
61+
// organization.
6162
//
6263
// Use this method to:
6364
//
@@ -76,6 +77,18 @@ func (r *EditorService) Get(ctx context.Context, body EditorGetParams, opts ...o
7677
// pagination:
7778
// pageSize: 20
7879
// ```
80+
//
81+
// - List editors available to the organization:
82+
//
83+
// Shows all available editors that are allowed by the policies enforced in the
84+
// organization with pagination.
85+
//
86+
// ```yaml
87+
// pagination:
88+
// pageSize: 20
89+
// filter:
90+
// allowedByPolicy: true
91+
// ```
7992
func (r *EditorService) List(ctx context.Context, params EditorListParams, opts ...option.RequestOption) (res *pagination.EditorsPage[Editor], err error) {
8093
var raw *http.Response
8194
opts = append(r.Options[:], opts...)
@@ -93,7 +106,8 @@ func (r *EditorService) List(ctx context.Context, params EditorListParams, opts
93106
return res, nil
94107
}
95108

96-
// Lists all available code editors.
109+
// Lists all available code editors, optionally filtered to those allowed in an
110+
// organization.
97111
//
98112
// Use this method to:
99113
//
@@ -112,6 +126,18 @@ func (r *EditorService) List(ctx context.Context, params EditorListParams, opts
112126
// pagination:
113127
// pageSize: 20
114128
// ```
129+
//
130+
// - List editors available to the organization:
131+
//
132+
// Shows all available editors that are allowed by the policies enforced in the
133+
// organization with pagination.
134+
//
135+
// ```yaml
136+
// pagination:
137+
// pageSize: 20
138+
// filter:
139+
// allowedByPolicy: true
140+
// ```
115141
func (r *EditorService) ListAutoPaging(ctx context.Context, params EditorListParams, opts ...option.RequestOption) *pagination.EditorsPageAutoPager[Editor] {
116142
return pagination.NewEditorsPageAutoPager(r.List(ctx, params, opts...))
117143
}
@@ -231,6 +257,8 @@ func (r EditorGetParams) MarshalJSON() (data []byte, err error) {
231257
type EditorListParams struct {
232258
Token param.Field[string] `query:"token"`
233259
PageSize param.Field[int64] `query:"pageSize"`
260+
// filter contains the filter options for listing editors
261+
Filter param.Field[EditorListParamsFilter] `json:"filter"`
234262
// pagination contains the pagination options for listing environments
235263
Pagination param.Field[EditorListParamsPagination] `json:"pagination"`
236264
}
@@ -247,6 +275,17 @@ func (r EditorListParams) URLQuery() (v url.Values) {
247275
})
248276
}
249277

278+
// filter contains the filter options for listing editors
279+
type EditorListParamsFilter struct {
280+
// allowed_by_policy filters the response to only editors that are allowed by the
281+
// policies enforced in the organization
282+
AllowedByPolicy param.Field[bool] `json:"allowedByPolicy"`
283+
}
284+
285+
func (r EditorListParamsFilter) MarshalJSON() (data []byte, err error) {
286+
return apijson.MarshalRoot(r)
287+
}
288+
250289
// pagination contains the pagination options for listing environments
251290
type EditorListParamsPagination struct {
252291
// Token for the next set of results that was returned as next_token of a

editor_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ func TestEditorListWithOptionalParams(t *testing.T) {
5454
_, err := client.Editors.List(context.TODO(), gitpod.EditorListParams{
5555
Token: gitpod.F("token"),
5656
PageSize: gitpod.F(int64(0)),
57+
Filter: gitpod.F(gitpod.EditorListParamsFilter{
58+
AllowedByPolicy: gitpod.F(true),
59+
}),
5760
Pagination: gitpod.F(gitpod.EditorListParamsPagination{
5861
Token: gitpod.F("token"),
5962
PageSize: gitpod.F(int64(20)),

environment.go

Lines changed: 79 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,27 @@ func (r *EnvironmentService) Delete(ctx context.Context, body EnvironmentDeleteP
318318
return
319319
}
320320

321+
// Creates an access token for the environment.
322+
//
323+
// Generated tokens are valid for one hour and provide environment-specific access
324+
// permissions. The token is scoped to a specific environment.
325+
//
326+
// ### Examples
327+
//
328+
// - Generate environment token:
329+
//
330+
// Creates a temporary access token for accessing an environment.
331+
//
332+
// ```yaml
333+
// environmentId: "07e03a28-65a5-4d98-b532-8ea67b188048"
334+
// ```
335+
func (r *EnvironmentService) NewEnvironmentToken(ctx context.Context, body EnvironmentNewEnvironmentTokenParams, opts ...option.RequestOption) (res *EnvironmentNewEnvironmentTokenResponse, err error) {
336+
opts = append(r.Options[:], opts...)
337+
path := "gitpod.v1.EnvironmentService/CreateEnvironmentAccessToken"
338+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
339+
return
340+
}
341+
321342
// Creates an environment from an existing project configuration and starts it.
322343
//
323344
// This method uses project settings as defaults but allows overriding specific
@@ -731,6 +752,9 @@ func (r environmentSpecContentJSON) RawJSON() string {
731752

732753
// devcontainer is the devcontainer spec of the environment
733754
type EnvironmentSpecDevcontainer struct {
755+
// default_devcontainer_image is the default image that is used to start the
756+
// devcontainer if no devcontainer config file is found
757+
DefaultDevcontainerImage string `json:"defaultDevcontainerImage"`
734758
// devcontainer_file_path is the path to the devcontainer file relative to the repo
735759
// root path must not be absolute (start with a /):
736760
//
@@ -747,11 +771,12 @@ type EnvironmentSpecDevcontainer struct {
747771
// environmentSpecDevcontainerJSON contains the JSON metadata for the struct
748772
// [EnvironmentSpecDevcontainer]
749773
type environmentSpecDevcontainerJSON struct {
750-
DevcontainerFilePath apijson.Field
751-
Dotfiles apijson.Field
752-
Session apijson.Field
753-
raw string
754-
ExtraFields map[string]apijson.Field
774+
DefaultDevcontainerImage apijson.Field
775+
DevcontainerFilePath apijson.Field
776+
Dotfiles apijson.Field
777+
Session apijson.Field
778+
raw string
779+
ExtraFields map[string]apijson.Field
755780
}
756781

757782
func (r *EnvironmentSpecDevcontainer) UnmarshalJSON(data []byte) (err error) {
@@ -839,6 +864,8 @@ func (r environmentSpecPortJSON) RawJSON() string {
839864
}
840865

841866
type EnvironmentSpecSecret struct {
867+
// id is the unique identifier of the secret.
868+
ID string `json:"id"`
842869
// container_registry_basic_auth_host is the hostname of the container registry
843870
// that supports basic auth
844871
ContainerRegistryBasicAuthHost string `json:"containerRegistryBasicAuthHost"`
@@ -861,6 +888,7 @@ type EnvironmentSpecSecret struct {
861888
// environmentSpecSecretJSON contains the JSON metadata for the struct
862889
// [EnvironmentSpecSecret]
863890
type environmentSpecSecretJSON struct {
891+
ID apijson.Field
864892
ContainerRegistryBasicAuthHost apijson.Field
865893
EnvironmentVariable apijson.Field
866894
FilePath apijson.Field
@@ -997,6 +1025,9 @@ func (r EnvironmentSpecContentParam) MarshalJSON() (data []byte, err error) {
9971025

9981026
// devcontainer is the devcontainer spec of the environment
9991027
type EnvironmentSpecDevcontainerParam struct {
1028+
// default_devcontainer_image is the default image that is used to start the
1029+
// devcontainer if no devcontainer config file is found
1030+
DefaultDevcontainerImage param.Field[string] `json:"defaultDevcontainerImage"`
10001031
// devcontainer_file_path is the path to the devcontainer file relative to the repo
10011032
// root path must not be absolute (start with a /):
10021033
//
@@ -1048,6 +1079,8 @@ func (r EnvironmentSpecPortParam) MarshalJSON() (data []byte, err error) {
10481079
}
10491080

10501081
type EnvironmentSpecSecretParam struct {
1082+
// id is the unique identifier of the secret.
1083+
ID param.Field[string] `json:"id"`
10511084
// container_registry_basic_auth_host is the hostname of the container registry
10521085
// that supports basic auth
10531086
ContainerRegistryBasicAuthHost param.Field[string] `json:"containerRegistryBasicAuthHost"`
@@ -1176,8 +1209,11 @@ type EnvironmentStatusAutomationsFile struct {
11761209
Phase EnvironmentStatusAutomationsFilePhase `json:"phase"`
11771210
// session is the automations file session that is currently applied in the
11781211
// environment.
1179-
Session string `json:"session"`
1180-
JSON environmentStatusAutomationsFileJSON `json:"-"`
1212+
Session string `json:"session"`
1213+
// warning_message contains warnings, e.g. when no triggers are defined in the
1214+
// automations file.
1215+
WarningMessage string `json:"warningMessage"`
1216+
JSON environmentStatusAutomationsFileJSON `json:"-"`
11811217
}
11821218

11831219
// environmentStatusAutomationsFileJSON contains the JSON metadata for the struct
@@ -1188,6 +1224,7 @@ type environmentStatusAutomationsFileJSON struct {
11881224
FailureMessage apijson.Field
11891225
Phase apijson.Field
11901226
Session apijson.Field
1227+
WarningMessage apijson.Field
11911228
raw string
11921229
ExtraFields map[string]apijson.Field
11931230
}
@@ -1700,6 +1737,8 @@ func (r EnvironmentStatusRunnerAckStatusCode) IsKnown() bool {
17001737
}
17011738

17021739
type EnvironmentStatusSecret struct {
1740+
// id is the unique identifier of the secret.
1741+
ID string `json:"id"`
17031742
// failure_message contains the reason the secret failed to be materialize.
17041743
FailureMessage string `json:"failureMessage"`
17051744
Phase EnvironmentStatusSecretsPhase `json:"phase"`
@@ -1715,6 +1754,7 @@ type EnvironmentStatusSecret struct {
17151754
// environmentStatusSecretJSON contains the JSON metadata for the struct
17161755
// [EnvironmentStatusSecret]
17171756
type environmentStatusSecretJSON struct {
1757+
ID apijson.Field
17181758
FailureMessage apijson.Field
17191759
Phase apijson.Field
17201760
SecretName apijson.Field
@@ -1844,6 +1884,28 @@ type EnvironmentUpdateResponse = interface{}
18441884

18451885
type EnvironmentDeleteResponse = interface{}
18461886

1887+
type EnvironmentNewEnvironmentTokenResponse struct {
1888+
// access_token is the token that can be used for environment authentication
1889+
AccessToken string `json:"accessToken,required"`
1890+
JSON environmentNewEnvironmentTokenResponseJSON `json:"-"`
1891+
}
1892+
1893+
// environmentNewEnvironmentTokenResponseJSON contains the JSON metadata for the
1894+
// struct [EnvironmentNewEnvironmentTokenResponse]
1895+
type environmentNewEnvironmentTokenResponseJSON struct {
1896+
AccessToken apijson.Field
1897+
raw string
1898+
ExtraFields map[string]apijson.Field
1899+
}
1900+
1901+
func (r *EnvironmentNewEnvironmentTokenResponse) UnmarshalJSON(data []byte) (err error) {
1902+
return apijson.UnmarshalRoot(data, r)
1903+
}
1904+
1905+
func (r environmentNewEnvironmentTokenResponseJSON) RawJSON() string {
1906+
return r.raw
1907+
}
1908+
18471909
type EnvironmentNewFromProjectResponse struct {
18481910
// +resource get environment
18491911
Environment Environment `json:"environment,required"`
@@ -2099,6 +2161,16 @@ func (r EnvironmentDeleteParams) MarshalJSON() (data []byte, err error) {
20992161
return apijson.MarshalRoot(r)
21002162
}
21012163

2164+
type EnvironmentNewEnvironmentTokenParams struct {
2165+
// environment_id specifies the environment for which the access token should be
2166+
// created.
2167+
EnvironmentID param.Field[string] `json:"environmentId,required" format:"uuid"`
2168+
}
2169+
2170+
func (r EnvironmentNewEnvironmentTokenParams) MarshalJSON() (data []byte, err error) {
2171+
return apijson.MarshalRoot(r)
2172+
}
2173+
21022174
type EnvironmentNewFromProjectParams struct {
21032175
ProjectID param.Field[string] `json:"projectId" format:"uuid"`
21042176
// Spec is the configuration of the environment that's required for the runner to

environment_test.go

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ func TestEnvironmentNewWithOptionalParams(t *testing.T) {
5555
}),
5656
DesiredPhase: gitpod.F(gitpod.EnvironmentPhaseUnspecified),
5757
Devcontainer: gitpod.F(gitpod.EnvironmentSpecDevcontainerParam{
58-
DevcontainerFilePath: gitpod.F("devcontainerFilePath"),
58+
DefaultDevcontainerImage: gitpod.F("defaultDevcontainerImage"),
59+
DevcontainerFilePath: gitpod.F("devcontainerFilePath"),
5960
Dotfiles: gitpod.F(gitpod.EnvironmentSpecDevcontainerDotfilesParam{
6061
Repository: gitpod.F("https://example.com"),
6162
}),
@@ -71,6 +72,7 @@ func TestEnvironmentNewWithOptionalParams(t *testing.T) {
7172
Port: gitpod.F(int64(1)),
7273
}}),
7374
Secrets: gitpod.F([]gitpod.EnvironmentSpecSecretParam{{
75+
ID: gitpod.F("id"),
7476
ContainerRegistryBasicAuthHost: gitpod.F("containerRegistryBasicAuthHost"),
7577
EnvironmentVariable: gitpod.F("environmentVariable"),
7678
FilePath: gitpod.F("filePath"),
@@ -254,6 +256,31 @@ func TestEnvironmentDeleteWithOptionalParams(t *testing.T) {
254256
}
255257
}
256258

259+
func TestEnvironmentNewEnvironmentToken(t *testing.T) {
260+
t.Skip("skipped: tests are disabled for the time being")
261+
baseURL := "http://localhost:4010"
262+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
263+
baseURL = envURL
264+
}
265+
if !testutil.CheckTestServer(t, baseURL) {
266+
return
267+
}
268+
client := gitpod.NewClient(
269+
option.WithBaseURL(baseURL),
270+
option.WithBearerToken("My Bearer Token"),
271+
)
272+
_, err := client.Environments.NewEnvironmentToken(context.TODO(), gitpod.EnvironmentNewEnvironmentTokenParams{
273+
EnvironmentID: gitpod.F("07e03a28-65a5-4d98-b532-8ea67b188048"),
274+
})
275+
if err != nil {
276+
var apierr *gitpod.Error
277+
if errors.As(err, &apierr) {
278+
t.Log(string(apierr.DumpRequest(true)))
279+
}
280+
t.Fatalf("err should be nil: %s", err.Error())
281+
}
282+
}
283+
257284
func TestEnvironmentNewFromProjectWithOptionalParams(t *testing.T) {
258285
t.Skip("skipped: tests are disabled for the time being")
259286
baseURL := "http://localhost:4010"
@@ -296,7 +323,8 @@ func TestEnvironmentNewFromProjectWithOptionalParams(t *testing.T) {
296323
}),
297324
DesiredPhase: gitpod.F(gitpod.EnvironmentPhaseUnspecified),
298325
Devcontainer: gitpod.F(gitpod.EnvironmentSpecDevcontainerParam{
299-
DevcontainerFilePath: gitpod.F("devcontainerFilePath"),
326+
DefaultDevcontainerImage: gitpod.F("defaultDevcontainerImage"),
327+
DevcontainerFilePath: gitpod.F("devcontainerFilePath"),
300328
Dotfiles: gitpod.F(gitpod.EnvironmentSpecDevcontainerDotfilesParam{
301329
Repository: gitpod.F("https://example.com"),
302330
}),
@@ -312,6 +340,7 @@ func TestEnvironmentNewFromProjectWithOptionalParams(t *testing.T) {
312340
Port: gitpod.F(int64(1)),
313341
}}),
314342
Secrets: gitpod.F([]gitpod.EnvironmentSpecSecretParam{{
343+
ID: gitpod.F("id"),
315344
ContainerRegistryBasicAuthHost: gitpod.F("containerRegistryBasicAuthHost"),
316345
EnvironmentVariable: gitpod.F("environmentVariable"),
317346
FilePath: gitpod.F("filePath"),

environmentautomationservice.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,9 @@ type ServiceStatus struct {
577577
FailureMessage string `json:"failureMessage"`
578578
// log_url contains the URL at which the service logs can be accessed.
579579
LogURL string `json:"logUrl"`
580+
// output contains the output of the service. setting an output field to empty
581+
// string will unset it.
582+
Output map[string]string `json:"output"`
580583
// phase is the current phase of the service.
581584
Phase ServicePhase `json:"phase"`
582585
// session is the current session of the service.
@@ -594,6 +597,7 @@ type ServiceStatus struct {
594597
type serviceStatusJSON struct {
595598
FailureMessage apijson.Field
596599
LogURL apijson.Field
600+
Output apijson.Field
597601
Phase apijson.Field
598602
Session apijson.Field
599603
StatusVersion apijson.Field
@@ -738,10 +742,12 @@ func (r EnvironmentAutomationServiceUpdateParamsSpecCommands) MarshalJSON() (dat
738742
// client of this API you are not expected to provide this field. Updating this
739743
// field requires the `environmentservice:update_status` permission.
740744
type EnvironmentAutomationServiceUpdateParamsStatus struct {
741-
FailureMessage param.Field[string] `json:"failureMessage"`
742-
LogURL param.Field[string] `json:"logUrl"`
743-
Phase param.Field[ServicePhase] `json:"phase"`
744-
Session param.Field[string] `json:"session"`
745+
FailureMessage param.Field[string] `json:"failureMessage"`
746+
LogURL param.Field[string] `json:"logUrl"`
747+
// setting an output field to empty string will unset it.
748+
Output param.Field[map[string]string] `json:"output"`
749+
Phase param.Field[ServicePhase] `json:"phase"`
750+
Session param.Field[string] `json:"session"`
745751
}
746752

747753
func (r EnvironmentAutomationServiceUpdateParamsStatus) MarshalJSON() (data []byte, err error) {

environmentautomationservice_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,11 @@ func TestEnvironmentAutomationServiceUpdateWithOptionalParams(t *testing.T) {
138138
Status: gitpod.F(gitpod.EnvironmentAutomationServiceUpdateParamsStatus{
139139
FailureMessage: gitpod.F("failureMessage"),
140140
LogURL: gitpod.F("logUrl"),
141-
Phase: gitpod.F(gitpod.ServicePhaseUnspecified),
142-
Session: gitpod.F("session"),
141+
Output: gitpod.F(map[string]string{
142+
"foo": "string",
143+
}),
144+
Phase: gitpod.F(gitpod.ServicePhaseUnspecified),
145+
Session: gitpod.F("session"),
143146
}),
144147
})
145148
if err != nil {

0 commit comments

Comments
 (0)