Skip to content

Commit d91ff3e

Browse files
feat(api): update via SDK Studio
1 parent 587e248 commit d91ff3e

24 files changed

+70
-4
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ import (
3737
"fmt"
3838

3939
"github.com/stainless-sdks/gitpod-go"
40+
"github.com/stainless-sdks/gitpod-go/option"
4041
)
4142

4243
func main() {
43-
client := gitpod.NewClient()
44+
client := gitpod.NewClient(
45+
option.WithAuthToken("My Auth Token"), // defaults to os.LookupEnv("GITPOD_API_KEY")
46+
)
4447
runner, err := client.Runners.New(context.TODO(), gitpod.RunnerNewParams{
4548
ConnectProtocolVersion: gitpod.F(gitpod.RunnerNewParamsConnectProtocolVersion1),
4649
})

automationsfile_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func TestAutomationsFileUpsertWithOptionalParams(t *testing.T) {
2323
}
2424
client := gitpod.NewClient(
2525
option.WithBaseURL(baseURL),
26+
option.WithAuthToken("My Auth Token"),
2627
)
2728
_, err := client.AutomationsFiles.Upsert(context.TODO(), gitpod.AutomationsFileUpsertParams{
2829
ConnectProtocolVersion: gitpod.F(gitpod.AutomationsFileUpsertParamsConnectProtocolVersion1),

client.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package gitpod
55
import (
66
"context"
77
"net/http"
8+
"os"
89

910
"github.com/stainless-sdks/gitpod-go/internal/requestconfig"
1011
"github.com/stainless-sdks/gitpod-go/option"
@@ -27,11 +28,14 @@ type Client struct {
2728
}
2829

2930
// NewClient generates a new client with the default option read from the
30-
// environment (). The option passed in as arguments are applied after these
31-
// default arguments, and all option will be passed down to the services and
32-
// requests that this client makes.
31+
// environment (GITPOD_API_KEY). The option passed in as arguments are applied
32+
// after these default arguments, and all option will be passed down to the
33+
// services and requests that this client makes.
3334
func NewClient(opts ...option.RequestOption) (r *Client) {
3435
defaults := []option.RequestOption{option.WithEnvironmentProduction()}
36+
if o, ok := os.LookupEnv("GITPOD_API_KEY"); ok {
37+
defaults = append(defaults, option.WithAuthToken(o))
38+
}
3539
opts = append(defaults, opts...)
3640

3741
r = &Client{Options: opts}

editor_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func TestEditorGetWithOptionalParams(t *testing.T) {
2323
}
2424
client := gitpod.NewClient(
2525
option.WithBaseURL(baseURL),
26+
option.WithAuthToken("My Auth Token"),
2627
)
2728
_, err := client.Editors.Get(context.TODO(), gitpod.EditorGetParams{
2829
ConnectProtocolVersion: gitpod.F(gitpod.EditorGetParamsConnectProtocolVersion1),
@@ -48,6 +49,7 @@ func TestEditorListWithOptionalParams(t *testing.T) {
4849
}
4950
client := gitpod.NewClient(
5051
option.WithBaseURL(baseURL),
52+
option.WithAuthToken("My Auth Token"),
5153
)
5254
_, err := client.Editors.List(context.TODO(), gitpod.EditorListParams{
5355
ConnectProtocolVersion: gitpod.F(gitpod.EditorListParamsConnectProtocolVersion1),
@@ -76,6 +78,7 @@ func TestEditorResolveEditorURLWithOptionalParams(t *testing.T) {
7678
}
7779
client := gitpod.NewClient(
7880
option.WithBaseURL(baseURL),
81+
option.WithAuthToken("My Auth Token"),
7982
)
8083
_, err := client.Editors.ResolveEditorURL(context.TODO(), gitpod.EditorResolveEditorURLParams{
8184
ConnectProtocolVersion: gitpod.F(gitpod.EditorResolveEditorURLParamsConnectProtocolVersion1),

environment_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func TestEnvironmentNewWithOptionalParams(t *testing.T) {
2424
}
2525
client := gitpod.NewClient(
2626
option.WithBaseURL(baseURL),
27+
option.WithAuthToken("My Auth Token"),
2728
)
2829
_, err := client.Environments.New(context.TODO(), gitpod.EnvironmentNewParams{
2930
ConnectProtocolVersion: gitpod.F(gitpod.EnvironmentNewParamsConnectProtocolVersion1),
@@ -86,6 +87,7 @@ func TestEnvironmentGetWithOptionalParams(t *testing.T) {
8687
}
8788
client := gitpod.NewClient(
8889
option.WithBaseURL(baseURL),
90+
option.WithAuthToken("My Auth Token"),
8991
)
9092
_, err := client.Environments.Get(context.TODO(), gitpod.EnvironmentGetParams{
9193
ConnectProtocolVersion: gitpod.F(gitpod.EnvironmentGetParamsConnectProtocolVersion1),
@@ -111,6 +113,7 @@ func TestEnvironmentListWithOptionalParams(t *testing.T) {
111113
}
112114
client := gitpod.NewClient(
113115
option.WithBaseURL(baseURL),
116+
option.WithAuthToken("My Auth Token"),
114117
)
115118
_, err := client.Environments.List(context.TODO(), gitpod.EnvironmentListParams{
116119
ConnectProtocolVersion: gitpod.F(gitpod.EnvironmentListParamsConnectProtocolVersion1),
@@ -147,6 +150,7 @@ func TestEnvironmentNewFromProjectWithOptionalParams(t *testing.T) {
147150
}
148151
client := gitpod.NewClient(
149152
option.WithBaseURL(baseURL),
153+
option.WithAuthToken("My Auth Token"),
150154
)
151155
_, err := client.Environments.NewFromProject(context.TODO(), gitpod.EnvironmentNewFromProjectParams{
152156
ConnectProtocolVersion: gitpod.F(gitpod.EnvironmentNewFromProjectParamsConnectProtocolVersion1),
@@ -210,6 +214,7 @@ func TestEnvironmentStartWithOptionalParams(t *testing.T) {
210214
}
211215
client := gitpod.NewClient(
212216
option.WithBaseURL(baseURL),
217+
option.WithAuthToken("My Auth Token"),
213218
)
214219
_, err := client.Environments.Start(context.TODO(), gitpod.EnvironmentStartParams{
215220
ConnectProtocolVersion: gitpod.F(gitpod.EnvironmentStartParamsConnectProtocolVersion1),

environmentautomationservice_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func TestEnvironmentAutomationServiceUpdateWithOptionalParams(t *testing.T) {
2323
}
2424
client := gitpod.NewClient(
2525
option.WithBaseURL(baseURL),
26+
option.WithAuthToken("My Auth Token"),
2627
)
2728
_, err := client.Environments.Automations.Services.Update(context.TODO(), gitpod.EnvironmentAutomationServiceUpdateParams{
2829
ConnectProtocolVersion: gitpod.F(gitpod.EnvironmentAutomationServiceUpdateParamsConnectProtocolVersion1),
@@ -51,6 +52,7 @@ func TestEnvironmentAutomationServiceListWithOptionalParams(t *testing.T) {
5152
}
5253
client := gitpod.NewClient(
5354
option.WithBaseURL(baseURL),
55+
option.WithAuthToken("My Auth Token"),
5456
)
5557
_, err := client.Environments.Automations.Services.List(context.TODO(), gitpod.EnvironmentAutomationServiceListParams{
5658
ConnectProtocolVersion: gitpod.F(gitpod.EnvironmentAutomationServiceListParamsConnectProtocolVersion1),
@@ -84,6 +86,7 @@ func TestEnvironmentAutomationServiceDeleteWithOptionalParams(t *testing.T) {
8486
}
8587
client := gitpod.NewClient(
8688
option.WithBaseURL(baseURL),
89+
option.WithAuthToken("My Auth Token"),
8790
)
8891
_, err := client.Environments.Automations.Services.Delete(context.TODO(), gitpod.EnvironmentAutomationServiceDeleteParams{
8992
ConnectProtocolVersion: gitpod.F(gitpod.EnvironmentAutomationServiceDeleteParamsConnectProtocolVersion1),
@@ -110,6 +113,7 @@ func TestEnvironmentAutomationServiceStartWithOptionalParams(t *testing.T) {
110113
}
111114
client := gitpod.NewClient(
112115
option.WithBaseURL(baseURL),
116+
option.WithAuthToken("My Auth Token"),
113117
)
114118
_, err := client.Environments.Automations.Services.Start(context.TODO(), gitpod.EnvironmentAutomationServiceStartParams{
115119
ConnectProtocolVersion: gitpod.F(gitpod.EnvironmentAutomationServiceStartParamsConnectProtocolVersion1),
@@ -135,6 +139,7 @@ func TestEnvironmentAutomationServiceStopWithOptionalParams(t *testing.T) {
135139
}
136140
client := gitpod.NewClient(
137141
option.WithBaseURL(baseURL),
142+
option.WithAuthToken("My Auth Token"),
138143
)
139144
_, err := client.Environments.Automations.Services.Stop(context.TODO(), gitpod.EnvironmentAutomationServiceStopParams{
140145
ConnectProtocolVersion: gitpod.F(gitpod.EnvironmentAutomationServiceStopParamsConnectProtocolVersion1),

environmentautomationtask_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func TestEnvironmentAutomationTaskNewWithOptionalParams(t *testing.T) {
2424
}
2525
client := gitpod.NewClient(
2626
option.WithBaseURL(baseURL),
27+
option.WithAuthToken("My Auth Token"),
2728
)
2829
_, err := client.Environments.Automations.Tasks.New(context.TODO(), gitpod.EnvironmentAutomationTaskNewParams{
2930
ConnectProtocolVersion: gitpod.F(gitpod.EnvironmentAutomationTaskNewParamsConnectProtocolVersion1),
@@ -65,6 +66,7 @@ func TestEnvironmentAutomationTaskUpdateWithOptionalParams(t *testing.T) {
6566
}
6667
client := gitpod.NewClient(
6768
option.WithBaseURL(baseURL),
69+
option.WithAuthToken("My Auth Token"),
6870
)
6971
_, err := client.Environments.Automations.Tasks.Update(context.TODO(), gitpod.EnvironmentAutomationTaskUpdateParams{
7072
ConnectProtocolVersion: gitpod.F(gitpod.EnvironmentAutomationTaskUpdateParamsConnectProtocolVersion1),
@@ -93,6 +95,7 @@ func TestEnvironmentAutomationTaskListWithOptionalParams(t *testing.T) {
9395
}
9496
client := gitpod.NewClient(
9597
option.WithBaseURL(baseURL),
98+
option.WithAuthToken("My Auth Token"),
9699
)
97100
_, err := client.Environments.Automations.Tasks.List(context.TODO(), gitpod.EnvironmentAutomationTaskListParams{
98101
ConnectProtocolVersion: gitpod.F(gitpod.EnvironmentAutomationTaskListParamsConnectProtocolVersion1),
@@ -126,6 +129,7 @@ func TestEnvironmentAutomationTaskDeleteWithOptionalParams(t *testing.T) {
126129
}
127130
client := gitpod.NewClient(
128131
option.WithBaseURL(baseURL),
132+
option.WithAuthToken("My Auth Token"),
129133
)
130134
_, err := client.Environments.Automations.Tasks.Delete(context.TODO(), gitpod.EnvironmentAutomationTaskDeleteParams{
131135
ConnectProtocolVersion: gitpod.F(gitpod.EnvironmentAutomationTaskDeleteParamsConnectProtocolVersion1),
@@ -151,6 +155,7 @@ func TestEnvironmentAutomationTaskStartWithOptionalParams(t *testing.T) {
151155
}
152156
client := gitpod.NewClient(
153157
option.WithBaseURL(baseURL),
158+
option.WithAuthToken("My Auth Token"),
154159
)
155160
_, err := client.Environments.Automations.Tasks.Start(context.TODO(), gitpod.EnvironmentAutomationTaskStartParams{
156161
ConnectProtocolVersion: gitpod.F(gitpod.EnvironmentAutomationTaskStartParamsConnectProtocolVersion1),

environmentclass_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func TestEnvironmentClassListWithOptionalParams(t *testing.T) {
2323
}
2424
client := gitpod.NewClient(
2525
option.WithBaseURL(baseURL),
26+
option.WithAuthToken("My Auth Token"),
2627
)
2728
_, err := client.EnvironmentClasses.List(context.TODO(), gitpod.EnvironmentClassListParams{
2829
ConnectProtocolVersion: gitpod.F(gitpod.EnvironmentClassListParamsConnectProtocolVersion1),

internal/requestconfig/requestconfig.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ type RequestConfig struct {
172172
BaseURL *url.URL
173173
HTTPClient *http.Client
174174
Middlewares []middleware
175+
AuthToken string
175176
// If ResponseBodyInto not nil, then we will attempt to deserialize into
176177
// ResponseBodyInto. If Destination is a []byte, then it will return the body as
177178
// is.
@@ -484,6 +485,7 @@ func (cfg *RequestConfig) Clone(ctx context.Context) *RequestConfig {
484485
BaseURL: cfg.BaseURL,
485486
HTTPClient: cfg.HTTPClient,
486487
Middlewares: cfg.Middlewares,
488+
AuthToken: cfg.AuthToken,
487489
}
488490

489491
return new

option/requestoption.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,11 @@ func WithRequestTimeout(dur time.Duration) RequestOption {
227227
func WithEnvironmentProduction() RequestOption {
228228
return WithBaseURL("https://localhost:8080/test-api/")
229229
}
230+
231+
// WithAuthToken returns a RequestOption that sets the client setting "auth_token".
232+
func WithAuthToken(value string) RequestOption {
233+
return func(r *requestconfig.RequestConfig) error {
234+
r.AuthToken = value
235+
return nil
236+
}
237+
}

0 commit comments

Comments
 (0)