1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
16 "github.com/sirupsen/logrus"
19 type APIEndpoint struct {
22 // "new attributes" key for create/update requests
27 EndpointConfigGet = APIEndpoint{"GET", "arvados/v1/config", ""}
28 EndpointVocabularyGet = APIEndpoint{"GET", "arvados/v1/vocabulary", ""}
29 EndpointDiscoveryDocument = APIEndpoint{"GET", "discovery/v1/apis/arvados/v1/rest", ""}
30 EndpointLogin = APIEndpoint{"GET", "login", ""}
31 EndpointLogout = APIEndpoint{"GET", "logout", ""}
32 EndpointAuthorizedKeyCreate = APIEndpoint{"POST", "arvados/v1/authorized_keys", "authorized_key"}
33 EndpointAuthorizedKeyUpdate = APIEndpoint{"PATCH", "arvados/v1/authorized_keys/{uuid}", "authorized_key"}
34 EndpointAuthorizedKeyGet = APIEndpoint{"GET", "arvados/v1/authorized_keys/{uuid}", ""}
35 EndpointAuthorizedKeyList = APIEndpoint{"GET", "arvados/v1/authorized_keys", ""}
36 EndpointAuthorizedKeyDelete = APIEndpoint{"DELETE", "arvados/v1/authorized_keys/{uuid}", ""}
37 EndpointCollectionCreate = APIEndpoint{"POST", "arvados/v1/collections", "collection"}
38 EndpointCollectionUpdate = APIEndpoint{"PATCH", "arvados/v1/collections/{uuid}", "collection"}
39 EndpointCollectionGet = APIEndpoint{"GET", "arvados/v1/collections/{uuid}", ""}
40 EndpointCollectionList = APIEndpoint{"GET", "arvados/v1/collections", ""}
41 EndpointCollectionProvenance = APIEndpoint{"GET", "arvados/v1/collections/{uuid}/provenance", ""}
42 EndpointCollectionUsedBy = APIEndpoint{"GET", "arvados/v1/collections/{uuid}/used_by", ""}
43 EndpointCollectionDelete = APIEndpoint{"DELETE", "arvados/v1/collections/{uuid}", ""}
44 EndpointCollectionTrash = APIEndpoint{"POST", "arvados/v1/collections/{uuid}/trash", ""}
45 EndpointCollectionUntrash = APIEndpoint{"POST", "arvados/v1/collections/{uuid}/untrash", ""}
46 EndpointComputedPermissionList = APIEndpoint{"GET", "arvados/v1/computed_permissions", ""}
47 EndpointContainerCreate = APIEndpoint{"POST", "arvados/v1/containers", "container"}
48 EndpointContainerUpdate = APIEndpoint{"PATCH", "arvados/v1/containers/{uuid}", "container"}
49 EndpointContainerPriorityUpdate = APIEndpoint{"POST", "arvados/v1/containers/{uuid}/update_priority", "container"}
50 EndpointContainerGet = APIEndpoint{"GET", "arvados/v1/containers/{uuid}", ""}
51 EndpointContainerList = APIEndpoint{"GET", "arvados/v1/containers", ""}
52 EndpointContainerDelete = APIEndpoint{"DELETE", "arvados/v1/containers/{uuid}", ""}
53 EndpointContainerLock = APIEndpoint{"POST", "arvados/v1/containers/{uuid}/lock", ""}
54 EndpointContainerUnlock = APIEndpoint{"POST", "arvados/v1/containers/{uuid}/unlock", ""}
55 EndpointContainerSSH = APIEndpoint{"POST", "arvados/v1/containers/{uuid}/ssh", ""}
56 EndpointContainerSSHCompat = APIEndpoint{"POST", "arvados/v1/connect/{uuid}/ssh", ""} // for compatibility with arvados <2.7
57 EndpointContainerGatewayTunnel = APIEndpoint{"POST", "arvados/v1/containers/{uuid}/gateway_tunnel", ""}
58 EndpointContainerGatewayTunnelCompat = APIEndpoint{"POST", "arvados/v1/connect/{uuid}/gateway_tunnel", ""} // for compatibility with arvados <2.7
59 EndpointContainerRequestCreate = APIEndpoint{"POST", "arvados/v1/container_requests", "container_request"}
60 EndpointContainerRequestUpdate = APIEndpoint{"PATCH", "arvados/v1/container_requests/{uuid}", "container_request"}
61 EndpointContainerRequestGet = APIEndpoint{"GET", "arvados/v1/container_requests/{uuid}", ""}
62 EndpointContainerRequestList = APIEndpoint{"GET", "arvados/v1/container_requests", ""}
63 EndpointContainerRequestDelete = APIEndpoint{"DELETE", "arvados/v1/container_requests/{uuid}", ""}
64 EndpointContainerRequestContainerStatus = APIEndpoint{"GET", "arvados/v1/container_requests/{uuid}/container_status", ""}
65 EndpointContainerRequestLog = APIEndpoint{"GET", "arvados/v1/container_requests/{uuid}/log{path:|/.*}", ""}
66 EndpointGroupCreate = APIEndpoint{"POST", "arvados/v1/groups", "group"}
67 EndpointGroupUpdate = APIEndpoint{"PATCH", "arvados/v1/groups/{uuid}", "group"}
68 EndpointGroupGet = APIEndpoint{"GET", "arvados/v1/groups/{uuid}", ""}
69 EndpointGroupList = APIEndpoint{"GET", "arvados/v1/groups", ""}
70 EndpointGroupContents = APIEndpoint{"GET", "arvados/v1/groups/contents", ""}
71 EndpointGroupContentsUUIDInPath = APIEndpoint{"GET", "arvados/v1/groups/{uuid}/contents", ""} // Alternative HTTP route; client-side code should always use EndpointGroupContents instead
72 EndpointGroupShared = APIEndpoint{"GET", "arvados/v1/groups/shared", ""}
73 EndpointGroupDelete = APIEndpoint{"DELETE", "arvados/v1/groups/{uuid}", ""}
74 EndpointGroupTrash = APIEndpoint{"POST", "arvados/v1/groups/{uuid}/trash", ""}
75 EndpointGroupUntrash = APIEndpoint{"POST", "arvados/v1/groups/{uuid}/untrash", ""}
76 EndpointLinkCreate = APIEndpoint{"POST", "arvados/v1/links", "link"}
77 EndpointLinkUpdate = APIEndpoint{"PATCH", "arvados/v1/links/{uuid}", "link"}
78 EndpointLinkGet = APIEndpoint{"GET", "arvados/v1/links/{uuid}", ""}
79 EndpointLinkList = APIEndpoint{"GET", "arvados/v1/links", ""}
80 EndpointLinkDelete = APIEndpoint{"DELETE", "arvados/v1/links/{uuid}", ""}
81 EndpointLogCreate = APIEndpoint{"POST", "arvados/v1/logs", "log"}
82 EndpointLogUpdate = APIEndpoint{"PATCH", "arvados/v1/logs/{uuid}", "log"}
83 EndpointLogGet = APIEndpoint{"GET", "arvados/v1/logs/{uuid}", ""}
84 EndpointLogList = APIEndpoint{"GET", "arvados/v1/logs", ""}
85 EndpointLogDelete = APIEndpoint{"DELETE", "arvados/v1/logs/{uuid}", ""}
86 EndpointSysTrashSweep = APIEndpoint{"POST", "sys/trash_sweep", ""}
87 EndpointUserActivate = APIEndpoint{"POST", "arvados/v1/users/{uuid}/activate", ""}
88 EndpointUserCreate = APIEndpoint{"POST", "arvados/v1/users", "user"}
89 EndpointUserCurrent = APIEndpoint{"GET", "arvados/v1/users/current", ""}
90 EndpointUserDelete = APIEndpoint{"DELETE", "arvados/v1/users/{uuid}", ""}
91 EndpointUserGet = APIEndpoint{"GET", "arvados/v1/users/{uuid}", ""}
92 EndpointUserGetCurrent = APIEndpoint{"GET", "arvados/v1/users/current", ""}
93 EndpointUserGetSystem = APIEndpoint{"GET", "arvados/v1/users/system", ""}
94 EndpointUserList = APIEndpoint{"GET", "arvados/v1/users", ""}
95 EndpointUserMerge = APIEndpoint{"POST", "arvados/v1/users/merge", ""}
96 EndpointUserSetup = APIEndpoint{"POST", "arvados/v1/users/setup", "user"}
97 EndpointUserSystem = APIEndpoint{"GET", "arvados/v1/users/system", ""}
98 EndpointUserUnsetup = APIEndpoint{"POST", "arvados/v1/users/{uuid}/unsetup", ""}
99 EndpointUserUpdate = APIEndpoint{"PATCH", "arvados/v1/users/{uuid}", "user"}
100 EndpointUserBatchUpdate = APIEndpoint{"PATCH", "arvados/v1/users/batch_update", ""}
101 EndpointUserAuthenticate = APIEndpoint{"POST", "arvados/v1/users/authenticate", ""}
102 EndpointAPIClientAuthorizationCurrent = APIEndpoint{"GET", "arvados/v1/api_client_authorizations/current", ""}
103 EndpointAPIClientAuthorizationCreate = APIEndpoint{"POST", "arvados/v1/api_client_authorizations", "api_client_authorization"}
104 EndpointAPIClientAuthorizationUpdate = APIEndpoint{"PUT", "arvados/v1/api_client_authorizations/{uuid}", "api_client_authorization"}
105 EndpointAPIClientAuthorizationList = APIEndpoint{"GET", "arvados/v1/api_client_authorizations", ""}
106 EndpointAPIClientAuthorizationDelete = APIEndpoint{"DELETE", "arvados/v1/api_client_authorizations/{uuid}", ""}
107 EndpointAPIClientAuthorizationGet = APIEndpoint{"GET", "arvados/v1/api_client_authorizations/{uuid}", ""}
108 EndpointCredentialCreate = APIEndpoint{"POST", "arvados/v1/credentials", "credential"}
109 EndpointCredentialUpdate = APIEndpoint{"PATCH", "arvados/v1/credentials/{uuid}", "credential"}
110 EndpointCredentialGet = APIEndpoint{"GET", "arvados/v1/credentials/{uuid}", ""}
111 EndpointCredentialDelete = APIEndpoint{"DELETE", "arvados/v1/credentials/{uuid}", ""}
112 EndpointCredentialSecret = APIEndpoint{"GET", "arvados/v1/credentials/{uuid}/credential_secret", ""}
115 type ContainerHTTPProxyOptions struct {
116 // "{container uuid}-{port}", ":{dynamic-external-port}", or
117 // the name of a published port
118 Target string `json:"target"`
119 NoForward bool `json:"no_forward"`
120 Request *http.Request `json:"-"`
123 type ContainerSSHOptions struct {
124 UUID string `json:"uuid"`
125 DetachKeys string `json:"detach_keys"`
126 LoginUsername string `json:"login_username"`
127 NoForward bool `json:"no_forward"`
130 type ConnectionResponse struct {
131 Conn net.Conn `json:"-"`
132 Bufrw *bufio.ReadWriter `json:"-"`
133 Logger logrus.FieldLogger `json:"-"`
134 Header http.Header `json:"-"`
137 type ContainerGatewayTunnelOptions struct {
138 UUID string `json:"uuid"`
139 AuthSecret string `json:"auth_secret"`
142 type GetOptions struct {
143 UUID string `json:"uuid,omitempty"`
144 Select []string `json:"select"`
145 IncludeTrash bool `json:"include_trash"`
146 ForwardedFor string `json:"forwarded_for,omitempty"`
147 Remote string `json:"remote,omitempty"`
150 type UntrashOptions struct {
151 UUID string `json:"uuid"`
152 EnsureUniqueName bool `json:"ensure_unique_name"`
155 type ListOptions struct {
156 ClusterID string `json:"cluster_id"`
157 Select []string `json:"select"`
158 Filters []Filter `json:"filters"`
159 Where map[string]interface{} `json:"where"`
160 Limit int64 `json:"limit"`
161 Offset int64 `json:"offset"`
162 Order []string `json:"order"`
163 Distinct bool `json:"distinct"`
164 Count string `json:"count"`
165 IncludeTrash bool `json:"include_trash"`
166 IncludeOldVersions bool `json:"include_old_versions"`
167 BypassFederation bool `json:"bypass_federation"`
168 ForwardedFor string `json:"forwarded_for,omitempty"`
169 Include []string `json:"include"`
172 type CreateOptions struct {
173 ClusterID string `json:"cluster_id"`
174 EnsureUniqueName bool `json:"ensure_unique_name"`
175 Select []string `json:"select"`
176 Attrs map[string]interface{} `json:"attrs"`
177 // ReplaceFiles and ReplaceSegments only apply when creating a
179 ReplaceFiles map[string]string `json:"replace_files"`
180 ReplaceSegments map[BlockSegment]BlockSegment `json:"replace_segments"`
183 type UpdateOptions struct {
184 UUID string `json:"uuid"`
185 Attrs map[string]interface{} `json:"attrs"`
186 Select []string `json:"select"`
187 BypassFederation bool `json:"bypass_federation"`
188 // ReplaceFiles and ReplaceSegments only apply when updating a
190 ReplaceFiles map[string]string `json:"replace_files"`
191 ReplaceSegments map[BlockSegment]BlockSegment `json:"replace_segments"`
194 type GroupContentsOptions struct {
195 ClusterID string `json:"cluster_id"`
196 UUID string `json:"uuid,omitempty"`
197 Select []string `json:"select"`
198 Filters []Filter `json:"filters"`
199 Limit int64 `json:"limit"`
200 Offset int64 `json:"offset"`
201 Order []string `json:"order"`
202 Distinct bool `json:"distinct"`
203 Count string `json:"count"`
204 Include []string `json:"include"`
205 Recursive bool `json:"recursive"`
206 IncludeTrash bool `json:"include_trash"`
207 IncludeOldVersions bool `json:"include_old_versions"`
208 ExcludeHomeProject bool `json:"exclude_home_project"`
211 type UserActivateOptions struct {
212 UUID string `json:"uuid"`
215 type UserSetupOptions struct {
216 UUID string `json:"uuid,omitempty"`
217 Email string `json:"email,omitempty"`
218 OpenIDPrefix string `json:"openid_prefix,omitempty"`
219 RepoName string `json:"repo_name,omitempty"`
220 VMUUID string `json:"vm_uuid,omitempty"`
221 SendNotificationEmail bool `json:"send_notification_email,omitempty"`
222 Attrs map[string]interface{} `json:"attrs"`
225 type UserMergeOptions struct {
226 NewUserUUID string `json:"new_user_uuid,omitempty"`
227 OldUserUUID string `json:"old_user_uuid,omitempty"`
228 NewOwnerUUID string `json:"new_owner_uuid,omitempty"`
229 NewUserToken string `json:"new_user_token,omitempty"`
230 RedirectToNewUser bool `json:"redirect_to_new_user"`
233 type UserBatchUpdateOptions struct {
234 Updates map[string]map[string]interface{} `json:"updates"`
237 type UserBatchUpdateResponse struct{}
239 type DeleteOptions struct {
240 UUID string `json:"uuid"`
243 type LoginOptions struct {
244 ReturnTo string `json:"return_to"` // On success, redirect to this target with api_token=xxx query param
245 Remote string `json:"remote,omitempty"` // Salt token for remote Cluster ID
246 Code string `json:"code,omitempty"` // OAuth2 callback code
247 State string `json:"state,omitempty"` // OAuth2 callback state
250 type UserAuthenticateOptions struct {
251 Username string `json:"username,omitempty"` // PAM username
252 Password string `json:"password,omitempty"` // PAM password
255 type LogoutOptions struct {
256 ReturnTo string `json:"return_to"` // Redirect to this URL after logging out
259 type BlockReadOptions struct {
262 LocalLocator func(string)
263 // If true, do not read the block data, just check whether the
264 // block is available in a local filesystem or memory cache.
265 // If not, return ErrNotCached.
269 // See CheckCacheOnly field of BlockReadOptions.
270 var ErrNotCached = errors.New("block is not in cache")
272 type BlockWriteOptions struct {
275 Reader io.Reader // Must be set if Data is nil.
276 DataSize int // Must be set if Data is nil.
278 StorageClasses []string
283 type BlockWriteResponse struct {
286 StorageClasses map[string]int
289 type WebDAVOptions struct {
295 type ContainerLogOptions struct {
296 UUID string `json:"uuid"`
297 NoForward bool `json:"no_forward"`
301 type RepackOptions struct {
308 ConfigGet(ctx context.Context) (json.RawMessage, error)
309 VocabularyGet(ctx context.Context) (Vocabulary, error)
310 Login(ctx context.Context, options LoginOptions) (LoginResponse, error)
311 Logout(ctx context.Context, options LogoutOptions) (LogoutResponse, error)
312 AuthorizedKeyCreate(ctx context.Context, options CreateOptions) (AuthorizedKey, error)
313 AuthorizedKeyUpdate(ctx context.Context, options UpdateOptions) (AuthorizedKey, error)
314 AuthorizedKeyGet(ctx context.Context, options GetOptions) (AuthorizedKey, error)
315 AuthorizedKeyList(ctx context.Context, options ListOptions) (AuthorizedKeyList, error)
316 AuthorizedKeyDelete(ctx context.Context, options DeleteOptions) (AuthorizedKey, error)
317 CollectionCreate(ctx context.Context, options CreateOptions) (Collection, error)
318 CollectionUpdate(ctx context.Context, options UpdateOptions) (Collection, error)
319 CollectionGet(ctx context.Context, options GetOptions) (Collection, error)
320 CollectionList(ctx context.Context, options ListOptions) (CollectionList, error)
321 CollectionProvenance(ctx context.Context, options GetOptions) (map[string]interface{}, error)
322 CollectionUsedBy(ctx context.Context, options GetOptions) (map[string]interface{}, error)
323 CollectionDelete(ctx context.Context, options DeleteOptions) (Collection, error)
324 CollectionTrash(ctx context.Context, options DeleteOptions) (Collection, error)
325 CollectionUntrash(ctx context.Context, options UntrashOptions) (Collection, error)
326 ComputedPermissionList(ctx context.Context, options ListOptions) (ComputedPermissionList, error)
327 ContainerCreate(ctx context.Context, options CreateOptions) (Container, error)
328 ContainerUpdate(ctx context.Context, options UpdateOptions) (Container, error)
329 ContainerPriorityUpdate(ctx context.Context, options UpdateOptions) (Container, error)
330 ContainerGet(ctx context.Context, options GetOptions) (Container, error)
331 ContainerList(ctx context.Context, options ListOptions) (ContainerList, error)
332 ContainerDelete(ctx context.Context, options DeleteOptions) (Container, error)
333 ContainerLock(ctx context.Context, options GetOptions) (Container, error)
334 ContainerUnlock(ctx context.Context, options GetOptions) (Container, error)
335 ContainerSSH(ctx context.Context, options ContainerSSHOptions) (ConnectionResponse, error)
336 ContainerGatewayTunnel(ctx context.Context, options ContainerGatewayTunnelOptions) (ConnectionResponse, error)
337 ContainerHTTPProxy(ctx context.Context, options ContainerHTTPProxyOptions) (http.Handler, error)
338 ContainerRequestCreate(ctx context.Context, options CreateOptions) (ContainerRequest, error)
339 ContainerRequestUpdate(ctx context.Context, options UpdateOptions) (ContainerRequest, error)
340 ContainerRequestGet(ctx context.Context, options GetOptions) (ContainerRequest, error)
341 ContainerRequestList(ctx context.Context, options ListOptions) (ContainerRequestList, error)
342 ContainerRequestDelete(ctx context.Context, options DeleteOptions) (ContainerRequest, error)
343 ContainerRequestContainerStatus(ctx context.Context, options GetOptions) (ContainerStatus, error)
344 ContainerRequestLog(ctx context.Context, options ContainerLogOptions) (http.Handler, error)
345 GroupCreate(ctx context.Context, options CreateOptions) (Group, error)
346 GroupUpdate(ctx context.Context, options UpdateOptions) (Group, error)
347 GroupGet(ctx context.Context, options GetOptions) (Group, error)
348 GroupList(ctx context.Context, options ListOptions) (GroupList, error)
349 GroupContents(ctx context.Context, options GroupContentsOptions) (ObjectList, error)
350 GroupShared(ctx context.Context, options ListOptions) (GroupList, error)
351 GroupDelete(ctx context.Context, options DeleteOptions) (Group, error)
352 GroupTrash(ctx context.Context, options DeleteOptions) (Group, error)
353 GroupUntrash(ctx context.Context, options UntrashOptions) (Group, error)
354 LinkCreate(ctx context.Context, options CreateOptions) (Link, error)
355 LinkUpdate(ctx context.Context, options UpdateOptions) (Link, error)
356 LinkGet(ctx context.Context, options GetOptions) (Link, error)
357 LinkList(ctx context.Context, options ListOptions) (LinkList, error)
358 LinkDelete(ctx context.Context, options DeleteOptions) (Link, error)
359 LogCreate(ctx context.Context, options CreateOptions) (Log, error)
360 LogUpdate(ctx context.Context, options UpdateOptions) (Log, error)
361 LogGet(ctx context.Context, options GetOptions) (Log, error)
362 LogList(ctx context.Context, options ListOptions) (LogList, error)
363 LogDelete(ctx context.Context, options DeleteOptions) (Log, error)
364 SysTrashSweep(ctx context.Context, options struct{}) (struct{}, error)
365 UserCreate(ctx context.Context, options CreateOptions) (User, error)
366 UserUpdate(ctx context.Context, options UpdateOptions) (User, error)
367 UserMerge(ctx context.Context, options UserMergeOptions) (User, error)
368 UserActivate(ctx context.Context, options UserActivateOptions) (User, error)
369 UserSetup(ctx context.Context, options UserSetupOptions) (map[string]interface{}, error)
370 UserUnsetup(ctx context.Context, options GetOptions) (User, error)
371 UserGet(ctx context.Context, options GetOptions) (User, error)
372 UserGetCurrent(ctx context.Context, options GetOptions) (User, error)
373 UserGetSystem(ctx context.Context, options GetOptions) (User, error)
374 UserList(ctx context.Context, options ListOptions) (UserList, error)
375 UserDelete(ctx context.Context, options DeleteOptions) (User, error)
376 UserBatchUpdate(context.Context, UserBatchUpdateOptions) (UserList, error)
377 UserAuthenticate(ctx context.Context, options UserAuthenticateOptions) (APIClientAuthorization, error)
378 APIClientAuthorizationCurrent(ctx context.Context, options GetOptions) (APIClientAuthorization, error)
379 APIClientAuthorizationCreate(ctx context.Context, options CreateOptions) (APIClientAuthorization, error)
380 APIClientAuthorizationList(ctx context.Context, options ListOptions) (APIClientAuthorizationList, error)
381 APIClientAuthorizationDelete(ctx context.Context, options DeleteOptions) (APIClientAuthorization, error)
382 APIClientAuthorizationUpdate(ctx context.Context, options UpdateOptions) (APIClientAuthorization, error)
383 APIClientAuthorizationGet(ctx context.Context, options GetOptions) (APIClientAuthorization, error)
384 DiscoveryDocument(ctx context.Context) (DiscoveryDocument, error)