.. _reference-macros-sync-delete-threshold:

Pull sync delete threshold
----------------------------

.. _21.1|EKB-7436:
.. _19.3.4-PB1|EKB-7436:
.. _25.1|EKB-23581:

During a data sync where you delete an Automate resource from the device so that the
key is in the Automate list but not in the 'device' list, a pull sync will
remove the resource in Automate.

In order to manage the number of resources that are deleted on Automate during this process,
a named macro should be added to the system, with the following values:

* ``name``: *PULL_SYNC_DELETE_THRESHOLD_<device_type>*
* ``macro``: number
* ``hierarchy``: the hierarchy where the sync takes place.
 
Upon a data sync of the device type, a check for the named macro at the hierarchy will take place and
local deletes will be restricted to the number defined in the macro.

.. note::

   * The ``macro`` value is a JSON string containing the number, e.g. ``"macro": "20"``.
     This number defines the maximum number of deletes that are allowed to take place
     during a sync, so that if there are for example more than 20 deletes to process,
     then the data sync/import will fail.

     If the macro is created on the GUI, simply type in the number as value.
   * The ``<device_type>`` value is obtained from the model name component of the
     ``connection_parameters_type`` field of the ``data/DeviceModelMapping`` model.
     Refer to the table below.


In JSON format, the named macro is for example as in the snippets below:


::

   [...]
    "meta": {
      "model_type": "data/Macro",
      "hierarchy": "sys.hcs.CS-P.CS-NB.AAAGlobal",
      "tags": []
    },

    "data": {
      "macro": "20",
      "name": "PULL_SYNC_DELETE_THRESHOLD_MSTeamsOnline",
      "description": "PULL_SYNC_DELETE_THRESHOLD_MSTeamsOnline"
    }
   [...]

The list of provided PULL_SYNC macros and their maximum number of deletes are listed below.
These macros can be cloned to a lower hierarchy and adjusted if required.

.. tabularcolumns:: |p{12cm}|p{3cm}|

======================================================  =====
Name                                                    macro
======================================================  =====
PULL_SYNC_DELETE_THRESHOLD_CallManager                  50
PULL_SYNC_DELETE_THRESHOLD_Ldap                         50
PULL_SYNC_DELETE_THRESHOLD_MSExchangeOnline             50
PULL_SYNC_DELETE_THRESHOLD_MSGraph                      20
PULL_SYNC_DELETE_THRESHOLD_MSTeamsOnline                20
PULL_SYNC_DELETE_THRESHOLD_Spark                        50
PULL_SYNC_DELETE_THRESHOLD_UnityConnection              50
PULL_SYNC_DELETE_THRESHOLD_Zoom                         50
======================================================  =====




.. note::

   The model name following the ``data/`` model type is inserted into the macro name.

The table below maps the device type names as seen on the Data Sync GUI to the
related model in full (remove ``data/`` in the macro) : 



.. tabularcolumns:: |p{9cm}|p{6cm}|

.. csv-table:: Pull Sync Table
   :file: pull-sync-table.csv
   :class: longtable
   :header-rows: 1
   :widths: 3 2


If during a sync the macro is available and the number value in the macro is reached 
while there are more instances, the sync log will also show an error.
If no macro is defined as above, then the pull sync will remove all local instances on
Automate.

