policy

package
v0.0.0-...-6a8978f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2022 License: MIT Imports: 16 Imported by: 0

README

策略管理

user role namespace ...

Documentation

Index

Constants

View Source
const (
	AppName = "policy"
)

Variables

View Source
var (
	PolicyType_name = map[int32]string{
		0: "CUSTOM",
		1: "BUILD_IN",
	}
	PolicyType_value = map[string]int32{
		"CUSTOM":   0,
		"BUILD_IN": 1,
	}
)

Enum value maps for PolicyType.

View Source
var File_apps_policy_pb_policy_proto protoreflect.FileDescriptor
View Source
var File_apps_policy_pb_rpc_proto protoreflect.FileDescriptor
View Source
var RPC_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "go8.devcloud.mcenter.policy.RPC",
	HandlerType: (*RPCServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "QueryPolicy",
			Handler:    _RPC_QueryPolicy_Handler,
		},
		{
			MethodName: "DescribePolicy",
			Handler:    _RPC_DescribePolicy_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "apps/policy/pb/rpc.proto",
}

RPC_ServiceDesc is the grpc.ServiceDesc for RPC service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterRPCServer

func RegisterRPCServer(s grpc.ServiceRegistrar, srv RPCServer)

Types

type CreatePolicyRequest

type CreatePolicyRequest struct {

	// 创建者
	// @gotags: bson:"create_by" json:"create_by"
	CreateBy string `protobuf:"bytes,1,opt,name=create_by,json=createBy,proto3" json:"create_by" bson:"create_by"`
	// 策略所属域
	// @gotags: bson:"domain" json:"domain"
	Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain" bson:"domain"`
	// 范围
	// @gotags: bson:"namespace" json:"namespace" validate:"lte=120"
	Namespace string `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace" bson:"namespace" validate:"lte=120"`
	// 比如namepsace更小的维度, 比如 你namespace还有很多小的组
	// 研发云这个项目, group 用于控制环境(env)
	// @gotags: bson:"group" json:"group"
	Group string `protobuf:"bytes,4,opt,name=group,proto3" json:"group" bson:"group"`
	// 范围控制
	// @gotags: bson:"scope" json:"scope"
	Scope string `protobuf:"bytes,5,opt,name=scope,proto3" json:"scope" bson:"scope"`
	// 用户
	// @gotags: bson:"username" json:"username" validate:"required,lte=120"
	Username string `protobuf:"bytes,6,opt,name=username,proto3" json:"username" bson:"username" validate:"required,lte=120"`
	// 角色名称
	// @gotags: bson:"role_id" json:"role_id" validate:"required,lte=40"
	RoleId string `protobuf:"bytes,7,opt,name=role_id,json=roleId,proto3" json:"role_id" bson:"role_id" validate:"required,lte=40"`
	// 策略过期时间
	// @gotags: bson:"expired_time" json:"expired_time"
	ExpiredTime int64 `protobuf:"varint,8,opt,name=expired_time,json=expiredTime,proto3" json:"expired_time" bson:"expired_time"`
	// 策略的类型
	// @gotags: bson:"type" json:"type"
	Type PolicyType `protobuf:"varint,9,opt,name=type,proto3,enum=go8.devcloud.mcenter.policy.PolicyType" json:"type" bson:"type"`
	// contains filtered or unexported fields
}

CreatePolicyRequest 创建策略的请求

func NewCreatePolicyRequest

func NewCreatePolicyRequest() *CreatePolicyRequest

NewCreatePolicyRequest 请求实例

func (*CreatePolicyRequest) Descriptor deprecated

func (*CreatePolicyRequest) Descriptor() ([]byte, []int)

Deprecated: Use CreatePolicyRequest.ProtoReflect.Descriptor instead.

func (*CreatePolicyRequest) GetCreateBy

func (x *CreatePolicyRequest) GetCreateBy() string

func (*CreatePolicyRequest) GetDomain

func (x *CreatePolicyRequest) GetDomain() string

func (*CreatePolicyRequest) GetExpiredTime

func (x *CreatePolicyRequest) GetExpiredTime() int64

func (*CreatePolicyRequest) GetGroup

func (x *CreatePolicyRequest) GetGroup() string

func (*CreatePolicyRequest) GetNamespace

func (x *CreatePolicyRequest) GetNamespace() string

func (*CreatePolicyRequest) GetRoleId

func (x *CreatePolicyRequest) GetRoleId() string

func (*CreatePolicyRequest) GetScope

func (x *CreatePolicyRequest) GetScope() string

func (*CreatePolicyRequest) GetType

func (x *CreatePolicyRequest) GetType() PolicyType

