1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
19 "git.arvados.org/arvados.git/lib/config"
20 "git.arvados.org/arvados.git/lib/controller/localdb"
21 "git.arvados.org/arvados.git/lib/controller/rpc"
22 "git.arvados.org/arvados.git/sdk/go/arvados"
23 "git.arvados.org/arvados.git/sdk/go/auth"
24 "git.arvados.org/arvados.git/sdk/go/ctxlog"
25 "git.arvados.org/arvados.git/sdk/go/health"
29 cluster *arvados.Cluster
31 remotes map[string]backend
34 func New(cluster *arvados.Cluster, healthFuncs *map[string]health.Func) *Conn {
35 local := localdb.NewConn(cluster)
36 remotes := map[string]backend{}
37 for id, remote := range cluster.RemoteClusters {
38 if !remote.Proxy || id == cluster.ClusterID {
41 conn := rpc.NewConn(id, &url.URL{Scheme: remote.Scheme, Host: remote.Host}, remote.Insecure, saltedTokenProvider(local, id))
42 // Older versions of controller rely on the Via header
44 conn.SendHeader = http.Header{"Via": {"HTTP/1.1 arvados-controller"}}
48 if healthFuncs != nil {
49 hf := map[string]health.Func{"vocabulary": local.LastVocabularyError}
60 // Return a new rpc.TokenProvider that takes the client-provided
61 // tokens from an incoming request context, determines whether they
62 // should (and can) be salted for the given remoteID, and returns the
64 func saltedTokenProvider(local backend, remoteID string) rpc.TokenProvider {
65 return func(ctx context.Context) ([]string, error) {
67 incoming, ok := auth.FromContext(ctx)
69 return nil, errors.New("no token provided")
71 for _, token := range incoming.Tokens {
72 salted, err := auth.SaltToken(token, remoteID)
75 tokens = append(tokens, salted)
77 tokens = append(tokens, token)
78 case auth.ErrTokenFormat:
79 // pass through unmodified (assume it's an OIDC access token)
80 tokens = append(tokens, token)
81 case auth.ErrObsoleteToken:
82 ctx := auth.NewContext(ctx, &auth.Credentials{Tokens: []string{token}})
83 aca, err := local.APIClientAuthorizationCurrent(ctx, arvados.GetOptions{})
84 if errStatus(err) == http.StatusUnauthorized {
85 // pass through unmodified
86 tokens = append(tokens, token)
88 } else if err != nil {
91 if strings.HasPrefix(aca.UUID, remoteID) {
92 // We have it cached here, but
93 // the token belongs to the
94 // remote target itself, so
95 // pass it through unmodified.
96 tokens = append(tokens, token)
99 salted, err := auth.SaltToken(aca.TokenV2(), remoteID)
103 tokens = append(tokens, salted)
112 // Return suitable backend for a query about the given cluster ID
113 // ("aaaaa") or object UUID ("aaaaa-dz642-abcdefghijklmno").
114 func (conn *Conn) chooseBackend(id string) backend {
117 } else if len(id) != 5 {
121 if id == conn.cluster.ClusterID {
123 } else if be, ok := conn.remotes[id]; ok {
126 // TODO: return an "always error" backend?
131 func (conn *Conn) localOrLoginCluster() backend {
132 if conn.cluster.Login.LoginCluster != "" {
133 return conn.chooseBackend(conn.cluster.Login.LoginCluster)
138 // Call fn with the local backend; then, if fn returned 404, call fn
139 // on the available remote backends (possibly concurrently) until one
142 // The second argument to fn is the cluster ID of the remote backend,
143 // or "" for the local backend.
145 // A non-nil error means all backends failed.
146 func (conn *Conn) tryLocalThenRemotes(ctx context.Context, forwardedFor string, fn func(context.Context, string, backend) error) error {
147 if err := fn(ctx, "", conn.local); err == nil || errStatus(err) != http.StatusNotFound || forwardedFor != "" {
148 // Note: forwardedFor != "" means this request came
149 // from a remote cluster, so we don't take a second
150 // hop. This avoids cycles, redundant calls to a
151 // mutually reachable remote, and use of double-salted
156 ctx, cancel := context.WithCancel(ctx)
158 errchan := make(chan error, len(conn.remotes))
159 for remoteID, be := range conn.remotes {
160 remoteID, be := remoteID, be
162 errchan <- fn(ctx, remoteID, be)
167 for i := 0; i < cap(errchan); i++ {
172 all404 = all404 && errStatus(err) == http.StatusNotFound
173 errs = append(errs, err)
176 return notFoundError{}
178 return httpErrorf(http.StatusBadGateway, "errors: %v", errs)
181 func (conn *Conn) CollectionCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Collection, error) {
182 return conn.chooseBackend(options.ClusterID).CollectionCreate(ctx, options)
185 func (conn *Conn) CollectionUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Collection, error) {
186 return conn.chooseBackend(options.UUID).CollectionUpdate(ctx, options)
189 func rewriteManifest(mt, remoteID string) string {
190 return regexp.MustCompile(` [0-9a-f]{32}\+[^ ]*`).ReplaceAllStringFunc(mt, func(tok string) string {
191 return strings.Replace(tok, "+A", "+R"+remoteID+"-", -1)
195 func (conn *Conn) ConfigGet(ctx context.Context) (json.RawMessage, error) {
197 err := config.ExportJSON(&buf, conn.cluster)
198 return json.RawMessage(buf.Bytes()), err
201 func (conn *Conn) VocabularyGet(ctx context.Context) (arvados.Vocabulary, error) {
202 return conn.chooseBackend(conn.cluster.ClusterID).VocabularyGet(ctx)
205 func (conn *Conn) Login(ctx context.Context, options arvados.LoginOptions) (arvados.LoginResponse, error) {
206 if id := conn.cluster.Login.LoginCluster; id != "" && id != conn.cluster.ClusterID {
207 // defer entire login procedure to designated cluster
208 remote, ok := conn.remotes[id]
210 return arvados.LoginResponse{}, fmt.Errorf("configuration problem: designated login cluster %q is not defined", id)
212 baseURL := remote.BaseURL()
213 target, err := baseURL.Parse(arvados.EndpointLogin.Path)
215 return arvados.LoginResponse{}, fmt.Errorf("internal error getting redirect target: %s", err)
217 params := url.Values{
218 "return_to": []string{options.ReturnTo},
220 if options.Remote != "" {
221 params.Set("remote", options.Remote)
223 target.RawQuery = params.Encode()
224 return arvados.LoginResponse{
225 RedirectLocation: target.String(),
228 return conn.local.Login(ctx, options)
231 func (conn *Conn) Logout(ctx context.Context, options arvados.LogoutOptions) (arvados.LogoutResponse, error) {
232 // If the logout request comes with an API token from a known
233 // remote cluster, redirect to that cluster's logout handler
234 // so it has an opportunity to clear sessions, expire tokens,
235 // etc. Otherwise use the local endpoint.
236 reqauth, ok := auth.FromContext(ctx)
237 if !ok || len(reqauth.Tokens) == 0 || len(reqauth.Tokens[0]) < 8 || !strings.HasPrefix(reqauth.Tokens[0], "v2/") {
238 return conn.local.Logout(ctx, options)
240 id := reqauth.Tokens[0][3:8]
241 if id == conn.cluster.ClusterID {
242 return conn.local.Logout(ctx, options)
244 remote, ok := conn.remotes[id]
246 return conn.local.Logout(ctx, options)
248 baseURL := remote.BaseURL()
249 target, err := baseURL.Parse(arvados.EndpointLogout.Path)
251 return arvados.LogoutResponse{}, fmt.Errorf("internal error getting redirect target: %s", err)
253 target.RawQuery = url.Values{"return_to": {options.ReturnTo}}.Encode()
254 return arvados.LogoutResponse{RedirectLocation: target.String()}, nil
257 func (conn *Conn) CollectionGet(ctx context.Context, options arvados.GetOptions) (arvados.Collection, error) {
258 if len(options.UUID) == 27 {
259 // UUID is really a UUID
260 c, err := conn.chooseBackend(options.UUID).CollectionGet(ctx, options)
261 if err == nil && options.UUID[:5] != conn.cluster.ClusterID {
262 c.ManifestText = rewriteManifest(c.ManifestText, options.UUID[:5])
267 first := make(chan arvados.Collection, 1)
268 err := conn.tryLocalThenRemotes(ctx, options.ForwardedFor, func(ctx context.Context, remoteID string, be backend) error {
269 remoteOpts := options
270 remoteOpts.ForwardedFor = conn.cluster.ClusterID + "-" + options.ForwardedFor
271 c, err := be.CollectionGet(ctx, remoteOpts)
276 if options.Select != nil {
278 for _, s := range options.Select {
279 if s == "manifest_text" {
286 pdh := arvados.PortableDataHash(c.ManifestText)
287 // options.UUID is either hash+size or
288 // hash+size+hints; only hash+size need to
289 // match the computed PDH.
290 if pdh != options.UUID && !strings.HasPrefix(options.UUID, pdh+"+") {
291 err = httpErrorf(http.StatusBadGateway, "bad portable data hash %q received from remote %q (expected %q)", pdh, remoteID, options.UUID)
292 ctxlog.FromContext(ctx).Warn(err)
297 c.ManifestText = rewriteManifest(c.ManifestText, remoteID)
303 // lost race, return value doesn't matter
308 return arvados.Collection{}, err
313 func (conn *Conn) CollectionList(ctx context.Context, options arvados.ListOptions) (arvados.CollectionList, error) {
314 return conn.generated_CollectionList(ctx, options)
317 func (conn *Conn) CollectionProvenance(ctx context.Context, options arvados.GetOptions) (map[string]interface{}, error) {
318 return conn.chooseBackend(options.UUID).CollectionProvenance(ctx, options)
321 func (conn *Conn) CollectionUsedBy(ctx context.Context, options arvados.GetOptions) (map[string]interface{}, error) {
322 return conn.chooseBackend(options.UUID).CollectionUsedBy(ctx, options)
325 func (conn *Conn) CollectionDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Collection, error) {
326 return conn.chooseBackend(options.UUID).CollectionDelete(ctx, options)
329 func (conn *Conn) CollectionTrash(ctx context.Context, options arvados.DeleteOptions) (arvados.Collection, error) {
330 return conn.chooseBackend(options.UUID).CollectionTrash(ctx, options)
333 func (conn *Conn) CollectionUntrash(ctx context.Context, options arvados.UntrashOptions) (arvados.Collection, error) {
334 return conn.chooseBackend(options.UUID).CollectionUntrash(ctx, options)
337 func (conn *Conn) ContainerList(ctx context.Context, options arvados.ListOptions) (arvados.ContainerList, error) {
338 return conn.generated_ContainerList(ctx, options)
341 func (conn *Conn) ContainerCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Container, error) {
342 return conn.chooseBackend(options.ClusterID).ContainerCreate(ctx, options)
345 func (conn *Conn) ContainerUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Container, error) {
346 return conn.chooseBackend(options.UUID).ContainerUpdate(ctx, options)
349 func (conn *Conn) ContainerGet(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
350 return conn.chooseBackend(options.UUID).ContainerGet(ctx, options)
353 func (conn *Conn) ContainerDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Container, error) {
354 return conn.chooseBackend(options.UUID).ContainerDelete(ctx, options)
357 func (conn *Conn) ContainerLock(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
358 return conn.chooseBackend(options.UUID).ContainerLock(ctx, options)
361 func (conn *Conn) ContainerUnlock(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
362 return conn.chooseBackend(options.UUID).ContainerUnlock(ctx, options)
365 func (conn *Conn) ContainerSSH(ctx context.Context, options arvados.ContainerSSHOptions) (arvados.ContainerSSHConnection, error) {
366 return conn.chooseBackend(options.UUID).ContainerSSH(ctx, options)
369 func (conn *Conn) ContainerRequestList(ctx context.Context, options arvados.ListOptions) (arvados.ContainerRequestList, error) {
370 return conn.generated_ContainerRequestList(ctx, options)
373 func (conn *Conn) ContainerRequestCreate(ctx context.Context, options arvados.CreateOptions) (arvados.ContainerRequest, error) {
374 be := conn.chooseBackend(options.ClusterID)
375 if be == conn.local {
376 return be.ContainerRequestCreate(ctx, options)
378 if _, ok := options.Attrs["runtime_token"]; !ok {
379 // If runtime_token is not set, create a new token
380 aca, err := conn.local.APIClientAuthorizationCurrent(ctx, arvados.GetOptions{})
382 // This should probably be StatusUnauthorized
383 // (need to update test in
384 // lib/controller/federation_test.go):
385 // When RoR is out of the picture this should be:
386 // return arvados.ContainerRequest{}, httpErrorf(http.StatusUnauthorized, "%w", err)
387 return arvados.ContainerRequest{}, httpErrorf(http.StatusForbidden, "%s", "invalid API token")
389 user, err := conn.local.UserGetCurrent(ctx, arvados.GetOptions{})
391 return arvados.ContainerRequest{}, err
393 if len(aca.Scopes) == 0 || aca.Scopes[0] != "all" {
394 return arvados.ContainerRequest{}, httpErrorf(http.StatusForbidden, "token scope is not [all]")
396 if strings.HasPrefix(aca.UUID, conn.cluster.ClusterID) {
397 // Local user, submitting to a remote cluster.
398 // Create a new time-limited token.
399 local, ok := conn.local.(*localdb.Conn)
401 return arvados.ContainerRequest{}, httpErrorf(http.StatusInternalServerError, "bug: local backend is a %T, not a *localdb.Conn", conn.local)
403 aca, err = local.CreateAPIClientAuthorization(ctx, conn.cluster.SystemRootToken, rpc.UserSessionAuthInfo{UserUUID: user.UUID,
404 ExpiresAt: time.Now().UTC().Add(conn.cluster.Collections.BlobSigningTTL.Duration())})
406 return arvados.ContainerRequest{}, err
408 options.Attrs["runtime_token"] = aca.TokenV2()
410 // Remote user. Container request will use the
411 // current token, minus the trailing portion
412 // (optional container uuid).
413 options.Attrs["runtime_token"] = aca.TokenV2()
416 return be.ContainerRequestCreate(ctx, options)
419 func (conn *Conn) ContainerRequestUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.ContainerRequest, error) {
420 return conn.chooseBackend(options.UUID).ContainerRequestUpdate(ctx, options)
423 func (conn *Conn) ContainerRequestGet(ctx context.Context, options arvados.GetOptions) (arvados.ContainerRequest, error) {
424 return conn.chooseBackend(options.UUID).ContainerRequestGet(ctx, options)
427 func (conn *Conn) ContainerRequestDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.ContainerRequest, error) {
428 return conn.chooseBackend(options.UUID).ContainerRequestDelete(ctx, options)
431 func (conn *Conn) GroupCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Group, error) {
432 return conn.chooseBackend(options.ClusterID).GroupCreate(ctx, options)
435 func (conn *Conn) GroupUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Group, error) {
436 return conn.chooseBackend(options.UUID).GroupUpdate(ctx, options)
439 func (conn *Conn) GroupGet(ctx context.Context, options arvados.GetOptions) (arvados.Group, error) {
440 return conn.chooseBackend(options.UUID).GroupGet(ctx, options)
443 func (conn *Conn) GroupList(ctx context.Context, options arvados.ListOptions) (arvados.GroupList, error) {
444 return conn.generated_GroupList(ctx, options)
447 var userUuidRe = regexp.MustCompile(`^[0-9a-z]{5}-tpzed-[0-9a-z]{15}$`)
449 func (conn *Conn) GroupContents(ctx context.Context, options arvados.GroupContentsOptions) (arvados.ObjectList, error) {
450 if options.ClusterID != "" {
451 // explicitly selected cluster
452 return conn.chooseBackend(options.ClusterID).GroupContents(ctx, options)
453 } else if userUuidRe.MatchString(options.UUID) {
454 // user, get the things they own on the local cluster
455 return conn.local.GroupContents(ctx, options)
457 // a group, potentially want to make federated request
458 return conn.chooseBackend(options.UUID).GroupContents(ctx, options)
462 func (conn *Conn) GroupShared(ctx context.Context, options arvados.ListOptions) (arvados.GroupList, error) {
463 return conn.chooseBackend(options.ClusterID).GroupShared(ctx, options)
466 func (conn *Conn) GroupDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Group, error) {
467 return conn.chooseBackend(options.UUID).GroupDelete(ctx, options)
470 func (conn *Conn) GroupTrash(ctx context.Context, options arvados.DeleteOptions) (arvados.Group, error) {
471 return conn.chooseBackend(options.UUID).GroupTrash(ctx, options)
474 func (conn *Conn) GroupUntrash(ctx context.Context, options arvados.UntrashOptions) (arvados.Group, error) {
475 return conn.chooseBackend(options.UUID).GroupUntrash(ctx, options)
478 func (conn *Conn) LinkCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Link, error) {
479 return conn.chooseBackend(options.ClusterID).LinkCreate(ctx, options)
482 func (conn *Conn) LinkUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Link, error) {
483 return conn.chooseBackend(options.UUID).LinkUpdate(ctx, options)
486 func (conn *Conn) LinkGet(ctx context.Context, options arvados.GetOptions) (arvados.Link, error) {
487 return conn.chooseBackend(options.UUID).LinkGet(ctx, options)
490 func (conn *Conn) LinkList(ctx context.Context, options arvados.ListOptions) (arvados.LinkList, error) {
491 return conn.generated_LinkList(ctx, options)
494 func (conn *Conn) LinkDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Link, error) {
495 return conn.chooseBackend(options.UUID).LinkDelete(ctx, options)
498 func (conn *Conn) SpecimenList(ctx context.Context, options arvados.ListOptions) (arvados.SpecimenList, error) {
499 return conn.generated_SpecimenList(ctx, options)
502 func (conn *Conn) SpecimenCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Specimen, error) {
503 return conn.chooseBackend(options.ClusterID).SpecimenCreate(ctx, options)
506 func (conn *Conn) SpecimenUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Specimen, error) {
507 return conn.chooseBackend(options.UUID).SpecimenUpdate(ctx, options)
510 func (conn *Conn) SpecimenGet(ctx context.Context, options arvados.GetOptions) (arvados.Specimen, error) {
511 return conn.chooseBackend(options.UUID).SpecimenGet(ctx, options)
514 func (conn *Conn) SpecimenDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Specimen, error) {
515 return conn.chooseBackend(options.UUID).SpecimenDelete(ctx, options)
518 var userAttrsCachedFromLoginCluster = map[string]bool{
532 "identity_url": false,
534 "modified_by_client_uuid": false,
535 "modified_by_user_uuid": false,
538 "writable_by": false,
541 func (conn *Conn) batchUpdateUsers(ctx context.Context,
542 options arvados.ListOptions,
543 items []arvados.User) (err error) {
545 id := conn.cluster.Login.LoginCluster
546 logger := ctxlog.FromContext(ctx)
547 batchOpts := arvados.UserBatchUpdateOptions{Updates: map[string]map[string]interface{}{}}
548 for _, user := range items {
549 if !strings.HasPrefix(user.UUID, id) {
552 logger.Debugf("cache user info for uuid %q", user.UUID)
554 // If the remote cluster has null timestamps
555 // (e.g., test server with incomplete
556 // fixtures) use dummy timestamps (instead of
557 // the zero time, which causes a Rails API
558 // error "year too big to marshal: 1 UTC").
559 if user.ModifiedAt.IsZero() {
560 user.ModifiedAt = time.Now()
562 if user.CreatedAt.IsZero() {
563 user.CreatedAt = time.Now()
566 var allFields map[string]interface{}
567 buf, err := json.Marshal(user)
569 return fmt.Errorf("error encoding user record from remote response: %s", err)
571 err = json.Unmarshal(buf, &allFields)
573 return fmt.Errorf("error transcoding user record from remote response: %s", err)
576 if len(options.Select) > 0 {
577 updates = map[string]interface{}{}
578 for _, k := range options.Select {
579 if v, ok := allFields[k]; ok && userAttrsCachedFromLoginCluster[k] {
584 for k := range updates {
585 if !userAttrsCachedFromLoginCluster[k] {
590 batchOpts.Updates[user.UUID] = updates
592 if len(batchOpts.Updates) > 0 {
593 ctxRoot := auth.NewContext(ctx, &auth.Credentials{Tokens: []string{conn.cluster.SystemRootToken}})
594 _, err = conn.local.UserBatchUpdate(ctxRoot, batchOpts)
596 return fmt.Errorf("error updating local user records: %s", err)
602 func (conn *Conn) UserList(ctx context.Context, options arvados.ListOptions) (arvados.UserList, error) {
603 if id := conn.cluster.Login.LoginCluster; id != "" && id != conn.cluster.ClusterID && !options.BypassFederation {
604 resp, err := conn.chooseBackend(id).UserList(ctx, options)
608 err = conn.batchUpdateUsers(ctx, options, resp.Items)
610 return arvados.UserList{}, err
614 return conn.generated_UserList(ctx, options)
617 func (conn *Conn) UserCreate(ctx context.Context, options arvados.CreateOptions) (arvados.User, error) {
618 return conn.chooseBackend(options.ClusterID).UserCreate(ctx, options)
621 func (conn *Conn) UserUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.User, error) {
622 if options.BypassFederation {
623 return conn.local.UserUpdate(ctx, options)
625 resp, err := conn.chooseBackend(options.UUID).UserUpdate(ctx, options)
629 if !strings.HasPrefix(options.UUID, conn.cluster.ClusterID) {
630 // Copy the updated user record to the local cluster
631 err = conn.batchUpdateUsers(ctx, arvados.ListOptions{}, []arvados.User{resp})
633 return arvados.User{}, err
639 func (conn *Conn) UserMerge(ctx context.Context, options arvados.UserMergeOptions) (arvados.User, error) {
640 return conn.local.UserMerge(ctx, options)
643 func (conn *Conn) UserActivate(ctx context.Context, options arvados.UserActivateOptions) (arvados.User, error) {
644 return conn.localOrLoginCluster().UserActivate(ctx, options)
647 func (conn *Conn) UserSetup(ctx context.Context, options arvados.UserSetupOptions) (map[string]interface{}, error) {
648 upstream := conn.localOrLoginCluster()
649 if upstream != conn.local {
650 // When LoginCluster is in effect, and we're setting
651 // up a remote user, and we want to give that user
652 // access to a local VM, we can't include the VM in
653 // the setup call, because the remote cluster won't
656 // Similarly, if we want to create a git repo,
657 // it should be created on the local cluster,
658 // not the remote one.
660 upstreamOptions := options
661 upstreamOptions.VMUUID = ""
662 upstreamOptions.RepoName = ""
664 ret, err := upstream.UserSetup(ctx, upstreamOptions)
670 return conn.local.UserSetup(ctx, options)
673 func (conn *Conn) UserUnsetup(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
674 return conn.localOrLoginCluster().UserUnsetup(ctx, options)
677 func (conn *Conn) UserGet(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
678 resp, err := conn.chooseBackend(options.UUID).UserGet(ctx, options)
682 if options.UUID != resp.UUID {
683 return arvados.User{}, httpErrorf(http.StatusBadGateway, "Had requested %v but response was for %v", options.UUID, resp.UUID)
685 if options.UUID[:5] != conn.cluster.ClusterID {
686 err = conn.batchUpdateUsers(ctx, arvados.ListOptions{Select: options.Select}, []arvados.User{resp})
688 return arvados.User{}, err
694 func (conn *Conn) UserGetCurrent(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
695 return conn.local.UserGetCurrent(ctx, options)
698 func (conn *Conn) UserGetSystem(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
699 return conn.chooseBackend(options.UUID).UserGetSystem(ctx, options)
702 func (conn *Conn) UserDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.User, error) {
703 return conn.chooseBackend(options.UUID).UserDelete(ctx, options)
706 func (conn *Conn) UserBatchUpdate(ctx context.Context, options arvados.UserBatchUpdateOptions) (arvados.UserList, error) {
707 return conn.local.UserBatchUpdate(ctx, options)
710 func (conn *Conn) UserAuthenticate(ctx context.Context, options arvados.UserAuthenticateOptions) (arvados.APIClientAuthorization, error) {
711 return conn.local.UserAuthenticate(ctx, options)
714 func (conn *Conn) APIClientAuthorizationCurrent(ctx context.Context, options arvados.GetOptions) (arvados.APIClientAuthorization, error) {
715 return conn.chooseBackend(options.UUID).APIClientAuthorizationCurrent(ctx, options)
718 type backend interface {
723 type notFoundError struct{}
725 func (notFoundError) HTTPStatus() int { return http.StatusNotFound }
726 func (notFoundError) Error() string { return "not found" }
728 func errStatus(err error) int {
729 if httpErr, ok := err.(interface{ HTTPStatus() int }); ok {
730 return httpErr.HTTPStatus()
732 return http.StatusInternalServerError