patch-private-units-UNIT.rst (1465B)
1 .. http:patch:: [/instances/$INSTANCE]/private/units/$UNIT 2 3 Update attributes of a measurement unit. 4 5 **Required permission:** ``units-write`` 6 7 **Request:** 8 9 The request must be a `UnitPatchRequest`. 10 11 **Response:** 12 13 :http:statuscode:`204 No content`: 14 The backend updated the unit. 15 :http:statuscode:`404 Not found`: 16 The unit is unknown to the backend. 17 18 Built-in units allow changing ``unit_allow_fraction``, ``unit_precision_level``, and 19 ``unit_active``; other fields are immutable for built-ins. 20 21 .. ts:def:: UnitPatchRequest 22 23 interface UnitPatchRequest { 24 // Updated human-readable long label. 25 unit_name_long?: string; 26 27 // Updated human-readable short label. 28 unit_name_short?: string; 29 30 // Updated translations for the long label keyed by BCP 47 language tags. 31 unit_name_long_i18n?: { [lang_tag: string]: string }; 32 33 // Updated translations for the short label keyed by BCP 47 language tags. 34 unit_name_short_i18n?: { [lang_tag: string]: string }; 35 36 // Override to allow or forbid fractional quantities. 37 unit_allow_fraction?: boolean; 38 39 // Override for the fractional precision (0-6). Ignored if fractions are disabled. 40 unit_precision_level?: Integer; 41 42 // Toggle whether the unit is active. 43 unit_active?: boolean; 44 } 45 46 Fractional precision is capped at six decimal places. Disabling 47 ``unit_allow_fraction`` forces ``unit_precision_level`` to zero.