feat: sdk update for tasks api#16
Open
L0RD-ZER0 wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the SDK’s Tasks API to align with the documented task-creation flow and improve DX by introducing type-specific task creation helpers, updating model parsing, and adding dedicated examples for each bulk task type.
Changes:
- Added dedicated
TasksClientcreation methods (create_software,create_find_files,create_wp_cli,create_wpcloud_scan) plus shared helpers to centralize payload construction and posting. - Updated task model parsing to Pydantic v2-style
model_validateand expanded examples/README to showcase the new methods. - Adjusted
ResourceClient._posttyping to allow tuple-list form payloads and addedtyping-extensionsfor@deprecated.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
pyproject.toml |
Adds typing-extensions dependency (currently placed under build-system). |
atomic_sdk/api/base.py |
Broadens _post data typing to support tuple-list form encoding. |
atomic_sdk/api/tasks.py |
Adds per-task-type create methods, shared payload helpers, and switches to model_validate. |
examples/README.md |
Documents new dedicated bulk task examples. |
examples/tasks/04_run_bulk_software_task.py |
New example for create_software. |
examples/tasks/05_run_bulk_find_files_task.py |
New example for create_find_files. |
examples/tasks/06_run_bulk_wp_cli_task.py |
New example for create_wp_cli. |
examples/tasks/07_run_bulk_wpcloud_scan_task.py |
New example for create_wpcloud_scan. |
Comments suppressed due to low confidence (1)
atomic_sdk/api/base.py:41
- The
_posttype annotation uses PEP 604 unions (dict | ...) and built-in generics (list[tuple[...]]), which require Python 3.10+ / 3.9+. This project declaresrequires-python = ">=3.7", so this will raiseTypeError/SyntaxErroron supported runtimes. Usetyping.Union/typing.List/typing.Tuple(orfrom __future__ import annotationsplus compatible syntax) to keep 3.7+ compatibility.
def _post(self, endpoint: str, data: Optional[dict | list[tuple[str, str]]] = None, json: Optional[dict] = None) -> dict:
"""
Performs a POST request and handles the response.
Args:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates to Task API's Task Creation Flow based on Create Task documentation, and some DX Improvements to make usage less error-prone.
This pull request introduces significant enhancements to the bulk task management functionality in the SDK, focusing on clearer, type-specific task creation methods, improved maintainability, and expanded example coverage. The changes include adding dedicated methods for each bulk task type, refactoring the internal payload construction, updating model validation, and providing new example scripts for each task type.
Bulk Task Management Enhancements:
TasksClientfor each bulk task type:create_software,create_find_files,create_wp_cli, andcreate_wpcloud_scan, each accepting only the parameters relevant to their task type. This improves usability and reduces errors compared to the previous generic method._build_common_payload,_create_task) to centralize and simplify payload construction and endpoint logic for all task creation methods.createmethod in favor of the new, more specific methods.Model and Type Improvements:
model_validateinstead of the deprecatedparse_objfor bothTaskandTaskCreationResponse. [1] [2]tasks.py, and added new type aliases (WebhookCondition,TaskType) for clarity.API and Dependency Updates:
_postmethod inbase.pyto accept bothdictandlist[tuple[str, str]]for thedataargument, supporting more flexible form encoding.typing-extensionsas a dependency for the@deprecateddecorator and improved type support.Examples and Documentation:
04_run_bulk_software_task.py,05_run_bulk_find_files_task.py,06_run_bulk_wp_cli_task.py, and07_run_bulk_wpcloud_scan_task.py. [1] [2] [3] [4]examples/README.mdto document and showcase the new dedicated examples and their use cases.