github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/apiserver/adminv3.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package apiserver 5 6 import ( 7 "fmt" 8 9 "github.com/juju/juju/apiserver/common" 10 "github.com/juju/juju/apiserver/observer" 11 "github.com/juju/juju/apiserver/params" 12 ) 13 14 type adminAPIV3 struct { 15 *admin 16 } 17 18 func newAdminAPIV3(srv *Server, root *apiHandler, apiObserver observer.Observer) interface{} { 19 return &adminAPIV3{ 20 &admin{ 21 srv: srv, 22 root: root, 23 apiObserver: apiObserver, 24 }, 25 } 26 } 27 28 // Admin returns an object that provides API access to methods that can be 29 // called even when not authenticated. 30 func (r *adminAPIV3) Admin(id string) (*adminAPIV3, error) { 31 if id != "" { 32 // Safeguard id for possible future use. 33 return nil, common.ErrBadId 34 } 35 return r, nil 36 } 37 38 // Login logs in with the provided credentials. All subsequent requests on the 39 // connection will act as the authenticated user. 40 func (a *adminAPIV3) Login(req params.LoginRequest) (params.LoginResult, error) { 41 return a.login(req, 3) 42 } 43 44 // RedirectInfo returns redirected host information for the model. 45 // In Juju it always returns an error because the Juju controller 46 // does not multiplex controllers. 47 func (a *adminAPIV3) RedirectInfo() (params.RedirectInfoResult, error) { 48 return params.RedirectInfoResult{}, fmt.Errorf("not redirected") 49 }