Commit eaa0bcfd authored by ozzeh's avatar ozzeh
Browse files

Add role service for online bot

parent 5faaf291
......@@ -71,3 +71,31 @@ class UserServiceStub:
grpc_madmin.user_pb2.RequestSSGListing,
grpc_madmin.user_pb2.ServerSpecificGroup,
)
class BotServiceBase(abc.ABC):
@abc.abstractmethod
async def UpdateUserRoles(self, stream: 'grpclib.server.Stream[grpc_madmin.user_pb2.RoleAccessUpdate, grpc_madmin.generic_pb2.GenericResponse]') -> None:
pass
def __mapping__(self) -> typing.Dict[str, grpclib.const.Handler]:
return {
'/grpc_madmin.user.BotService/UpdateUserRoles': grpclib.const.Handler(
self.UpdateUserRoles,
grpclib.const.Cardinality.UNARY_UNARY,
grpc_madmin.user_pb2.RoleAccessUpdate,
grpc_madmin.generic_pb2.GenericResponse,
),
}
class BotServiceStub:
def __init__(self, channel: grpclib.client.Channel) -> None:
self.UpdateUserRoles = grpclib.client.UnaryUnaryMethod(
channel,
'/grpc_madmin.user.BotService/UpdateUserRoles',
grpc_madmin.user_pb2.RoleAccessUpdate,
grpc_madmin.generic_pb2.GenericResponse,
)
......@@ -21,13 +21,58 @@ DESCRIPTOR = _descriptor.FileDescriptor(
package='grpc_madmin.user',
syntax='proto3',
serialized_options=None,
serialized_pb=_b('\n\x16grpc_madmin/user.proto\x12\x10grpc_madmin.user\x1a\x19grpc_madmin/generic.proto\"\xc2\x01\n\x11UserAccessUpdated\x12\x0f\n\x07\x61uth_id\x18\x01 \x01(\x05\x12\x10\n\x08sso_uuid\x18\x02 \x01(\t\x12\x10\n\x08username\x18\x03 \x01(\t\x12\x12\n\ndiscord_id\x18\x04 \x01(\x03\x12\x1e\n\x16primary_character_name\x18\x05 \x01(\t\x12 \n\x18primary_corporation_name\x18\x06 \x01(\t\x12\"\n\x1aprimary_corporation_ticker\x18\x07 \x01(\t\"I\n\x10UserGroupRequest\x12\x0f\n\x07user_id\x18\x01 \x01(\x03\x12\x10\n\x08guild_id\x18\x02 \x01(\x03\x12\x12\n\ngroup_name\x18\x03 \x01(\t\"O\n\x13ServerSpecificGroup\x12\x10\n\x08guild_id\x18\x01 \x01(\x03\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x18\n\x10requestable_name\x18\x03 \x01(\t\"%\n\x11RequestSSGListing\x12\x10\n\x08guild_id\x18\x01 \x01(\x03\x32\x9e\x02\n\x0bUserService\x12Y\n\x0cOnUpdateUser\x12#.grpc_madmin.user.UserAccessUpdated\x1a$.grpc_madmin.generic.GenericResponse\x12Z\n\rOnDisableUser\x12#.grpc_madmin.user.UserAccessUpdated\x1a$.grpc_madmin.generic.GenericResponse\x12X\n\x08ListSSGs\x12#.grpc_madmin.user.RequestSSGListing\x1a%.grpc_madmin.user.ServerSpecificGroup0\x01\x62\x06proto3')
serialized_pb=_b('\n\x16grpc_madmin/user.proto\x12\x10grpc_madmin.user\x1a\x19grpc_madmin/generic.proto\"G\n\x10RoleAccessUpdate\x12\x12\n\ndiscord_id\x18\x01 \x01(\x03\x12\x10\n\x08guild_id\x18\x02 \x01(\x03\x12\r\n\x05roles\x18\x03 \x03(\x03\"\xc2\x01\n\x11UserAccessUpdated\x12\x0f\n\x07\x61uth_id\x18\x01 \x01(\x05\x12\x10\n\x08sso_uuid\x18\x02 \x01(\t\x12\x10\n\x08username\x18\x03 \x01(\t\x12\x12\n\ndiscord_id\x18\x04 \x01(\x03\x12\x1e\n\x16primary_character_name\x18\x05 \x01(\t\x12 \n\x18primary_corporation_name\x18\x06 \x01(\t\x12\"\n\x1aprimary_corporation_ticker\x18\x07 \x01(\t\"I\n\x10UserGroupRequest\x12\x0f\n\x07user_id\x18\x01 \x01(\x03\x12\x10\n\x08guild_id\x18\x02 \x01(\x03\x12\x12\n\ngroup_name\x18\x03 \x01(\t\"O\n\x13ServerSpecificGroup\x12\x10\n\x08guild_id\x18\x01 \x01(\x03\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x18\n\x10requestable_name\x18\x03 \x01(\t\"%\n\x11RequestSSGListing\x12\x10\n\x08guild_id\x18\x01 \x01(\x03\x32\x9e\x02\n\x0bUserService\x12Y\n\x0cOnUpdateUser\x12#.grpc_madmin.user.UserAccessUpdated\x1a$.grpc_madmin.generic.GenericResponse\x12Z\n\rOnDisableUser\x12#.grpc_madmin.user.UserAccessUpdated\x1a$.grpc_madmin.generic.GenericResponse\x12X\n\x08ListSSGs\x12#.grpc_madmin.user.RequestSSGListing\x1a%.grpc_madmin.user.ServerSpecificGroup0\x01\x32i\n\nBotService\x12[\n\x0fUpdateUserRoles\x12\".grpc_madmin.user.RoleAccessUpdate\x1a$.grpc_madmin.generic.GenericResponseb\x06proto3')
,
dependencies=[grpc__madmin_dot_generic__pb2.DESCRIPTOR,])
_ROLEACCESSUPDATE = _descriptor.Descriptor(
name='RoleAccessUpdate',
full_name='grpc_madmin.user.RoleAccessUpdate',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='discord_id', full_name='grpc_madmin.user.RoleAccessUpdate.discord_id', index=0,
number=1, type=3, cpp_type=2, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='guild_id', full_name='grpc_madmin.user.RoleAccessUpdate.guild_id', index=1,
number=2, type=3, cpp_type=2, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='roles', full_name='grpc_madmin.user.RoleAccessUpdate.roles', index=2,
number=3, type=3, cpp_type=2, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=71,
serialized_end=142,
)
_USERACCESSUPDATED = _descriptor.Descriptor(
name='UserAccessUpdated',
full_name='grpc_madmin.user.UserAccessUpdated',
......@@ -96,8 +141,8 @@ _USERACCESSUPDATED = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=72,
serialized_end=266,
serialized_start=145,
serialized_end=339,
)
......@@ -141,8 +186,8 @@ _USERGROUPREQUEST = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=268,
serialized_end=341,
serialized_start=341,
serialized_end=414,
)
......@@ -186,8 +231,8 @@ _SERVERSPECIFICGROUP = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=343,
serialized_end=422,
serialized_start=416,
serialized_end=495,
)
......@@ -217,16 +262,24 @@ _REQUESTSSGLISTING = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=424,
serialized_end=461,
serialized_start=497,
serialized_end=534,
)
DESCRIPTOR.message_types_by_name['RoleAccessUpdate'] = _ROLEACCESSUPDATE
DESCRIPTOR.message_types_by_name['UserAccessUpdated'] = _USERACCESSUPDATED
DESCRIPTOR.message_types_by_name['UserGroupRequest'] = _USERGROUPREQUEST
DESCRIPTOR.message_types_by_name['ServerSpecificGroup'] = _SERVERSPECIFICGROUP
DESCRIPTOR.message_types_by_name['RequestSSGListing'] = _REQUESTSSGLISTING
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
RoleAccessUpdate = _reflection.GeneratedProtocolMessageType('RoleAccessUpdate', (_message.Message,), {
'DESCRIPTOR' : _ROLEACCESSUPDATE,
'__module__' : 'grpc_madmin.user_pb2'
# @@protoc_insertion_point(class_scope:grpc_madmin.user.RoleAccessUpdate)
})
_sym_db.RegisterMessage(RoleAccessUpdate)
UserAccessUpdated = _reflection.GeneratedProtocolMessageType('UserAccessUpdated', (_message.Message,), {
'DESCRIPTOR' : _USERACCESSUPDATED,
'__module__' : 'grpc_madmin.user_pb2'
......@@ -263,8 +316,8 @@ _USERSERVICE = _descriptor.ServiceDescriptor(
file=DESCRIPTOR,
index=0,
serialized_options=None,
serialized_start=464,
serialized_end=750,
serialized_start=537,
serialized_end=823,
methods=[
_descriptor.MethodDescriptor(
name='OnUpdateUser',
......@@ -298,4 +351,28 @@ _sym_db.RegisterServiceDescriptor(_USERSERVICE)
DESCRIPTOR.services_by_name['UserService'] = _USERSERVICE
_BOTSERVICE = _descriptor.ServiceDescriptor(
name='BotService',
full_name='grpc_madmin.user.BotService',
file=DESCRIPTOR,
index=1,
serialized_options=None,
serialized_start=825,
serialized_end=930,
methods=[
_descriptor.MethodDescriptor(
name='UpdateUserRoles',
full_name='grpc_madmin.user.BotService.UpdateUserRoles',
index=0,
containing_service=None,
input_type=_ROLEACCESSUPDATE,
output_type=grpc__madmin_dot_generic__pb2._GENERICRESPONSE,
serialized_options=None,
),
])
_sym_db.RegisterServiceDescriptor(_BOTSERVICE)
DESCRIPTOR.services_by_name['BotService'] = _BOTSERVICE
# @@protoc_insertion_point(module_scope)
......@@ -79,3 +79,45 @@ def add_UserServiceServicer_to_server(servicer, server):
generic_handler = grpc.method_handlers_generic_handler(
'grpc_madmin.user.UserService', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))
class BotServiceStub(object):
# missing associated documentation comment in .proto file
pass
def __init__(self, channel):
"""Constructor.
Args:
channel: A grpc.Channel.
"""
self.UpdateUserRoles = channel.unary_unary(
'/grpc_madmin.user.BotService/UpdateUserRoles',
request_serializer=grpc__madmin_dot_user__pb2.RoleAccessUpdate.SerializeToString,
response_deserializer=grpc__madmin_dot_generic__pb2.GenericResponse.FromString,
)
class BotServiceServicer(object):
# missing associated documentation comment in .proto file
pass
def UpdateUserRoles(self, request, context):
# missing associated documentation comment in .proto file
pass
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def add_BotServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
'UpdateUserRoles': grpc.unary_unary_rpc_method_handler(
servicer.UpdateUserRoles,
request_deserializer=grpc__madmin_dot_user__pb2.RoleAccessUpdate.FromString,
response_serializer=grpc__madmin_dot_generic__pb2.GenericResponse.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'grpc_madmin.user.BotService', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))
syntax = "proto3";
package grpc_madmin.user;
import "grpc_madmin/generic.proto";
message UserAccessUpdated {
int32 auth_id = 1;
string sso_uuid = 2;
string username = 3;
int64 discord_id = 4;
string primary_character_name = 5;
string primary_corporation_name = 6;
string primary_corporation_ticker = 7;
}
message UserGroupRequest {
int64 user_id = 1;
int64 guild_id = 2;
string group_name = 3;
}
message ServerSpecificGroup {
int64 guild_id = 1;
string name = 2;
string requestable_name = 3;
}
message RequestSSGListing {
int64 guild_id = 1;
}
service UserService {
rpc OnUpdateUser (UserAccessUpdated) returns (grpc_madmin.generic.GenericResponse);
rpc OnDisableUser (UserAccessUpdated) returns (grpc_madmin.generic.GenericResponse);
rpc ListSSGs (RequestSSGListing) returns (stream ServerSpecificGroup);
syntax = "proto3";
package grpc_madmin.user;
import "grpc_madmin/generic.proto";
message RoleAccessUpdate {
int64 discord_id = 1;
int64 guild_id = 2;
repeated int64 roles = 3;
}
message UserAccessUpdated {
int32 auth_id = 1;
string sso_uuid = 2;
string username = 3;
int64 discord_id = 4;
string primary_character_name = 5;
string primary_corporation_name = 6;
string primary_corporation_ticker = 7;
}
message UserGroupRequest {
int64 user_id = 1;
int64 guild_id = 2;
string group_name = 3;
}
message ServerSpecificGroup {
int64 guild_id = 1;
string name = 2;
string requestable_name = 3;
}
message RequestSSGListing {
int64 guild_id = 1;
}
service UserService {
rpc OnUpdateUser (UserAccessUpdated) returns (grpc_madmin.generic.GenericResponse);
rpc OnDisableUser (UserAccessUpdated) returns (grpc_madmin.generic.GenericResponse);
rpc ListSSGs (RequestSSGListing) returns (stream ServerSpecificGroup);
}
service BotService {
rpc UpdateUserRoles(RoleAccessUpdate) returns (grpc_madmin.generic.GenericResponse);
}
\ No newline at end of file
......@@ -2,7 +2,7 @@ from setuptools import setup
setup(
name="grpc_madmin",
version="0.9",
version="0.10",
packages=["grpc_madmin"],
install_requires=["grpcio", "googleapis-common-protos"],
zip_safe=False,
......
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