-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathgitpod-service.go
2076 lines (1740 loc) · 65.9 KB
/
gitpod-service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.
//go:generate ./generate-mock.sh
package protocol
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"net/url"
"sync"
"github.com/sourcegraph/jsonrpc2"
"golang.org/x/xerrors"
"github.com/sirupsen/logrus"
)
// APIInterface wraps the
type APIInterface interface {
io.Closer
GetOwnerToken(ctx context.Context, workspaceID string) (res string, err error)
AdminBlockUser(ctx context.Context, req *AdminBlockUserRequest) (err error)
GetLoggedInUser(ctx context.Context) (res *User, err error)
UpdateLoggedInUser(ctx context.Context, user *User) (res *User, err error)
GetAuthProviders(ctx context.Context) (res []*AuthProviderInfo, err error)
GetOwnAuthProviders(ctx context.Context) (res []*AuthProviderEntry, err error)
UpdateOwnAuthProvider(ctx context.Context, params *UpdateOwnAuthProviderParams) (err error)
DeleteOwnAuthProvider(ctx context.Context, params *DeleteOwnAuthProviderParams) (err error)
GetConfiguration(ctx context.Context) (res *Configuration, err error)
GetGitpodTokenScopes(ctx context.Context, tokenHash string) (res []string, err error)
GetToken(ctx context.Context, query *GetTokenSearchOptions) (res *Token, err error)
GetPortAuthenticationToken(ctx context.Context, workspaceID string) (res *Token, err error)
DeleteAccount(ctx context.Context) (err error)
GetClientRegion(ctx context.Context) (res string, err error)
HasPermission(ctx context.Context, permission *PermissionName) (res bool, err error)
GetWorkspaces(ctx context.Context, options *GetWorkspacesOptions) (res []*WorkspaceInfo, err error)
GetWorkspaceOwner(ctx context.Context, workspaceID string) (res *UserInfo, err error)
GetWorkspaceUsers(ctx context.Context, workspaceID string) (res []*WorkspaceInstanceUser, err error)
GetFeaturedRepositories(ctx context.Context) (res []*WhitelistedRepository, err error)
GetWorkspace(ctx context.Context, id string) (res *WorkspaceInfo, err error)
IsWorkspaceOwner(ctx context.Context, workspaceID string) (res bool, err error)
CreateWorkspace(ctx context.Context, options *CreateWorkspaceOptions) (res *WorkspaceCreationResult, err error)
StartWorkspace(ctx context.Context, id string, options *StartWorkspaceOptions) (res *StartWorkspaceResult, err error)
StopWorkspace(ctx context.Context, id string) (err error)
DeleteWorkspace(ctx context.Context, id string) (err error)
SetWorkspaceDescription(ctx context.Context, id string, desc string) (err error)
ControlAdmission(ctx context.Context, id string, level *AdmissionLevel) (err error)
UpdateWorkspaceUserPin(ctx context.Context, id string, action *PinAction) (err error)
SendHeartBeat(ctx context.Context, options *SendHeartBeatOptions) (err error)
WatchWorkspaceImageBuildLogs(ctx context.Context, workspaceID string) (err error)
IsPrebuildDone(ctx context.Context, pwsid string) (res bool, err error)
SetWorkspaceTimeout(ctx context.Context, workspaceID string, duration *WorkspaceTimeoutDuration) (res *SetWorkspaceTimeoutResult, err error)
GetWorkspaceTimeout(ctx context.Context, workspaceID string) (res *GetWorkspaceTimeoutResult, err error)
GetOpenPorts(ctx context.Context, workspaceID string) (res []*WorkspaceInstancePort, err error)
OpenPort(ctx context.Context, workspaceID string, port *WorkspaceInstancePort) (res *WorkspaceInstancePort, err error)
ClosePort(ctx context.Context, workspaceID string, port float32) (err error)
GetUserStorageResource(ctx context.Context, options *GetUserStorageResourceOptions) (res string, err error)
UpdateUserStorageResource(ctx context.Context, options *UpdateUserStorageResourceOptions) (err error)
GetEnvVars(ctx context.Context) (res []*UserEnvVarValue, err error)
SetEnvVar(ctx context.Context, variable *UserEnvVarValue) (err error)
DeleteEnvVar(ctx context.Context, variable *UserEnvVarValue) (err error)
HasSSHPublicKey(ctx context.Context) (res bool, err error)
GetSSHPublicKeys(ctx context.Context) (res []*UserSSHPublicKeyValue, err error)
AddSSHPublicKey(ctx context.Context, value *SSHPublicKeyValue) (res *UserSSHPublicKeyValue, err error)
DeleteSSHPublicKey(ctx context.Context, id string) (err error)
GetContentBlobUploadURL(ctx context.Context, name string) (url string, err error)
GetContentBlobDownloadURL(ctx context.Context, name string) (url string, err error)
GetGitpodTokens(ctx context.Context) (res []*APIToken, err error)
GenerateNewGitpodToken(ctx context.Context, options *GenerateNewGitpodTokenOptions) (res string, err error)
DeleteGitpodToken(ctx context.Context, tokenHash string) (err error)
RegisterGithubApp(ctx context.Context, installationID string) (err error)
TakeSnapshot(ctx context.Context, options *TakeSnapshotOptions) (res string, err error)
WaitForSnapshot(ctx context.Context, snapshotId string) (err error)
GetSnapshots(ctx context.Context, workspaceID string) (res []*string, err error)
GuessGitTokenScopes(ctx context.Context, params *GuessGitTokenScopesParams) (res *GuessedGitTokenScopes, err error)
TrackEvent(ctx context.Context, event *RemoteTrackMessage) (err error)
GetSupportedWorkspaceClasses(ctx context.Context) (res []*SupportedWorkspaceClass, err error)
InstanceUpdates(ctx context.Context, instanceID string) (<-chan *WorkspaceInstance, error)
}
// FunctionName is the name of an RPC function
type FunctionName string
const (
// FunctionGetOwnerToken is the name of the getOwnerToken function
FunctionGetOwnerToken FunctionName = "getOwnerToken"
// FunctionAdminBlockUser is the name of the adminBlockUser function
FunctionAdminBlockUser FunctionName = "adminBlockUser"
// FunctionGetLoggedInUser is the name of the getLoggedInUser function
FunctionGetLoggedInUser FunctionName = "getLoggedInUser"
// FunctionUpdateLoggedInUser is the name of the updateLoggedInUser function
FunctionUpdateLoggedInUser FunctionName = "updateLoggedInUser"
// FunctionGetAuthProviders is the name of the getAuthProviders function
FunctionGetAuthProviders FunctionName = "getAuthProviders"
// FunctionGetOwnAuthProviders is the name of the getOwnAuthProviders function
FunctionGetOwnAuthProviders FunctionName = "getOwnAuthProviders"
// FunctionUpdateOwnAuthProvider is the name of the updateOwnAuthProvider function
FunctionUpdateOwnAuthProvider FunctionName = "updateOwnAuthProvider"
// FunctionDeleteOwnAuthProvider is the name of the deleteOwnAuthProvider function
FunctionDeleteOwnAuthProvider FunctionName = "deleteOwnAuthProvider"
// FunctionGetConfiguration is the name of the getConfiguration function
FunctionGetConfiguration FunctionName = "getConfiguration"
// FunctionGetGitpodTokenScopes is the name of the GetGitpodTokenScopes function
FunctionGetGitpodTokenScopes FunctionName = "getGitpodTokenScopes"
// FunctionGetToken is the name of the getToken function
FunctionGetToken FunctionName = "getToken"
// FunctionGetPortAuthenticationToken is the name of the getPortAuthenticationToken function
FunctionGetPortAuthenticationToken FunctionName = "getPortAuthenticationToken"
// FunctionDeleteAccount is the name of the deleteAccount function
FunctionDeleteAccount FunctionName = "deleteAccount"
// FunctionGetClientRegion is the name of the getClientRegion function
FunctionGetClientRegion FunctionName = "getClientRegion"
// FunctionHasPermission is the name of the hasPermission function
FunctionHasPermission FunctionName = "hasPermission"
// FunctionGetWorkspaces is the name of the getWorkspaces function
FunctionGetWorkspaces FunctionName = "getWorkspaces"
// FunctionGetWorkspaceOwner is the name of the getWorkspaceOwner function
FunctionGetWorkspaceOwner FunctionName = "getWorkspaceOwner"
// FunctionGetWorkspaceUsers is the name of the getWorkspaceUsers function
FunctionGetWorkspaceUsers FunctionName = "getWorkspaceUsers"
// FunctionGetFeaturedRepositories is the name of the getFeaturedRepositories function
FunctionGetFeaturedRepositories FunctionName = "getFeaturedRepositories"
// FunctionGetWorkspace is the name of the getWorkspace function
FunctionGetWorkspace FunctionName = "getWorkspace"
// FunctionIsWorkspaceOwner is the name of the isWorkspaceOwner function
FunctionIsWorkspaceOwner FunctionName = "isWorkspaceOwner"
// FunctionCreateWorkspace is the name of the createWorkspace function
FunctionCreateWorkspace FunctionName = "createWorkspace"
// FunctionStartWorkspace is the name of the startWorkspace function
FunctionStartWorkspace FunctionName = "startWorkspace"
// FunctionStopWorkspace is the name of the stopWorkspace function
FunctionStopWorkspace FunctionName = "stopWorkspace"
// FunctionDeleteWorkspace is the name of the deleteWorkspace function
FunctionDeleteWorkspace FunctionName = "deleteWorkspace"
// FunctionSetWorkspaceDescription is the name of the setWorkspaceDescription function
FunctionSetWorkspaceDescription FunctionName = "setWorkspaceDescription"
// FunctionControlAdmission is the name of the controlAdmission function
FunctionControlAdmission FunctionName = "controlAdmission"
// FunctionUpdateWorkspaceUserPin is the name of the updateWorkspaceUserPin function
FunctionUpdateWorkspaceUserPin FunctionName = "updateWorkspaceUserPin"
// FunctionSendHeartBeat is the name of the sendHeartBeat function
FunctionSendHeartBeat FunctionName = "sendHeartBeat"
// FunctionWatchWorkspaceImageBuildLogs is the name of the watchWorkspaceImageBuildLogs function
FunctionWatchWorkspaceImageBuildLogs FunctionName = "watchWorkspaceImageBuildLogs"
// FunctionIsPrebuildDone is the name of the isPrebuildDone function
FunctionIsPrebuildDone FunctionName = "isPrebuildDone"
// FunctionSetWorkspaceTimeout is the name of the setWorkspaceTimeout function
FunctionSetWorkspaceTimeout FunctionName = "setWorkspaceTimeout"
// FunctionGetWorkspaceTimeout is the name of the getWorkspaceTimeout function
FunctionGetWorkspaceTimeout FunctionName = "getWorkspaceTimeout"
// FunctionGetOpenPorts is the name of the getOpenPorts function
FunctionGetOpenPorts FunctionName = "getOpenPorts"
// FunctionOpenPort is the name of the openPort function
FunctionOpenPort FunctionName = "openPort"
// FunctionClosePort is the name of the closePort function
FunctionClosePort FunctionName = "closePort"
// FunctionGetUserStorageResource is the name of the getUserStorageResource function
FunctionGetUserStorageResource FunctionName = "getUserStorageResource"
// FunctionUpdateUserStorageResource is the name of the updateUserStorageResource function
FunctionUpdateUserStorageResource FunctionName = "updateUserStorageResource"
// FunctionGetEnvVars is the name of the getEnvVars function
FunctionGetEnvVars FunctionName = "getEnvVars"
// FunctionSetEnvVar is the name of the setEnvVar function
FunctionSetEnvVar FunctionName = "setEnvVar"
// FunctionDeleteEnvVar is the name of the deleteEnvVar function
FunctionDeleteEnvVar FunctionName = "deleteEnvVar"
// FunctionHasSSHPublicKey is the name of the hasSSHPublicKey function
FunctionHasSSHPublicKey FunctionName = "hasSSHPublicKey"
// FunctionGetSSHPublicKeys is the name of the getSSHPublicKeys function
FunctionGetSSHPublicKeys FunctionName = "getSSHPublicKeys"
// FunctionAddSSHPublicKey is the name of the addSSHPublicKey function
FunctionAddSSHPublicKey FunctionName = "addSSHPublicKey"
// FunctionDeleteSSHPublicKey is the name of the deleteSSHPublicKey function
FunctionDeleteSSHPublicKey FunctionName = "deleteSSHPublicKey"
// FunctionGetContentBlobUploadURL is the name fo the getContentBlobUploadUrl function
FunctionGetContentBlobUploadURL FunctionName = "getContentBlobUploadUrl"
// FunctionGetContentBlobDownloadURL is the name fo the getContentBlobDownloadUrl function
FunctionGetContentBlobDownloadURL FunctionName = "getContentBlobDownloadUrl"
// FunctionGetGitpodTokens is the name of the getGitpodTokens function
FunctionGetGitpodTokens FunctionName = "getGitpodTokens"
// FunctionGenerateNewGitpodToken is the name of the generateNewGitpodToken function
FunctionGenerateNewGitpodToken FunctionName = "generateNewGitpodToken"
// FunctionDeleteGitpodToken is the name of the deleteGitpodToken function
FunctionDeleteGitpodToken FunctionName = "deleteGitpodToken"
// FunctionRegisterGithubApp is the name of the registerGithubApp function
FunctionRegisterGithubApp FunctionName = "registerGithubApp"
// FunctionTakeSnapshot is the name of the takeSnapshot function
FunctionTakeSnapshot FunctionName = "takeSnapshot"
// FunctionGetSnapshots is the name of the getSnapshots function
FunctionGetSnapshots FunctionName = "getSnapshots"
// FunctionGuessGitTokenScopes is the name of the guessGitTokenScopes function
FunctionGuessGitTokenScope FunctionName = "guessGitTokenScopes"
// FunctionTrackEvent is the name of the trackEvent function
FunctionTrackEvent FunctionName = "trackEvent"
// FunctionGetSupportedWorkspaceClasses is the name of the getSupportedWorkspaceClasses function
FunctionGetSupportedWorkspaceClasses FunctionName = "getSupportedWorkspaceClasses"
// FunctionOnInstanceUpdate is the name of the onInstanceUpdate callback function
FunctionOnInstanceUpdate = "onInstanceUpdate"
)
var errNotConnected = errors.New("not connected to Gitpod server")
// ConnectToServerOpts configures the server connection
type ConnectToServerOpts struct {
Context context.Context
Token string
Log *logrus.Entry
ReconnectionHandler func()
CloseHandler func(error)
ExtraHeaders map[string]string
}
// ConnectToServer establishes a new websocket connection to the server
func ConnectToServer(endpoint string, opts ConnectToServerOpts) (*APIoverJSONRPC, error) {
if opts.Context == nil {
opts.Context = context.Background()
}
epURL, err := url.Parse(endpoint)
if err != nil {
return nil, xerrors.Errorf("invalid endpoint URL: %w", err)
}
var protocol string
if epURL.Scheme == "wss:" {
protocol = "https"
} else {
protocol = "http"
}
origin := fmt.Sprintf("%s://%s/", protocol, epURL.Hostname())
reqHeader := http.Header{}
reqHeader.Set("Origin", origin)
for k, v := range opts.ExtraHeaders {
reqHeader.Set(k, v)
}
if opts.Token != "" {
reqHeader.Set("Authorization", "Bearer "+opts.Token)
}
ws := NewReconnectingWebsocket(endpoint, reqHeader, opts.Log)
ws.ReconnectionHandler = opts.ReconnectionHandler
go func() {
err := ws.Dial(opts.Context)
if opts.CloseHandler != nil {
opts.CloseHandler(err)
}
}()
var res APIoverJSONRPC
res.log = opts.Log
res.C = jsonrpc2.NewConn(opts.Context, ws, jsonrpc2.HandlerWithError(res.handler))
return &res, nil
}
// APIoverJSONRPC makes JSON RPC calls to the Gitpod server is the APIoverJSONRPC message type
type APIoverJSONRPC struct {
C jsonrpc2.JSONRPC2
log *logrus.Entry
mu sync.RWMutex
subs map[string]map[chan *WorkspaceInstance]struct{}
}
// Close closes the connection
func (gp *APIoverJSONRPC) Close() (err error) {
if gp == nil {
err = errNotConnected
return
}
e1 := gp.C.Close()
if e1 != nil {
return e1
}
return nil
}
// InstanceUpdates subscribes to workspace instance updates until the context is canceled or the workspace
// instance is stopped.
func (gp *APIoverJSONRPC) InstanceUpdates(ctx context.Context, instanceID string) (<-chan *WorkspaceInstance, error) {
if gp == nil {
return nil, errNotConnected
}
chn := make(chan *WorkspaceInstance)
gp.mu.Lock()
if gp.subs == nil {
gp.subs = make(map[string]map[chan *WorkspaceInstance]struct{})
}
if sub, ok := gp.subs[instanceID]; ok {
sub[chn] = struct{}{}
} else {
gp.subs[instanceID] = map[chan *WorkspaceInstance]struct{}{chn: {}}
}
gp.mu.Unlock()
go func() {
<-ctx.Done()
gp.mu.Lock()
delete(gp.subs[instanceID], chn)
close(chn)
gp.mu.Unlock()
}()
return chn, nil
}
func (gp *APIoverJSONRPC) handler(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) {
if gp == nil {
err = errNotConnected
return
}
if req.Method != FunctionOnInstanceUpdate {
return
}
var instance WorkspaceInstance
err = json.Unmarshal(*req.Params, &instance)
if err != nil {
gp.log.WithError(err).WithField("raw", string(*req.Params)).Error("cannot unmarshal instance update")
return
}
gp.mu.RLock()
defer gp.mu.RUnlock()
for chn := range gp.subs[instance.ID] {
select {
case chn <- &instance:
default:
}
}
for chn := range gp.subs[""] {
select {
case chn <- &instance:
default:
}
}
return
}
func (gp *APIoverJSONRPC) GetOwnerToken(ctx context.Context, workspaceID string) (res string, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, workspaceID)
var _result string
err = gp.C.Call(ctx, "getOwnerToken", _params, &_result)
if err != nil {
return "", err
}
res = _result
return
}
// AdminBlockUser calls adminBlockUser on the server
func (gp *APIoverJSONRPC) AdminBlockUser(ctx context.Context, message *AdminBlockUserRequest) (err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, message)
var _result interface{}
err = gp.C.Call(ctx, "adminBlockUser", _params, &_result)
if err != nil {
return err
}
return
}
// GetLoggedInUser calls getLoggedInUser on the server
func (gp *APIoverJSONRPC) GetLoggedInUser(ctx context.Context) (res *User, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
var result User
err = gp.C.Call(ctx, "getLoggedInUser", _params, &result)
if err != nil {
return
}
res = &result
return
}
// UpdateLoggedInUser calls updateLoggedInUser on the server
func (gp *APIoverJSONRPC) UpdateLoggedInUser(ctx context.Context, user *User) (res *User, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, user)
var result User
err = gp.C.Call(ctx, "updateLoggedInUser", _params, &result)
if err != nil {
return
}
res = &result
return
}
// GetAuthProviders calls getAuthProviders on the server
func (gp *APIoverJSONRPC) GetAuthProviders(ctx context.Context) (res []*AuthProviderInfo, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
var result []*AuthProviderInfo
err = gp.C.Call(ctx, "getAuthProviders", _params, &result)
if err != nil {
return
}
res = result
return
}
// GetOwnAuthProviders calls getOwnAuthProviders on the server
func (gp *APIoverJSONRPC) GetOwnAuthProviders(ctx context.Context) (res []*AuthProviderEntry, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
var result []*AuthProviderEntry
err = gp.C.Call(ctx, "getOwnAuthProviders", _params, &result)
if err != nil {
return
}
res = result
return
}
// UpdateOwnAuthProvider calls updateOwnAuthProvider on the server
func (gp *APIoverJSONRPC) UpdateOwnAuthProvider(ctx context.Context, params *UpdateOwnAuthProviderParams) (err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, params)
err = gp.C.Call(ctx, "updateOwnAuthProvider", _params, nil)
if err != nil {
return
}
return
}
// DeleteOwnAuthProvider calls deleteOwnAuthProvider on the server
func (gp *APIoverJSONRPC) DeleteOwnAuthProvider(ctx context.Context, params *DeleteOwnAuthProviderParams) (err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, params)
err = gp.C.Call(ctx, "deleteOwnAuthProvider", _params, nil)
if err != nil {
return
}
return
}
// GetConfiguration calls getConfiguration on the server
func (gp *APIoverJSONRPC) GetConfiguration(ctx context.Context) (res *Configuration, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
var result Configuration
err = gp.C.Call(ctx, "getConfiguration", _params, &result)
if err != nil {
return
}
res = &result
return
}
// GetGitpodTokenScopes calls getGitpodTokenScopes on the server
func (gp *APIoverJSONRPC) GetGitpodTokenScopes(ctx context.Context, tokenHash string) (res []string, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, tokenHash)
var result []string
err = gp.C.Call(ctx, "getGitpodTokenScopes", _params, &result)
if err != nil {
return
}
res = result
return
}
// GetToken calls getToken on the server
func (gp *APIoverJSONRPC) GetToken(ctx context.Context, query *GetTokenSearchOptions) (res *Token, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, query)
var result Token
err = gp.C.Call(ctx, "getToken", _params, &result)
if err != nil {
return
}
res = &result
return
}
// GetPortAuthenticationToken calls getPortAuthenticationToken on the server
func (gp *APIoverJSONRPC) GetPortAuthenticationToken(ctx context.Context, workspaceID string) (res *Token, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, workspaceID)
var result Token
err = gp.C.Call(ctx, "getPortAuthenticationToken", _params, &result)
if err != nil {
return
}
res = &result
return
}
// DeleteAccount calls deleteAccount on the server
func (gp *APIoverJSONRPC) DeleteAccount(ctx context.Context) (err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
err = gp.C.Call(ctx, "deleteAccount", _params, nil)
if err != nil {
return
}
return
}
// GetClientRegion calls getClientRegion on the server
func (gp *APIoverJSONRPC) GetClientRegion(ctx context.Context) (res string, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
var result string
err = gp.C.Call(ctx, "getClientRegion", _params, &result)
if err != nil {
return
}
res = result
return
}
// HasPermission calls hasPermission on the server
func (gp *APIoverJSONRPC) HasPermission(ctx context.Context, permission *PermissionName) (res bool, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, permission)
var result bool
err = gp.C.Call(ctx, "hasPermission", _params, &result)
if err != nil {
return
}
res = result
return
}
// GetWorkspaces calls getWorkspaces on the server
func (gp *APIoverJSONRPC) GetWorkspaces(ctx context.Context, options *GetWorkspacesOptions) (res []*WorkspaceInfo, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, options)
var result []*WorkspaceInfo
err = gp.C.Call(ctx, "getWorkspaces", _params, &result)
if err != nil {
return
}
res = result
return
}
// GetWorkspaceOwner calls getWorkspaceOwner on the server
func (gp *APIoverJSONRPC) GetWorkspaceOwner(ctx context.Context, workspaceID string) (res *UserInfo, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, workspaceID)
var result UserInfo
err = gp.C.Call(ctx, "getWorkspaceOwner", _params, &result)
if err != nil {
return
}
res = &result
return
}
// GetWorkspaceUsers calls getWorkspaceUsers on the server
func (gp *APIoverJSONRPC) GetWorkspaceUsers(ctx context.Context, workspaceID string) (res []*WorkspaceInstanceUser, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, workspaceID)
var result []*WorkspaceInstanceUser
err = gp.C.Call(ctx, "getWorkspaceUsers", _params, &result)
if err != nil {
return
}
res = result
return
}
// GetFeaturedRepositories calls getFeaturedRepositories on the server
func (gp *APIoverJSONRPC) GetFeaturedRepositories(ctx context.Context) (res []*WhitelistedRepository, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
var result []*WhitelistedRepository
err = gp.C.Call(ctx, "getFeaturedRepositories", _params, &result)
if err != nil {
return
}
res = result
return
}
// GetWorkspace calls getWorkspace on the server
func (gp *APIoverJSONRPC) GetWorkspace(ctx context.Context, id string) (res *WorkspaceInfo, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, id)
var result WorkspaceInfo
err = gp.C.Call(ctx, "getWorkspace", _params, &result)
if err != nil {
return
}
res = &result
return
}
// IsWorkspaceOwner calls isWorkspaceOwner on the server
func (gp *APIoverJSONRPC) IsWorkspaceOwner(ctx context.Context, workspaceID string) (res bool, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, workspaceID)
var result bool
err = gp.C.Call(ctx, "isWorkspaceOwner", _params, &result)
if err != nil {
return
}
res = result
return
}
// CreateWorkspace calls createWorkspace on the server
func (gp *APIoverJSONRPC) CreateWorkspace(ctx context.Context, options *CreateWorkspaceOptions) (res *WorkspaceCreationResult, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, options)
var result WorkspaceCreationResult
err = gp.C.Call(ctx, "createWorkspace", _params, &result)
if err != nil {
return
}
res = &result
return
}
// StartWorkspace calls startWorkspace on the server
func (gp *APIoverJSONRPC) StartWorkspace(ctx context.Context, id string, options *StartWorkspaceOptions) (res *StartWorkspaceResult, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, id)
_params = append(_params, options)
var result StartWorkspaceResult
err = gp.C.Call(ctx, "startWorkspace", _params, &result)
if err != nil {
return
}
res = &result
return
}
// StopWorkspace calls stopWorkspace on the server
func (gp *APIoverJSONRPC) StopWorkspace(ctx context.Context, id string) (err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, id)
err = gp.C.Call(ctx, "stopWorkspace", _params, nil)
if err != nil {
return
}
return
}
// DeleteWorkspace calls deleteWorkspace on the server
func (gp *APIoverJSONRPC) DeleteWorkspace(ctx context.Context, id string) (err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, id)
err = gp.C.Call(ctx, "deleteWorkspace", _params, nil)
if err != nil {
return
}
return
}
// SetWorkspaceDescription calls setWorkspaceDescription on the server
func (gp *APIoverJSONRPC) SetWorkspaceDescription(ctx context.Context, id string, desc string) (err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, id)
_params = append(_params, desc)
err = gp.C.Call(ctx, "setWorkspaceDescription", _params, nil)
if err != nil {
return
}
return
}
// ControlAdmission calls controlAdmission on the server
func (gp *APIoverJSONRPC) ControlAdmission(ctx context.Context, id string, level *AdmissionLevel) (err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, id)
_params = append(_params, level)
err = gp.C.Call(ctx, "controlAdmission", _params, nil)
if err != nil {
return
}
return
}
// WatchWorkspaceImageBuildLogs calls watchWorkspaceImageBuildLogs on the server
func (gp *APIoverJSONRPC) WatchWorkspaceImageBuildLogs(ctx context.Context, workspaceID string) (err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, workspaceID)
err = gp.C.Call(ctx, "watchWorkspaceImageBuildLogs", _params, nil)
if err != nil {
return
}
return
}
// IsPrebuildDone calls isPrebuildDone on the server
func (gp *APIoverJSONRPC) IsPrebuildDone(ctx context.Context, pwsid string) (res bool, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, pwsid)
var result bool
err = gp.C.Call(ctx, "isPrebuildDone", _params, &result)
if err != nil {
return
}
res = result
return
}
// SetWorkspaceTimeout calls setWorkspaceTimeout on the server
func (gp *APIoverJSONRPC) SetWorkspaceTimeout(ctx context.Context, workspaceID string, duration *WorkspaceTimeoutDuration) (res *SetWorkspaceTimeoutResult, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, workspaceID)
_params = append(_params, duration)
var result SetWorkspaceTimeoutResult
err = gp.C.Call(ctx, "setWorkspaceTimeout", _params, &result)
if err != nil {
return
}
res = &result
return
}
// GetWorkspaceTimeout calls getWorkspaceTimeout on the server
func (gp *APIoverJSONRPC) GetWorkspaceTimeout(ctx context.Context, workspaceID string) (res *GetWorkspaceTimeoutResult, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, workspaceID)
var result GetWorkspaceTimeoutResult
err = gp.C.Call(ctx, "getWorkspaceTimeout", _params, &result)
if err != nil {
return
}
res = &result
return
}
// SendHeartBeat calls sendHeartBeat on the server
func (gp *APIoverJSONRPC) SendHeartBeat(ctx context.Context, options *SendHeartBeatOptions) (err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, options)
err = gp.C.Call(ctx, "sendHeartBeat", _params, nil)
if err != nil {
return
}
return
}
// UpdateWorkspaceUserPin calls updateWorkspaceUserPin on the server
func (gp *APIoverJSONRPC) UpdateWorkspaceUserPin(ctx context.Context, id string, action *PinAction) (err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, id)
_params = append(_params, action)
err = gp.C.Call(ctx, "updateWorkspaceUserPin", _params, nil)
if err != nil {
return
}
return
}
// GetOpenPorts calls getOpenPorts on the server
func (gp *APIoverJSONRPC) GetOpenPorts(ctx context.Context, workspaceID string) (res []*WorkspaceInstancePort, err error) {
if gp == nil {
err = errNotConnected
return
}
var _params []interface{}
_params = append(_params, workspaceID)
var result []*WorkspaceInstancePort
err = gp.C.Call(ctx, "getOpenPorts", _params, &result)
if err != nil {
return
}
res = result
return
}
// OpenPort calls openPort on the server
func (gp *APIoverJSONRPC) OpenPort(ctx context.Context, workspaceID string, port *WorkspaceInstancePort) (res *WorkspaceInstancePort, err error) {
if gp == nil {
err = errNotConnected