From bf6890551b06243426821fc99fdfdab052d3c02c Mon Sep 17 00:00:00 2001 From: ImMin5 Date: Thu, 21 Dec 2023 04:31:41 +0900 Subject: [PATCH] feat: modify register datasource --- .../manager/repository_manager.py | 19 ++++++++++++------- .../service/data_source_service.py | 6 +++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/spaceone/cost_analysis/manager/repository_manager.py b/src/spaceone/cost_analysis/manager/repository_manager.py index e93a8a62..4165d107 100644 --- a/src/spaceone/cost_analysis/manager/repository_manager.py +++ b/src/spaceone/cost_analysis/manager/repository_manager.py @@ -8,20 +8,25 @@ class RepositoryManager(BaseManager): - def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.repo_connector: SpaceConnector = self.locator.get_connector('SpaceConnector', service='repository') + self.repo_connector: SpaceConnector = self.locator.get_connector( + "SpaceConnector", service="repository" + ) - def get_plugin(self, plugin_id, domain_id): - return self.repo_connector.dispatch('Plugin.get', {'plugin_id': plugin_id, 'domain_id': domain_id}) + def get_plugin(self, plugin_id: str): + return self.repo_connector.dispatch("Plugin.get", {"plugin_id": plugin_id}) def check_plugin_version(self, plugin_id, version, domain_id): - response = self.repo_connector.dispatch('Plugin.get_versions', {'plugin_id': plugin_id, 'domain_id': domain_id}) - versions = response.get('results', []) + response = self.repo_connector.dispatch( + "Plugin.get_versions", {"plugin_id": plugin_id, "domain_id": domain_id} + ) + versions = response.get("results", []) if version not in versions: raise ERROR_INVALID_PLUGIN_VERSION(plugin_id=plugin_id, version=version) def list_schemas(self, query, domain_id): - return self.repo_connector.dispatch('Schema.list', {'query': query, 'domain_id': domain_id}) + return self.repo_connector.dispatch( + "Schema.list", {"query": query, "domain_id": domain_id} + ) diff --git a/src/spaceone/cost_analysis/service/data_source_service.py b/src/spaceone/cost_analysis/service/data_source_service.py index fb00041f..54d6f90a 100644 --- a/src/spaceone/cost_analysis/service/data_source_service.py +++ b/src/spaceone/cost_analysis/service/data_source_service.py @@ -77,7 +77,7 @@ def register(self, params): raise ERROR_REQUIRED_PARAMETER(key="provider") self._validate_plugin_info(plugin_info, secret_type) - self._check_plugin(plugin_info["plugin_id"], domain_id) + self._check_plugin(plugin_info["plugin_id"]) if "secret_filter" in params: self.validate_secret_filter( @@ -543,9 +543,9 @@ def validate_secret_filter(self, secret_filter, domain_id): key="secret_filter.schema", reason="Schema not found" ) - def _check_plugin(self, plugin_id, domain_id): + def _check_plugin(self, plugin_id): repo_mgr: RepositoryManager = self.locator.get_manager("RepositoryManager") - repo_mgr.get_plugin(plugin_id, domain_id) + repo_mgr.get_plugin(plugin_id) def _init_plugin(self, endpoint, options, domain_id): self.ds_plugin_mgr.initialize(endpoint)