This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
role.go
43 lines (38 loc) · 1.42 KB
/
role.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
package graylog
import (
"github.com/suzuki-shunsuke/go-ptr"
"github.com/suzuki-shunsuke/go-set/v6"
)
type (
// Role represents a role.
Role struct {
Name string `json:"name,omitempty" v-create:"required" v-update:"required"`
Description string `json:"description,omitempty"`
// ex. ["clusterconfigentry:read", "users:edit"]
Permissions set.StrSet `json:"permissions,omitempty" v-create:"required" v-update:"required"`
ReadOnly bool `json:"read_only"`
}
// RoleUpdateParams represents Update Role API's parameters.
RoleUpdateParams struct {
Name string `json:"name,omitempty" v-create:"required" v-update:"required"`
Description *string `json:"description,omitempty"`
// ex. ["clusterconfigentry:read", "users:edit"]
Permissions set.StrSet `json:"permissions,omitempty" v-create:"required" v-update:"required"`
ReadOnly *bool `json:"read_only"`
}
// RolesBody represents Get Roles API's response body.
// Basically users don't use this struct, but this struct is public because some sub packages use this struct.
RolesBody struct {
Roles []Role `json:"roles"`
Total int `json:"total"`
}
)
// NewUpdateParams returns Update Role API's parameters.
func (role *Role) NewUpdateParams() *RoleUpdateParams {
return &RoleUpdateParams{
Name: role.Name,
Description: ptr.PStr(role.Description),
Permissions: role.Permissions,
ReadOnly: ptr.PBool(role.ReadOnly),
}
}