kaxil commented on code in PR #44562:
URL: https://github.com/apache/airflow/pull/44562#discussion_r1868005553


##########
task_sdk/src/airflow/sdk/api/client.py:
##########
@@ -157,6 +158,12 @@ def get(self, key: str) -> VariableResponse:
         resp = self.client.get(f"variables/{key}")
         return VariableResponse.model_validate_json(resp.read())
 
+    def set(self, msg: PutVariable):
+        """Set an Airflow Variable via the API server."""
+        key = msg.key
+        self.client.put(f"variables/{key}", content=msg.model_dump_json())

Review Comment:
   You can do something similar to:
   
   
https://github.com/apache/airflow/blob/cc503aad6bd99e0008a19fe2b2eaedec4411a871/task_sdk/src/airflow/sdk/api/client.py#L132
   
   ```py
   key = msg.key
   body = VariablePostBody(**msg.model_dump(exclude_unset=True))
   self.client.put(f"variables/{key}", content=body)
   ```
   
   I don't love recreating the class but if you have any other ideas feel free 
to explore



-- 
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