{
  "definitions": {
    "path_t": {
      "description": "Complete object element path as per TR181",
      "type": "string",
      "minLength": 6,
      "maxLength": 1024,
      "examples": [
        "Device.",
        "Device.DeviceInfo.Manufacturer",
        "Device.WiFi.SSID.1.",
        "Device.WiFi."
      ]
    },
    "schema_path_t": {
      "description": "Datamodel object schema path",
      "type": "string",
      "minLength": 6,
      "maxLength": 1024,
      "examples": [
        "Device.Bridging.Bridge.{i}.",
        "Device.DeviceInfo.Manufacturer",
        "Device.WiFi.SSID.{i}.SSID"
      ]
    },
    "boolean_t": {
      "type": "string",
      "enum": [
        "0",
        "1"
      ]
    },
    "datatype_t": {
      "type": "string",
      "enum": [
        "int",
        "unsignedInt",
        "long",
        "unsignedLong",
        "string",
        "boolean",
        "dateTime",
        "base64",
        "hexBinary"
      ]
    },
    "operate_path_t": {
      "description": "Datamodel object schema path",
      "type": "string",
      "minLength": 6,
      "maxLength": 1024,
      "examples": [
      	"Device.IP.Diagnostics.IPPing()",
        "Device.DHCPv4.Client.{i}.Renew()",
        "Device.FactoryReset()"
      ]
    },
    "query_path_t": {
      "description": "DM object path with search queries",
      "type": "string",
      "minLength": 6,
      "maxLength": 1024,
      "examples": [
        "Device.",
        "Device.DeviceInfo.Manufacturer",
        "Device.WiFi.SSID.1.BSSID",
        "Device.WiFi.SSID.*.BSSID",
        "Device.WiFi."
      ]
    },
    "proto_t": {
      "type": "string",
      "default": "both",
      "enum": [
        "usp",
        "cwmp",
        "both"
      ]
    },
    "type_t": {
      "type": "string",
      "enum": [
        "xsd:string",
        "xsd:unsignedInt",
        "xsd:int",
        "xsd:unsignedLong",
        "xsd:long",
        "xsd:boolean",
        "xsd:dateTime",
        "xsd:hexBinary",
        "xsd:object",
        "xsd:command",
        "xsd:event"
      ]
    },
    "fault_t": {
      "type": "integer",
      "minimum": 7000,
      "maximum": 9050
    },
    "format_t": {
      "type": "string",
      "default": "pretty",
      "enum": [
        "raw",
        "pretty"
      ]
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://dev.iopsys.eu/bbf/bbfdm/-/blob/devel/docs/api/ubus/bbfdm.md",
  "type": "object",
  "title": "bbf",
  "object": "bbf",
  "additionalProperties": false,
  "properties": {
    "schema": {
      "title": "Get list of supported datamodel parameters",
      "description": "Schema will have all the nodes/objects supported by libbbf",
      "type": "object",
      "required": [
        "output"
      ],
      "properties": {
        "input": {
          "type": "object",
          "properties": {
            "path": {
              "$ref": "#/definitions/query_path_t"
            },
            "first_level": {
              "type": "boolean",
              "description": "gets only first level objects if true"
            },
            "optional": {
              "type": "object",
              "properties": {
                "proto": {
                  "$ref": "#/definitions/proto_t"
                }
              }
            }
          }
        },
        "output": {
          "type": "object",
          "properties": {
            "results": {
              "type": "array",
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "path": {
                      "$ref": "#/definitions/schema_path_t"
                    },
                    "data": {
                      "$ref": "#/definitions/boolean_t"
                    },
                    "type": {
                      "$ref": "#/definitions/type_t"
                    },
                    "fault": {
                      "$ref": "#/definitions/fault_t",
                      "Description": "Any discrepancy in input will result in fault. The type of fault can be identified by fault code"
                    },
                    "fault_msg": {
                      "type": "string",
                      "Description": "Any discrepancy in input will result in fault. The type of fault can be identified by fault code"
                    },
                    "input": {
                      "type": "array",
                      "items": [
                        {
                          "type": "object",
                          "properties": {
                            "path": {
                              "$ref": "#/definitions/schema_path_t"
                            },
                            "data": {
                              "$ref": "#/definitions/boolean_t"
                            },
                            "type": {
                              "$ref": "#/definitions/type_t"
                            }
                          }
                        }
                      ]
                    },
                    "output": {
                      "type": "array",
                      "items": [
                        {
                          "type": "object",
                          "properties": {
                            "path": {
                              "$ref": "#/definitions/schema_path_t"
                            },
                            "data": {
                              "$ref": "#/definitions/boolean_t"
                            },
                            "type": {
                              "$ref": "#/definitions/type_t"
                            }
                          }
                        }
                      ]
                    }
                  },
                  "required": [
                    "path"
                  ]
                }
              ]
            }
          }
        }
      }
    },
    "get": {
      "title": "Get handler",
      "description": "Query the datamodel object",
      "type": "object",
      "required": [
        "input",
        "output"
      ],
      "properties": {
        "input": {
          "type": "object",
          "required": [
            "path"
          ],
          "properties": {
            "path": {
              "$ref": "#/definitions/query_path_t"
            },
            "optional": {
              "type": "object",
              "properties": {
                "format": {
                  "$ref": "#/definitions/format_t"
                },
                "proto": {
                  "$ref": "#/definitions/proto_t"
                }
              }
            }
          }
        },
        "output": {
          "type": "object",
          "properties": {
            "results": {
              "type": "array",
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "path": {
                      "$ref": "#/definitions/path_t"
                    },
                    "data": {
                      "type": "string"
                    },
                    "type": {
                      "$ref": "#/definitions/type_t"
                    },
                    "fault": {
                      "$ref": "#/definitions/fault_t",
                      "Description": "Any discrepancy in input will result in fault. The type of fault can be identified by fault code"
                    },
                    "fault_msg": {
                      "type": "string",
                      "Description": "Any discrepancy in input will result in fault. The type of fault can be identified by fault code"
                    }
                  },
                  "required": [
                    "path"
                  ]
                }
              ]
            }
          }
        }
      }
    },
    "instances": {
      "title": "Instance query handler",
      "description": "Get the instances of multi object",
      "type": "object",
      "required": [
        "input"
      ],
      "properties": {
        "input": {
          "type": "object",
          "required": [
            "path"
          ],
          "properties": {
            "path": {
              "$ref": "#/definitions/query_path_t"
            },
            "optional": {
              "type": "object",
              "properties": {
                "proto": {
                  "$ref": "#/definitions/proto_t"
                }
              }
            }
          }
        },
        "output": {
          "type": "object",
          "properties": {
            "results": {
              "type": "array",
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "path": {
                      "$ref": "#/definitions/path_t"
                    },
                    "fault": {
                      "$ref": "#/definitions/fault_t",
                      "Description": "Any discrepancy in input will result in fault. The type of fault can be identified by fault code"
                    },
                    "fault_msg": {
                      "type": "string",
                      "Description": "Any discrepancy in input will result in fault. The type of fault can be identified by fault code"
                    }
                  },
                  "required": [
                    "path"
                  ]
                }
              ]
            }
          }
        }
      }
    },
    "add": {
      "title": "Add a new object instance",
      "description": "Add a new object in multi instance object",
      "type": "object",
      "required": [
        "input",
        "output"
      ],
      "properties": {
        "input": {
          "type": "object",
          "required": [
            "path"
          ],
          "properties": {
            "path": {
              "$ref": "#/definitions/path_t"
            },
            "obj_path": {
              "type": "object",
              "properties": {}
            }
          }
        },
        "output": {
          "type": "object",
          "properties": {
            "results": {
              "type": "array",
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "path": {
                      "$ref": "#/definitions/path_t"
                    },
                    "data": {
                      "type": "string"
                    },
                    "fault": {
                      "$ref": "#/definitions/fault_t",
                      "Description": "Any discrepancy in input will result in fault. The type of fault can be identified by fault code"
                    },
                    "fault_msg": {
                      "type": "string",
                      "Description": "Any discrepancy in input will result in fault. The type of fault can be identified by fault code"
                    }
                  },
                  "required": [
                    "path"
                  ]
                }
              ]
            }
          }
        }
      }
    },
    "del": {
      "title": "Delete object instance",
      "description": "Delete a object instance from multi instance object",
      "type": "object",
      "required": [
        "input",
        "output"
      ],
      "properties": {
        "input": {
          "type": "object",
          "required": [
            "path"
          ],
          "properties": {
            "path": {
              "$ref": "#/definitions/path_t"
            },
            "paths": {
              "type": "array",
              "uniqueItems": true,
              "items": [
                {
                  "$ref": "#/definitions/query_path_t"
                }
              ]
            }
          }
        },
        "output": {
          "type": "object",
          "properties": {
            "results": {
              "type": "array",
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "path": {
                      "$ref": "#/definitions/path_t"
                    },
                    "data": {
                      "type": "string"
                    },
                    "fault": {
                      "$ref": "#/definitions/fault_t",
                      "Description": "Any discrepancy in input will result in fault. The type of fault can be identified by fault code"
                    },
                    "fault_msg": {
                      "type": "string",
                      "Description": "Any discrepancy in input will result in fault. The type of fault can be identified by fault code"
                    }
                  },
                  "required": [
                    "parameter",
                    "type"
                  ]
                }
              ]
            }
          }
        }
      }
    },
    "set": {
      "title": "Set handler",
      "description": "Set values of datamodel object element",
      "type": "object",
      "required": [
        "input",
        "output"
      ],
      "properties": {
        "input": {
          "type": "object",
          "required": [
            "path",
            "value"
          ],
          "properties": {
            "path": {
              "$ref": "#/definitions/query_path_t"
            },
            "value": {
              "description": "value of the object element provided in path, path should contains valid writable object element",
              "type": "string",
              "examples": [
                "{\"path\":\"Device.WiFi.SSID.1.SSID\", \"value\":\"test_ssid\"}",
                "{\"path\":\"Device.WiFi.SSID.2.Enable\", \"value\":\"true\"}",
                "{\"path\":\"Device.WiFi.SSID.1.Enable\", \"value\":\"0\"}"
              ]
            },
            "datatype": {
              "description": "datatype of the object element provided in path",
              "$ref": "#/definitions/datatype_t",
              "examples": [
                "{\"path\":\"Device.WiFi.SSID.1.SSID\", \"value\":\"test_ssid\", \"datatype\":\"string\"}",
                "{\"path\":\"Device.WiFi.SSID.2.Enable\", \"value\":\"true\", \"datatype\":\"boolean\"}",
                "{\"path\":\"Device.DHCPv4.Relay.Forwarding.1.ClientID\", \"value\":\"0103060C\", \"datatype\":\"hexBinary\"}",
                "{\"path\":\"Device.DHCPv4.Server.Pool.1.LeaseTime\", \"value\":\"120\", \"datatype\":\"int\"}",
                "{\"path\":\"Device.DHCPv4.Relay.Forwarding.1.Order\", \"value\":\"1\", \"datatype\":\"unsignedInt\"}",
                "{\"path\":\"Device.QoS.Queue.1.ShapingRate\", \"value\":\"1002\", \"datatype\":\"long\"}",
                "{\"path\":\"Device.IP.Diagnostics.UploadDiagnostics.TestFileLength\", \"value\":\"1002\", \"datatype\":\"unsignedLong\"}",
                "{\"path\":\"Device.USPAgent.ControllerTrust.Challenge.1.Value\", \"value\":\"01Z3A6YC\", \"datatype\":\"base64\"}",
                "{\"path\":\"Device.ManagementServer.ScheduleReboot\", \"value\":\"2024-08-23T23:59:59Z\", \"datatype\":\"dateTime\"}"
              ]
            },
            "obj_path": {
              "description": "To set multiple values at once, path should be relative to object elements",
              "examples": [
                "{\"path\":\"Device.WiFi.SSID.1.\", \"obj_path\":{\"SSID\":\"test_ssid\",\"Name\":\"test_name\"}}",
                "{\"path\":\"Device.WiFi.SSID.2.\", \"obj_path\":{\"SSID\":\"test_ssid\"}}"
              ],
              "type": "object",
              "properties": {}
            }
          }
        },
        "output": {
          "type": "object",
          "properties": {
            "results": {
              "type": "array",
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "path": {
                      "$ref": "#/definitions/path_t"
                    },
                    "data": {
                      "$ref": "#/definitions/boolean_t"
                    },
                    "fault": {
                      "$ref": "#/definitions/fault_t",
                      "Description": "Any discrepancy in input will result in fault. The type of fault can be identified by fault code"
                    },
                    "fault_msg": {
                      "type": "string",
                      "Description": "Any discrepancy in input will result in fault. The type of fault can be identified by fault code"
                    }
                  },
                  "required": [
                    "path"
                  ]
                }
              ]
            }
          }
        }
      }
    },
    "operate": {
      "title": "Operate handler",
      "description": "Operate on object element provided in path",
      "type": "object",
      "required": [
        "input",
        "output"
      ],
      "properties": {
        "input": {
          "type": "object",
          "required": [
            "path"
          ],
          "properties": {
            "path": {
              "$ref": "#/definitions/operate_path_t"
            },
            "command_key": {
              "type": "string"
            },
            "input": {
              "description": "Input arguments for the operate command as defined in TR-181-2.13",
              "examples": [
                "{\"path\":\"Device.IP.Diagnostics.IPPing\\(\\)\", \"input\":{\"Host\":\"iopsys.eu\"}}"
              ],
              "type": "object",
              "properties": {}
            },
            "optional": {
              "type": "object",
              "properties": {
                "proto": {
                  "$ref": "#/definitions/proto_t"
                }
              }
            }
          }
        },
        "output": {
          "type": "object",
          "properties": {
            "results": {
              "type": "array",
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "path": {
                      "$ref": "#/definitions/path_t"
                    },
                    "data": {
                      "$ref": "#/definitions/boolean_t"
                    },
                    "fault": {
                      "$ref": "#/definitions/fault_t",
                      "Description": "Any discrepancy in input will result in fault. The type of fault can be identified by fault code"
                    },
                    "fault_msg": {
                      "type": "string",
                      "Description": "Any discrepancy in input will result in fault. The type of fault can be identified by fault code"
                    },
                    "output": {
                      "type": "array",
                      "items": [
                        {
                          "type": "object",
                          "properties": {
                            "path": {
                              "$ref": "#/definitions/path_t"
                            },
                            "data": {
                              "$ref": "#/definitions/boolean_t"
                            },
                            "type": {
                              "$ref": "#/definitions/type_t"
                            }
                          }
                        }
                      ]
                    }
                  },
                  "required": [
                    "path",
                    "data"
                  ]
                }
              ]
            }
          }
        }
      }
    },
    "services": {
      "title": "show the list of micro-service registred in the Data Model",
      "type": "object",
      "required": [
        "output"
      ],
      "properties": {
        "intput": {},
        "output": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "Description": "Name of the micro-service ubus object"
            },
            "objects": {
              "type": "object",
              "properties": {
                "parent_dm": {
                  "type": "string",
                  "Description": "Object path where the micro-service object will be added"
                },
                "object": {
                  "type": "string",
                  "Description": "Name of object will be added"
                },
                "proto": {
                  "$ref": "#/definitions/proto_t"
                }  
              }
            },
            "proto": {
              "$ref": "#/definitions/proto_t"
            },
            "unified_daemon": {
              "type": "boolean",
              "Description": "type of micro-service: unified daemon or dm-service"
            }
          }
        }
      }
    }
  }
}
