示例#1
0
 def to_json(self):
     r = {
         "name": self.name,
         "$collection": self._meta["json_collection"],
         "uuid": self.uuid,
         "single_service": self.single_service,
         "single_client": self.single_client,
         "allow_children": self.allow_children,
     }
     if self.description:
         r["description"] = self.description
     if self.service_model:
         r["service_model"] = self.service_model
     if self.client_model:
         r["client_model"] = self.client_model
     return to_json(
         r,
         order=[
             "name",
             "$collection",
             "uuid",
             "description",
             "service_model",
             "client_model",
             "single_service",
             "single_client",
             "allow_children",
         ],
     )
示例#2
0
 def to_json(self):
     return to_json(
         {
             "name": self.name,
             "$collection": self._meta["json_collection"],
             "uuid": self.uuid,
             "values": self.values,
         },
         order=["name", "$collection", "uuid"],
     )
示例#3
0
 def to_json(self):
     return to_json(
         {
             "$collection": self._meta["json_collection"],
             "name": self.name,
             "uuid": self.uuid,
             "description": self.description,
         },
         order=["name", "uuid", "description"],
     )
示例#4
0
 def to_json(self):
     return to_json(
         {
             "name": self.name,
             "$collection": self._meta["json_collection"],
             "uuid": self.uuid,
             "syntax": self.syntax,
         },
         order=["name", "$collection", "uuid", "syntax"],
     )
示例#5
0
 def to_json(self):
     return to_json(
         {
             "$collection": self._meta["json_collection"],
             "rewrite_mib": self.rewrite_mib,
             "to_mib": self.to_mib,
             "uuid": self.uuid,
         },
         order=["$collection", "rewrite_mib", "to_mib", "uuid"],
     )
示例#6
0
 def to_json(self):
     return to_json(
         {
             "mib": self.mib,
             "$collection": self._meta["json_collection"],
             "uuid": self.uuid,
             "preference": self.preference,
         },
         order=["mib", "$collection", "uuid", "preference"],
     )
示例#7
0
 def to_json(self):
     r = {
         "rewrite_oid": self.rewrite_oid,
         "to_oid": self.to_oid,
         "uuid": self.uuid,
         "$collection": self._meta["json_collection"],
     }
     if self.description:
         r["description"] = self.description
     return to_json(r,
                    order=["$collection", "rewrite_oid", "to_oid", "uuid"])
示例#8
0
 def to_json(self):
     return to_json(
         {
             "name": self.name,
             "$collection": self._meta["json_collection"],
             "uuid": self.uuid,
             "description": self.description,
             "cells": [s.to_json() for s in self.cells],
         },
         order=["name", "uuid", "description", "cells"],
     )
示例#9
0
文件: firmware.py 项目: nbashev/noc
 def to_json(self):
     return to_json(
         {
             "$collection": self._meta["json_collection"],
             "profile__name": self.profile.name,
             "vendor__code": self.vendor.code[0],
             "version": self.version,
             "uuid": self.uuid,
         },
         order=["profile__name", "vendor__code", "version", "uuid"],
     )
示例#10
0
文件: vendor.py 项目: marcosvella/noc
 def to_json(self):
     return to_json(
         {
             "name": self.name,
             "$collection": self._meta["json_collection"],
             "full_name": self.full_name,
             "code": self.code,
             "site": self.site,
             "uuid": self.uuid,
         },
         order=["name", "uuid", "full_name", "code", "site"],
     )
示例#11
0
 def to_json(self):
     return to_json(
         self.json_data,
         order=[
             "name",
             "$collection",
             "uuid",
             "table_name",
             "description",
             "key_fields",
             "path",
         ],
     )
示例#12
0
 def to_json(self):
     return to_json(
         self.json_data,
         order=[
             "name",
             "$collection",
             "uuid",
             "label",
             "description",
             "access_level",
             "handler",
             "params",
         ],
     )
示例#13
0
 def to_json(self):
     return to_json(
         self.json_data,
         order=[
             "name",
             "$collection",
             "uuid",
             "description",
             "revision",
             "disclaimer",
             "changes",
             "questions",
         ],
     )
示例#14
0
 def to_json(self):
     return to_json(
         self.json_data,
         order=[
             "name",
             "$collection",
             "uuid",
             "description",
             "revision",
             "quiz__name",
             "author",
             "profile__name",
             "answers",
         ],
     )
示例#15
0
 def to_json(self):
     return to_json(
         self.json_data,
         order=[
             "name",
             "$collection",
             "uuid",
             "description",
             "label",
             "dashboard_label",
             "scale_type",
             "alt_units",
             "enum",
         ],
     )
示例#16
0
 def to_json(self):
     return to_json(
         self.json_data,
         order=[
             "name",
             "$collection",
             "uuid",
             "vendor__code",
             "description",
             "connection_rule__name",
             "cr_context",
             "plugins",
             "tags",
         ],
     )
示例#17
0
文件: metrictype.py 项目: nbashev/noc
 def to_json(self):
     return to_json(
         self.json_data,
         order=[
             "name",
             "$collection",
             "uuid",
             "scope__name",
             "field_name",
             "field_type",
             "description",
             "measure",
             "vector_tag",
         ],
     )
示例#18
0
 def to_json(self):
     return to_json(
         {
             "title": self.title,
             "$collection": self._meta["json_collection"],
             "uuid": str(self.uuid),
             "description": self.description,
             "format": self.format,
             "config": smart_text(b85encode(self.config)),
             "created": self.created.isoformat(),
             "changed": self.changed.isoformat(),
             "access": [],
         },
         order=["title", "uuid", "description", "created"],
     )
