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"
28 cluster *arvados.Cluster
30 remotes map[string]backend
33 func New(cluster *arvados.Cluster) *Conn {
34 local := localdb.NewConn(cluster)
35 remotes := map[string]backend{}
36 for id, remote := range cluster.RemoteClusters {
37 if !remote.Proxy || id == cluster.ClusterID {
40 conn := rpc.NewConn(id, &url.URL{Scheme: remote.Scheme, Host: remote.Host}, remote.Insecure, saltedTokenProvider(local, id))
41 // Older versions of controller rely on the Via header
43 conn.SendHeader = http.Header{"Via": {"HTTP/1.1 arvados-controller"}}
54 // Return a new rpc.TokenProvider that takes the client-provided
55 // tokens from an incoming request context, determines whether they
56 // should (and can) be salted for the given remoteID, and returns the
58 func saltedTokenProvider(local backend, remoteID string) rpc.TokenProvider {
59 return func(ctx context.Context) ([]string, error) {
61 incoming, ok := auth.FromContext(ctx)
63 return nil, errors.New("no token provided")
65 for _, token := range incoming.Tokens {
66 salted, err := auth.SaltToken(token, remoteID)
69 tokens = append(tokens, salted)
71 tokens = append(tokens, token)
72 case auth.ErrTokenFormat:
73 // pass through unmodified (assume it's an OIDC access token)
74 tokens = append(tokens, token)
75 case auth.ErrObsoleteToken:
76 ctx := auth.NewContext(ctx, &auth.Credentials{Tokens: []string{token}})
77 aca, err := local.APIClientAuthorizationCurrent(ctx, arvados.GetOptions{})
78 if errStatus(err) == http.StatusUnauthorized {
79 // pass through unmodified
80 tokens = append(tokens, token)
82 } else if err != nil {
85 if strings.HasPrefix(aca.UUID, remoteID) {
86 // We have it cached here, but
87 // the token belongs to the
88 // remote target itself, so
89 // pass it through unmodified.
90 tokens = append(tokens, token)
93 salted, err := auth.SaltToken(aca.TokenV2(), remoteID)
97 tokens = append(tokens, salted)
106 // Return suitable backend for a query about the given cluster ID
107 // ("aaaaa") or object UUID ("aaaaa-dz642-abcdefghijklmno").
108 func (conn *Conn) chooseBackend(id string) backend {
111 } else if len(id) != 5 {
115 if id == conn.cluster.ClusterID {
117 } else if be, ok := conn.remotes[id]; ok {
120 // TODO: return an "always error" backend?
125 func (conn *Conn) localOrLoginCluster() backend {
126 if conn.cluster.Login.LoginCluster != "" {
127 return conn.chooseBackend(conn.cluster.Login.LoginCluster)
132 // Call fn with the local backend; then, if fn returned 404, call fn
133 // on the available remote backends (possibly concurrently) until one
136 // The second argument to fn is the cluster ID of the remote backend,
137 // or "" for the local backend.
139 // A non-nil error means all backends failed.
140 func (conn *Conn) tryLocalThenRemotes(ctx context.Context, forwardedFor string, fn func(context.Context, string, backend) error) error {
141 if err := fn(ctx, "", conn.local); err == nil || errStatus(err) != http.StatusNotFound || forwardedFor != "" {
142 // Note: forwardedFor != "" means this request came
143 // from a remote cluster, so we don't take a second
144 // hop. This avoids cycles, redundant calls to a
145 // mutually reachable remote, and use of double-salted
150 ctx, cancel := context.WithCancel(ctx)
152 errchan := make(chan error, len(conn.remotes))
153 for remoteID, be := range conn.remotes {
154 remoteID, be := remoteID, be
156 errchan <- fn(ctx, remoteID, be)
161 for i := 0; i < cap(errchan); i++ {
166 all404 = all404 && errStatus(err) == http.StatusNotFound
167 errs = append(errs, err)
170 return notFoundError{}
172 return httpErrorf(http.StatusBadGateway, "errors: %v", errs)
175 func (conn *Conn) CollectionCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Collection, error) {
176 return conn.chooseBackend(options.ClusterID).CollectionCreate(ctx, options)
179 func (conn *Conn) CollectionUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Collection, error) {
180 return conn.chooseBackend(options.UUID).CollectionUpdate(ctx, options)
183 func rewriteManifest(mt, remoteID string) string {
184 return regexp.MustCompile(` [0-9a-f]{32}\+[^ ]*`).ReplaceAllStringFunc(mt, func(tok string) string {
185 return strings.Replace(tok, "+A", "+R"+remoteID+"-", -1)
189 func (conn *Conn) ConfigGet(ctx context.Context) (json.RawMessage, error) {
191 err := config.ExportJSON(&buf, conn.cluster)
192 return json.RawMessage(buf.Bytes()), err
195 func (conn *Conn) VocabularyGet(ctx context.Context) (arvados.Vocabulary, error) {
196 return conn.chooseBackend(conn.cluster.ClusterID).VocabularyGet(ctx)
199 func (conn *Conn) Login(ctx context.Context, options arvados.LoginOptions) (arvados.LoginResponse, error) {
200 if id := conn.cluster.Login.LoginCluster; id != "" && id != conn.cluster.ClusterID {
201 // defer entire login procedure to designated cluster
202 remote, ok := conn.remotes[id]
204 return arvados.LoginResponse{}, fmt.Errorf("configuration problem: designated login cluster %q is not defined", id)
206 baseURL := remote.BaseURL()
207 target, err := baseURL.Parse(arvados.EndpointLogin.Path)
209 return arvados.LoginResponse{}, fmt.Errorf("internal error getting redirect target: %s", err)
211 params := url.Values{
212 "return_to": []string{options.ReturnTo},
214 if options.Remote != "" {
215 params.Set("remote", options.Remote)
217 target.RawQuery = params.Encode()
218 return arvados.LoginResponse{
219 RedirectLocation: target.String(),
222 return conn.local.Login(ctx, options)
225 func (conn *Conn) Logout(ctx context.Context, options arvados.LogoutOptions) (arvados.LogoutResponse, error) {
226 // If the logout request comes with an API token from a known
227 // remote cluster, redirect to that cluster's logout handler
228 // so it has an opportunity to clear sessions, expire tokens,
229 // etc. Otherwise use the local endpoint.
230 reqauth, ok := auth.FromContext(ctx)
231 if !ok || len(reqauth.Tokens) == 0 || len(reqauth.Tokens[0]) < 8 || !strings.HasPrefix(reqauth.Tokens[0], "v2/") {
232 return conn.local.Logout(ctx, options)
234 id := reqauth.Tokens[0][3:8]
235 if id == conn.cluster.ClusterID {
236 return conn.local.Logout(ctx, options)
238 remote, ok := conn.remotes[id]
240 return conn.local.Logout(ctx, options)
242 baseURL := remote.BaseURL()
243 target, err := baseURL.Parse(arvados.EndpointLogout.Path)
245 return arvados.LogoutResponse{}, fmt.Errorf("internal error getting redirect target: %s", err)
247 target.RawQuery = url.Values{"return_to": {options.ReturnTo}}.Encode()
248 return arvados.LogoutResponse{RedirectLocation: target.String()}, nil
251 func (conn *Conn) CollectionGet(ctx context.Context, options arvados.GetOptions) (arvados.Collection, error) {
252 if len(options.UUID) == 27 {
253 // UUID is really a UUID
254 c, err := conn.chooseBackend(options.UUID).CollectionGet(ctx, options)
255 if err == nil && options.UUID[:5] != conn.cluster.ClusterID {
256 c.ManifestText = rewriteManifest(c.ManifestText, options.UUID[:5])
261 first := make(chan arvados.Collection, 1)
262 err := conn.tryLocalThenRemotes(ctx, options.ForwardedFor, func(ctx context.Context, remoteID string, be backend) error {
263 remoteOpts := options
264 remoteOpts.ForwardedFor = conn.cluster.ClusterID + "-" + options.ForwardedFor
265 c, err := be.CollectionGet(ctx, remoteOpts)
270 if options.Select != nil {
272 for _, s := range options.Select {
273 if s == "manifest_text" {
280 pdh := arvados.PortableDataHash(c.ManifestText)
281 // options.UUID is either hash+size or
282 // hash+size+hints; only hash+size need to
283 // match the computed PDH.
284 if pdh != options.UUID && !strings.HasPrefix(options.UUID, pdh+"+") {
285 err = httpErrorf(http.StatusBadGateway, "bad portable data hash %q received from remote %q (expected %q)", pdh, remoteID, options.UUID)
286 ctxlog.FromContext(ctx).Warn(err)
291 c.ManifestText = rewriteManifest(c.ManifestText, remoteID)
297 // lost race, return value doesn't matter
302 return arvados.Collection{}, err
307 func (conn *Conn) CollectionList(ctx context.Context, options arvados.ListOptions) (arvados.CollectionList, error) {
308 return conn.generated_CollectionList(ctx, options)
311 func (conn *Conn) CollectionProvenance(ctx context.Context, options arvados.GetOptions) (map[string]interface{}, error) {
312 return conn.chooseBackend(options.UUID).CollectionProvenance(ctx, options)
315 func (conn *Conn) CollectionUsedBy(ctx context.Context, options arvados.GetOptions) (map[string]interface{}, error) {
316 return conn.chooseBackend(options.UUID).CollectionUsedBy(ctx, options)
319 func (conn *Conn) CollectionDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Collection, error) {
320 return conn.chooseBackend(options.UUID).CollectionDelete(ctx, options)
323 func (conn *Conn) CollectionTrash(ctx context.Context, options arvados.DeleteOptions) (arvados.Collection, error) {
324 return conn.chooseBackend(options.UUID).CollectionTrash(ctx, options)
327 func (conn *Conn) CollectionUntrash(ctx context.Context, options arvados.UntrashOptions) (arvados.Collection, error) {
328 return conn.chooseBackend(options.UUID).CollectionUntrash(ctx, options)
331 func (conn *Conn) ContainerList(ctx context.Context, options arvados.ListOptions) (arvados.ContainerList, error) {
332 return conn.generated_ContainerList(ctx, options)
335 func (conn *Conn) ContainerCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Container, error) {
336 return conn.chooseBackend(options.ClusterID).ContainerCreate(ctx, options)
339 func (conn *Conn) ContainerUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Container, error) {
340 return conn.chooseBackend(options.UUID).ContainerUpdate(ctx, options)
343 func (conn *Conn) ContainerGet(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
344 return conn.chooseBackend(options.UUID).ContainerGet(ctx, options)
347 func (conn *Conn) ContainerDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Container, error) {
348 return conn.chooseBackend(options.UUID).ContainerDelete(ctx, options)
351 func (conn *Conn) ContainerLock(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
352 return conn.chooseBackend(options.UUID).ContainerLock(ctx, options)
355 func (conn *Conn) ContainerUnlock(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
356 return conn.chooseBackend(options.UUID).ContainerUnlock(ctx, options)
359 func (conn *Conn) ContainerSSH(ctx context.Context, options arvados.ContainerSSHOptions) (arvados.ContainerSSHConnection, error) {
360 return conn.chooseBackend(options.UUID).ContainerSSH(ctx, options)
363 func (conn *Conn) ContainerRequestList(ctx context.Context, options arvados.ListOptions) (arvados.ContainerRequestList, error) {
364 return conn.generated_ContainerRequestList(ctx, options)
367 func (conn *Conn) ContainerRequestCreate(ctx context.Context, options arvados.CreateOptions) (arvados.ContainerRequest, error) {
368 be := conn.chooseBackend(options.ClusterID)
369 if be == conn.local {
370 return be.ContainerRequestCreate(ctx, options)
372 if _, ok := options.Attrs["runtime_token"]; !ok {
373 // If runtime_token is not set, create a new token
374 aca, err := conn.local.APIClientAuthorizationCurrent(ctx, arvados.GetOptions{})
376 // This should probably be StatusUnauthorized
377 // (need to update test in
378 // lib/controller/federation_test.go):
379 // When RoR is out of the picture this should be:
380 // return arvados.ContainerRequest{}, httpErrorf(http.StatusUnauthorized, "%w", err)
381 return arvados.ContainerRequest{}, httpErrorf(http.StatusForbidden, "%s", "invalid API token")
383 user, err := conn.local.UserGetCurrent(ctx, arvados.GetOptions{})
385 return arvados.ContainerRequest{}, err
387 if len(aca.Scopes) == 0 || aca.Scopes[0] != "all" {
388 return arvados.ContainerRequest{}, httpErrorf(http.StatusForbidden, "token scope is not [all]")
390 if strings.HasPrefix(aca.UUID, conn.cluster.ClusterID) {
391 // Local user, submitting to a remote cluster.
392 // Create a new time-limited token.
393 local, ok := conn.local.(*localdb.Conn)
395 return arvados.ContainerRequest{}, httpErrorf(http.StatusInternalServerError, "bug: local backend is a %T, not a *localdb.Conn", conn.local)
397 aca, err = local.CreateAPIClientAuthorization(ctx, conn.cluster.SystemRootToken, rpc.UserSessionAuthInfo{UserUUID: user.UUID,
398 ExpiresAt: time.Now().UTC().Add(conn.cluster.Collections.BlobSigningTTL.Duration())})
400 return arvados.ContainerRequest{}, err
402 options.Attrs["runtime_token"] = aca.TokenV2()
404 // Remote user. Container request will use the
405 // current token, minus the trailing portion
406 // (optional container uuid).
407 options.Attrs["runtime_token"] = aca.TokenV2()
410 return be.ContainerRequestCreate(ctx, options)
413 func (conn *Conn) ContainerRequestUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.ContainerRequest, error) {
414 return conn.chooseBackend(options.UUID).ContainerRequestUpdate(ctx, options)
417 func (conn *Conn) ContainerRequestGet(ctx context.Context, options arvados.GetOptions) (arvados.ContainerRequest, error) {
418 return conn.chooseBackend(options.UUID).ContainerRequestGet(ctx, options)
421 func (conn *Conn) ContainerRequestDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.ContainerRequest, error) {
422 return conn.chooseBackend(options.UUID).ContainerRequestDelete(ctx, options)
425 func (conn *Conn) GroupCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Group, error) {
426 return conn.chooseBackend(options.ClusterID).GroupCreate(ctx, options)
429 func (conn *Conn) GroupUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Group, error) {
430 return conn.chooseBackend(options.UUID).GroupUpdate(ctx, options)
433 func (conn *Conn) GroupGet(ctx context.Context, options arvados.GetOptions) (arvados.Group, error) {
434 return conn.chooseBackend(options.UUID).GroupGet(ctx, options)
437 func (conn *Conn) GroupList(ctx context.Context, options arvados.ListOptions) (arvados.GroupList, error) {
438 return conn.generated_GroupList(ctx, options)
441 var userUuidRe = regexp.MustCompile(`^[0-9a-z]{5}-tpzed-[0-9a-z]{15}$`)
443 func (conn *Conn) GroupContents(ctx context.Context, options arvados.GroupContentsOptions) (arvados.ObjectList, error) {
444 if options.ClusterID != "" {
445 // explicitly selected cluster
446 return conn.chooseBackend(options.ClusterID).GroupContents(ctx, options)
447 } else if userUuidRe.MatchString(options.UUID) {
448 // user, get the things they own on the local cluster
449 return conn.local.GroupContents(ctx, options)
451 // a group, potentially want to make federated request
452 return conn.chooseBackend(options.UUID).GroupContents(ctx, options)
456 func (conn *Conn) GroupShared(ctx context.Context, options arvados.ListOptions) (arvados.GroupList, error) {
457 return conn.chooseBackend(options.ClusterID).GroupShared(ctx, options)
460 func (conn *Conn) GroupDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Group, error) {
461 return conn.chooseBackend(options.UUID).GroupDelete(ctx, options)
464 func (conn *Conn) GroupTrash(ctx context.Context, options arvados.DeleteOptions) (arvados.Group, error) {
465 return conn.chooseBackend(options.UUID).GroupTrash(ctx, options)
468 func (conn *Conn) GroupUntrash(ctx context.Context, options arvados.UntrashOptions) (arvados.Group, error) {
469 return conn.chooseBackend(options.UUID).GroupUntrash(ctx, options)
472 func (conn *Conn) LinkCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Link, error) {
473 return conn.chooseBackend(options.ClusterID).LinkCreate(ctx, options)
476 func (conn *Conn) LinkUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Link, error) {
477 return conn.chooseBackend(options.UUID).LinkUpdate(ctx, options)
480 func (conn *Conn) LinkGet(ctx context.Context, options arvados.GetOptions) (arvados.Link, error) {
481 return conn.chooseBackend(options.UUID).LinkGet(ctx, options)
484 func (conn *Conn) LinkList(ctx context.Context, options arvados.ListOptions) (arvados.LinkList, error) {
485 return conn.generated_LinkList(ctx, options)
488 func (conn *Conn) LinkDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Link, error) {
489 return conn.chooseBackend(options.UUID).LinkDelete(ctx, options)
492 func (conn *Conn) SpecimenList(ctx context.Context, options arvados.ListOptions) (arvados.SpecimenList, error) {
493 return conn.generated_SpecimenList(ctx, options)
496 func (conn *Conn) SpecimenCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Specimen, error) {
497 return conn.chooseBackend(options.ClusterID).SpecimenCreate(ctx, options)
500 func (conn *Conn) SpecimenUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Specimen, error) {
501 return conn.chooseBackend(options.UUID).SpecimenUpdate(ctx, options)
504 func (conn *Conn) SpecimenGet(ctx context.Context, options arvados.GetOptions) (arvados.Specimen, error) {
505 return conn.chooseBackend(options.UUID).SpecimenGet(ctx, options)
508 func (conn *Conn) SpecimenDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Specimen, error) {
509 return conn.chooseBackend(options.UUID).SpecimenDelete(ctx, options)
512 var userAttrsCachedFromLoginCluster = map[string]bool{
526 "identity_url": false,
528 "modified_by_client_uuid": false,
529 "modified_by_user_uuid": false,
532 "writable_by": false,
535 func (conn *Conn) batchUpdateUsers(ctx context.Context,
536 options arvados.ListOptions,
537 items []arvados.User) (err error) {
539 id := conn.cluster.Login.LoginCluster
540 logger := ctxlog.FromContext(ctx)
541 batchOpts := arvados.UserBatchUpdateOptions{Updates: map[string]map[string]interface{}{}}
542 for _, user := range items {
543 if !strings.HasPrefix(user.UUID, id) {
546 logger.Debugf("cache user info for uuid %q", user.UUID)
548 // If the remote cluster has null timestamps
549 // (e.g., test server with incomplete
550 // fixtures) use dummy timestamps (instead of
551 // the zero time, which causes a Rails API
552 // error "year too big to marshal: 1 UTC").
553 if user.ModifiedAt.IsZero() {
554 user.ModifiedAt = time.Now()
556 if user.CreatedAt.IsZero() {
557 user.CreatedAt = time.Now()
560 var allFields map[string]interface{}
561 buf, err := json.Marshal(user)
563 return fmt.Errorf("error encoding user record from remote response: %s", err)
565 err = json.Unmarshal(buf, &allFields)
567 return fmt.Errorf("error transcoding user record from remote response: %s", err)
570 if len(options.Select) > 0 {
571 updates = map[string]interface{}{}
572 for _, k := range options.Select {
573 if v, ok := allFields[k]; ok && userAttrsCachedFromLoginCluster[k] {
578 for k := range updates {
579 if !userAttrsCachedFromLoginCluster[k] {
584 batchOpts.Updates[user.UUID] = updates
586 if len(batchOpts.Updates) > 0 {
587 ctxRoot := auth.NewContext(ctx, &auth.Credentials{Tokens: []string{conn.cluster.SystemRootToken}})
588 _, err = conn.local.UserBatchUpdate(ctxRoot, batchOpts)
590 return fmt.Errorf("error updating local user records: %s", err)
596 func (conn *Conn) UserList(ctx context.Context, options arvados.ListOptions) (arvados.UserList, error) {
597 if id := conn.cluster.Login.LoginCluster; id != "" && id != conn.cluster.ClusterID && !options.BypassFederation {
598 resp, err := conn.chooseBackend(id).UserList(ctx, options)
602 err = conn.batchUpdateUsers(ctx, options, resp.Items)
604 return arvados.UserList{}, err
608 return conn.generated_UserList(ctx, options)
611 func (conn *Conn) UserCreate(ctx context.Context, options arvados.CreateOptions) (arvados.User, error) {
612 return conn.chooseBackend(options.ClusterID).UserCreate(ctx, options)
615 func (conn *Conn) UserUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.User, error) {
616 if options.BypassFederation {
617 return conn.local.UserUpdate(ctx, options)
619 resp, err := conn.chooseBackend(options.UUID).UserUpdate(ctx, options)
623 if !strings.HasPrefix(options.UUID, conn.cluster.ClusterID) {
624 // Copy the updated user record to the local cluster
625 err = conn.batchUpdateUsers(ctx, arvados.ListOptions{}, []arvados.User{resp})
627 return arvados.User{}, err
633 func (conn *Conn) UserMerge(ctx context.Context, options arvados.UserMergeOptions) (arvados.User, error) {
634 return conn.local.UserMerge(ctx, options)
637 func (conn *Conn) UserActivate(ctx context.Context, options arvados.UserActivateOptions) (arvados.User, error) {
638 return conn.localOrLoginCluster().UserActivate(ctx, options)
641 func (conn *Conn) UserSetup(ctx context.Context, options arvados.UserSetupOptions) (map[string]interface{}, error) {
642 upstream := conn.localOrLoginCluster()
643 if upstream != conn.local {
644 // When LoginCluster is in effect, and we're setting
645 // up a remote user, and we want to give that user
646 // access to a local VM, we can't include the VM in
647 // the setup call, because the remote cluster won't
650 // Similarly, if we want to create a git repo,
651 // it should be created on the local cluster,
652 // not the remote one.
654 upstreamOptions := options
655 upstreamOptions.VMUUID = ""
656 upstreamOptions.RepoName = ""
658 ret, err := upstream.UserSetup(ctx, upstreamOptions)
664 return conn.local.UserSetup(ctx, options)
667 func (conn *Conn) UserUnsetup(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
668 return conn.localOrLoginCluster().UserUnsetup(ctx, options)
671 func (conn *Conn) UserGet(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
672 resp, err := conn.chooseBackend(options.UUID).UserGet(ctx, options)
676 if options.UUID != resp.UUID {
677 return arvados.User{}, httpErrorf(http.StatusBadGateway, "Had requested %v but response was for %v", options.UUID, resp.UUID)
679 if options.UUID[:5] != conn.cluster.ClusterID {
680 err = conn.batchUpdateUsers(ctx, arvados.ListOptions{Select: options.Select}, []arvados.User{resp})
682 return arvados.User{}, err
688 func (conn *Conn) UserGetCurrent(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
689 return conn.local.UserGetCurrent(ctx, options)
692 func (conn *Conn) UserGetSystem(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
693 return conn.chooseBackend(options.UUID).UserGetSystem(ctx, options)
696 func (conn *Conn) UserDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.User, error) {
697 return conn.chooseBackend(options.UUID).UserDelete(ctx, options)
700 func (conn *Conn) UserBatchUpdate(ctx context.Context, options arvados.UserBatchUpdateOptions) (arvados.UserList, error) {
701 return conn.local.UserBatchUpdate(ctx, options)
704 func (conn *Conn) UserAuthenticate(ctx context.Context, options arvados.UserAuthenticateOptions) (arvados.APIClientAuthorization, error) {
705 return conn.local.UserAuthenticate(ctx, options)
708 func (conn *Conn) APIClientAuthorizationCurrent(ctx context.Context, options arvados.GetOptions) (arvados.APIClientAuthorization, error) {
709 return conn.chooseBackend(options.UUID).APIClientAuthorizationCurrent(ctx, options)
712 type backend interface {
717 type notFoundError struct{}
719 func (notFoundError) HTTPStatus() int { return http.StatusNotFound }
720 func (notFoundError) Error() string { return "not found" }
722 func errStatus(err error) int {
723 if httpErr, ok := err.(interface{ HTTPStatus() int }); ok {
724 return httpErr.HTTPStatus()
726 return http.StatusInternalServerError