コード例 #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
ファイル: dashboardlayout.py プロジェクト: nbashev/noc
 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
ファイル: measurementunits.py プロジェクト: nbashev/noc
 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
ファイル: thresholdprofile.py プロジェクト: nbashev/noc
 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
ファイル: platform.py プロジェクト: marcosvella/noc
 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"])