This repository was archived by the owner on Aug 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathinterface.go
More file actions
260 lines (177 loc) · 11.6 KB
/
interface.go
File metadata and controls
260 lines (177 loc) · 11.6 KB
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
package coder
import (
"context"
"net/url"
"cdr.dev/wsep"
"github.com/pion/webrtc/v3"
"nhooyr.io/websocket"
)
// Client wraps the Coder HTTP API.
// This is an interface to allow for mocking of coder-sdk client usage.
type Client interface {
// PushActivity pushes CLI activity to Coder.
PushActivity(ctx context.Context, source, workspaceID string) error
// Me gets the details of the authenticated user.
Me(ctx context.Context) (*User, error)
// UserByID get the details of a user by their id.
UserByID(ctx context.Context, id string) (*User, error)
// SSHKey gets the current SSH kepair of the authenticated user.
SSHKey(ctx context.Context) (*SSHKey, error)
// Users gets the list of user accounts.
Users(ctx context.Context) ([]User, error)
// UserByEmail gets a user by email.
UserByEmail(ctx context.Context, email string) (*User, error)
// UpdateUser applyes the partial update to the given user.
UpdateUser(ctx context.Context, userID string, req UpdateUserReq) error
// UpdateUXState applies a partial update of the user's UX State.
UpdateUXState(ctx context.Context, userID string, uxsPartial map[string]interface{}) error
// CreateUser creates a new user account.
CreateUser(ctx context.Context, req CreateUserReq) error
// DeleteUser deletes a user account.
DeleteUser(ctx context.Context, userID string) error
// SiteConfigAuth fetches the sitewide authentication configuration.
SiteConfigAuth(ctx context.Context) (*ConfigAuth, error)
// PutSiteConfigAuth sets the sitewide authentication configuration.
PutSiteConfigAuth(ctx context.Context, req ConfigAuth) error
// SiteConfigOAuth fetches the sitewide git provider OAuth configuration.
SiteConfigOAuth(ctx context.Context) (*ConfigOAuth, error)
// PutSiteConfigOAuth sets the sitewide git provider OAuth configuration.
PutSiteConfigOAuth(ctx context.Context, req ConfigOAuth) error
// SiteSetupModeEnabled fetches the current setup_mode state of a Coder deployment.
SiteSetupModeEnabled(ctx context.Context) (bool, error)
// SiteConfigExtensionMarketplace fetches the extension marketplace configuration.
SiteConfigExtensionMarketplace(ctx context.Context) (*ConfigExtensionMarketplace, error)
// PutSiteConfigExtensionMarketplace sets the extension marketplace configuration.
PutSiteConfigExtensionMarketplace(ctx context.Context, req ConfigExtensionMarketplace) error
// SiteConfigWorkspaces fetches the workspace configuration.
SiteConfigWorkspaces(ctx context.Context) (*ConfigWorkspaces, error)
// DeleteDevURL deletes the specified devurl.
DeleteDevURL(ctx context.Context, workspaceID, urlID string) error
// CreateDevURL inserts a new devurl for the authenticated user.
CreateDevURL(ctx context.Context, workspaceID string, req CreateDevURLReq) error
// DevURLs fetches the Dev URLs for a given workspace.
DevURLs(ctx context.Context, workspaceID string) ([]DevURL, error)
// PutDevURL updates an existing devurl for the authenticated user.
PutDevURL(ctx context.Context, workspaceID, urlID string, req PutDevURLReq) error
// CreateWorkspace sends a request to create a workspace.
CreateWorkspace(ctx context.Context, req CreateWorkspaceRequest) (*Workspace, error)
// ParseTemplate parses a template config. It support both remote repositories and local files.
// If a local file is specified then all other values in the request are ignored.
ParseTemplate(ctx context.Context, req ParseTemplateRequest) (*TemplateVersion, error)
// CreateWorkspaceFromRepo sends a request to create a workspace from a repository.
CreateWorkspaceFromRepo(ctx context.Context, orgID string, req TemplateVersion) (*Workspace, error)
// Workspaces lists workspaces returned by the given filter.
Workspaces(ctx context.Context) ([]Workspace, error)
// UserWorkspacesByOrganization gets the list of workspaces owned by the given user.
UserWorkspacesByOrganization(ctx context.Context, userID, orgID string) ([]Workspace, error)
// DeleteWorkspace deletes the workspace.
DeleteWorkspace(ctx context.Context, workspaceID string) error
// StopWorkspace stops the workspace.
StopWorkspace(ctx context.Context, workspaceID string) error
// RebuildWorkspace requests that the given workspaceID is rebuilt with no changes to its specification.
RebuildWorkspace(ctx context.Context, workspaceID string) error
// EditWorkspace modifies the workspace specification and initiates a rebuild.
EditWorkspace(ctx context.Context, workspaceID string, req UpdateWorkspaceReq) error
// DialWsep dials a workspace's command execution interface
// See https://github.com/cdr/wsep for details.
DialWsep(ctx context.Context, baseURL *url.URL, workspaceID string) (*websocket.Conn, error)
// DialExecutor gives a remote execution interface for performing commands inside a workspace.
DialExecutor(ctx context.Context, baseURL *url.URL, workspaceID string) (wsep.Execer, error)
// DialIDEStatus opens a websocket connection for cpu load metrics on the workspace.
DialIDEStatus(ctx context.Context, baseURL *url.URL, workspaceID string) (*websocket.Conn, error)
// DialWorkspaceBuildLog opens a websocket connection for the workspace build log messages.
DialWorkspaceBuildLog(ctx context.Context, workspaceID string) (*websocket.Conn, error)
// FollowWorkspaceBuildLog trails the build log of a Coder workspace.
FollowWorkspaceBuildLog(ctx context.Context, workspaceID string) (<-chan BuildLogFollowMsg, error)
// DialWorkspaceStats opens a websocket connection for workspace stats.
DialWorkspaceStats(ctx context.Context, workspaceID string) (*websocket.Conn, error)
// DialResourceLoad opens a websocket connection for cpu load metrics on the workspace.
DialResourceLoad(ctx context.Context, workspaceID string) (*websocket.Conn, error)
// WaitForWorkspaceReady will watch the build log and return when done.
WaitForWorkspaceReady(ctx context.Context, workspaceID string) error
// WorkspaceByID get the details of a workspace by its id.
WorkspaceByID(ctx context.Context, id string) (*Workspace, error)
// WorkspacesByWorkspaceProvider returns workspaces that belong to a particular workspace provider.
WorkspacesByWorkspaceProvider(ctx context.Context, wpID string) ([]Workspace, error)
// ImportImage creates a new image and optionally a new registry.
ImportImage(ctx context.Context, req ImportImageReq) (*Image, error)
// ImageByID returns an image entity, fetched by its ID.
ImageByID(ctx context.Context, id string) (*Image, error)
// OrganizationImages returns all of the images imported for orgID.
OrganizationImages(ctx context.Context, orgID string) ([]Image, error)
// UpdateImage applies a partial update to an image resource.
UpdateImage(ctx context.Context, imageID string, req UpdateImageReq) error
// UpdateImageTags refreshes the latest digests for all tags of the image.
UpdateImageTags(ctx context.Context, imageID string) error
// Organizations gets all Organizations.
Organizations(ctx context.Context) ([]Organization, error)
// OrganizationByID get the Organization by its ID.
OrganizationByID(ctx context.Context, orgID string) (*Organization, error)
// OrganizationMembers get all members of the given organization.
OrganizationMembers(ctx context.Context, orgID string) ([]OrganizationUser, error)
// UpdateOrganization applys a partial update of an Organization resource.
UpdateOrganization(ctx context.Context, orgID string, req UpdateOrganizationReq) error
// CreateOrganization creates a new Organization in Coder.
CreateOrganization(ctx context.Context, req CreateOrganizationReq) error
// DeleteOrganization deletes an organization.
DeleteOrganization(ctx context.Context, orgID string) error
// Registries fetches all registries in an organization.
Registries(ctx context.Context, orgID string) ([]Registry, error)
// RegistryByID fetches a registry resource by its ID.
RegistryByID(ctx context.Context, registryID string) (*Registry, error)
// UpdateRegistry applies a partial update to a registry resource.
UpdateRegistry(ctx context.Context, registryID string, req UpdateRegistryReq) error
// DeleteRegistry deletes a registry resource by its ID.
DeleteRegistry(ctx context.Context, registryID string) error
// CreateImageTag creates a new image tag resource.
CreateImageTag(ctx context.Context, imageID string, req CreateImageTagReq) (*ImageTag, error)
// DeleteImageTag deletes an image tag resource.
DeleteImageTag(ctx context.Context, imageID, tag string) error
// ImageTags fetch all image tags.
ImageTags(ctx context.Context, imageID string) ([]ImageTag, error)
// ImageTagByID fetch an image tag by ID.
ImageTagByID(ctx context.Context, imageID, tagID string) (*ImageTag, error)
// CreateAPIToken creates a new APIToken for making authenticated requests to Coder.
CreateAPIToken(ctx context.Context, userID string, req CreateAPITokenReq) (string, error)
// APITokens fetches all APITokens owned by the given user.
APITokens(ctx context.Context, userID string) ([]APIToken, error)
// APITokenByID fetches the metadata for a given APIToken.
APITokenByID(ctx context.Context, userID, tokenID string) (*APIToken, error)
// DeleteAPIToken deletes an APIToken.
DeleteAPIToken(ctx context.Context, userID, tokenID string) error
// RegenerateAPIToken regenerates the given APIToken and returns the new value.
RegenerateAPIToken(ctx context.Context, userID, tokenID string) (string, error)
// APIVersion parses the coder-version http header from an authenticated request.
APIVersion(ctx context.Context) (string, error)
// WorkspaceProviderByID fetches a workspace provider entity by its unique ID.
WorkspaceProviderByID(ctx context.Context, id string) (*KubernetesProvider, error)
// WorkspaceProviders fetches all workspace providers known to the Coder control plane.
WorkspaceProviders(ctx context.Context) (*WorkspaceProviders, error)
// CreateWorkspaceProvider creates a new WorkspaceProvider entity.
CreateWorkspaceProvider(ctx context.Context, req CreateWorkspaceProviderReq) (*CreateWorkspaceProviderRes, error)
// DeleteWorkspaceProviderByID deletes a workspace provider entity from the Coder control plane.
DeleteWorkspaceProviderByID(ctx context.Context, id string) error
// Token returns the API Token used to authenticate.
Token() string
// BaseURL returns the BaseURL configured for this Client.
BaseURL() url.URL
// CordonWorkspaceProvider prevents the provider from having any more workspaces placed on it.
CordonWorkspaceProvider(ctx context.Context, id, reason string) error
// UnCordonWorkspaceProvider changes an existing cordoned providers status to 'Ready';
// allowing it to continue creating new workspaces and provisioning resources for them.
UnCordonWorkspaceProvider(ctx context.Context, id string) error
// RenameWorkspaceProvider changes an existing providers name field.
RenameWorkspaceProvider(ctx context.Context, id string, name string) error
// SetPolicyTemplate sets the workspace policy template
SetPolicyTemplate(ctx context.Context, templateID string, templateScope TemplateScope, dryRun bool) (*SetPolicyTemplateResponse, error)
// Satellites fetches all satellitess known to the Coder control plane.
Satellites(ctx context.Context) ([]Satellite, error)
// CreateSatellite creates a new satellite entity.
CreateSatellite(ctx context.Context, req CreateSatelliteReq) (*Satellite, error)
// DeleteSatelliteByID deletes a satellite entity from the Coder control plane.
DeleteSatelliteByID(ctx context.Context, id string) error
// UpdateLastConnectionAt updates the last connection at attribute of a workspace.
UpdateLastConnectionAt(ctx context.Context, workspaceID string) error
// ICEServers fetches the list of ICE servers advertised by the deployment.
ICEServers(ctx context.Context) ([]webrtc.ICEServer, error)
}