-
Notifications
You must be signed in to change notification settings - Fork 0
/
revoke.go
46 lines (37 loc) · 889 Bytes
/
revoke.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
45
46
package influxqb
import "github.com/influxdata/influxql"
type RevokeBuilder struct {
isAdmin bool
db string
username string
privilege influxql.Privilege
}
func (b *RevokeBuilder) Admin() *RevokeBuilder {
b.isAdmin = true
return b
}
func (b *RevokeBuilder) FromUsername(username string) *RevokeBuilder {
b.username = username
return b
}
func (b *RevokeBuilder) OnDatabase(database string) *RevokeBuilder {
b.db = database
return b
}
func (b *RevokeBuilder) WithPrivilege(privilege influxql.Privilege) *RevokeBuilder {
b.privilege = privilege
return b
}
func (b *RevokeBuilder) Build() (string, error) {
if b.isAdmin {
stm := &influxql.RevokeAdminStatement{User: b.username}
return stm.String(), nil
} else {
stm := &influxql.RevokeStatement{
Privilege: b.privilege,
On: b.db,
User: b.username,
}
return stm.String(), nil
}
}