Skip to content

Commit

Permalink
feat: add metadata for init repsonse
Browse files Browse the repository at this point in the history
  • Loading branch information
ImMin5 committed Apr 2, 2024
1 parent d223105 commit c033e6a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
20 changes: 18 additions & 2 deletions src/plugin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,23 @@ def account_collector_init(params: dict) -> dict:
}
"""

return {"metadata": {}}
metadata = {
"options_schema": {
"type": "object",
"properties": {
"exclude_tenant_root_group": {
"title": "Exclude Tenant Root Group",
"type": "boolean",
"default": False,
},
},
}
}

if options := params.get("options"):
pass

return {"metadata": metadata}


@app.route("AccountCollector.sync")
Expand Down Expand Up @@ -59,7 +75,7 @@ def account_collector_sync(params: dict) -> dict:
domain_id = params["domain_id"]

results = []
for account_collector_manager in AzureBaseManager.get_all_managers(options={}):
for account_collector_manager in AzureBaseManager.get_all_managers(options=options):
ac_mgr = account_collector_manager()
results.extend(
ac_mgr.sync(
Expand Down
10 changes: 8 additions & 2 deletions src/plugin/manager/resource_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def sync(
name = entity_info["display_name"]
tenant_id = entity_info["tenant_id"]
subscription_id = entity_info["name"]
location = self._create_location_from_entity_info(entity_info)
location = self._create_location_from_entity_info(
entity_info, options
)

result = {
"name": name,
Expand All @@ -69,11 +71,15 @@ def sync(
return results

@staticmethod
def _create_location_from_entity_info(entity_info: dict) -> List[dict]:
def _create_location_from_entity_info(
entity_info: dict, options: dict
) -> List[dict]:
location = []
parent_display_name_chain = entity_info.get("parent_display_name_chain", [])
parent_name_chain = entity_info.get("parent_name_chain", [])
for idx, name in enumerate(parent_display_name_chain):
if options.get("exclude_tenant_root_group") and idx == 0:
continue
location.append(
{
"name": name,
Expand Down

0 comments on commit c033e6a

Please sign in to comment.