|
5 | 5 | ApplyDiscoveryPayload, |
6 | 6 | AwsDiscoveryResult, |
7 | 7 | AwsOrgHierarchy, |
| 8 | + AzureDiscoveryResult, |
| 9 | + AzureOrgHierarchy, |
8 | 10 | GcpDiscoveryResult, |
9 | 11 | GcpOrgHierarchy, |
10 | 12 | NODE_KIND, |
@@ -84,6 +86,43 @@ export function mapGcpDiscovery(result: GcpDiscoveryResult): GcpOrgHierarchy { |
84 | 86 | }; |
85 | 87 | } |
86 | 88 |
|
| 89 | +/** |
| 90 | + * Ingestion mapper: Azure discovery wire result → normalized hierarchy model. |
| 91 | + * |
| 92 | + * A management group's identity is its canonical resource ID |
| 93 | + * (`/providers/Microsoft.Management/managementGroups/{name}`), which is exactly |
| 94 | + * what its children carry as `parent_id`, so nesting matches on that ref. The |
| 95 | + * selected root group is collapsed away — it is absent from the node set, so |
| 96 | + * groups and subscriptions parented by it rebuild as top-level. |
| 97 | + */ |
| 98 | +export function mapAzureDiscovery( |
| 99 | + result: AzureDiscoveryResult, |
| 100 | +): AzureOrgHierarchy { |
| 101 | + return { |
| 102 | + orgType: ORGANIZATION_TYPE.AZURE, |
| 103 | + organization: { |
| 104 | + // Tenant id: what the user typed and what the organization stores as |
| 105 | + // `external_id`. |
| 106 | + uid: result.root_management_group.tenant_id, |
| 107 | + name: |
| 108 | + result.root_management_group.display_name || |
| 109 | + result.root_management_group.name, |
| 110 | + }, |
| 111 | + nodes: result.management_groups.map((group) => ({ |
| 112 | + id: group.id, |
| 113 | + kind: NODE_KIND.MANAGEMENT_GROUP, |
| 114 | + name: group.display_name || group.name, |
| 115 | + parentId: group.parent_id, |
| 116 | + })), |
| 117 | + candidates: result.subscriptions.map((subscription) => ({ |
| 118 | + uid: subscription.subscription_id, |
| 119 | + label: subscription.display_name || subscription.subscription_id, |
| 120 | + parentId: subscription.parent_id, |
| 121 | + registration: subscription.registration, |
| 122 | + })), |
| 123 | + }; |
| 124 | +} |
| 125 | + |
87 | 126 | /** |
88 | 127 | * Transforms the normalized hierarchy into hierarchical TreeDataItem[] for |
89 | 128 | * TreeView. Container nodes (OUs / folders) nest candidates (accounts / |
@@ -338,6 +377,14 @@ export function buildApplyPayload( |
338 | 377 | selectedCandidateIds, |
339 | 378 | ).map((id) => ({ id })), |
340 | 379 | }; |
| 380 | + case ORGANIZATION_TYPE.AZURE: |
| 381 | + return { |
| 382 | + orgType: ORGANIZATION_TYPE.AZURE, |
| 383 | + subscriptions: selectedCandidateIds.map((id) => ({ |
| 384 | + subscription_id: id, |
| 385 | + ...aliasOf(id), |
| 386 | + })), |
| 387 | + }; |
341 | 388 | case ORGANIZATION_TYPE.GCP: |
342 | 389 | return { |
343 | 390 | orgType: ORGANIZATION_TYPE.GCP, |
|
0 commit comments