Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/asyncplatform/resources/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand All @@ -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:
Expand Down
10 changes: 9 additions & 1 deletion src/asyncplatform/services/automation_studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,
)
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/test_resources_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down