update_connection
Modify connection settings in Apache Airflow by updating parameters like host, port, credentials, and schema for a specified connection ID.
Instructions
Update a connection by ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| conn_id | Yes | ||
| conn_type | No | ||
| extra | No | ||
| host | No | ||
| login | No | ||
| password | No | ||
| port | No | ||
| schema | No |
Input Schema (JSON Schema)
{
"properties": {
"conn_id": {
"title": "Conn Id",
"type": "string"
},
"conn_type": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Conn Type"
},
"extra": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Extra"
},
"host": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Host"
},
"login": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Login"
},
"password": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Password"
},
"port": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Port"
},
"schema": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Schema"
}
},
"required": [
"conn_id"
],
"type": "object"
}
Implementation Reference
- src/airflow/connection.py:77-106 (handler)The async handler function that implements the update_connection tool. It constructs an update request from provided parameters and uses Airflow's ConnectionApi to patch the connection.async def update_connection( conn_id: str, conn_type: Optional[str] = None, host: Optional[str] = None, port: Optional[int] = None, login: Optional[str] = None, password: Optional[str] = None, schema: Optional[str] = None, extra: Optional[str] = None, ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: update_request = {} if conn_type is not None: update_request["conn_type"] = conn_type if host is not None: update_request["host"] = host if port is not None: update_request["port"] = port if login is not None: update_request["login"] = login if password is not None: update_request["password"] = password if schema is not None: update_request["schema"] = schema if extra is not None: update_request["extra"] = extra response = connection_api.patch_connection( connection_id=conn_id, update_mask=list(update_request.keys()), connection_request=update_request ) return [types.TextContent(type="text", text=str(response.to_dict()))]
- src/airflow/connection.py:11-20 (registration)Registration of the update_connection tool within the get_all_functions list, including the handler reference, tool name, description, and read-only flag.def get_all_functions() -> list[tuple[Callable, str, str, bool]]: """Return list of (function, name, description, is_read_only) tuples for registration.""" return [ (list_connections, "list_connections", "List all connections", True), (create_connection, "create_connection", "Create a connection", False), (get_connection, "get_connection", "Get a connection by ID", True), (update_connection, "update_connection", "Update a connection by ID", False), (delete_connection, "delete_connection", "Delete a connection by ID", False), (test_connection, "test_connection", "Test a connection", True), ]