InventoryResult¶
cloudg.inventory.InventoryResult (defined in cloudg/inventory/mapper_result.py, re-exported
from cloudg.inventory.mapper and the package root). A dataclass.
8.1 Fields¶
| Field | Type | Meaning |
|---|---|---|
assets |
list[CloudAsset] |
Every asset after deduplication and linking, including organization / hierarchy assets, external account placeholders and the account nodes added by add_account_hierarchy. |
edges |
list[NetworkEdge] |
Collector edges, then linker edges, then hierarchy edges. The linker adds no edge whose source, target and edge_type an earlier edge already has. Parallel collector rules between the same two endpoints (one security group rule per port, say) are kept as separate edges. |
coverage |
list[CollectionCoverage] |
One record per discovery step and per provider × account × region collection run (section 10). Exported under coverage in inventory-map.json. |
providers |
list[str] |
The configured providers, lower case (["aws", "gcp"]). |
regions |
dict[str, list[str]] |
Regions actually collected per provider after all expansion, e.g. {"aws": ["us-east-1", "eu-west-1"]}. |
duration_ms |
int |
Wall-clock time of map_inventory(). 0 after load(). |
organization |
dict \| None |
OrganizationTopology.to_dict() when an AWS Organization was mapped, else None (section 17). |
unresolved_references |
list[dict] |
Declared relations whose target resolved to nothing, at most 2000 (section 11). |
throttling |
dict \| None |
The run's throttling summary (totals, messages, skipped, scopes, breakers, slowed_buckets), or None when no cloud API pushed back. The keys are described in the rate limits guide. |
8.2 Methods and properties¶
| Member | Returns | Notes |
|---|---|---|
summary (property) |
dict[str, Any] |
Recomputed on every access. Section 9. |
dependency_graph(include_hierarchy=False) |
DependencyGraph |
A new graph each call. Section 12. |
analysis(top=25) |
dict[str, Any] |
Section 13. |
export(output_dir) |
dict[str, Path] |
8.3. |
load(path) (classmethod) |
InventoryResult |
8.4. |
8.3 export¶
export(output_dir) creates the directory and writes:
| Return key | File | Always |
|---|---|---|
map |
inventory-map.json |
yes |
graphml |
inventory-map.graphml |
yes |
graph |
inventory-graph.json |
yes |
dependencies |
inventory-dependencies.json |
yes |
organization |
inventory-organization.json |
only when organization is set |
The values are pathlib.Path objects. JSON files are written with indent=2 and
default=str (datetimes and other non-JSON values become strings).
8.4 load¶
InventoryResult.load(path) accepts inventory-map.json or the directory holding it.
assetsandedgesare re-validated into models (display_idis dropped before validation).providerscomes from the file'sproviders, orsummary.providersfor older files.regions,unresolved_referencesandthrottlingare read back.organizationis read frominventory-organization.jsonnext to the map, when present.coverageis read back from the file'scoveragelist; a map written before that key existed loads with an empty list.duration_msis0: it is not stored in the files.raw_datais empty on every asset (it is never serialised). Linking rules that use raw payloads (instance profiles, Lambda roles fromRole) therefore only work on fresh collections, not on loaded maps; the declared relations do work.