iguanaServer.lua – Manipulate local or remote Iguana channels from the comfort of the Translator

One of the developers here at iNTERFACEWARE, Luke Walker, and myself have put together a neat Lua module which can manipulate channels on local or remote Iguana instances. We’re excited about the possible applications of this and we hope you are too.

This module will only work when connecting to an Iguana version 5.6 and above (because it uses the new HTTP-based channel API added in Iguana 5.6.1).

Equivalent code could be written and executed in any language to accomplish the same operations (by calling the HTTP Channel API). We provide a Lua module here because we know you all have access to a wonderful Lua IDE (namely, the Translator).

How it Works

The script itself is quite long, so the easiest way to understand it is to include it in your project, call iguanaServer.connect() (help data will be present to guide your typing), and use auto-completion to browse the options available to you.  In other words, type in something like the following:

   local Server = iguanaServer.connect{
      url='192.168.1.12:6543', username='admin', password='password'}
   Server: -- at this point, auto-completion will be a big help

The methods that auto-completion will suggest for you are as follows:

  • listChannels()Returns a XML report with information on the server itself and the channels within it.
  • getChannelConfig()Retrieves the configuration for a channel serialized as XML.
  • removeChannel()Removes a channel from the Iguana server.
  • versionInfo()Returns a table containing version information for the Iguana server.
  • startChannel()Starts a channel in the Iguana server.
  • stopChannel()Stops a channel in the Iguana server.
  • startAllChannels()Starts all channels in the Iguana server.
  • stopAllChannels()Stops all channels in the Iguana server.
  • getDefaultConfig()Returns the default configuration for a channel with the specified components.
  • addChannel()Adds a new channel to the Iguana server.
  • pollChannelStatus()Continuously polls the server until the specified channel reaches a particular status, or until the number of retries is exceeded.
  • cloneChannel()Clones a channel within the same Iguana server or to a remote one.
  • getServerSalt()Retrieves the salt used by the Iguana server for encryption purposes.
  • updateChannel()Updates the configuration of an existing channel.
  • exportProject()Retrieves a zip file containing the contents of a Translator project.
  • importProject()Sets the contents of a Translator project to the contents of a project zip file.
  • saveProjectMilestone()Saves a milestone for the specified Translator project.
  • updateProject()Copies a source Translator project to a destination Translator project.
  • isLive()Returns true if the connection to the Iguana server is “live”.

How to use it:

  1. Download iguanaServer.lua.
  2. Add it to your shared modules in any Translator project.
  3. Made sure to require 'iguanaServer' at the top of your script.
  4. Use the Translator auto-completion to understand the parameters.
  5. Use it as your heart desires to clone, export, import channels, or just their Translator projects.
  6. Feel free to dive into the code and make any changes to suit your needs.  The underlying HTTP API being used should give you all the flexibility you need.

Code

Download the latest “iguanaServer” module from our code repository: iguanaServer.lua.

If you have any feedback or questions please contact us at support@interfaceware.com, or post in our Community Forums.

Leave A Comment?