Provide extension methods
This commit is contained in:
parent
bc5eb0561d
commit
675f35f2a6
@ -2,3 +2,7 @@ import grpc
|
|||||||
|
|
||||||
from .sys_mon_agent_api_pb2 import AgentConfiguration, AgentConfigurationResponse, MonitoringStats, MonitoredServiceState, MonitoredService, MonitoredStorage
|
from .sys_mon_agent_api_pb2 import AgentConfiguration, AgentConfigurationResponse, MonitoringStats, MonitoredServiceState, MonitoredService, MonitoredStorage
|
||||||
from .sys_mon_agent_api_pb2_grpc import AgentServicer, AgentStub, add_AgentServicer_to_server
|
from .sys_mon_agent_api_pb2_grpc import AgentServicer, AgentStub, add_AgentServicer_to_server
|
||||||
|
from .api_extensions import _MonitoringStats_get_storage_by_name, _MonitoringStats_get_service_by_name
|
||||||
|
|
||||||
|
MonitoringStats.storage_by_name = _MonitoringStats_get_storage_by_name
|
||||||
|
MonitoringStats.service_by_name = _MonitoringStats_get_service_by_name
|
||||||
|
|||||||
17
api/api_extensions.py
Normal file
17
api/api_extensions.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from .sys_mon_agent_api_pb2 import MonitoringStats, MonitoredStorage, MonitoredService
|
||||||
|
|
||||||
|
def _MonitoringStats_get_storage_by_name(self: MonitoringStats, name: str) -> Optional[MonitoredStorage]:
|
||||||
|
for storage in self.storage:
|
||||||
|
if storage.name == name:
|
||||||
|
return storage
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _MonitoringStats_get_service_by_name(self: MonitoringStats, name: str) -> Optional[MonitoredService]:
|
||||||
|
for service in self.services:
|
||||||
|
if service.name == name:
|
||||||
|
return service
|
||||||
|
|
||||||
|
return None
|
||||||
Loading…
x
Reference in New Issue
Block a user