Commit 478c5151 authored by 张醒狮's avatar 张醒狮

add GetMajorOwnership function

parent d51d1bd9
......@@ -34,6 +34,18 @@ func (rc *ResourceCenterClient) GetOwnership(ctx context.Context, resourceId str
return rc.Client.GetOwnership(ctx, req)
}
func (rc *ResourceCenterClient) GetMajorOwnership(ctx context.Context, resourceId string) (*pb.Organ, error) {
organ := &pb.Organ{Team: "质量运维部", Group: "运维保障组"}
response, err := rc.GetOwnership(ctx, resourceId)
if err != nil {
return nil, err
}
if response.Mode > 0 {
organ = response.Items[0]
}
return organ, nil
}
func (rc *ResourceCenterClient) SearchAsset(ctx context.Context, resourceType string, opts ...Option) (*pb.AssetResponse, error) {
req := &pb.AssetRequest{ResourceType: resourceType}
......
......@@ -67,7 +67,7 @@ func (x *OwnershipRequest) GetInstanceId() string {
return ""
}
type Items struct {
type Organ struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
......@@ -80,8 +80,8 @@ type Items struct {
AppId string `protobuf:"bytes,6,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty"`
}
func (x *Items) Reset() {
*x = Items{}
func (x *Organ) Reset() {
*x = Organ{}
if protoimpl.UnsafeEnabled {
mi := &file_pb_resource_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
......@@ -89,13 +89,13 @@ func (x *Items) Reset() {
}
}
func (x *Items) String() string {
func (x *Organ) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Items) ProtoMessage() {}
func (*Organ) ProtoMessage() {}
func (x *Items) ProtoReflect() protoreflect.Message {
func (x *Organ) ProtoReflect() protoreflect.Message {
mi := &file_pb_resource_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
......@@ -107,47 +107,47 @@ func (x *Items) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use Items.ProtoReflect.Descriptor instead.
func (*Items) Descriptor() ([]byte, []int) {
// Deprecated: Use Organ.ProtoReflect.Descriptor instead.
func (*Organ) Descriptor() ([]byte, []int) {
return file_pb_resource_proto_rawDescGZIP(), []int{1}
}
func (x *Items) GetTeam() string {
func (x *Organ) GetTeam() string {
if x != nil {
return x.Team
}
return ""
}
func (x *Items) GetTeamId() string {
func (x *Organ) GetTeamId() string {
if x != nil {
return x.TeamId
}
return ""
}
func (x *Items) GetGroup() string {
func (x *Organ) GetGroup() string {
if x != nil {
return x.Group
}
return ""
}
func (x *Items) GetGroupId() string {
func (x *Organ) GetGroupId() string {
if x != nil {
return x.GroupId
}
return ""
}
func (x *Items) GetApp() string {
func (x *Organ) GetApp() string {
if x != nil {
return x.App
}
return ""
}
func (x *Items) GetAppId() string {
func (x *Organ) GetAppId() string {
if x != nil {
return x.AppId
}
......@@ -159,7 +159,7 @@ type OwnershipResponse struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Items []*Items `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"`
Items []*Organ `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"`
Mode int32 `protobuf:"varint,2,opt,name=mode,proto3" json:"mode,omitempty"`
}
......@@ -195,7 +195,7 @@ func (*OwnershipResponse) Descriptor() ([]byte, []int) {
return file_pb_resource_proto_rawDescGZIP(), []int{2}
}
func (x *OwnershipResponse) GetItems() []*Items {
func (x *OwnershipResponse) GetItems() []*Organ {
if x != nil {
return x.Items
}
......@@ -446,7 +446,7 @@ var file_pb_resource_proto_rawDesc = []byte{
0x77, 0x6e, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64,
0x22, 0x8e, 0x01, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65,
0x22, 0x8e, 0x01, 0x0a, 0x05, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65,
0x61, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x61, 0x6d, 0x12, 0x17,
0x0a, 0x07, 0x74, 0x65, 0x61, 0x6d, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x06, 0x74, 0x65, 0x61, 0x6d, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70,
......@@ -457,8 +457,8 @@ var file_pb_resource_proto_rawDesc = []byte{
0x70, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49,
0x64, 0x22, 0x4c, 0x0a, 0x11, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18,
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x67, 0x75, 0x69, 0x64, 0x6f, 0x6e, 0x2e, 0x69,
0x74, 0x65, 0x6d, 0x73, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6d,
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x67, 0x75, 0x69, 0x64, 0x6f, 0x6e, 0x2e, 0x4f,
0x72, 0x67, 0x61, 0x6e, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6d,
0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x22,
0xf1, 0x01, 0x0a, 0x0c, 0x41, 0x73, 0x73, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d,
......@@ -520,14 +520,14 @@ func file_pb_resource_proto_rawDescGZIP() []byte {
var file_pb_resource_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_pb_resource_proto_goTypes = []interface{}{
(*OwnershipRequest)(nil), // 0: guidon.OwnershipRequest
(*Items)(nil), // 1: guidon.items
(*Organ)(nil), // 1: guidon.Organ
(*OwnershipResponse)(nil), // 2: guidon.OwnershipResponse
(*AssetRequest)(nil), // 3: guidon.AssetRequest
(*AssetResponse)(nil), // 4: guidon.AssetResponse
(*AssertInfo)(nil), // 5: guidon.AssertInfo
}
var file_pb_resource_proto_depIdxs = []int32{
1, // 0: guidon.OwnershipResponse.items:type_name -> guidon.items
1, // 0: guidon.OwnershipResponse.items:type_name -> guidon.Organ
5, // 1: guidon.AssetResponse.items:type_name -> guidon.AssertInfo
0, // 2: guidon.ResourceCenter.GetOwnership:input_type -> guidon.OwnershipRequest
3, // 3: guidon.ResourceCenter.SearchAsset:input_type -> guidon.AssetRequest
......@@ -559,7 +559,7 @@ func file_pb_resource_proto_init() {
}
}
file_pb_resource_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Items); i {
switch v := v.(*Organ); i {
case 0:
return &v.state
case 1:
......
......@@ -7,7 +7,7 @@ message OwnershipRequest {
string instance_id = 1;
}
message items {
message Organ {
string team = 1;
string team_id = 2;
string group = 3;
......@@ -17,7 +17,7 @@ message items {
}
message OwnershipResponse {
repeated items items = 1;
repeated Organ items = 1;
int32 mode = 2;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment