Skip to content

Commit

Permalink
Merge pull request #8 from ImMin5/master
Browse files Browse the repository at this point in the history
Modify inventory-v2 collector request spec
  • Loading branch information
ImMin5 authored Dec 9, 2024
2 parents f0bdcd5 + bd25ce0 commit 041c454
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion src/spaceone/inventory_v2/model/collector/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
96 changes: 48 additions & 48 deletions src/spaceone/inventory_v2/service/collector_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(
[
Expand All @@ -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:
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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": [
Expand All @@ -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": [
Expand All @@ -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": [
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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()

Expand All @@ -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"}]

Expand All @@ -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(
{
Expand Down

0 comments on commit 041c454

Please sign in to comment.