Skip to content

feat: sdk update for tasks api#16

Open
L0RD-ZER0 wants to merge 4 commits into
mainfrom
feat/tasks-update
Open

feat: sdk update for tasks api#16
L0RD-ZER0 wants to merge 4 commits into
mainfrom
feat/tasks-update

Conversation

@L0RD-ZER0
Copy link
Copy Markdown

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:

  • Added dedicated methods to TasksClient for each bulk task type: create_software, create_find_files, create_wp_cli, and create_wpcloud_scan, each accepting only the parameters relevant to their task type. This improves usability and reduces errors compared to the previous generic method.
  • Introduced internal helpers (_build_common_payload, _create_task) to centralize and simplify payload construction and endpoint logic for all task creation methods.
  • Deprecated the generic create method in favor of the new, more specific methods.

Model and Type Improvements:

  • Updated all model parsing to use model_validate instead of the deprecated parse_obj for both Task and TaskCreationResponse. [1] [2]
  • Improved type annotations throughout tasks.py, and added new type aliases (WebhookCondition, TaskType) for clarity.

API and Dependency Updates:

  • Modified the _post method in base.py to accept both dict and list[tuple[str, str]] for the data argument, supporting more flexible form encoding.
  • Added typing-extensions as a dependency for the @deprecated decorator and improved type support.

Examples and Documentation:

  • Added four new example scripts demonstrating each dedicated bulk task method: 04_run_bulk_software_task.py, 05_run_bulk_find_files_task.py, 06_run_bulk_wp_cli_task.py, and 07_run_bulk_wpcloud_scan_task.py. [1] [2] [3] [4]
  • Updated examples/README.md to document and showcase the new dedicated examples and their use cases.

Copilot AI review requested due to automatic review settings April 28, 2026 11:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TasksClient creation 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_validate and expanded examples/README to showcase the new methods.
  • Adjusted ResourceClient._post typing to allow tuple-list form payloads and added typing-extensions for @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 _post type annotation uses PEP 604 unions (dict | ...) and built-in generics (list[tuple[...]]), which require Python 3.10+ / 3.9+. This project declares requires-python = ">=3.7", so this will raise TypeError / SyntaxError on supported runtimes. Use typing.Union/typing.List/typing.Tuple (or from __future__ import annotations plus 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.

Comment thread atomic_sdk/api/tasks.py Outdated
Comment thread atomic_sdk/api/tasks.py Outdated
Comment thread pyproject.toml Outdated
Comment thread atomic_sdk/api/tasks.py Outdated
Comment thread atomic_sdk/api/tasks.py
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.

2 participants