<% /*
    $Revision$
    $Id$

    File:           model_apis.inc

    Description:    Api model.
    Parameters:
    Context:

    Notes:
*/

%>
<%
model_apis =
{
    table: "apis",
    primary: "id",
    records_name: "apis",
    record_name: "api",
    fields : { "id"           : {  xxdbs: "fac_usrrap_key",          typ: "varchar",      label: "Api",    filter: "exact" }},

    REST_GET: function _GET(params)
        {
            var autfunction = "WEB_APIDOC"; // is dit niet erg streng?
            params.authparams = user.checkAutorisation(autfunction, null, null, true); // pessimistisch

            var api2_names = [];

            var fullpath = Server.MapPath("./appl/api2");
            var objFso = new ActiveXObject("Scripting.FileSystemObject");
            var objFiles = objFso.GetFolder(fullpath);
            var allFiles = new Enumerator(objFiles.files);
            for (; !allFiles.atEnd(); allFiles.moveNext())
            {
                var attFile = allFiles.item();

                var ext = objFso.GetExtensionName(attFile);
                if ((attFile.name.indexOf("api_") == 0) && (ext == "asp"))
                {
                    var name = attFile.name.substring(4, attFile.name.indexOf(".asp"))
                    api2_names.push({ id: name });
                }
                // Graag zou ik er ook info instoppen over het model zelf.
                // Dan moet ik echter alle model_xxxx.inc bestanden includen wat ik niet wil.
                // Daarom moet je zelf maar /api2/xxxx.api aanroepen voor de details
            }

            return api2_names;
        },
    PUT: function (params) /* update api */
    {
    },
    POST: function (params) /* new api */
    {
    },
    DELETE: function (params) /* delete api */
    {
    },

    search: { autosearch: true },
    list: { default_url: "api2/{0}.scf" }
//    list: { default_url: "api2/{0}.api?pretty=1" }
}
%>