Skip to content

Commit

Permalink
feat(client): added workflow to client
Browse files Browse the repository at this point in the history
  • Loading branch information
keithmanville committed Dec 24, 2024
1 parent 22341d4 commit 01f0fba
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/dioptra/client/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
# ACCESS THE FULL CC BY 4.0 LICENSE HERE:
# https://creativecommons.org/licenses/by/4.0/legalcode
from pathlib import Path
from typing import ClassVar, Final, TypeVar
from typing import Any, ClassVar, Final, TypeVar

from .base import CollectionClient, IllegalArgumentError

T = TypeVar("T")

JOB_FILES_DOWNLOAD: Final[str] = "jobFilesDownload"
DRAFT_COMMIT: Final[str] = "draftCommit"


class WorkflowsCollectionClient(CollectionClient[T]):
Expand Down Expand Up @@ -86,3 +87,22 @@ def download_job_files(
return self._session.download(
self.url, JOB_FILES_DOWNLOAD, output_path=job_files_path, params=params
)

def commit_draft(
self,
draft_id: str | int,
) -> dict[str, Any]:
"""
Commit a draft as a new resource snapshot.
The draft can be a draft of a new resource or a draft modifications to an
existing resource.
Args:
draft_id: The draft id, an intiger.
Returns:
A dictionary containing the contents of the new resource.
"""

return self._session.post(self.url, DRAFT_COMMIT, str(draft_id))

0 comments on commit 01f0fba

Please sign in to comment.