|
47 | 47 | from .warmup import WarmUpTrigger
|
48 | 48 | from .._http_asgi import AsgiMiddleware
|
49 | 49 | from .._http_wsgi import WsgiMiddleware, Context
|
| 50 | +from azure.functions.decorators.mysql import MySqlInput, MySqlOutput, \ |
| 51 | + MySqlTrigger |
50 | 52 |
|
51 | 53 |
|
52 | 54 | class Function(object):
|
@@ -1443,6 +1445,58 @@ def decorator():
|
1443 | 1445 |
|
1444 | 1446 | return wrap
|
1445 | 1447 |
|
| 1448 | + def mysql_trigger(self, |
| 1449 | + arg_name: str, |
| 1450 | + table_name: str, |
| 1451 | + connection_string_setting: str, |
| 1452 | + leases_table_name: Optional[str] = None, |
| 1453 | + data_type: Optional[DataType] = None, |
| 1454 | + **kwargs) -> Callable[..., Any]: |
| 1455 | + """The mysql_trigger decorator adds :class:`MySqlTrigger` |
| 1456 | + to the :class:`FunctionBuilder` object |
| 1457 | + for building :class:`Function` object used in worker function |
| 1458 | + indexing model. This decorator will work only with extension bundle 4.x |
| 1459 | + and above. |
| 1460 | + This is equivalent to defining MySqlTrigger in the function.json which |
| 1461 | + enables function to be triggered when there are changes in the MySql |
| 1462 | + table. |
| 1463 | + All optional fields will be given default value by function host when |
| 1464 | + they are parsed by function host. |
| 1465 | + Ref: https://aka.ms/mysqlbindings |
| 1466 | + :param arg_name: The name of the variable that represents a |
| 1467 | + :class:`MySqlRowList` object in the function code |
| 1468 | + :param table_name: The name of the table monitored by the trigger |
| 1469 | + :param connection_string_setting: The name of an app setting that |
| 1470 | + contains the connection string for the database against which the |
| 1471 | + query or stored procedure is being executed |
| 1472 | + :param leases_table_name: The name of the table used to store |
| 1473 | + leases. If not specified, the leases table name will be |
| 1474 | + Leases_{FunctionId}_{TableId}. |
| 1475 | + :param data_type: Defines how Functions runtime should treat the |
| 1476 | + parameter value |
| 1477 | + :param kwargs: Keyword arguments for specifying additional binding |
| 1478 | + fields to include in the binding json |
| 1479 | + :return: Decorator function. |
| 1480 | + """ |
| 1481 | + |
| 1482 | + @self._configure_function_builder |
| 1483 | + def wrap(fb): |
| 1484 | + def decorator(): |
| 1485 | + fb.add_trigger( |
| 1486 | + trigger=MySqlTrigger( |
| 1487 | + name=arg_name, |
| 1488 | + table_name=table_name, |
| 1489 | + connection_string_setting=connection_string_setting, |
| 1490 | + leases_table_name=leases_table_name, |
| 1491 | + data_type=parse_singular_param_to_enum(data_type, |
| 1492 | + DataType), |
| 1493 | + **kwargs)) |
| 1494 | + return fb |
| 1495 | + |
| 1496 | + return decorator() |
| 1497 | + |
| 1498 | + return wrap |
| 1499 | + |
1446 | 1500 | def generic_trigger(self,
|
1447 | 1501 | arg_name: str,
|
1448 | 1502 | type: str,
|
@@ -3552,6 +3606,109 @@ def decorator():
|
3552 | 3606 |
|
3553 | 3607 | return wrap
|
3554 | 3608 |
|
| 3609 | + def mysql_input(self, |
| 3610 | + arg_name: str, |
| 3611 | + command_text: str, |
| 3612 | + connection_string_setting: str, |
| 3613 | + command_type: Optional[str] = 'Text', |
| 3614 | + parameters: Optional[str] = None, |
| 3615 | + data_type: Optional[DataType] = None, |
| 3616 | + **kwargs) -> Callable[..., Any]: |
| 3617 | + """The mysql_input decorator adds |
| 3618 | + :class:`MySqlInput` to the :class:`FunctionBuilder` object |
| 3619 | + for building :class:`Function` object used in worker function |
| 3620 | + indexing model. This decorator will work only with extension bundle 4.x |
| 3621 | + and above. |
| 3622 | + This is equivalent to defining MySqlInput in the function.json which |
| 3623 | + enables the function to read from a MySql database. |
| 3624 | + All optional fields will be given default value by function host when |
| 3625 | + they are parsed by function host. |
| 3626 | + Ref: https://aka.ms/mysqlbindings |
| 3627 | + :param arg_name: The name of the variable that represents a |
| 3628 | + :class:`MySqlRowList` input object in function code |
| 3629 | + :param command_text: The Transact-SQL query command or name of the |
| 3630 | + stored procedure executed by the binding |
| 3631 | + :param connection_string_setting: The name of an app setting that |
| 3632 | + contains the connection string for the database against which the |
| 3633 | + query or stored procedure is being executed |
| 3634 | + :param command_type: A CommandType value, which is Text for a query |
| 3635 | + and StoredProcedure for a stored procedure |
| 3636 | + :param parameters: Zero or more parameter values passed to the |
| 3637 | + command during execution as a single string. Must follow the format |
| 3638 | + @param1=param1,@param2=param2 |
| 3639 | + :param data_type: Defines how Functions runtime should treat the |
| 3640 | + parameter value |
| 3641 | + :param kwargs: Keyword arguments for specifying additional binding |
| 3642 | + fields to include in the binding json |
| 3643 | + :return: Decorator function. |
| 3644 | + """ |
| 3645 | + |
| 3646 | + @self._configure_function_builder |
| 3647 | + def wrap(fb): |
| 3648 | + def decorator(): |
| 3649 | + fb.add_binding( |
| 3650 | + binding=MySqlInput( |
| 3651 | + name=arg_name, |
| 3652 | + command_text=command_text, |
| 3653 | + connection_string_setting=connection_string_setting, |
| 3654 | + command_type=command_type, |
| 3655 | + parameters=parameters, |
| 3656 | + data_type=parse_singular_param_to_enum(data_type, |
| 3657 | + DataType), |
| 3658 | + **kwargs)) |
| 3659 | + return fb |
| 3660 | + |
| 3661 | + return decorator() |
| 3662 | + |
| 3663 | + return wrap |
| 3664 | + |
| 3665 | + def mysql_output(self, |
| 3666 | + arg_name: str, |
| 3667 | + command_text: str, |
| 3668 | + connection_string_setting: str, |
| 3669 | + data_type: Optional[DataType] = None, |
| 3670 | + **kwargs) -> Callable[..., Any]: |
| 3671 | + """The mysql_output decorator adds |
| 3672 | + :class:`MySqlOutput` to the :class:`FunctionBuilder` object |
| 3673 | + for building :class:`Function` object used in worker function |
| 3674 | + indexing model. This decorator will work only with extension bundle 4.x |
| 3675 | + and above. |
| 3676 | + This is equivalent to defining MySqlOutput in the function.json which |
| 3677 | + enables the function to write to a MySql database. |
| 3678 | + All optional fields will be given default value by function host when |
| 3679 | + they are parsed by function host. |
| 3680 | + Ref: https://aka.ms/mysqlbindings |
| 3681 | + :param arg_name: The name of the variable that represents |
| 3682 | + MySql output object in function code |
| 3683 | + :param command_text: The Transact-SQL query command or name of the |
| 3684 | + stored procedure executed by the binding |
| 3685 | + :param connection_string_setting: The name of an app setting that |
| 3686 | + contains the connection string for the database against which the |
| 3687 | + query or stored procedure is being executed |
| 3688 | + :param data_type: Defines how Functions runtime should treat the |
| 3689 | + parameter value |
| 3690 | + :param kwargs: Keyword arguments for specifying additional binding |
| 3691 | + fields to include in the binding json |
| 3692 | + :return: Decorator function. |
| 3693 | + """ |
| 3694 | + |
| 3695 | + @self._configure_function_builder |
| 3696 | + def wrap(fb): |
| 3697 | + def decorator(): |
| 3698 | + fb.add_binding( |
| 3699 | + binding=MySqlOutput( |
| 3700 | + name=arg_name, |
| 3701 | + command_text=command_text, |
| 3702 | + connection_string_setting=connection_string_setting, |
| 3703 | + data_type=parse_singular_param_to_enum(data_type, |
| 3704 | + DataType), |
| 3705 | + **kwargs)) |
| 3706 | + return fb |
| 3707 | + |
| 3708 | + return decorator() |
| 3709 | + |
| 3710 | + return wrap |
| 3711 | + |
3555 | 3712 |
|
3556 | 3713 | class SettingsApi(DecoratorApi, ABC):
|
3557 | 3714 | """Interface to extend for using existing settings decorator in
|
|
0 commit comments