{
  "code_name": "omada_sdn_openapi",
  "unique_prefix": "OMDSDNOPENAPI",
  "plugin_type": "device_scanner",
  "execution_order" : "Layer_0",
  "enabled": true,
  "data_source": "script",
  "mapped_to_table": "CurrentScan",
  "data_filters": [
    {
      "compare_column": "Object_PrimaryID",
      "compare_operator": "==",
      "compare_field_id": "txtMacFilter",
      "compare_js_template": "'{value}'.toString()",
      "compare_use_quotes": true
    }
  ],
  "show_ui": true,
  "localized": ["display_name", "description", "icon"],
  "display_name": [
    {
      "language_code": "en_us",
      "string": "Omada SDN using OpenAPI"
    }
  ],
  "description": [
    {
      "language_code": "en_us",
      "string": "This plugin imports devices and clients from the Omada SDN (Omada Controller) through the provided OpenAPI."
    }
  ],
  "icon": [
    {
      "language_code": "en_us",
      "string": "<i class=\"fa fa-search\"></i>"
    }
  ],
  "params": [],
  "settings": [
    {
      "function": "RUN",
      "events": ["run"],
      "type": {
        "dataType": "string",
        "elements": [
          { "elementType": "select", "elementOptions": [], "transformers": [] }
        ]
      },

      "default_value": "disabled",
      "options": ["disabled", "once", "schedule", "always_after_scan"],
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "When to run"
        }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "When the scan should run, good option is <code>schedule</code>."
        }
      ]
    },
    {
      "function": "RUN_SCHD",
      "type": {
        "dataType": "string",
        "elements": [
          {
            "elementType": "span",
            "elementOptions": [
              {
                "cssClasses": "input-group-addon validityCheck"
              },
              {
                "getStringKey": "Gen_ValidIcon"
              }
            ],
            "transformers": []
          },
          {
            "elementType": "input",
            "elementOptions": [
              {
                "focusout": "validateRegex(this)"
              },
              {
                "base64Regex": "Xig/OlwqfCg/OlswLTldfFsxLTVdWzAtOV18WzAtOV0rLVswLTldK3xcKi9bMC05XSspKVxzKyg/OlwqfCg/OlswLTldfDFbMC05XXwyWzAtM118WzAtOV0rLVswLTldK3xcKi9bMC05XSspKVxzKyg/OlwqfCg/OlsxLTldfFsxMl1bMC05XXwzWzAxXXxbMC05XSstWzAtOV0rfFwqL1swLTldKykpXHMrKD86XCp8KD86WzEtOV18MVswLTJdfFswLTldKy1bMC05XSt8XCovWzAtOV0rKSlccysoPzpcKnwoPzpbMC02XXxbMC02XS1bMC02XXxcKi9bMC05XSspKSQ="
              }
            ],
            "transformers": []
          }
        ]
      },

      "default_value": "*/5 * * * *",
      "options": [],
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Schedule"
        }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "Only enabled if you select <code>schedule</code> in the <a href=\"#OMDSDNOPENAPI_RUN\"><code>OMDSDNOPENAPI_RUN</code> setting</a>. Make sure you enter the schedule in the correct cron-like format (e.g. validate at <a href=\"https://crontab.guru/\" target=\"_blank\">crontab.guru</a>). For example entering <code>0 4 * * *</code> will run the scan after 4 am in the selected <a onclick=\"toggleAllSettings()\" href=\"#TIMEZONE\"><code>TIMEZONE</code></a>. Will be run NEXT time the time passes."
        }
      ]
    },
    {
      "function": "host",
      "type": {
        "dataType": "string",
        "elements": [
          { "elementType": "input", "elementOptions": [], "transformers": [] }
        ]
      },
      "maxLength": 100,
      "default_value": "",
      "options": [],
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Host URL"
        }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "Specify the host URL of your <code>Omada Controller</code>, including the protocol, eg. <code>https://example.com:1234</code>."
        }
      ]
    },
    {
      "function": "omada_id",
      "type": {
        "dataType": "string",
        "elements": [
          { "elementType": "input", "elementOptions": [], "transformers": [] }
        ]
      },
      "maxLength": 100,
      "default_value": "",
      "options": [],
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Omada ID"
        }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "Provide your <code>Omada ID</code>, which can be found in the <code>OpenAPI</code> section of your <code>Omada Controller</code>."
        }
      ]
    },
    {
      "function": "client_id",
      "type": {
        "dataType": "string",
        "elements": [
          { "elementType": "input", "elementOptions": [], "transformers": [] }
        ]
      },
      "maxLength": 100,
      "default_value": "",
      "options": [],
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Client ID"
        }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "Enter the <code>Client ID</code> generated by your <code>Omada Controller</code> in the <code>OpenAPI</code> section."
        }
      ]
    },
    {
      "function": "client_secret",
      "type": {
        "dataType": "string",
        "elements": [
          {
            "elementType": "input",
            "elementOptions": [{ "type": "password" }],
            "transformers": []
          }
        ]
      },
      "maxLength": 100,
      "default_value": "",
      "options": [],
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Client Secret"
        }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "Input the <code>Client Secret</code> obtained from the <code>OpenAPI</code> section of your <code>Omada Controller</code>."
        }
      ]
    },
    {
      "function": "sites",
      "type": {
        "dataType": "array",
        "elements": [
          {
            "elementType": "input",
            "elementOptions": [
              { "placeholder": "Enter value" },
              { "suffix": "_in" },
              { "cssClasses": "col-sm-10" },
              { "prefillValue": "null" }
            ],
            "transformers": []
          },
          {
            "elementType": "button",
            "elementOptions": [
              { "sourceSuffixes": ["_in"] },
              { "separator": "" },
              { "cssClasses": "col-xs-12" },
              { "onClick": "addList(this, false)" },
              { "getStringKey": "Gen_Add" }
            ],
            "transformers": []
          },
          {
            "elementType": "select",
            "elementHasInputValue": 1,
            "elementOptions": [
              { "multiple": "true" },
              { "readonly": "true" },
              { "editable": "true" }
            ],
            "transformers": []
          },
          {
            "elementType": "button",
            "elementOptions": [
              { "sourceSuffixes": [] },
              { "separator": "" },
              { "cssClasses": "col-xs-6" },
              { "onClick": "removeAllOptions(this)" },
              { "getStringKey": "Gen_Remove_All" }
            ],
            "transformers": []
          },
          {
            "elementType": "button",
            "elementOptions": [
              { "sourceSuffixes": [] },
              { "separator": "" },
              { "cssClasses": "col-xs-6" },
              { "onClick": "removeFromList(this)" },
              { "getStringKey": "Gen_Remove_Last" }
            ],
            "transformers": []
          }
        ]
      },
      "default_value": [],
      "options": [],
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Omada Sites"
        }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "You can enter either the <code>site name</code> or <code>site ID</code>. If an invalid value is provided or neither is specified, the plugin will default to the first accessible site using the supplied credentials."
        }
      ]
    },
    {
      "function": "verify_ssl",
      "type": {
        "dataType": "boolean",
        "elements": [
          {
            "elementType": "input",
            "elementOptions": [{ "type": "checkbox" }],
            "transformers": []
          }
        ]
      },
      "default_value": true,
      "options": [],
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Verify SSL"
        }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "Check this option to enable SSL verification for requests to your Omada Controller's OpenAPI. If unchecked, SSL verification will be disabled."
        }
      ]
    },
    {
      "function": "CMD",
      "type": {
        "dataType": "string",
        "elements": [
          {
            "elementType": "input",
            "elementOptions": [{ "readonly": "true" }],
            "transformers": []
          }
        ]
      },
      "default_value": "python3 /app/front/plugins/omada_sdn_openapi/script.py",
      "options": [],
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Command"
        }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "Command to run. This can not be changed."
        }
      ]
    },
    {
      "function": "RUN_TIMEOUT",
      "type": {
        "dataType": "integer",
        "elements": [
          {
            "elementType": "input",
            "elementOptions": [{ "type": "number" }],
            "transformers": []
          }
        ]
      },
      "default_value": 30,
      "options": [],
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Run timeout"
        }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "Maximum time in seconds to wait for the script to finish. If this time is exceeded the script is aborted."
        }
      ]
    },
    {
      "default_value": [],
      "description": [
        {
          "language_code": "en_us",
          "string": "Send a notification if selected values change. Use <code>CTRL + Click</code> to select/deselect. <ul> <li><code>Watched_Value1</code> is Device Name </li><li><code>Watched_Value2</code> is Parent Node MAC</li><li><code>Watched_Value3</code> is Parent Node Port </li><li><code>Watched_Value4</code> is Parent Node SSID </li></ul>"
        }
      ],
      "function": "WATCH",
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Watched"
        }
      ],
      "options": [
        "Watched_Value1",
        "Watched_Value2",
        "Watched_Value3",
        "Watched_Value4"
      ],
      "type": {
        "dataType": "array",
        "elements": [
          {
            "elementType": "select",
            "elementOptions": [{ "multiple": "true" }],
            "transformers": []
          }
        ]
      }
    },
    {
      "default_value": ["new", "watched-changed"],
      "description": [
        {
          "language_code": "en_us",
          "string": "Send a notification only on these statuses. <code>new</code> means a new unique (unique combination of PrimaryId and SecondaryId) object was discovered. <code>watched-changed</code> means that selected <code>Watched_ValueN</code> columns changed."
        }
      ],
      "function": "REPORT_ON",
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Report on"
        }
      ],
      "options": [
        "new",
        "watched-changed",
        "watched-not-changed",
        "missing-in-last-scan"
      ],
      "type": {
        "dataType": "array",
        "elements": [
          {
            "elementType": "select",
            "elementOptions": [{ "multiple": "true" }],
            "transformers": []
          }
        ]
      }
    }
  ],
  "database_column_definitions": [
    {
      "column": "Index",
      "css_classes": "col-sm-2",
      "show": true,
      "type": "none",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Index"
        }
      ]
    },
    {
      "column": "Object_PrimaryID",
      "mapped_to_column": "cur_MAC",
      "css_classes": "col-sm-3",
      "show": true,
      "type": "device_name_mac",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "MAC Address"
        }
      ]
    },
    {
      "column": "Object_SecondaryID",
      "mapped_to_column": "cur_IP",
      "css_classes": "col-sm-2",
      "show": true,
      "type": "device_ip",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "IP Address"
        }
      ]
    },
    {
      "column": "Watched_Value1",
      "mapped_to_column": "cur_Name",
      "css_classes": "col-sm-2",
      "show": true,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Device Name"
        }
      ]
    },
    {
      "column": "Watched_Value2",
      "mapped_to_column": "cur_NetworkNodeMAC",
      "css_classes": "col-sm-2",
      "show": true,
      "type": "device_name_mac",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Parent Node MAC"
        }
      ]
    },
    {
      "column": "Watched_Value3",
      "mapped_to_column": "cur_PORT",
      "css_classes": "col-sm-2",
      "show": true,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Parent Node Port"
        }
      ]
    },
    {
      "column": "Watched_Value4",
      "mapped_to_column": "cur_SSID",
      "css_classes": "col-sm-2",
      "show": true,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Parent Node SSID"
        }
      ]
    },
    {
      "column": "Extra",
      "mapped_to_column": "cur_Type",
      "css_classes": "col-sm-2",
      "show": false,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Device Type"
        }
      ]
    },
    {
      "column": "Dummy",
      "mapped_to_column": "cur_ScanMethod",
      "mapped_to_column_data": {
        "value": "OMDSDNOPENAPI"
      },
      "css_classes": "col-sm-2",
      "show": false,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Scan method"
        }
      ]
    },
    {
      "column": "DateTimeCreated",
      "css_classes": "col-sm-2",
      "show": true,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Created"
        }
      ]
    },
    {
      "column": "DateTimeChanged",
      "css_classes": "col-sm-2",
      "show": false,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Changed"
        }
      ]
    },
    {
      "column": "HelpVal1",
      "css_classes": "col-sm-2",
      "show": true,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Last Seen"
        }
      ]
    },
    {
      "column": "HelpVal2",
      "mapped_to_column": "cur_NetworkSite",
      "css_classes": "col-sm-2",
      "show": true,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Omada Site"
        }
      ]
    },
    {
      "column": "HelpVal3",
      "css_classes": "col-sm-2",
      "show": true,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "VLAN ID"
        }
      ]
    }
  ]
}
