Atomia Billing System developer guide

Admin panel scripting guide

38 views 0

Overview

The Admin Panel contains a scripting facility allowing you to run short scripts written in IronPython with easy access to the Atomia APIs.

Script console

The script console allows you to type and run the scripts in the browser without saving them anywhere. The script can be an arbitrary IronPyton script. When the script starts API proxy objects for easily accessing Atomia APIs are available without doing anything special. These objects are currently:

  • accountApi
  • billingApi
  • coreApi
  • userApi

Often an API method will take some class defined in the .NET class library as parameter, since we are using the .NET proxy objects generated from the WSDL of the APIs. Some examples for how to create such parameters are:

  • Guid
    import System
    
    guidvar = System.Guid("ae20d2c2-4bf5-46b7-ba5c-95b37fa28507")
    
  • Dictionary<string,string>
    from System.Collections.Generic import Dictionary
    dictvar = Dictionary[str,str](somepythondict)
    
  • List<string>
    from System.Collections.Generic import List
    listvar = List[str](['a','list','of','strings'])
    

A simple example script showing how to use the scripting system follows, you can find more examples at the script archive:

import System

accountId = System.Guid("dd20d2c2-4bf5-46b7-ba5c-95b37fa28507")
subscriptionId = System.Guid("ae20d2c2-4bf5-46b7-ba5c-95b37fa28507")
account = billingApi.GetAccountById(accountId)
subscription = billingApi.GetSubscriptionById(subscriptionId, account)

print "Subscription status is " + subscription.State

Local scripts

In the local script section of the scripting facility all scripts stored on the local drive of the Admin Panel server is showed and can be easily executed. The files should be placed in C:\Program Files (x86)\Atomia\AdminPanel\App_Data\LocalScripts, and should contain a header with some metadata for the script, such as author and description. This header also contains a list of the parameters that the script expects. When the script is executed the user is asked for values for these parameters and the parameters are then available as variables with the same name once the script executes.

You can find an example script in the script library.

Script library

The script library works exactly like the local scripts section, i.e. the parameters are populated in the same way, the metadata is stored in the same, etc. The only difference is that the available scripts are found by accessing https://github.com/atomia/atomia-script-library in realtime. You are welcome to submit your scripts as pull requests for this repository to make them available to other Atomia users.

Was this helpful?