func (*CreatePolicyRequest) GetUsername

func (x *CreatePolicyRequest) GetUsername() string

func (*CreatePolicyRequest) ProtoMessage

func (*CreatePolicyRequest) ProtoMessage()

func (*CreatePolicyRequest) ProtoReflect

func (x *CreatePolicyRequest) ProtoReflect() protoreflect.Message

func (*CreatePolicyRequest) Reset

func (x *CreatePolicyRequest) Reset()

func (*CreatePolicyRequest) String

func (x *CreatePolicyRequest) String() string

func (*CreatePolicyRequest) Validate

func (req *CreatePolicyRequest) Validate() error

Validate 校验请求合法

type DeletePolicyRequest

type DeletePolicyRequest struct {

	// @gotags: json:"id"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"`
	// @gotags: json:"username,omitempty"
	Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
	// @gotags: json:"role_id,omitempty"
	RoleId string `protobuf:"bytes,3,opt,name=role_id,json=roleId,proto3" json:"role_id,omitempty"`
	// @gotags: json:"namespace,omitempty"
	Namespace string `protobuf:"bytes,4,opt,name=namespace,proto3" json:"namespace,omitempty"`
	// @gotags: json:"type,omitempty"
	Type *PolicyType `protobuf:"varint,5,opt,name=type,proto3,enum=go8.devcloud.mcenter.policy.PolicyType,oneof" json:"type,omitempty"`
	// @gotags: json:"domain"
	Domain string `protobuf:"bytes,6,opt,name=domain,proto3" json:"domain"`
	// contains filtered or unexported fields
}

DeletePolicyRequest todo

func NewDeletePolicyRequestWithID

func NewDeletePolicyRequestWithID(id string) *DeletePolicyRequest

NewDeletePolicyRequestWithID todo

func (*DeletePolicyRequest) Descriptor deprecated

func (*DeletePolicyRequest) Descriptor() ([]byte, []int)

Deprecated: Use DeletePolicyRequest.ProtoReflect.Descriptor instead.

func (*DeletePolicyRequest) GetDomain

func (x *DeletePolicyRequest) GetDomain() string

func (*DeletePolicyRequest) GetId

func (x *DeletePolicyRequest) GetId() string

func (*DeletePolicyRequest) GetNamespace

func (x *DeletePolicyRequest) GetNamespace() string

func (*DeletePolicyRequest) GetRoleId

func (x *DeletePolicyRequest) GetRoleId() string

func (*DeletePolicyRequest) GetType

func (x *DeletePolicyRequest) GetType() PolicyType

func (*DeletePolicyRequest) GetUsername

func (x *DeletePolicyRequest) GetUsername() string

func (*DeletePolicyRequest) ProtoMessage

func (*DeletePolicyRequest) ProtoMessage()

func (*DeletePolicyRequest) ProtoReflect

func (x *DeletePolicyRequest) ProtoReflect() protoreflect.Message

func (*DeletePolicyRequest) Reset

func (x *DeletePolicyRequest) Reset()

func (*DeletePolicyRequest) String

func (x *DeletePolicyRequest) String() string

type DescribePolicyRequest

type DescribePolicyRequest struct {

	// @gotags: json:"id"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"`
	// contains filtered or unexported fields
}

DescribePolicyRequest todo

func NewDescriptPolicyRequest

func NewDescriptPolicyRequest() *DescribePolicyRequest

NewDescriptPolicyRequest new实例

func (*DescribePolicyRequest) Descriptor deprecated

func (*DescribePolicyRequest) Descriptor() ([]byte, []int)

Deprecated: Use DescribePolicyRequest.ProtoReflect.Descriptor instead.

func (*DescribePolicyRequest) GetId

func (x *DescribePolicyRequest) GetId() string

func (*DescribePolicyRequest) ProtoMessage

func (*DescribePolicyRequest) ProtoMessage()

func (*DescribePolicyRequest) ProtoReflect

func (x *DescribePolicyRequest) ProtoReflect() protoreflect.Message

func (*DescribePolicyRequest) Reset

func (x *DescribePolicyRequest) Reset()

func (*DescribePolicyRequest) String

func (x *DescribePolicyRequest) String() string

func (*DescribePolicyRequest) Validate

func (req *DescribePolicyRequest) Validate() error

Validate todo

type Policy

