jscheffl commented on code in PR #45577:
URL: https://github.com/apache/airflow/pull/45577#discussion_r1912408514
##########
airflow/api_fastapi/core_api/datamodels/variables.py:
##########
@@ -73,3 +74,50 @@ class VariablesImportResponse(BaseModel):
created_variable_keys: list[str]
import_count: int
created_count: int
+
+
+class VariableActionCreate(BaseModel):
+ """Bulk Create Variable serializer for request bodies."""
+
+ action: Literal["create"] = "create"
+ variables: list[VariableBody] = Field(..., description="A list of
variables to be created.")
+ action_if_exists: Literal["skip", "overwrite", "fail"] = "fail"
+
+
+class VariableActionUpdate(BaseModel):
+ """Bulk Update Variable serializer for request bodies."""
+
+ action: Literal["update"] = "update"
+ variables: list[VariableBody] = Field(..., description="A list of
variables to be updated.")
+ action_if_not_exists: Literal["skip", "fail"] = "fail"
+
+
+class VariableActionDelete(BaseModel):
+ """Bulk Delete Variable serializer for request bodies."""
+
+ action: Literal["delete"] = "delete"
+ keys: list[str] = Field(..., description="A list of variable keys to be
deleted.")
+ action_if_not_exists: Literal["skip", "fail"] = "fail"
+
+
+class BulkVariablesBody(BaseModel):
+ """Request body for bulk variable operations (create, update, delete)."""
+
+ actions: list[VariableActionCreate | VariableActionUpdate |
VariableActionDelete] = Field(
+ ..., description="A list of variable actions to perform."
+ )
+
+
+class BulkActionResponse(BaseModel):
+ """Bulk Action serializer for responses."""
+
+ success: list[str] = []
+ errors: list[dict[str, Any]] = []
+
+
+class BulkVariableResponse(BaseModel):
+ """Bulk Variable operation serializer for responses."""
+
+ create: BulkActionResponse | None = Field(default=None)
+ update: BulkActionResponse | None = Field(default=None)
+ delete: BulkActionResponse | None = Field(default=None)
Review Comment:
Can you add some descriptions to the fields content? Because they would be
added to FastAPI docs and thereby make the model of response better documented.
Took me 5 minutes to understand it... but would be great if this is in the code
better documented so that developers can better consume.
--
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]