-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadminv1.go
44 lines (38 loc) · 1.04 KB
/
adminv1.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package apiserver
import (
"github.com/juju/juju/apiserver/common"
"github.com/juju/juju/apiserver/params"
)
type adminApiV1 struct {
admin *adminV1
}
// adminV1 is the only object that unlogged-in clients can access. It holds any
// methods that are needed to log in.
type adminV1 struct {
*admin
}
func newAdminApiV1(srv *Server, root *apiHandler, reqNotifier *requestNotifier) interface{} {
return &adminApiV1{
admin: &adminV1{
&admin{
srv: srv,
root: root,
reqNotifier: reqNotifier,
},
},
}
}
// Admin returns an object that provides API access to methods that can be
// called even when not authenticated.
func (r *adminApiV1) Admin(id string) (*adminV1, error) {
if id != "" {
// Safeguard id for possible future use.
return nil, common.ErrBadId
}
return r.admin, nil
}
// Login logs in with the provided credentials. All subsequent requests on the
// connection will act as the authenticated user.
func (a *adminV1) Login(req params.LoginRequest) (params.LoginResultV1, error) {
return a.doLogin(req)
}