type Policy struct {

	// 策略ID
	// @gotags: bson:"_id" json:"id"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"`
	// 创建时间
	// @gotags: bson:"create_at" json:"create_at"
	CreateAt int64 `protobuf:"varint,2,opt,name=create_at,json=createAt,proto3" json:"create_at" bson:"create_at"`
	// 更新时间
	// @gotags: bson:"update_at" json:"update_at"
	UpdateAt int64 `protobuf:"varint,3,opt,name=update_at,json=updateAt,proto3" json:"update_at" bson:"update_at"`
	// 策略定义
	// @gotags: bson:"spec" json:"spec"
	Spec *CreatePolicyRequest `protobuf:"bytes,4,opt,name=spec,proto3" json:"spec" bson:"spec"`
	// 关联的角色对象
	// @gotags: bson:"-" json:"role,omitempty"
	Role *role.Role `protobuf:"bytes,13,opt,name=role,proto3" json:"role,omitempty" bson:"-"`
	// contains filtered or unexported fields
}

Policy 权限策略

func New

func New(req *CreatePolicyRequest) (*Policy, error)

New 新实例

func NewDefaultPolicy

func NewDefaultPolicy() *Policy

NewDefaultPolicy todo

func (*Policy) Descriptor deprecated

func (*Policy) Descriptor() ([]byte, []int)

Deprecated: Use Policy.ProtoReflect.Descriptor instead.

func (*Policy) GetCreateAt

func (x *Policy) GetCreateAt() int64

func (*Policy) GetId

func (x *Policy) GetId() string

func (*Policy) GetRole

func (x *Policy) GetRole() *role.Role

func (*Policy) GetSpec

func (x *Policy) GetSpec() *CreatePolicyRequest

func (*Policy) GetUpdateAt

func (x *Policy) GetUpdateAt() int64

func (*Policy) ProtoMessage

func (*Policy) ProtoMessage()

func (*Policy) ProtoReflect

func (x *Policy) ProtoReflect() protoreflect.Message

func (*Policy) Reset

func (x *Policy) Reset()

func (*Policy) String

func (x *Policy) String() string

type PolicySet

type PolicySet struct {

	// @gotags: bson:"total" json:"total"
	Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total" bson:"total"`
	// @gotags: bson:"items" json:"items"
	Items []*Policy `protobuf:"bytes,2,rep,name=items,proto3" json:"items" bson:"items"`
	// contains filtered or unexported fields
}

func NewPolicySet

func NewPolicySet() *PolicySet

NewPolicySet todo

func (*PolicySet) Add

func (s *PolicySet) Add(e *Policy)

Add 添加

func (*PolicySet) Descriptor deprecated

func (*PolicySet) Descriptor() ([]byte, []int)

Deprecated: Use PolicySet.ProtoReflect.Descriptor instead.

func (*PolicySet) GetItems

func (x *PolicySet) GetItems() []*Policy

func (*PolicySet) GetRoles

func (s *PolicySet) GetRoles(ctx context.Context) (*role.RoleSet, error)

GetRoles todo

func (*PolicySet) GetTotal

func (x *PolicySet) GetTotal() int64

func (*PolicySet) ProtoMessage

func (*PolicySet) ProtoMessage()

func (*PolicySet) ProtoReflect

func (x *PolicySet) ProtoReflect() protoreflect.Message

func (*PolicySet) Reset

func (x *PolicySet) Reset()

func (*PolicySet) String

func (x *PolicySet) String() string

type PolicyType

type PolicyType int32
const (
	// CustomPolicy (custom) 用户自己定义的策略
	PolicyType_CUSTOM PolicyType = 0
	// BuildInPolicy (build_in) 系统内部逻辑, 不允许用户看到并修改
	PolicyType_BUILD_IN PolicyType = 1
)

func ParsePolicyTypeFromString

func ParsePolicyTypeFromString(str string) (PolicyType, error)

ParsePolicyTypeFromString Parse PolicyType from string

func (PolicyType) Descriptor

func (PolicyType) Descriptor() protoreflect.EnumDescriptor

func (PolicyType) Enum

func (x PolicyType) Enum() *PolicyType

func (PolicyType) EnumDescriptor deprecated

func (PolicyType) EnumDescriptor() ([]byte, []int)

Deprecated: Use PolicyType.Descriptor instead.

func (PolicyType) Equal

func (t PolicyType) Equal(target PolicyType) bool

Equal type compare

func (PolicyType) IsIn

func (t PolicyType) IsIn(targets ...PolicyType) bool

IsIn todo

func (PolicyType) MarshalJSON

func (t PolicyType) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (PolicyType) Number

func (x PolicyType) Number() protoreflect.EnumNumber

func (PolicyType) String

func (x PolicyType) String() string

func (PolicyType) Type

func (*PolicyType) UnmarshalJSON

func (t *PolicyType) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type QueryPolicyRequest

