Kludex commented on code in PR #44223:
URL: https://github.com/apache/airflow/pull/44223#discussion_r1852470729


##########
airflow/api_fastapi/core_api/datamodels/task_instances.py:
##########
@@ -150,3 +152,41 @@ class TaskInstanceHistoryCollectionResponse(BaseModel):
 
     task_instances: list[TaskInstanceHistoryResponse]
     total_entries: int
+
+
+class PatchTaskInstanceBody(BaseModel):
+    """Request body for Clear Task Instances endpoint."""
+
+    dry_run: bool = True
+    new_state: str | None = None
+    note: str | None = None
+
+    @model_validator(mode="before")
+    @classmethod
+    def validate_model(cls, data: Any) -> Any:
+        if data.get("note") is None and data.get("new_state") is None:
+            raise ValueError("new_state is required.")
+        return data
+
+    @field_validator("note", mode="before")
+    @classmethod
+    def validate_note(cls, note: str | None) -> str | None:
+        """Validate note."""
+        if note is None:
+            return None
+        if len(note) > 1000:
+            raise ValueError("Note length should not exceed 1000 characters.")

Review Comment:
   Shared the link above.



##########
airflow/api_fastapi/core_api/datamodels/task_instances.py:
##########
@@ -150,3 +152,41 @@ class TaskInstanceHistoryCollectionResponse(BaseModel):
 
     task_instances: list[TaskInstanceHistoryResponse]
     total_entries: int
+
+
+class PatchTaskInstanceBody(BaseModel):
+    """Request body for Clear Task Instances endpoint."""
+
+    dry_run: bool = True
+    new_state: str | None = None
+    note: str | None = None

Review Comment:
   https://docs.pydantic.dev/latest/api/types/#pydantic.types.StringConstraints
   ```suggestion
       note: Annotated[str, StringConstraints(max_length=1000)] | None = None
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to