Files
harmony/opnsense-codegen/fixtures/example_service_ir.json

255 lines
7.1 KiB
JSON

{
"mount": "/example/service",
"description": "Example Service for Codegen Testing",
"version": "1.0.0",
"api_key": "exampleservice",
"root_struct_name": "ExampleService",
"enums": [
{
"name": "LogLevel",
"variants": [
{ "rust_name": "Debug", "wire_value": "debug" },
{ "rust_name": "Info", "wire_value": "info" },
{ "rust_name": "Warn", "wire_value": "warn" },
{ "rust_name": "Error", "wire_value": "error" }
]
},
{
"name": "TagColor",
"variants": [
{ "rust_name": "Red", "wire_value": "red" },
{ "rust_name": "Green", "wire_value": "green" },
{ "rust_name": "Blue", "wire_value": "blue" }
]
}
],
"structs": [
{
"name": "ExampleService",
"kind": "root",
"fields": [
{
"name": "enable",
"rust_type": "Option<bool>",
"serde_with": "opn_bool",
"opn_type": "BooleanField",
"required": false,
"doc": "Enable service"
},
{
"name": "name",
"rust_type": "String",
"opn_type": "TextField",
"required": true,
"doc": "Service name (required)"
},
{
"name": "port",
"rust_type": "Option<u16>",
"serde_with": "opn_u16",
"opn_type": "IntegerField",
"required": false,
"default": "8080",
"min": 1,
"max": 65535,
"doc": "Port number [1-65535] default: 8080"
},
{
"name": "log_level",
"rust_type": "Option<LogLevel>",
"serde_with": "serde_log_level",
"opn_type": "OptionField",
"required": false,
"default": "info",
"enum_ref": "LogLevel",
"doc": "Log level: debug|info|warn|error, default: info"
},
{
"name": "listen_address",
"rust_type": "Option<String>",
"serde_with": "opn_string",
"opn_type": "NetworkField",
"required": false,
"doc": "Listen IP address"
},
{
"name": "interface",
"rust_type": "Option<Vec<String>>",
"serde_with": "opn_csv",
"opn_type": "InterfaceField",
"required": false,
"multiple": true,
"doc": "Bind interfaces (comma-separated)"
},
{
"name": "domain",
"rust_type": "Option<String>",
"serde_with": "opn_string",
"opn_type": "HostnameField",
"required": false,
"doc": "DNS domain name"
},
{
"name": "cache_size",
"rust_type": "Option<u32>",
"serde_with": "opn_u32",
"opn_type": "IntegerField",
"required": false,
"min": 0,
"doc": "Cache size [0-∞)"
},
{
"name": "upstream",
"rust_type": "ExampleServiceUpstream",
"opn_type": "Container",
"required": true,
"field_kind": "container",
"struct_ref": "ExampleServiceUpstream",
"doc": "Upstream DNS settings"
},
{
"name": "hosts",
"rust_type": "HashMap<String, ExampleServiceHost>",
"opn_type": "ArrayField",
"required": false,
"field_kind": "array_field",
"struct_ref": "ExampleServiceHost",
"doc": "Host override entries (keyed by UUID)"
},
{
"name": "tags",
"rust_type": "HashMap<String, ExampleServiceTag>",
"opn_type": "ArrayField",
"required": false,
"field_kind": "array_field",
"struct_ref": "ExampleServiceTag",
"doc": "Tag definitions (keyed by UUID)"
}
]
},
{
"name": "ExampleServiceUpstream",
"kind": "container",
"json_key": "upstream",
"fields": [
{
"name": "dns_servers",
"rust_type": "Option<Vec<String>>",
"serde_with": "opn_csv",
"opn_type": "NetworkField",
"required": false,
"as_list": true,
"doc": "Upstream DNS servers (comma-separated IPs)"
},
{
"name": "use_system_dns",
"rust_type": "bool",
"serde_with": "opn_bool_req",
"opn_type": "BooleanField",
"required": true,
"default": "1",
"doc": "Use system DNS servers (required, default: true)"
}
]
},
{
"name": "ExampleServiceHost",
"kind": "array_item",
"json_key": "hosts",
"fields": [
{
"name": "enabled",
"rust_type": "Option<bool>",
"serde_with": "opn_bool",
"opn_type": "BooleanField",
"required": false,
"default": "1",
"doc": "Entry enabled (default: true)"
},
{
"name": "hostname",
"rust_type": "String",
"opn_type": "HostnameField",
"required": true,
"doc": "Hostname (required)"
},
{
"name": "ip",
"rust_type": "String",
"opn_type": "NetworkField",
"required": true,
"doc": "IP address (required)"
},
{
"name": "tag",
"rust_type": "Option<String>",
"serde_with": "opn_string",
"opn_type": "ModelRelationField",
"required": false,
"relation": {
"source": "OPNsense.Example.ExampleService",
"items": "tags",
"display": "name"
},
"doc": "Associated tag UUID"
},
{
"name": "aliases",
"rust_type": "Option<Vec<String>>",
"serde_with": "opn_csv",
"opn_type": "HostnameField",
"required": false,
"as_list": true,
"doc": "Hostname aliases (comma-separated)"
},
{
"name": "description",
"rust_type": "Option<String>",
"serde_with": "opn_string",
"opn_type": "TextField",
"required": false,
"doc": "Description"
}
]
},
{
"name": "ExampleServiceTag",
"kind": "array_item",
"json_key": "tags",
"fields": [
{
"name": "name",
"rust_type": "String",
"opn_type": "TextField",
"required": true,
"mask": "/^[a-zA-Z0-9_]{1,64}$/",
"constraints": [
{
"type": "UniqueConstraint",
"message": "Tag names must be unique."
}
],
"doc": "Tag name (required, unique, alphanumeric+underscore, 1-64 chars)"
},
{
"name": "color",
"rust_type": "Option<TagColor>",
"serde_with": "serde_tag_color",
"opn_type": "OptionField",
"required": false,
"enum_ref": "TagColor",
"doc": "Tag color: red|green|blue"
},
{
"name": "description",
"rust_type": "Option<String>",
"serde_with": "opn_string",
"opn_type": "TextField",
"required": false,
"doc": "Description"
}
]
}
]
}