示例#19
0
 def to_json(self):
     return to_json(
         {
             "name": self.name,
             "$collection": self._meta["json_collection"],
             "uuid": self.uuid,
             "re": self.re,
             "key_re": self.key_re,
             "value_re": self.value_re,
             "rewrite_from": self.rewrite_from,
             "rewrite_to": self.rewrite_to,
         },
         order=[
             "name", "uuid", "re", "key_re", "value_re", "rewrite_from",
             "rewrite_to"
         ],
     )
示例#20
0
 def to_json(self):
     return to_json(
         self.json_data,
         order=[
             "name",
             "$collection",
             "uuid",
             "action__name",
             "description",
             "profile__name",
             "config_mode",
             "preference",
             "match",
             "commands",
             "timeout",
         ],
     )
示例#21
0
 def to_json(self):
     return to_json(
         self.json_data,
         order=[
             "name",
             "$collection",
             "uuid",
             "description",
             "preference",
             "method",
             "param",
             "match_method",
             "value",
             "action",
             "profile__name",
         ],
     )
示例#22
0
 def to_json(self):
     return to_json(
         {
             "name": self.name,
             "$collection": self._meta["json_collection"],
             "uuid": str(self.uuid),
             "description": self.description,
             "umbrella_filter_handler": self.umbrella_filter_handler,
             "window_type": self.window_type,
             "window": self.window,
             "window_function": self.window_function,
             "window_config": self.window_config,
             "value_handler": self.value_handler,
             "thresholds": [thrh.to_json() for thrh in self.thresholds],
         },
         order=["name", "uuid", "thresholds"],
     )
示例#23
0
 def to_json(self):
     r = {
         "name": self.name,
         "$collection": self._meta["json_collection"],
         "uuid": self.uuid,
         "subject_template": self.subject_template,
         "body_template": self.body_template,
     }
     if self.description:
         r["description"] = self.description
     return to_json(
         r,
         order=[
             "name",
             "$collection",
             "uuid",
             "description",
             "subject_template",
             "body_template",
         ],
     )
示例#24
0
 def to_json(self):
     r = {
         "$collection": self._meta["json_collection"],
         "vendor__code": self.vendor.code[0],
         "name": self.name,
         "uuid": self.uuid,
     }
     if self.aliases:
         r["aliases"] = [str(x) for x in self.aliases]
     if self.description:
         r["description"] = self.description
     if self.start_of_sale:
         r["start_of_sale"] = self.start_of_sale.strftime("%Y-%m-%d")
     if self.end_of_sale:
         r["end_of_sale"] = self.end_of_sale.strftime("%Y-%m-%d")
     if self.end_of_support:
         r["end_of_support"] = self.end_of_support.strftime("%Y-%m-%d")
     if self.snmp_sysobjectid:
         r["snmp_sysobjectid"] = self.snmp_sysobjectid
     if self.labels:
         r["labels"] = self.labels
     return to_json(
         r,
         order=[
             "vendor__code",
             "name",
             "$collection",
             "uuid",
             "aliases",
             "description",
             "start_of_sale",
             "end_of_sale",
             "end_of_support",
             "snmp_sysobjectid",
             "labels",
         ],
     )
示例#25
0
 def to_json(self):
     r = {
         "name": self.name,
         "$collection": self._meta["json_collection"],
         "uuid": self.uuid,
         "from_mac": self.from_mac,
         "to_mac": self.to_mac,
         "affected": [a.to_json() for a in self.affected],
         "is_duplicated": self.is_duplicated,
     }
     if self.description:
         r["description"] = self.description
     return to_json(
         r,
         order=[
             "name",
             "uuid",
             "from_mac",
             "to_mac",
             "description",
             "is_duplicated",
             "affected",
         ],
     )
示例#26
0
 def to_json(self):
     r = {
         "name": self.name,
         "$collection": self._meta["json_collection"],
         "uuid": self.uuid,
         "source": self.source,
         "params": [p.to_json() for p in self.params],
         "allow_object_filter": self.allow_object_filter,
         "allow_interface_filter": self.allow_interface_filter,
         "allow_object_validation": self.allow_object_validation,
         "allow_interface_validation": self.allow_interface_validation,
         "allow_object_classification": self.allow_object_classification,
         "allow_interface_classification":
         self.allow_interface_classification,
         "require_raw": self.require_raw,
     }
     if self.description:
         r["description"] = self.description
     return to_json(
         r,
         order=[
             "name",
             "$collection",
             "uuid",
             "description",
             "source",
             "params",
             "allow_object_filter",
             "allow_interface_filter",
             "allow_object_validation",
             "allow_interface_validation",
             "allow_object_classification",
             "allow_interface_classification",
             "require_raw",
         ],
     )
示例#27
0
def test_prettyjson_error(config, expected):
    with pytest.raises(TypeError):
        assert to_json(config).startswith("{\n") == expected
示例#28
0
def test_prettyjson(config, expected):
    assert to_json(config).startswith("{\n") == expected
示例#29
0
 def api_action_json(self, request, ids):
     r = [o.json_data for o in ids]
     s = to_json(r, order=["name", "vendor__code", "description"])
     return {"data": s}
示例#30
0
 def to_json(self):
     return to_json(self.json_data,
                    order=["name", "$collection", "uuid", "description"])