Skip to content
Snippets Groups Projects
Verified Commit 469d809c authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Work around Kentik API limitation

parent df9df1c4
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !235. Comments created here will be created in the context of that merge request.
...@@ -114,7 +114,8 @@ class KentikClient: ...@@ -114,7 +114,8 @@ class KentikClient:
plan_id = self.get_plan_by_name(self.config.billing_plans[device.site_tier])["id"] plan_id = self.get_plan_by_name(self.config.billing_plans[device.site_tier])["id"]
request_body = { request_body = {
"device": { "device": {
**device.model_dump(exclude=set("site_tier")), **device.model_dump(exclude=set("device_name" "site_tier")),
"device_name": device.device_description,
"device_type": self.config.device_type, "device_type": self.config.device_type,
"device_subtype": self.config.device_type, "device_subtype": self.config.device_type,
"minimize_snmp": self.config.minimize_snmp, "minimize_snmp": self.config.minimize_snmp,
...@@ -128,7 +129,14 @@ class KentikClient: ...@@ -128,7 +129,14 @@ class KentikClient:
} }
} }
return self._send_request("POST", "v5/device", request_body).json() new_device = self._send_request("POST", "v5/device", request_body).json()
# The name of the device has to be updated from the subscription ID to its FQDN.
# This is a limitation of the Kentik API that disallows settings device names containing a . symbol.
self.update_device(new_device["device"]["id"], {"device": {"device_name": device.device_name}})
new_device["device"]["device_name"] = device.device_name
return new_device
def update_device(self, device_id: str, updated_device: dict[str, Any]) -> dict[str, Any]: def update_device(self, device_id: str, updated_device: dict[str, Any]) -> dict[str, Any]:
"""Update an existing device in Kentik.""" """Update an existing device in Kentik."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment