From f76dc9bbcd92c40c698b5c395ea096d3b58a2412 Mon Sep 17 00:00:00 2001 From: Mikhail G Date: Fri, 5 May 2023 16:07:13 +0200 Subject: [PATCH 1/2] update inlined documentation --- emnify/modules/device/manager.py | 12 +++++++--- emnify/modules/sim/manager.py | 39 ++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/emnify/modules/device/manager.py b/emnify/modules/device/manager.py index bdb2570..caf0c36 100644 --- a/emnify/modules/device/manager.py +++ b/emnify/modules/device/manager.py @@ -209,9 +209,15 @@ def change_status( enable: bool = None, disable: bool = None ) -> None: """ - :param device: id or device model for update - :param enable: boolean parameter for enable a Device - :param disable: boolean parameter for disable a Device + Change the status of a device and assigned SIM to enabled or disabled. + + :param device: The ID or device model to update. + :type device: Union[UpdateDevice, Device, RetrieveDevice, int] + :param enable: Whether to enable the device. + :type enable: bool + :param disable: Whether to disable the device. + :type disable: bool + :raises ValidationErrorException: If neither `enable` nor `disable` is provided, or if both are provided. """ if not (enable or disable) or (enable and disable): raise emnify_errors.ValidationErrorException('"enable" or "disable" arguments must be provided ') diff --git a/emnify/modules/sim/manager.py b/emnify/modules/sim/manager.py index 6be10a5..4c9a41a 100644 --- a/emnify/modules/sim/manager.py +++ b/emnify/modules/sim/manager.py @@ -6,23 +6,41 @@ class SimManager: + """ + Provides methods for interacting with SIM cards using the EMnify API. + + Args: + client: An instance of the EMnify class used for making API requests. + """ def __init__(self, client): self.client = client @property def get_sim_list_model(self): + """ + Returns the model for the SIM list. + """ return sim_models.SimList @property def get_sim_update_model(self): + """ + Returns the model for updating SIM cards. + """ return sim_models.SimUpdate @property def get_sim_filter_model(self): + """ + Returns the model for filtering SIM cards. + """ return sim_models.SimFilter @property def get_sim_sort_enum(self): + """ + Returns sim sorting options. + """ return emnify_const.SimSort def get_sim_list( @@ -73,7 +91,9 @@ def update_sim(self, sim_id: int, sim: sim_models.SimUpdate) -> bool: def activate_sim(self, sim_id: int): """ - Method for activating sim - changing status to 'active' + Activates `suspended` or `issued` SIM. + If you want to control both the device and SIM as a whole, it's recommended to use the :class:`DeviceManager.change_status` method if the SIM is assigned to a device. + Learn more about SIM Lifecycle: https://docs.emnify.com/services/sim-lifecycle-management :param sim_id: int of sim to update """ return SimUpdateApi() \ @@ -84,8 +104,10 @@ def activate_sim(self, sim_id: int): def suspend_sim(self, sim_id: int): """ - Method for activating sim - changing status to 'active' - :param sim_id: int of sim to update + Puts the `active` SIM to `suspended` state. + If you want to control both the device and SIM as a whole, it's recommended to use the :class:`DeviceManager.change_status` method if the SIM is assigned to a device. + Learn more about SIM Lifecycle: https://docs.emnify.com/services/sim-lifecycle-management + :param sim_id: id of sim to update """ return SimUpdateApi() \ .call_api( @@ -95,9 +117,16 @@ def suspend_sim(self, sim_id: int): def issue_sim(self, sim_id: int): """ - Method for activating sim - changing status to 'active' - :param sim_id: int of sim to update + .. deprecated:: 0.2.13 + Use :func:`suspend_sim` instead. + + + It's impossible to put the SIM back to issued state. + Learn more about SIM Lifecycle: https://docs.emnify.com/services/sim-lifecycle-management + This method is deprecated and will be removed in a future version of the SDK. """ + import warnings + warnings.warn("issue_sim() is deprecated and will be removed in a future version of the SDK.", DeprecationWarning) return SimUpdateApi() \ .call_api( client=self.client, data={'status': emnify_const.SimStatusesDict.ISSUED_DICT.value}, From ea56182beb9988c40bd36f81caabe12263a16f06 Mon Sep 17 00:00:00 2001 From: Mikhail G Date: Fri, 5 May 2023 16:19:03 +0200 Subject: [PATCH 2/2] feat: remove SimManager.issue_sim --- emnify/modules/sim/manager.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/emnify/modules/sim/manager.py b/emnify/modules/sim/manager.py index 4c9a41a..85c912a 100644 --- a/emnify/modules/sim/manager.py +++ b/emnify/modules/sim/manager.py @@ -115,24 +115,6 @@ def suspend_sim(self, sim_id: int): path_params={'sim': sim_id} ) - def issue_sim(self, sim_id: int): - """ - .. deprecated:: 0.2.13 - Use :func:`suspend_sim` instead. - - - It's impossible to put the SIM back to issued state. - Learn more about SIM Lifecycle: https://docs.emnify.com/services/sim-lifecycle-management - This method is deprecated and will be removed in a future version of the SDK. - """ - import warnings - warnings.warn("issue_sim() is deprecated and will be removed in a future version of the SDK.", DeprecationWarning) - return SimUpdateApi() \ - .call_api( - client=self.client, data={'status': emnify_const.SimStatusesDict.ISSUED_DICT.value}, - path_params={'sim': sim_id} - ) - @staticmethod def __transform_sim_filter_params( filter_model: sim_models.SimFilter = None,