Prepare NPM references and mutation API
This commit is contained in:
@@ -6,6 +6,7 @@ from ...adapters import (
|
||||
Capability,
|
||||
CapabilityOperation,
|
||||
DiscoveredObject,
|
||||
ObjectReference,
|
||||
)
|
||||
from ...npm_client import NpmClient
|
||||
|
||||
@@ -81,11 +82,39 @@ class Plugin:
|
||||
field: row.get(field)
|
||||
for field in _PROXY_HOST_FIELDS
|
||||
}
|
||||
certificate_id = row.get("certificate_id")
|
||||
|
||||
if certificate_id in (None, "", 0, "0"):
|
||||
references = ()
|
||||
else:
|
||||
if isinstance(certificate_id, bool):
|
||||
raise RuntimeError(
|
||||
"NPM proxy host has invalid certificate_id"
|
||||
)
|
||||
|
||||
certificate_local_key = str(
|
||||
certificate_id
|
||||
).strip()
|
||||
|
||||
if not certificate_local_key:
|
||||
raise RuntimeError(
|
||||
"NPM proxy host has invalid certificate_id"
|
||||
)
|
||||
|
||||
references = (
|
||||
ObjectReference(
|
||||
relation="certificate",
|
||||
object_type=CERTIFICATES,
|
||||
local_key=certificate_local_key,
|
||||
),
|
||||
)
|
||||
|
||||
discovered.append(
|
||||
DiscoveredObject(
|
||||
object_type=PROXY_HOSTS,
|
||||
local_key=self._local_key(row, "proxy host"),
|
||||
payload=payload,
|
||||
references=references,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user