github.com/mwhudson/juju@v0.0.0-20160512215208-90ff01f3497f/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 "github.com/juju/juju/apiserver/common" 8 "github.com/juju/juju/apiserver/params" 9 ) 10 11 type adminApiV3 struct { 12 *admin 13 } 14 15 func newAdminApiV3(srv *Server, root *apiHandler, reqNotifier *requestNotifier) interface{} { 16 return &adminApiV3{ 17 &admin{ 18 srv: srv, 19 root: root, 20 reqNotifier: reqNotifier, 21 }, 22 } 23 } 24 25 // Admin returns an object that provides API access to methods that can be 26 // called even when not authenticated. 27 func (r *adminApiV3) Admin(id string) (*adminApiV3, error) { 28 if id != "" { 29 // Safeguard id for possible future use. 30 return nil, common.ErrBadId 31 } 32 return r, nil 33 } 34 35 // Login logs in with the provided credentials. All subsequent requests on the 36 // connection will act as the authenticated user. 37 func (a *adminApiV3) Login(req params.LoginRequest) (params.LoginResultV1, error) { 38 return a.doLogin(req, 3) 39 }