From 5792a9bb5b65fe021fd00f4eee6cfbc785069c3d Mon Sep 17 00:00:00 2001 From: Jenn Lu Date: Wed, 4 Feb 2026 13:37:56 -0500 Subject: [PATCH] feat: add skip_reference_validation parameter to project import Add new skip_reference_validation parameter to import_project and importer functions to allow skipping reference validation during project imports. Changes: - Added skip_reference_validation parameter to import_project in automation_studio.py - Added skip_reference_validation parameter to importer in projects.py - Updated test to account for new parameter - Parameter defaults to False to maintain backward compatibility --- src/asyncplatform/resources/projects.py | 7 ++++++- src/asyncplatform/services/automation_studio.py | 10 +++++++++- tests/unit/test_resources_projects.py | 4 +++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/asyncplatform/resources/projects.py b/src/asyncplatform/resources/projects.py index e1f098f..4c8e276 100644 --- a/src/asyncplatform/resources/projects.py +++ b/src/asyncplatform/resources/projects.py @@ -169,6 +169,7 @@ async def importer( members: list[ProjectMember] | None = None, preserve_existing_members: bool = True, overwrite: bool = False, + skip_reference_validation: bool = False, ) -> dict[str, Any]: """Import a project into the platform with optional member assignments. @@ -189,6 +190,8 @@ async def importer( overwrite: If True, overwrites the project if it already exists in the target environment. If False (default), raises an error if the project already exists + skip_reference_validation: If True, skips validation of references + during import. Defaults to False. Returns: The imported project data including _id, name, and complete @@ -212,7 +215,9 @@ async def importer( await self.studio.delete_project(existing_projects[0]["_id"]) # Import the project - result = await self.studio.import_project(project) + result = await self.studio.import_project( + project, skip_reference_validation=skip_reference_validation + ) # Add members if specified if members: diff --git a/src/asyncplatform/services/automation_studio.py b/src/asyncplatform/services/automation_studio.py index c5eaa91..2347403 100644 --- a/src/asyncplatform/services/automation_studio.py +++ b/src/asyncplatform/services/automation_studio.py @@ -154,7 +154,12 @@ async def find_projects(self, *, name: str | None = None) -> list[dict[str, Any] return json_data["data"] @logging.trace - async def import_project(self, project: Mapping[str, Any]) -> Mapping[str, Any]: + async def import_project( + self, + project: Mapping[str, Any], + *, + skip_reference_validation: bool = False, + ) -> Mapping[str, Any]: """Import a project into Automation Studio. Imports a project configuration into the Itential Platform. The import @@ -164,6 +169,8 @@ async def import_project(self, project: Mapping[str, Any]) -> Mapping[str, Any]: Args: project: A mapping containing the complete project definition including name, description, workflows, and other project components + skip_reference_validation: If True, skips validation of references during + import. Defaults to False. Returns: A mapping containing the imported project data, including the newly @@ -178,6 +185,7 @@ async def import_project(self, project: Mapping[str, Any]) -> Mapping[str, Any]: "project": project, "assignNewReferences": False, "conflictMode": "insert-new", + "skipReferenceValidation": skip_reference_validation, }, expected_status=HTTPStatus.OK, ) diff --git a/tests/unit/test_resources_projects.py b/tests/unit/test_resources_projects.py index 21c4e70..fa6daee 100644 --- a/tests/unit/test_resources_projects.py +++ b/tests/unit/test_resources_projects.py @@ -292,7 +292,9 @@ async def test_importer_without_members(self): assert result == {"_id": "proj1", "name": "Test Project"} mock_studio.find_projects.assert_called_once_with(name="Test Project") - mock_studio.import_project.assert_called_once_with(project) + mock_studio.import_project.assert_called_once_with( + project, skip_reference_validation=False + ) @pytest.mark.asyncio async def test_importer_project_already_exists(self):