Skip to content

Commit d9375a8

Browse files
authored
Update ncm.py
1 parent d0c1918 commit d9375a8

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

ncm/ncm/ncm.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2667,6 +2667,40 @@ def regrade(self, subscription_id, mac, action="UPGRADE"):
26672667
result = self._return_handler(ncm.status_code, ncm.json(), call_type)
26682668
return result
26692669

2670+
def unlicense_device(self, mac_address):
2671+
"""
2672+
Unlicenses a device by MAC address.
2673+
:param mac_address: MAC address of the device to unlicense
2674+
:return: Result of the unlicense operation
2675+
"""
2676+
call_type = 'Unlicense Device'
2677+
post_url = f'{self.base_url}/asset_endpoints/regrades'
2678+
2679+
payload = {
2680+
"atomic:operations": [
2681+
{
2682+
"op": "add",
2683+
"data": {
2684+
"type": "regrades",
2685+
"attributes": {
2686+
"mac_address": mac_address.replace(':', '') if len(mac_address) == 17 else mac_address,
2687+
"action": "UNLICENSE"
2688+
}
2689+
}
2690+
}
2691+
]
2692+
}
2693+
2694+
headers = {
2695+
'Content-Type': 'application/vnd.api+json;ext="https://jsonapi.org/ext/atomic"',
2696+
'Accept': 'application/vnd.api+json;ext="https://jsonapi.org/ext/atomic"'
2697+
}
2698+
2699+
response = self.session.post(post_url, json=payload, headers=headers)
2700+
2701+
result = self._return_handler(response.status_code, response.json(), call_type)
2702+
return result
2703+
26702704
def get_regrades(self, **kwargs):
26712705
"""
26722706
Returns regrade jobs with details.

0 commit comments

Comments
 (0)