Skip to content

feature: enhance import project to support API conflict and reference options#210

Open
davhparry wants to merge 7 commits into
itential:mainfrom
davhparry:feat/import-project-api-options
Open

feature: enhance import project to support API conflict and reference options#210
davhparry wants to merge 7 commits into
itential:mainfrom
davhparry:feat/import-project-api-options

Conversation

@davhparry

Copy link
Copy Markdown
Contributor

Summary

Closes #208

Adds three new flags to import project that mirror the capabilities of the Itential Platform import API, giving users server-side control over how conflicts and references are handled during import.

New flags

Flag Type Default Description
--skip-reference-validation bool false Bypass server reference validation on import
--conflict-mode string (none) Server-side conflict resolution strategy: overwrite or insert-new
--assign-new-references bool false Have the server assign new references to imported components

--replace vs --conflict-mode behaviour

These two flags address different use cases and are mutually exclusive:

  • Neither set — command fails if a project with the same name already exists (existing behaviour, unchanged)
  • --replace only — client-side: deletes the entire existing project before importing (existing behaviour, unchanged)
  • --conflict-mode only — server-side: skips the local existence check and lets the server resolve conflicts per component
  • Both set--replace takes precedence; --conflict-mode is ignored

Other fixes included

  • AddMembers deduplication — when adding members to an imported project, existing members with the same reference as a newly-supplied member are no longer duplicated in the PATCH body. This prevents the server from rejecting the request.
  • --verbose support — passing --verbose to import project now logs the resolved values of the three new options before the import call.

Test plan

  • import project with no flags fails if project exists
  • import project --replace deletes and reimports an existing project
  • import project --conflict-mode overwrite succeeds without a local existence check
  • import project --conflict-mode insert-new succeeds without a local existence check
  • import project --replace --conflict-mode overwrite behaves the same as --replace alone
  • import project --conflict-mode invalid returns a validation error
  • import project --skip-reference-validation sends skipReferenceValidation: true in the request body
  • import project --assign-new-references sends assignNewReferences: true in the request body
  • import project --verbose logs all three option values before import
  • import project --help shows updated CONFLICT RESOLUTION and REFERENCE HANDLING sections
  • All unit tests pass (make test)

davhparry and others added 7 commits June 26, 2026 14:37
…-templates and command-templates

Exporting assets with tags caused an unmarshal error because Tags was
typed as []string, but the platform API returns tag objects with _id,
name and description fields. Changed Tags to []Tag on Transformation,
AnalyticTemplate and CommandTemplate structs, and initialised the field
to []Tag{} in each factory function so newly created assets emit
"tags": [] to match the API.
Adds Options field to all trigger structs so LCM action configuration
(actionId, chooseTargetAtRuntime) is no longer dropped during
export/import. Also adds a default passthrough in transformTrigger and
updateTriggers so unknown trigger types are preserved rather than
erroring or being silently dropped.

Fixes itential#177
ApiService.request was passing the full URI (including query string) as
the request path. url.URL then percent-encoded the '?' as '%3F' in the
path while also appending the params via RawQuery, resulting in doubled
and malformed query strings. Fix uses u.Path (path only) so params flow
through RawQuery exclusively.

Adds ApiService tests that verify params arrive correctly at the server
and adds AddHandlerToMux to testlib for request inspection.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…to import project

Mirrors the Itential Platform API import capabilities with three new flags:
- --skip-reference-validation: bypass server reference checks on import
- --conflict-mode: server-side conflict resolution (insert-new or overwrite)
- --assign-new-references: have server assign new references to imported components

--replace remains a client-side delete-then-reimport. When both --replace and
--conflict-mode are supplied, --replace takes precedence and --conflict-mode is
ignored. When only --conflict-mode is supplied the local existence check is
skipped and the server handles the conflict.

Also fixes AddMembers deduplication to prevent the server rejecting duplicate-
reference members on PATCH. Adds Verbose flag to Request so runners can log
import options when --verbose is set.

Resolves itential#208

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: import project - Add support to skipReferenceValidation and conflictMode.

1 participant