Ai
1 Star 0 Fork 0

ryancartoon/sensu-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
clusterrole.go 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
package client
import (
corev2 "github.com/sensu/sensu-go/api/core/v2"
"github.com/sensu/sensu-go/types"
)
var clusterRolesPath = CreateBasePath(coreAPIGroup, coreAPIVersion, "clusterroles")
// CreateClusterRole with the given cluster role
func (client *RestClient) CreateClusterRole(clusterRole *types.ClusterRole) error {
return client.Post(clusterRolesPath(), clusterRole)
}
// DeleteClusterRole with the given name
func (client *RestClient) DeleteClusterRole(name string) error {
return client.Delete(clusterRolesPath(name))
}
// FetchClusterRole with the given name
func (client *RestClient) FetchClusterRole(name string) (*types.ClusterRole, error) {
clusterRole := &types.ClusterRole{}
if err := client.Get(clusterRolesPath(name), clusterRole); err != nil {
return nil, err
}
return clusterRole, nil
}
// ListClusterRoles within the namespace
func (client *RestClient) ListClusterRoles(options *ListOptions) ([]corev2.ClusterRole, error) {
clusterRoles := []corev2.ClusterRole{}
if err := client.List(clusterRolesPath(), &clusterRoles, options); err != nil {
return clusterRoles, err
}
return clusterRoles, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ryancartoon/sensu-go.git
git@gitee.com:ryancartoon/sensu-go.git
ryancartoon
sensu-go
sensu-go
v5.10.1

搜索帮助