pyfsr.archetypes.harvest¶
Harvest a draft archetype from a real FortiSOAR solution pack.
A solution pack (whether the git source tree under
corpus_builder/repos/fortisoar/solution-pack-* or the .zip returned by
pyfsr.api.solution_packs.SolutionPackAPI.export_pack()) is a directory of JSON:
info.json (pack metadata), modules/<mod>/mmd.json (module field/relationship/picklist
schema), playbooks/<collection>/*.json (playbook step graphs), and picklists/*.json.
The harvester turns that into a draft Archetype – a honest
extraction of the module fields, the connector/operation pairs the playbooks use, and a step
skeleton per playbook. It does not parameterize (no {{param}} slots), assign connector
roles, or write a when_to_use – that curation is step 3. Call store.put(draft) to
persist a draft for later curation.
Pure stdlib (zipfile / json / pathlib); the only network I/O is the optional
export_pack call inside harvest_archetype_from_pack().
Example:
from pyfsr.archetypes import harvest_from_dir, ArchetypeStore
draft = harvest_from_dir("path/to/solution-pack-servicenow-...", name="snow-sir-draft")
ArchetypeStore().put(draft)
Functions¶
|
Harvest a draft archetype from an unpacked solution-pack directory. |
|
Harvest a draft archetype from a solution-pack export |
Harvest a draft archetype from a live appliance's solution pack. |
Module Contents¶
- pyfsr.archetypes.harvest.harvest_from_dir(pack_dir: str | pathlib.Path, *, name: str | None = None) pyfsr.archetypes.record.Archetype[source]¶
Harvest a draft archetype from an unpacked solution-pack directory.
Works on both the git source tree and an unpacked export
.zip(discovery usesrglob, so a top-level prefix directory in the export is tolerated). Parsesinfo.json,modules/*/mmd.json, andplaybooks/**/*.jsoninto a draftArchetype.- Parameters:
pack_dir – path to the unpacked pack.
name – the archetype name (key). Defaults to the pack’s
info.jsonname, falling back to the directory name.
- Returns:
A draft
Archetype(when_to_useempty,parametersempty).
- pyfsr.archetypes.harvest.harvest_from_zip(zip_path: str | pathlib.Path, *, name: str | None = None) pyfsr.archetypes.record.Archetype[source]¶
Harvest a draft archetype from a solution-pack export
.zip.Extracts the archive to a temporary directory and delegates to
harvest_from_dir(). Use this with the path returned bypyfsr.api.solution_packs.SolutionPackAPI.export_pack().
- pyfsr.archetypes.harvest.harvest_archetype_from_pack(client: Any, pack_identifier: str, archetype_name: str) pyfsr.archetypes.record.Archetype[source]¶
Harvest a draft archetype from a live appliance’s solution pack.
Wraps
pyfsr.api.solution_packs.SolutionPackAPI.export_pack()(which finds the installed pack, triggers the export, and downloads the.zip) and parses it withharvest_from_zip(). Returns the draft namedarchetype_name– curate it, thenArchetypeStore().put(draft)to persist.