Bulk Dell warranty sync + add-warranty from asset pages
- POST /warranty/sync/dell: auto-detect Dell hardware by service tag (asset serial) and create warranties for the ones Dell recognizes, in batches of 100. Only looks up assets that lack a dated warranty, so re-runs are cheap and non-Dell serials are filtered out by Dell. DellProvider.bulk_lookup batches tags over the cached token. - "Sync Dell" button on the Warranties page with a toast summary. - WarrantyPanel "Add one / Add-manage" links deep-link to the warranties add modal pre-linked to that asset (?addfor=); WarrantiesList opens it prefilled. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -203,6 +203,34 @@ class DellProvider(WarrantyProvider):
|
||||
token = self._get_token(config)
|
||||
return self._map(self._fetch(config, token, servicetag))
|
||||
|
||||
def bulk_lookup(self, servicetags):
|
||||
"""Look up many tags at once. Dell takes up to 100 tags per call.
|
||||
|
||||
Returns {SERVICETAG_UPPER: {servicelevel, startdate, enddate}} for tags
|
||||
Dell recognizes; unknown/non-Dell tags are simply absent.
|
||||
"""
|
||||
config = self._config()
|
||||
if not (config['enabled'] and config['clientid'] and config['clientsecret']):
|
||||
raise ProviderNotConfigured(
|
||||
'Dell warranty lookup is not configured. Set warranty_dell_enabled, '
|
||||
'clientid and clientsecret in Settings > Integrations.'
|
||||
)
|
||||
tags = [t.strip() for t in servicetags if t and t.strip()]
|
||||
if not tags:
|
||||
return {}
|
||||
token = self._get_token(config)
|
||||
results = {}
|
||||
for start in range(0, len(tags), 100):
|
||||
chunk = tags[start:start + 100]
|
||||
payload = self._fetch(config, token, ','.join(chunk))
|
||||
assets = payload if isinstance(payload, list) else [payload]
|
||||
for asset in assets:
|
||||
tag = (asset.get('serviceTag') or '').upper()
|
||||
mapped = self._map([asset])
|
||||
if tag and mapped:
|
||||
results[tag] = mapped
|
||||
return results
|
||||
|
||||
|
||||
class ApiProvider(WarrantyProvider):
|
||||
"""Generic config-shaped stub for vendors not yet wired (Lenovo, HP)."""
|
||||
|
||||
Reference in New Issue
Block a user