grpc: removed set/get sessopm options, removed get session metadata/location, can be done with get/start session
This commit is contained in:
parent
d4c008e564
commit
d8a3f9e78c
6 changed files with 2 additions and 265 deletions
|
@ -298,48 +298,6 @@ class CoreGrpcClient:
|
|||
request = core_pb2.GetSessionRequest(session_id=session_id)
|
||||
return self.stub.GetSession(request)
|
||||
|
||||
def get_session_options(
|
||||
self, session_id: int
|
||||
) -> core_pb2.GetSessionOptionsResponse:
|
||||
"""
|
||||
Retrieve session options as a dict with id mapping.
|
||||
|
||||
:param session_id: id of session
|
||||
:return: response with a list of configuration groups
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetSessionOptionsRequest(session_id=session_id)
|
||||
return self.stub.GetSessionOptions(request)
|
||||
|
||||
def set_session_options(
|
||||
self, session_id: int, config: Dict[str, str]
|
||||
) -> core_pb2.SetSessionOptionsResponse:
|
||||
"""
|
||||
Set options for a session.
|
||||
|
||||
:param session_id: id of session
|
||||
:param config: configuration values to set
|
||||
:return: response with result of success or failure
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.SetSessionOptionsRequest(
|
||||
session_id=session_id, config=config
|
||||
)
|
||||
return self.stub.SetSessionOptions(request)
|
||||
|
||||
def get_session_metadata(
|
||||
self, session_id: int
|
||||
) -> core_pb2.GetSessionMetadataResponse:
|
||||
"""
|
||||
Retrieve session metadata as a dict with id mapping.
|
||||
|
||||
:param session_id: id of session
|
||||
:return: response with metadata dict
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetSessionMetadataRequest(session_id=session_id)
|
||||
return self.stub.GetSessionMetadata(request)
|
||||
|
||||
def set_session_metadata(
|
||||
self, session_id: int, config: Dict[str, str]
|
||||
) -> core_pb2.SetSessionMetadataResponse:
|
||||
|
@ -356,19 +314,6 @@ class CoreGrpcClient:
|
|||
)
|
||||
return self.stub.SetSessionMetadata(request)
|
||||
|
||||
def get_session_location(
|
||||
self, session_id: int
|
||||
) -> core_pb2.GetSessionLocationResponse:
|
||||
"""
|
||||
Get session location.
|
||||
|
||||
:param session_id: id of session
|
||||
:return: response with session position reference and scale
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetSessionLocationRequest(session_id=session_id)
|
||||
return self.stub.GetSessionLocation(request)
|
||||
|
||||
def set_session_location(
|
||||
self,
|
||||
session_id: int,
|
||||
|
|
|
@ -407,18 +407,6 @@ class CoreGrpcClient:
|
|||
response = self.stub.GetSession(request)
|
||||
return wrappers.Session.from_proto(response.session)
|
||||
|
||||
def get_session_metadata(self, session_id: int) -> Dict[str, str]:
|
||||
"""
|
||||
Retrieve session metadata as a dict with id mapping.
|
||||
|
||||
:param session_id: id of session
|
||||
:return: response with metadata dict
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetSessionMetadataRequest(session_id=session_id)
|
||||
response = self.stub.GetSessionMetadata(request)
|
||||
return dict(response.config)
|
||||
|
||||
def set_session_metadata(self, session_id: int, config: Dict[str, str]) -> bool:
|
||||
"""
|
||||
Set metadata for a session.
|
||||
|
@ -434,18 +422,6 @@ class CoreGrpcClient:
|
|||
response = self.stub.SetSessionMetadata(request)
|
||||
return response.result
|
||||
|
||||
def get_session_location(self, session_id: int) -> wrappers.SessionLocation:
|
||||
"""
|
||||
Get session location.
|
||||
|
||||
:param session_id: id of session
|
||||
:return: response with session position reference and scale
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetSessionLocationRequest(session_id=session_id)
|
||||
response = self.stub.GetSessionLocation(request)
|
||||
return wrappers.SessionLocation.from_proto(response.location)
|
||||
|
||||
def set_session_location(
|
||||
self, session_id: int, location: wrappers.SessionLocation
|
||||
) -> bool:
|
||||
|
|
|
@ -383,26 +383,6 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
sessions.append(session_summary)
|
||||
return core_pb2.GetSessionsResponse(sessions=sessions)
|
||||
|
||||
def GetSessionLocation(
|
||||
self, request: core_pb2.GetSessionLocationRequest, context: ServicerContext
|
||||
) -> core_pb2.GetSessionLocationResponse:
|
||||
"""
|
||||
Retrieve a requested session location
|
||||
|
||||
:param request: get-session-location request
|
||||
:param context: context object
|
||||
:return: a get-session-location response
|
||||
"""
|
||||
logger.debug("get session location: %s", request)
|
||||
session = self.get_session(request.session_id, context)
|
||||
x, y, z = session.location.refxyz
|
||||
lat, lon, alt = session.location.refgeo
|
||||
scale = session.location.refscale
|
||||
location = core_pb2.SessionLocation(
|
||||
x=x, y=y, z=z, lat=lat, lon=lon, alt=alt, scale=scale
|
||||
)
|
||||
return core_pb2.GetSessionLocationResponse(location=location)
|
||||
|
||||
def SetSessionLocation(
|
||||
self, request: core_pb2.SetSessionLocationRequest, context: ServicerContext
|
||||
) -> core_pb2.SetSessionLocationResponse:
|
||||
|
@ -462,56 +442,6 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
session.user = request.user
|
||||
return core_pb2.SetSessionUserResponse(result=True)
|
||||
|
||||
def GetSessionOptions(
|
||||
self, request: core_pb2.GetSessionOptionsRequest, context: ServicerContext
|
||||
) -> core_pb2.GetSessionOptionsResponse:
|
||||
"""
|
||||
Retrieve session options.
|
||||
|
||||
:param request:
|
||||
get-session-options request
|
||||
:param context: context object
|
||||
:return: get-session-options response about all session's options
|
||||
"""
|
||||
logger.debug("get session options: %s", request)
|
||||
session = self.get_session(request.session_id, context)
|
||||
current_config = session.options.get_configs()
|
||||
default_config = session.options.default_values()
|
||||
default_config.update(current_config)
|
||||
config = get_config_options(default_config, session.options)
|
||||
return core_pb2.GetSessionOptionsResponse(config=config)
|
||||
|
||||
def SetSessionOptions(
|
||||
self, request: core_pb2.SetSessionOptionsRequest, context: ServicerContext
|
||||
) -> core_pb2.SetSessionOptionsResponse:
|
||||
"""
|
||||
Update a session's configuration
|
||||
|
||||
:param request: set-session-options request
|
||||
:param context: context object
|
||||
:return: set-session-options response
|
||||
"""
|
||||
logger.debug("set session options: %s", request)
|
||||
session = self.get_session(request.session_id, context)
|
||||
config = session.options.get_configs()
|
||||
config.update(request.config)
|
||||
return core_pb2.SetSessionOptionsResponse(result=True)
|
||||
|
||||
def GetSessionMetadata(
|
||||
self, request: core_pb2.GetSessionMetadataRequest, context: ServicerContext
|
||||
) -> core_pb2.GetSessionMetadataResponse:
|
||||
"""
|
||||
Retrieve session metadata.
|
||||
|
||||
:param request: get session metadata
|
||||
request
|
||||
:param context: context object
|
||||
:return: get session metadata response
|
||||
"""
|
||||
logger.debug("get session metadata: %s", request)
|
||||
session = self.get_session(request.session_id, context)
|
||||
return core_pb2.GetSessionMetadataResponse(config=session.metadata)
|
||||
|
||||
def SetSessionMetadata(
|
||||
self, request: core_pb2.SetSessionMetadataRequest, context: ServicerContext
|
||||
) -> core_pb2.SetSessionMetadataResponse:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue