pyfsr.connector_dev¶
Local ConnectorsV2 development helpers: scaffold, package, deploy.
The full connector flow a coding agent (or a human) drives from a checkout:
scaffold_connector()– write a minimal, installable connector skeleton (info.json,connector.py,operations.py,requirements.txt).edit the generated files (add operations, config fields, icons).
package_connector()– build thedist/<name>-<version>.tgzbundle FortiSOAR installs, preferring git-tracked files.deploy_connector()– upload the bundle ($replaceso redeploys are idempotent), wait for the connector to activate, optionally configure it, and healthcheck.
CLI: pyfsr connector scaffold|package|deploy (see pyfsr.cli.connector).
Attributes¶
Functions¶
|
Write an installable ConnectorsV2 skeleton and return the paths. |
|
Build |
|
Poll |
|
Package (if |
Module Contents¶
- pyfsr.connector_dev.REQUIRED_FILES = ('info.json', 'connector.py', 'operations.py', 'requirements.txt')[source]¶
- pyfsr.connector_dev.scaffold_connector(name: str, directory: str | pathlib.Path | None = None, *, label: str | None = None, description: str = 'A custom FortiSOAR connector.', ops: list[dict] | None = None) list[pathlib.Path][source]¶
Write an installable ConnectorsV2 skeleton and return the paths.
By default the skeleton has one configuration field (
server), one operation (ping) and a health check, so it packages, installs, configures and runs end to end before any real logic is added.With
ops(a list of{operation, title?, description?, method?, parameters?:[{name,type?,required?,title?}], output_schema?}) the skeleton instead gets a shared, antipattern-clean request helper and one handler per op over abase_url/api_key/verifyconfiguration – a real-API foundation to fill in, not just a hello-world. Refuses to overwrite.
- pyfsr.connector_dev.package_connector(directory: str | pathlib.Path = '.', *, out_dir: str | pathlib.Path | None = None, version: str | None = None) pathlib.Path[source]¶
Build
<out_dir>/<name>-<version>.tgzunpacking to one<name>/dir.Ports the ConnectorsV2
package.sh: prefer git-tracked files, drop tests, packaging furniture and caches, and require the four core files. Returns the bundle path.out_dirdefaults to<directory>/dist.versionoverrides the version used for the bundle name AND injected into the archivedinfo.json– the source file is left untouched. This is how a redeploy ships a bumped version without a ghost connector.
- pyfsr.connector_dev.wait_for_active(client, name: str, timeout: float = 180.0, interval: float = 3.0) None[source]¶
Poll
list_configured(refresh=True)untilnameshows up active.The install job finishing does not mean the connector record is live yet (live-verified in lab deploys), so installs must wait on the listing.
- pyfsr.connector_dev.deploy_connector(client, source: str | pathlib.Path, *, config: dict[str, Any] | None = None, config_name: str = 'Default', replace: bool = True, timeout: float = 180.0, on_existing_version: str = 'bump_patch') dict[str, Any][source]¶
Package (if
sourceis a checkout), install, activate, configure, healthcheck.sourceis a connector directory (packaged first) or a built.tgz. Withconfig, an idempotent named configuration is upserted and marked default, then healthchecked. Returns a summary dict of what happened.GHOST-CONNECTOR GUARD. FortiSOAR keys a connector by name+version; reinstalling the SAME version over a changed bundle can leave a stale “ghost” alongside the new code.
on_existing_versioncontrols what happens when the box already has this connector at the version being deployed:"bump_patch"(default): bump the patch and ship that instead (a directory is repackaged, a built.tgzre-versioned); the result recordsbumped."error": raise, so the caller bumps info.json deliberately."allow": install over it anyway (the old behaviour).