Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
feat/admin_update_backend_config
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Jun 8, 2023
1 parent b2e1a9a commit d77a6ef
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ovos_backend_client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ def validate_backend_type(self):
if not API_REGISTRY[self.backend_type]["admin"]:
raise ValueError(f"{self.__class__.__name__} not available for {self.backend_type}")

def update_backend_config(self, config):
return self.backend.admin_update_backend_config(config)

def pair(self, uuid=None):
return self.backend.admin_pair(uuid)

Expand Down
4 changes: 4 additions & 0 deletions ovos_backend_client/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ def skill_settings_download(self):
def admin_pair(self, uuid=None):
raise NotImplementedError()

@abc.abstractmethod
def admin_update_backend_config(self, config):
raise NotImplementedError()

@abc.abstractmethod
def admin_set_device_location(self, uuid, loc):
"""
Expand Down
5 changes: 4 additions & 1 deletion ovos_backend_client/backends/offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ovos_utils.network_utils import get_external_ip
from ovos_utils.smtp_utils import send_smtp
from ovos_utils.xdg_utils import xdg_data_home

from ovos_utils.log import LOG
from ovos_backend_client.backends.base import AbstractBackend, BackendType
from ovos_backend_client.database import JsonMetricDatabase, JsonWakeWordDatabase, \
SkillSettingsModel, OAuthTokenDatabase, OAuthApplicationDatabase, DeviceModel, JsonUtteranceDatabase
Expand Down Expand Up @@ -436,6 +436,9 @@ def oauth_get_token(self, dev_cred):
return self.db_get_oauth_token(dev_cred)

# Admin API
def admin_update_backend_config(self, config):
LOG.error("tried to update backend config, but not using a backend. ignoring")

def admin_pair(self, uuid=None):
uuid = uuid or str(uuid4())
# create dummy identity file for third parties expecting it for pairing checks
Expand Down
5 changes: 5 additions & 0 deletions ovos_backend_client/backends/personal.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,11 @@ def admin_pair(self, uuid=None):
IdentityManager.save(identity)
return identity

def admin_update_backend_config(self, config):
return self.post(f"{self.backend_url}/{self.backend_version}/admin/config",
json={"config": config},
headers={"Authorization": f"Bearer {self.credentials['admin']}"}).json()

def admin_set_device_location(self, uuid, loc):
"""
loc = {
Expand Down

0 comments on commit d77a6ef

Please sign in to comment.