Skip to content

Commit 6f5cbf3

Browse files
committed
fix: scheduled jobs
1 parent 1147570 commit 6f5cbf3

File tree

2 files changed

+594
-489
lines changed

2 files changed

+594
-489
lines changed

scrapegraph-py/scrapegraph_py/models/scheduled_jobs.py

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
from typing import Any, Dict, Optional
2+
from enum import Enum
23
from pydantic import BaseModel, Field
34

45

6+
class ServiceType(str, Enum):
7+
"""Enum for service types"""
8+
SMART_SCRAPER = "smartscraper"
9+
SEARCH_SCRAPER = "searchscraper"
10+
AGENTIC_SCRAPER = "agenticscraper"
11+
12+
513
class ScheduledJobCreate(BaseModel):
614
"""Model for creating a new scheduled job"""
715
job_name: str = Field(..., description="Name of the scheduled job")
@@ -47,4 +55,58 @@ class GetJobExecutionsRequest(BaseModel):
4755
job_id: str = Field(..., description="ID of the scheduled job")
4856
page: int = Field(default=1, ge=1, description="Page number")
4957
page_size: int = Field(default=20, ge=1, le=100, description="Number of executions per page")
50-
status: Optional[str] = Field(None, description="Filter by execution status")
58+
status: Optional[str] = Field(None, description="Filter by execution status")
59+
60+
61+
class JobActionResponse(BaseModel):
62+
"""Response model for job actions"""
63+
success: bool = Field(..., description="Whether the action was successful")
64+
message: str = Field(..., description="Response message")
65+
job_id: str = Field(..., description="ID of the scheduled job")
66+
67+
68+
class JobExecutionListResponse(BaseModel):
69+
"""Response model for job execution list"""
70+
executions: list = Field(..., description="List of job executions")
71+
total_count: int = Field(..., description="Total number of executions")
72+
page: int = Field(..., description="Current page number")
73+
page_size: int = Field(..., description="Number of executions per page")
74+
75+
76+
class JobTriggerResponse(BaseModel):
77+
"""Response model for job trigger"""
78+
success: bool = Field(..., description="Whether the job was triggered successfully")
79+
message: str = Field(..., description="Response message")
80+
job_id: str = Field(..., description="ID of the scheduled job")
81+
execution_id: Optional[str] = Field(None, description="ID of the triggered execution")
82+
83+
84+
class ScheduledJobListResponse(BaseModel):
85+
"""Response model for scheduled job list"""
86+
jobs: list = Field(..., description="List of scheduled jobs")
87+
total_count: int = Field(..., description="Total number of jobs")
88+
page: int = Field(..., description="Current page number")
89+
page_size: int = Field(..., description="Number of jobs per page")
90+
91+
92+
class JobExecutionResponse(BaseModel):
93+
"""Response model for a single job execution"""
94+
execution_id: str = Field(..., description="ID of the job execution")
95+
job_id: str = Field(..., description="ID of the scheduled job")
96+
status: str = Field(..., description="Execution status")
97+
started_at: Optional[str] = Field(None, description="Execution start timestamp")
98+
completed_at: Optional[str] = Field(None, description="Execution completion timestamp")
99+
result: Optional[Dict[str, Any]] = Field(None, description="Execution result data")
100+
error_message: Optional[str] = Field(None, description="Error message if execution failed")
101+
102+
103+
class ScheduledJobResponse(BaseModel):
104+
"""Response model for a single scheduled job"""
105+
job_id: str = Field(..., description="ID of the scheduled job")
106+
job_name: str = Field(..., description="Name of the scheduled job")
107+
service_type: str = Field(..., description="Type of service")
108+
cron_expression: str = Field(..., description="Cron expression for scheduling")
109+
job_config: Dict[str, Any] = Field(..., description="Configuration for the job")
110+
is_active: bool = Field(..., description="Whether the job is active")
111+
created_at: Optional[str] = Field(None, description="Job creation timestamp")
112+
updated_at: Optional[str] = Field(None, description="Job last update timestamp")

0 commit comments

Comments
 (0)