This topic contains 5 replies, has 2 voices, and was last updated by  Eliot Muir 9 years ago.

HTTP API add_channel: New project GUIDs?

  • Hi,
    I’m trying out a new thing now. I’d like to add a new channel to the Iguana instance over the HTTP API.

    In case you’re wondering, here is the code (ugly, but just a proof of concept):

    using (var client = new WebClient())
        var values = InitParams();
        values["config"] = configData;
        var response = client.UploadValues(getUrl("add_channel"), values);
        string configtxt = Encoding.Default.GetString(response);
        MessageBox.Show("Channel added.");
        XPathDocument configdoc = new XPathDocument(new StringReader(configtxt));
        XPathNavigator nav = configdoc.CreateNavigator();
        nav = nav.SelectSingleNode("/channel/from_mapper");
        if (nav == null)
            MessageBox.Show("Cannot read /channel/from_mapper in config.");
        string luaguid = nav.GetAttribute("guid", string.Empty);
        string luamilestone = nav.GetAttribute("milestone", string.Empty);
        values = InitParams();
        values["project"] = encodedData;
        values["guid"] = luaguid;
        response = client.UploadValues(getUrl("import_project"), values);
        values = InitParams();
        values["milestone_name"] = luamilestone;
        values["guid"] = luaguid;
        response = client.UploadValues(getUrl("save_project_milestone"), values);

    With some helper methods:

    private string getUrl(string command)
        string url = string.Format("http://{0}:{1}/{2}", textBoxServer.Text, textBoxPort.Text, command);
        return url;
    private NameValueCollection InitParams()
        var values = new NameValueCollection();
        values["username"] = textBoxUser.Text;
        values["password"] = passwordBox1.Password;
        return values;

    My question is: When I add a new channel, it preservies the channel GUID from the config I give it, but the LUA projects receive a new GUID. I’d like to preserve the GUID, so it is always the same. Is there any way to achieve this?

    Or would I have to stop the Iguana service, add the snippet to IguanaConfiguration.xml myself, and start it again? In this case, I could just as well add the LUA code and the milestone by calling fossil manually, and the HTTP API would be kind of pointless for me.

    Hi Roho,

    Not that we know of. We’ve been working with the Channel API a lot ourselves over the last couple of months. So far it hasn’t seemed to be all that critical to make that a constant.

    If you look our Iguana apps with the channel manager:

    With the channel manager when we serialize out a channel we don’t keep the GUIDs of the translators in the repo. We rename the translator instances based on the name of the channel they are in and the type of translator, for example:

    At some point we’ll probably tweak things so that we stop exporting the translator GUIDs into the GIT altogether since it just creates noise.

    If you are playing with these APIs I suggest starting with the Channel Manager app:

    The Channel Manager app uses this module:

    We spent a bit of time refactoring that piece down to be a very clean implementation – it identifies the translator instances nicely with the function:


    You give a channel configuration to it and it gives you back a nice hash table of the GUIDs of the associated translator instances with different keys for types. It made it possible to write the export relatively elegantly since we could write code like this:

    local TranList =
    for TransType,Guid in pairs(TranList) do
    local Start = os.ts.time()
    local ZipData = BuildTransZip(RepoDir, Definition..'_'..TransType, Guid)
    local EndTime = os.ts.time()
    Api:importProject{project=ZipData, guid=Guid, sample_data='replace', live=true}
    Api:saveProjectMilestone{guid=Guid, milestone_name='Channel Manager ', live=true}

    We put APIs and into Iguana 5.6.5 that do in memory ZIPing and unzipping of the file data from the translators.

    I would recommend working through the channel API over manipulating Fossil directly for a few reasons:

    • You can use the channel API on a live Iguana instance which is pretty sweet for being able to implement things like pushing a channel out to two active-active Iguana instances
    • We’re evolving how the project structure works to make it more flexible and easier to work with. I am hopeful we can actually get the ability for Iguana to work natively with an external repo – GIT would be my first choice since the ecosystem is really impressive – gitHub is pretty amazing.
    • The channel manager is helpful tool moving channels from development, to test and production

    This document gives you a bit of idea of what is possible:

    I would recommend you start playing with the channel manager as a starting point. Heads up – Iguana 5.6.6 which being cut today will have the ability to edit the Javascript, CSS and HTML that is used in the projects.

    We’re open to accepting patches into these apps if it almost does what you want with a tweak or two.

    Hi Eliot,

    thank you for the valuable hints! So probably the project GUIDs are not really important. Even in the project import zip file, the folder can be named “00000000000000000000000000000000”, and it works.

    My approach of revision control is to copy the directory Iguana\edit\admin over into the SVN repository and check it in there. (Unfortunately we are stuck with Svn, no chance to use Git any time soon). And there they are again: subdirectories with the project guids! So it would be a small nuisance if the guids are different. But it is not so bad, because most of the code is in the “shared” directory, and the main.lua files seldom change.

    But still, I guess we’ll prefer the channel API over fossil manipulation, for the reasons you mentioned. (Also: Fossil manipulation needs admin rights to write under “C:\Program Files”!)

    Only on our Continuous Integration build server, I don’t think we’ll install a running Iguana instance. There, our MSBuild solution which bakes the SQLite file by hand works fine.

    Also, I’d love to visit you in Toronto, but it’s a bit far away. A pity! Perhaps you plan to visit Europe some time?

    Kind regards


    Some time – I get out there now and then… can’t in all places at all times 😉

    That approach will work too.

You must be logged in to reply to this topic.