Related to https://github.com/grafana/oncall-private/issues/2806#issuecomment-2246286918. Prepare engine for the backend plugin enablement/migration: - Refactor sync code - Improve plugin user authentication to set up user on-the-fly (when missing) - Implement v2 endpoints for install, sync and status (to be used via the backend plugin) (most of the changes come from https://github.com/grafana/oncall/pull/4657; backport all engine changes that keep backwards compatibility)
50 lines
834 B
Python
50 lines
834 B
Python
from dataclasses import dataclass
|
|
from typing import Dict, List, Optional
|
|
|
|
|
|
@dataclass
|
|
class SyncPermission:
|
|
action: str
|
|
|
|
|
|
@dataclass
|
|
class SyncUser:
|
|
id: int
|
|
name: str
|
|
login: str
|
|
email: str
|
|
role: str
|
|
avatar_url: str
|
|
permissions: List[SyncPermission]
|
|
teams: Optional[List[int]]
|
|
|
|
|
|
@dataclass
|
|
class SyncTeam:
|
|
team_id: int
|
|
name: str
|
|
email: str
|
|
avatar_url: str
|
|
|
|
|
|
@dataclass
|
|
class SyncSettings:
|
|
stack_id: int
|
|
org_id: int
|
|
license: str
|
|
oncall_api_url: str
|
|
oncall_token: str
|
|
grafana_url: str
|
|
grafana_token: str
|
|
rbac_enabled: bool
|
|
incident_enabled: bool
|
|
incident_backend_url: str
|
|
labels_enabled: bool
|
|
|
|
|
|
@dataclass
|
|
class SyncData:
|
|
users: List[SyncUser]
|
|
teams: List[SyncTeam]
|
|
team_members: Dict[int, List[int]]
|
|
settings: SyncSettings
|