diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index bbc592eb..0011cc54 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -1976,6 +1976,9 @@ Start an OS update on a device. Unsupported (unpublished) version will result in rejection. The version **must** be the exact version number, a "prod" variant and greater than the one running on the device. + run_detached (Optional[bool]): run the update in detached mode. + Default behaviour is run_detached=False but is DEPRECATED and will be + removed in a future release. Use run_detached=True. #### Returns: HUPStatusResponse: action response. @@ -1984,6 +1987,7 @@ Start an OS update on a device. ```python >>> balena.models.device.start_os_update('b6070f4', '2.29.2+rev1.prod') >>> balena.models.device.start_os_update('b6070f4', '2.89.0+rev1') +>>> balena.models.device.start_os_update('b6070f4', '2.89.0+rev1', run_detached=True) ``` diff --git a/balena/models/device.py b/balena/models/device.py index d94ceb73..98abbb5c 100644 --- a/balena/models/device.py +++ b/balena/models/device.py @@ -1727,7 +1727,13 @@ def set_supervisor_release( } ) - def start_os_update(self, uuid_or_id: Union[str, int], target_os_version: str) -> HUPStatusResponse: + def start_os_update( + self, + uuid_or_id: Union[str, int], + target_os_version: str, + *, # Force keyword arguments after this point + run_detached: Optional[bool] = None + ) -> HUPStatusResponse: """ Start an OS update on a device. @@ -1737,6 +1743,9 @@ def start_os_update(self, uuid_or_id: Union[str, int], target_os_version: str) - Unsupported (unpublished) version will result in rejection. The version **must** be the exact version number, a "prod" variant and greater than the one running on the device. + run_detached (Optional[bool]): run the update in detached mode. + Default behaviour is run_detached=False but is DEPRECATED and will be + removed in a future release. Use run_detached=True. Returns: HUPStatusResponse: action response. @@ -1744,8 +1753,13 @@ def start_os_update(self, uuid_or_id: Union[str, int], target_os_version: str) - Examples: >>> balena.models.device.start_os_update('b6070f4', '2.29.2+rev1.prod') >>> balena.models.device.start_os_update('b6070f4', '2.89.0+rev1') + >>> balena.models.device.start_os_update('b6070f4', '2.89.0+rev1', run_detached=True) """ + # Set default value for run_detached if None + if run_detached is None: + run_detached = False + if target_os_version is None or uuid_or_id is None: raise exceptions.InvalidParameter("target_os_version or UUID", None) @@ -1766,7 +1780,7 @@ def start_os_update(self, uuid_or_id: Union[str, int], target_os_version: str) - data = {"parameters": {"target_version": target_os_version}} url_base = self.__config.get_all()["deviceUrlsBase"] - action_api_version = self.__settings.get("device_actions_endpoint_version") + action_api_version = "v2" if run_detached is True else self.__settings.get("device_actions_endpoint_version") return request( method="POST", @@ -1776,6 +1790,7 @@ def start_os_update(self, uuid_or_id: Union[str, int], target_os_version: str) - endpoint=f"https://actions.{url_base}/{action_api_version}/", ) + @deprecated("This will be removed in a future major release") def get_os_update_status(self, uuid_or_id: Union[str, int]) -> HUPStatusResponse: """ Get the OS update status of a device.