From bd25ce065df538b686c8544cdea0070260108626 Mon Sep 17 00:00:00 2001 From: ImMin5 Date: Mon, 9 Dec 2024 16:19:47 +0900 Subject: [PATCH] fix: modify inventory-v2 collector request spec Signed-off-by: ImMin5 --- .../inventory_v2/model/collector/request.py | 2 +- .../inventory_v2/service/collector_service.py | 96 +++++++++---------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/spaceone/inventory_v2/model/collector/request.py b/src/spaceone/inventory_v2/model/collector/request.py index 5e511b2..96a6b68 100644 --- a/src/spaceone/inventory_v2/model/collector/request.py +++ b/src/spaceone/inventory_v2/model/collector/request.py @@ -71,7 +71,7 @@ class CollectorGetRequest(BaseModel): class CollectorSearchQueryRequest(BaseModel): query: Union[dict, None] = None collector_id: Union[str, None] = None - workspace_id: Union[str, None] = None + workspace_id: Union[str, list, None] = None domain_id: str diff --git a/src/spaceone/inventory_v2/service/collector_service.py b/src/spaceone/inventory_v2/service/collector_service.py index 459e113..6d3a92e 100644 --- a/src/spaceone/inventory_v2/service/collector_service.py +++ b/src/spaceone/inventory_v2/service/collector_service.py @@ -202,7 +202,7 @@ def update(self, params: CollectorUpdateRequest) -> Union[CollectorResponse, dic ) @convert_model def update_plugin( - self, params: CollectorUpdatePluginRequest + self, params: CollectorUpdatePluginRequest ) -> Union[CollectorResponse, dict]: """Update plugin info of collector Args: @@ -388,7 +388,6 @@ def get(self, params: CollectorGetRequest) -> Union[CollectorResponse, dict]: permission="inventory-v2:Collector.read", role_types=["DOMAIN_ADMIN", "WORKSPACE_OWNER", "WORKSPACE_MEMBER"], ) - @change_value_by_rule("APPEND", "workspace_id", "*") @check_required(["domain_id"]) @append_query_filter( [ @@ -403,9 +402,10 @@ def get(self, params: CollectorGetRequest) -> Union[CollectorResponse, dict]: ] ) @append_keyword_filter(_KEYWORD_FILTER) + @change_value_by_rule("APPEND", "workspace_id", "*") @convert_model def list( - self, params: CollectorSearchQueryRequest + self, params: CollectorSearchQueryRequest ) -> Union[CollectorsResponse, dict]: """List collectors Args: @@ -599,15 +599,15 @@ def collect(self, params: CollectorCollectRequest) -> Union[JobResponse, dict]: return JobResponse(**job_vo.to_dict()) def _get_tasks( - self, - params: dict, - endpoint: str, - collector_id: str, - collector_provider: str, - plugin_info: dict, - secret_filter: dict, - domain_id: str, - collector_workspace_id: str = None, + self, + params: dict, + endpoint: str, + collector_id: str, + collector_provider: str, + plugin_info: dict, + secret_filter: dict, + domain_id: str, + collector_workspace_id: str = None, ) -> list: secret_mgr: SecretManager = self.locator.get_manager(SecretManager) collector_plugin_mgr = CollectorPluginManager() @@ -644,7 +644,7 @@ def _get_tasks( @staticmethod def _check_secrets( - secret_mgr: SecretManager, secret_ids: list, provider: str, domain_id: str + secret_mgr: SecretManager, secret_ids: list, provider: str, domain_id: str ) -> None: query = { "filter": [ @@ -664,10 +664,10 @@ def _check_secrets( @staticmethod def _check_service_accounts( - identity_mgr: IdentityManager, - service_account_ids: list, - provider: str, - domain_id: str, + identity_mgr: IdentityManager, + service_account_ids: list, + provider: str, + domain_id: str, ) -> None: query = { "filter": [ @@ -692,10 +692,10 @@ def _check_service_accounts( @staticmethod def _check_schemas( - identity_mgr: IdentityManager, - schema_ids: list, - provider: str, - domain_id: str, + identity_mgr: IdentityManager, + schema_ids: list, + provider: str, + domain_id: str, ) -> None: query = { "filter": [ @@ -719,12 +719,12 @@ def _check_schemas( ) def _validate_secret_filter( - self, - identity_mgr: IdentityManager, - secret_mgr: SecretManager, - secret_filter: dict, - provider: str, - domain_id: str, + self, + identity_mgr: IdentityManager, + secret_mgr: SecretManager, + secret_filter: dict, + provider: str, + domain_id: str, ) -> None: if "secrets" in secret_filter: self._check_secrets( @@ -760,11 +760,11 @@ def _validate_secret_filter( ) def _update_collector_plugin( - self, - endpoint: str, - updated_version: str, - plugin_info: dict, - collector_vo: Collector, + self, + endpoint: str, + updated_version: str, + plugin_info: dict, + collector_vo: Collector, ) -> Collector: collector_plugin_mgr = CollectorPluginManager() plugin_response = collector_plugin_mgr.init_plugin( @@ -794,12 +794,12 @@ def _update_collector_plugin( return collector_vo def _get_secret_ids_from_filter( - self, - secret_filter: dict, - provider: str, - domain_id: str, - secret_id: str = None, - workspace_id: str = None, + self, + secret_filter: dict, + provider: str, + domain_id: str, + secret_id: str = None, + workspace_id: str = None, ) -> list: secret_manager: SecretManager = self.locator.get_manager(SecretManager) @@ -846,11 +846,11 @@ def _get_plugin_from_repository(plugin_id: str) -> dict: @staticmethod def create_collector_rules_by_metadata( - collector_rules: list, - collector_id: str, - resource_group: str, - domain_id: str, - workspace_id: str = None, + collector_rules: list, + collector_id: str, + resource_group: str, + domain_id: str, + workspace_id: str = None, ): collector_rule_mgr = CollectorRuleManager() @@ -877,10 +877,10 @@ def delete_collector_rules(collector_id: str, domain_id: str) -> None: @staticmethod def _make_secret_filter( - secret_filter: dict, - provider: str, - secret_id: str = None, - workspace_id: str = None, + secret_filter: dict, + provider: str, + secret_id: str = None, + workspace_id: str = None, ) -> list: _filter = [{"k": "provider", "v": provider, "o": "eq"}] @@ -906,7 +906,7 @@ def _make_secret_filter( _filter.append({"k": "secret_id", "v": exclude_secrets, "o": "not_in"}) if exclude_service_accounts := secret_filter.get( - "exclude_service_accounts" + "exclude_service_accounts" ): _filter.append( {