type QueryPolicyRequest struct {

	// @gotags: bson:"page" json:"page"
	Page *request.PageRequest `protobuf:"bytes,1,opt,name=page,proto3" json:"page" bson:"page"`
	// @gotags: json:"username,omitempty"
	Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
	// @gotags: json:"role_id,omitempty"
	RoleId string `protobuf:"bytes,3,opt,name=role_id,json=roleId,proto3" json:"role_id,omitempty"`
	// @gotags: json:"namespace,omitempty"
	Namespace string `protobuf:"bytes,4,opt,name=namespace,proto3" json:"namespace,omitempty"`
	// @gotags: json:"type,omitempty"
	Type *PolicyType `protobuf:"varint,5,opt,name=type,proto3,enum=go8.devcloud.mcenter.policy.PolicyType,oneof" json:"type,omitempty"`
	// @gotags: json:"with_role,omitempty"
	WithRole bool `protobuf:"varint,6,opt,name=with_role,json=withRole,proto3" json:"with_role,omitempty"`
	// @gotags: json:"with_namespace,omitempty"
	WithNamespace bool `protobuf:"varint,7,opt,name=with_namespace,json=withNamespace,proto3" json:"with_namespace,omitempty"`
	// @gotags: json:"domain"
	Domain string `protobuf:"bytes,8,opt,name=domain,proto3" json:"domain"`
	// contains filtered or unexported fields
}

QueryPolicyRequest 获取子账号列表

func NewQueryPolicyRequest

func NewQueryPolicyRequest() *QueryPolicyRequest

NewQueryPolicyRequest 列表查询请求

func (*QueryPolicyRequest) Descriptor deprecated

func (*QueryPolicyRequest) Descriptor() ([]byte, []int)

Deprecated: Use QueryPolicyRequest.ProtoReflect.Descriptor instead.

func (*QueryPolicyRequest) GetDomain

func (x *QueryPolicyRequest) GetDomain() string

func (*QueryPolicyRequest) GetNamespace

func (x *QueryPolicyRequest) GetNamespace() string

func (*QueryPolicyRequest) GetPage

func (x *QueryPolicyRequest) GetPage() *request.PageRequest

func (*QueryPolicyRequest) GetRoleId

func (x *QueryPolicyRequest) GetRoleId() string

func (*QueryPolicyRequest) GetType

func (x *QueryPolicyRequest) GetType() PolicyType

func (*QueryPolicyRequest) GetUsername

func (x *QueryPolicyRequest) GetUsername() string

func (*QueryPolicyRequest) GetWithNamespace

func (x *QueryPolicyRequest) GetWithNamespace() bool

func (*QueryPolicyRequest) GetWithRole

func (x *QueryPolicyRequest) GetWithRole() bool

func (*QueryPolicyRequest) ProtoMessage

func (*QueryPolicyRequest) ProtoMessage()

func (*QueryPolicyRequest) ProtoReflect

func (x *QueryPolicyRequest) ProtoReflect() protoreflect.Message

func (*QueryPolicyRequest) Reset

func (x *QueryPolicyRequest) Reset()

func (*QueryPolicyRequest) String

func (x *QueryPolicyRequest) String() string

func (*QueryPolicyRequest) Validate

func (req *QueryPolicyRequest) Validate() error

Validate 校验请求是否合法

type RPCClient

type RPCClient interface {
	QueryPolicy(ctx context.Context, in *QueryPolicyRequest, opts ...grpc.CallOption) (*PolicySet, error)
	DescribePolicy(ctx context.Context, in *DescribePolicyRequest, opts ...grpc.CallOption) (*Policy, error)
}

RPCClient is the client API for RPC service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewRPCClient

func NewRPCClient(cc grpc.ClientConnInterface) RPCClient

type RPCServer

type RPCServer interface {
	QueryPolicy(context.Context, *QueryPolicyRequest) (*PolicySet, error)
	DescribePolicy(context.Context, *DescribePolicyRequest) (*Policy, error)
	// contains filtered or unexported methods
}

RPCServer is the server API for RPC service. All implementations must embed UnimplementedRPCServer for forward compatibility

type Service

type Service interface {
	CreatePolicy(context.Context, *CreatePolicyRequest) (*Policy, error)
	DeletePolicy(context.Context, *DeletePolicyRequest) (*Policy, error)
	RPCServer
}

type UnimplementedRPCServer

type UnimplementedRPCServer struct {
}

UnimplementedRPCServer must be embedded to have forward compatible implementations.

func (UnimplementedRPCServer) DescribePolicy

func (UnimplementedRPCServer) QueryPolicy

type UnsafeRPCServer

type UnsafeRPCServer interface {
	// contains filtered or unexported methods
}

UnsafeRPCServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to RPCServer will result in compilation errors.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL