The Web Services API

The web services interface is provided at ws.aculabcloud.net:443 for programmatic access to several features on cloud.aculab.com. Including invoking outbound services and managing files. This interface is separate from the call channel API and should not be confused with it.

The web services API requires a set of information that is used for authorisation purposes; the Aculab Cloud region ID for your cloud region, your Aculab Cloud username and your password. When invoking an outbound service, the password you supply will be the one that is associated with the outbound service. For the other web services commands, your password will be the password for cloud.aculab.com.

The web services API can also be used to reserve large conferences, manage your inbound telephone numbers, retrieve information about your application instances and generate reports on your call traffic.

Web services samples

This document and the samples it refers to is for version 2 of the web services API.

The samples are provided in the samples_ws directory of the API package you downloaded and installed. On Windows this might be C:/Python27/Lib/site-packages/UAS/samples_ws. In this directory you will find the following files:

  • ws_connect.py, connect to cloud.aculab.com
  • ws_command.py, run a web-services command
  • list_files.py, list your media files
  • delete_files.py, delete one or more media files
  • download_file.py, download a media file
  • upload_file.py, upload a local media file to cloud.aculab.com
  • rename_file.py, rename a media file
  • download_monitor_file, download an outbound application’s monitor file
  • list_monitor_files, list an outbound application’s monitor files
  • invoke_outbound_service.py, invoke an outbound service
  • get_application_instance_result.py, get the result of an application run
  • wakeup_call.py, a wakeup call sample
  • wakeup_call.cfg, the wakeup call sample configuration file
  • manage_conferences.py, manage your conferences, including reserving a large conference on the cloud
  • manage_telephone_numbers.py, purchase PSTN telephone numbers
  • manage_sms_messages.py send and receive SMS messages
  • uas_monitor.py, monitor the UAS connection status
  • manage_reports.py, generate and download reports on your call traffic

Please have a look at the sample code, it is intended to be an aide to understanding the web services API.

ws_connect

This python module provides a sample for the web services API that is used to create an HTTP connection to Aculab Cloud.

For authentication we need to supply a username and a password.

When invoking outbound services, the outbound service name is appended to the username, separated by a ‘/’; for example user.name@domain.com/wakeup_call. In addition, the Aculab Cloud region ID is prepended to this, for example 1-2-0/user.name@domain.com/wakeup_call.

Note that the password provided is the outbound service password, not your Aculab Cloud password.

For other web-services operations the username is in the format region ID/username for example, 0-2-0/user.name@domain.com for Aculab Cloud Western Europe.

The password is your Aculab Cloud password.

ws_connect(username, password, target)

Create an HTTP connection to Aculab Cloud.

Required arguments:
  • username
    Your Aculab Cloud username.
  • password
    Your Aculab Cloud password or, when invoking an outbound service, your outbound service password.
  • target
    The Aculab Cloud region ID.

Returns a tuple of the connection object and the HTTP headers.

Usage example:

from samples_ws.ws_connect import ws_connect

connection, headers = ws_connect("username", "password", "1-2-0")

ws_command

This module is used by the samples to send a web-services request. It returns the response, or prints an error and returns None.

ws_command(connection, headers, type, page, contents='')

Send a web-services request to Aculab Cloud.

Required arguments:
  • connection
    The connection to Aculab Cloud as previously made with ws_connect.
  • headers
    The headers as returned by ws_connect.
  • type
    The request type: GET or POST.
  • contents
    If the type is POST, the contents of the request.

Returns the response.

For an overview of the web services offered please see the online documentation.

The file samples

These samples will each run one of the file operations
  • delete a file
  • download a file
  • upload a file
  • list files
  • rename files

The samples will prompt for some basic authentication and configuration information and then connect and run the web-services command. Some of these samples will ask for a file type. The type can be media or rest. Choose rest if you are working on REST application log files, choose media for WAV or TIFF files. When uploading a file, you will be asked whether the file is encrypted. When uploading a file, it will be checked for compatibility. Naturally, if the file is encrypted, this check can’t be done. So when uploading an encrypted file choose T when asked whether the file is encrypted so that the check will be skipped, otherwise the check will fail.

For these samples it is important that you also read the section about media files which describes some of the characteristics of the media file store on cloud.aculab.com.

For more information regarding working with files please read the online documentation.

  • The delete_files sample

    This python module provides a wrapper for the web-services API that is used to delete one or more files from Aculab Cloud.

    Note: it is important to be familiar with the notion of “eventual consistency” when working with files. Please read the section on “Working with media files” in the documentation. Due to the nature of “eventual consistency” it is possible for the web services file_list command to return the names of files that have recently been deleted.

    If run from the command line, this module will ask for the name of the file to delete, the Aculab Cloud region ID (for example 0-2-0 for Europe), and your Aculab Cloud username and password.

    delete_files(target, username, password, file_prefix, file_type='media')

    Delete files from your Aculab Cloud file store.

    Required arguments:
    • target
      The Aculab Cloud region (e.g. 1-2-0).
    • username
      Your Aculab Cloud username.
    • password
      Your Aculab Cloud password.
    • file_prefix
      The file to delete. This can be the whole file name or the first few characters followed by a *.
    Optional argument:
    • file_type
      There are two file types, ‘rest’ and ‘media’. These correspond to the two tabs on the File Management page on cloud.aculab.com.

    If file_prefix does not end on a star, it MUST be an exact match of the whole name of the file that you want to delete; only one file will be deleted. If file_prefix does end on a *, it can be just the first few characters of the name of the file or directory that you want to delete; but beware, ALL files and directories that match the prefix will be deleted. To delete every single file and directory, just provide *.

    Prints the result of the delete action. Returns the number of files deleted

    Usage example:

    from samples_ws.delete_files import delete_files
    
    number_deleted = delete_files("1-2-0", "username", "password", "new_remote_file_name.wav", "media")
    
  • The download_file sample

    This python module provides a wrapper for the web services API that is used to download files from your Aculab Cloud file store.

    If run from the command line, this module will ask for the name of the file to download, the name to give the file locally, the Aculab Cloud region ID (for example 0-2-0 for Europe), and your Aculab Cloud username and password.

    download_file(target, username, password, remote_file_name, file_type='media')

    Download a file from your Aculab Cloud file store.

    Required arguments:
    • target
      The Aculab Cloud region (e.g. 1-2-0).
    • username
      Your Aculab Cloud username.
    • password
      Your Aculab Cloud password.
    • remote_file_name
      The name of the file to download.
    Optional argument:
    • file_type
      There are two file types, ‘rest’ and ‘media’. These correspond to the two tabs on the File Management Page at cloud.aculab.com. Choose ‘rest’ to download a REST application log file, choose ‘media’ to download a WAV or TIFF file.

    Returns the file data or None.

    Usage example:

    from samples_ws.download_file import download_file
    
    data = download_file("1-2-0", "username", "password", "remote_file_name.wav", "media")
    if data is not None:
        with open("new_local_file_name.wav", "wb") as fp:
            fp.write(data)
    
  • The list_files sample

    This python module provides a wrapper for the web services API that is used to retrieve a list of the files currently stored in your Aculab Cloud file store.

    Note: it is important to be familiar with the characteristics of your media file storage when working with files. Please read the section on “Working with media files” in the documentation. It is possible for the web services file_list command to return the names of files that have been recently deleted.

    If run from the command line, this module will ask for the prefix of the files to list. By default it will list all your files.

    It will then ask for the maximum number of files to list and the index from which to start listing.

    Finally, it will ask for the Aculab Cloud region ID (for example 0-2-0 for Europe) and your Aculab Cloud username and password.

    list_files(target, username, password, file_prefix='', max_count=None, starting_index=None, file_type='media')

    List files in your Aculab Cloud file store.

    Required arguments:
    • target
      The Aculab Cloud region (e.g. 1-2-0).
    • username
      Your Aculab Cloud username.
    • password
      Your Aculab Cloud password.
    Optional arguments:
    • file_prefix
      Filter the file names to list. This can be the first few characters followed by a *.
    • max_count
      The maximum number of files to list, the default is ten thousand and that is also the absolute maximum.
    • starting_index
      The index of the first file to list, if there are more than max_count files to list use this to skip to the next batch.
    • file_type
      There are two file types, ‘rest’ and ‘media’. These correspond to the two tabs on the File Management page on cloud.aculab.com. Choose ‘rest’ to list the REST application log files, choose ‘media’ to list WAV or TIFF files.

    Returns the dictionary of file entries.

    Usage example:

    from samples_ws.list_files import list_files
    
    file_entries = list_files("1-2-0", "username", "password", file_type= "media")
    if file_entries is not None:
        for name, details in sorted(file_entries.items()):
            print("Name: {0} Size: {1}".format(name, details['size']))
    
  • The rename_file sample

    This python module provides a wrapper for the web services API that is used to rename files in your Aculab Cloud file store.

    If run from the command line, this module will ask for the name of the file to rename; the new name to give the file; the Aculab Cloud region ID (for example 0-2-0 for Europe); and your Aculab Cloud username and password.

    rename_file(target, username, password, from_file_name, to_file_name, file_type='media')

    Rename a file in your Aculab Cloud file store.

    Required arguments:
    • target
      The Aculab Cloud region (e.g. 1-2-0).
    • username
      Your Aculab Cloud username.
    • password
      Your Aculab Cloud password.
    • from_file_name
      The name of the file you want to rename.
    • to_file_name
      The new name you want to give the file
    Optional argument:
    • file_type
      There are two file types, ‘rest’ and ‘media’. Only media is currently supported for file rename.

    Returns True or False.

    Usage example:

    from samples_ws.rename_file import rename_file
    
    rename_file("1-2-0", "username", "password", "remote_file_name.wav", "new_remote_file_name.wav", "media")
    
  • The upload_file sample

    This python module provides a wrapper for the web services API that is used to upload files to your Aculab Cloud.

    If run from the command line, this module will ask for the name of the file to upload; the name to give the file on Aculab Cloud; the Aculab Cloud region ID (for example 0-2-0 for Europe); and your Aculab Cloud username and password.

    upload_file(target, username, password, local_file_name, remote_file_name, file_type='media', file_encrypted=False)

    Upload a file to your Aculab Cloud file store.

    Required arguments:
    • target
      The Aculab Cloud region (e.g. 1-2-0).
    • username
      Your Aculab Cloud username.
    • password
      Your Aculab Cloud password.
    • local_file_name
      The name of the file that will be uploaded.
    • remote_file_name
      The name to be given to the file on Aculab Cloud.
    Optional argument:
    • file_type
      There are two file types, ‘rest’ and ‘media’. Only media is currently supported for file upload.
    • file_encrypted
      Indicate whether the file is encrypted. True or False

    Returns True or False.

    Usage example:

    from samples_ws.upload_file import upload_file
    
    upload_file("1-2-0", "username", "password", "local_file_name.wav", "remote_file_name.wav")
    

The monitor files samples

These samples can be used to list or download monitor files. Monitor files are the recordings generated by monitoring outbound calls from a particular application instance.

For more information regarding monitoring please have a look at the online documentation.

  • The download_monitor_file sample

    This python module provides a wrapper for the web services API that is used to download the recordings generated by monitoring outbound calls on Aculab cloud.

    If run from the command line, this module will ask for the name of the file to download; the name to give the file locally; the Aculab Cloud region ID (for example 0-2-0 for Europe); and your Aculab Cloud username and password.

    download_monitor_file(cloud_id, username, password, file_name)

    Download the a particular monitor file.

    Required arguments:
    • cloud_id
      The Aculab Cloud region (e.g. 1-2-0).
    • username
      Your Aculab Cloud username.
    • password
      Your Aculab Cloud password.
    • file_name
      The name of the file to download.

    Returns the file data.

    Usage example:

    from samples_ws.download_monitor_file import download_monitor_file
    
    data = download_monitor_file("1-2-0", "username", "password", "file_name")
    
    if data is not None:
        with open("new_local_file_name.wav", "wb") as fp:
            fp.write(data)
    
  • The list_monitor_files sample

    This python module provides a wrapper for the web services API that is used to list the recordings generated by monitoring outbound calls on Aculab Cloud.

    If run from the command line, this module will ask for the application instance ID; the Aculab Cloud region ID (for example 0-2-0 for Europe); and your Aculab Cloud username and password.

    list_monitor_files(cloud_id, username, password, application_instance_id)

    List the monitor files for a particular application instance.

    Required arguments:
    • cloud_id
      The Aculab Cloud region (e.g. 1-2-0).
    • username
      Your Aculab Cloud username.
    • password
      Your Aculab Cloud password.
    • application_instance_id
      The id of the application for which to list the files.

    Returns the dictionary of file entries.

    Usage example:

    from samples_ws.list_monitor_files import list_monitor_files
    
    file_entries = list_monitor_files("1-2-0", "username", "password", "application_instance_id")
    
    if file_entries is not None:
        for file_name, file_info in sorted(file_entries.items()):
            print("File: {0}".format(file_name))
            for key, value in sorted(file_info.items()):
                print("    {0} : {1}".format(key, value))
    

The invoke outbound service sample

The web-services API provides the ability to start an outbound service. Typically, this will be used to place an outbound call. For more information on making outbound calls please browse the online documentation.

This python module provides a wrapper for the web-services API that is used to invoke an outbound service on Aculab Cloud. If run from the command line, this sample application will ask for the name of the outbound service you want to invoke. The outbound service will already have been registered on the Outbound Services page at cloud.aculab.com.

After entering the name of the outbound service you want to invoke, you will be asked to enter the outbound service parameters. What you need to enter here will depend on the application that will be started as a result of invoking the service, the string will be passed to the application’s main function via the outbound_parameters argument.

You will then be asked how many instances of the service you want to invoke. Typically, if the application registered to this service is going to ring a PSTN number, you would enter 1.

You will then be asked to enter the Aculab Cloud region. When connecting to a cloud region, enter it as the Cloud ID. For example, 0-2-0 is the ID for the Europe and 1-2-0 is the ID for USA-East.

Next is your Aculab Cloud username.

Finally you will be asked for the password that you assigned to the outbound service you want to invoke. This is not necessarily the same as your Aculab Cloud password - each outbound service should have its own password.

This sample will then attempt to invoke the outbound service.

Once the application has finished running, the sample will print a list of application instance IDs (one for each instance you started). These IDs are unique to each application instance and can be used to gather more information about each application run. The get_application_instance_result sample shows how to use the IDs.

For more details on placing outbound calls on Aculab cloud please refer to https://cloud.aculab.com/documents/outbound_pstn

invoke_outbound_service(target, username, service_name, service_password, outbound_parameters=None, number_instances=1)

Invoke one or more instances of an outbound service.

Required arguments:
  • target
    The Aculab Cloud region (e.g. 1-2-0).
  • username
    Your Aculab Cloud username.
  • service_name
    The name of the outbound service you want to invoke.
  • service_password
    Your outbound service password as set on the outbound services web page.
Optional arguments:
  • outbound_parameters
    The string of arguments you want passed to the outbound application that will be triggered by the outbound service.
  • number_instances
    The number of instances of the outbound service that you want to start.

The function will monitor the status of each outbound instance that was invoked. It will continue to monitor the instances until they have all been completed.

Returns a list of application instance IDs.

Usage example:

from samples_ws.invoke_outbound_service import invoke_outbound_service
application_instance_ids = invoke_outbound_service("1-2-0", "username", "service_name", "service_password", "outbound parameters", 1)

The get application instance result sample

The web-services API provides the ability to query the status of an inbound or outbound application. More information on using this API is available in the online documentation.

This python module provides a wrapper for the web services API that is used to query application IDs.

If run from the command line, this sample will use the application instance IDs provided to get more information about each application run.

The sample will first ask for a list of the application instance IDs to query. This will be given as a string of IDs with a ; as the delimiter.

Then you will be asked for the Aculab Cloud region ID.

Next you will be asked for your Aculab Cloud username.

And finally you will be asked to enter your Aculab Cloud password. This is not necessarily the same as the outbound service password that you used when invoking the service with invoke_outbound_service.

The application will print the start time and duration for each instance you are querying. But other information is also available.

get_outbound_service_results(target, username, password, application_instance_ids)

Get outbound service results.

Required arguments:
  • target
    The Aculab Cloud region (e.g. 1-2-0).
  • username
    Your Aculab Cloud username.
  • password
    Your Aculab Cloud password.
  • application_instance_ids
    A string of application instance ids using ; as the delimiter.

From the large amount of information that is returned for each application instance ID, this function will retrieve and print the start time, duration and application exit status.

Usage example:

from aculab.web_services.get_outbound_service_results import get_outbound_service_results
get_outbound_service_results("1-2-0", "username", "password", "01ea90ba4f7d54bb.797020")

The UAS monitor sample

The web-services API provides the ability to manage, request and retrieve reports from Aculab Cloud. More information regarding managing your reports is available here.

This python module connects to your UAS. It polls the UAS every 30 seconds for its Aculab Cloud connection statistics. These are simple statistics that represent the responsiveness of the UAS connections. The responsiveness is measured as the round trip time in seconds taken for a message between the UAS and Aculab Cloud. Presented are the Maximum, Minimum and Average time measured in seconds.

A guideline on interpreting the statistics is as follows:

  • Minimum: less than 1 is good, 1 to 2 is OK, more than 2 is bad.
  • Maximum: less than 5 is good, 5 to 10 OK, more than 10 is bad.
  • Average: less than 2 is good, 2 to 4 is OK, more than 4 is bad.

The information returned by the UAS is a JSON format object of the following:

[
    {
        "cloudid"   : "0-2-0",
        "minrespt"  : "0.02",
        "maxrespt"  : "0.15",
        "meanrespt" : "0.12"
    }
    {
        ...
    }
    ...
]

In Python terms this is a list of dictionaries, where each dictionary holds the statistics for a single cloud connection. There can be more than one connection per cloud region.

  • cloudid is the id of the cloud connection, for example 0-2-0 is the European cloud.
  • minrespt is the minimum response time recorded.
  • maxrespt is the maximum response time seen.
  • meanrespt is the average response time seen.
uas_monitor(ip_addr='localhost', port=38001)

Poll the UAS every 30 seconds for its connection statistics.

Optional arguments:
  • ip_addr
    Your UAS IP address. Default is localhost.
  • port
    Your UAS listening port. Default is 38001.

Prints the connection statistics every 30 seconds.

Usage example:

from samples_ws.uas_monitor import uas_monitor
uas_monitor()

The manage reports sample

The web-services API provides the ability to manage, request and retrieve reports from Aculab Cloud. For more information regarding reports please have a look at the sample and also refer to the online documentation.

This python module provides a sample for the web services API that is used to manage your reports. The following tasks are available:

  • Start a report.
  • Check the status of reports in progress.
  • Cancel a report in progress.
  • List available completed reports.
  • Download a completed report.
  • Delete a completed report.

Each of the above tasks is wrapped in its own function.

When run from the command line, this module takes a single argument that identifies which task (function) to run. The argument can be one of the following:

  • start to initiate a report.
  • progress to check the status of reports in progress
  • cancel to cancel a Report in progress
  • list to list available completed Reports
  • get to download a completed Report
  • delete to delete a completed Report

The module will also ask for the Aculab Cloud region ID (for example 0-2-0 for Europe) and your Aculab Cloud username and password.

In addition, when run from the command line, this module will read a configuration file manage_reports.cfg. The configuration file has arguments for each of the above tasks, for instance, the start task takes a report type, starting date and ending date. Please see the configuration file for more details.

report_cancel(connection, headers, report_name)

Stop generating a report.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • report_name
    The report’s file name as given by start_report.

Returns nothing.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_reports import report_cancel

connection, headers = ws_connect("username", "password", "1-2-0")
report_cancel(connection, headers, "1-2-0_bob.smith@home.com_adr_2014-07-21_16:00:00_2014-07-21_18:00:00.csv")
report_delete(connection, headers, report_name)

Delete a report.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • report_name
    The name of the report to delete.

Returns nothing.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_reports import report_delete

connection, headers = ws_connect("username", "password", "1-2-0")
report_delete(connection, headers, "1-2-0_bob.smith@home.com_adr_2014-07-21_16:00:00_2014-07-21_18:00:00.csv")
report_get(connection, headers, report_name, local_report_name)

Download a report.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • report_name
    The name of the report to download.
  • local_report_name
    The file name to which to write the downloaded report.

Writes the report file data..

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_reports import report_get

connection, headers = ws_connect("username", "password", "1-2-0")
report_get(connection, headers, "1-2-0_bob.smith@home.com_adr_2014-07-21_16:00:00_2014-07-21_18:00:00.csv", "my_file.csv")
report_list(connection, headers)

List the available reports.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.

Prints the name, modification date and size in bytes.

Returns the data.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_reports import report_list

connection, headers = ws_connect("username", "password", "1-2-0")
report_list(connection, headers)

Output example:

Name: 1-2-0_bob.smith@home.com_adr_2014-10-28_00:00:00_2014-10-28_23:59:59.csv
        Modified: 2014-10-28_15:19:43
        Size: 970
Name: 1-2-0_bob.smith@home.com_adr_2014-07-21_16:00:00_2014-07-21_18:00:00.csv
        Modified: 2014-07-22_14:29:36
        Size: 28863633
report_progress(connection, headers)

Get report generation progress.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.

Prints the result.

Returns the data.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_reports import report_progress

connection, headers = ws_connect("username", "password", "1-2-0")
report_progress(connection, headers)

Output example:

Name: 1-2-0_bob.smith@home.com_cdr_2014-11-10_09:00:00_2014-11-11_10:00:00.csv
        Record: 151
        Progress: 31.79%
start_report(connection, headers, report_type, from_date, to_date)

Start generating a report.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • report_type
    The type of report to generate. One of adr, cdr or err.
  • from_date
    The date from which to start generating the report. In the format YYYY-MM-DD_hh:mm:ss UTC (Coordinated Universal Time), for example 2014-07-10_13:30:00
  • to_date
    The date at which to stop generating the report. In the format YYYY-MM-DD_hh:mm:ss UTC (Coordinated Universal Time), for example 2014-07-10_17:30:00

Returns the report file name.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_reports import start_report

connection, headers = ws_connect("username", "password", "1-2-0")
report_file = start_report(connection, headers, "cdr", "2014-07-10_13:30:00", "2014-07-10_17:30:00")
print("Report file: {0}".format(report_file))

manage_telephone_numbers

The web-services API provides the ability to purchase and delete inbound telephone numbers. For more information regarding purchasing numbers please have a look at the sample and also look at the online documentation.

This python module provides a sample for the web services API that is used to manage your telephone numbers.

The following tasks are available:

  • List the countries for which PSTN (public switched telephone network) numbers can be bought.
  • For a given country, list the states for which numbers can be bought.
  • For a given country and state, list the regions for which numbers can be bought.
  • List the numbers that you have purchased. Country, state and region information can be provided to filter the list.
  • List any addresses you have registered.
  • Delete one or more numbers that you own.
  • Purchase an inbound number.

Each of the above tasks is wrapped in its own function.

When run from the command line, this module takes a single argument that identifies which task (function) to run. The argument can be one of the following:

  • list_countries to list the countries for which PSTN numbers can be bought.
  • list_states for a given country list the states for which numbers can be bought. Note, not all countries have states.
  • list_regions for the given country and state, list the regions for which numbers can be bought. All countries have regions.
  • list_numbers list the numbers that you have purchased. Country, state and region information can be provided to filter the list.
  • list_regulation_addresses list any addresses you have registered. Some countries require an address to be registered with any phone number you buy.
  • delete delete one or more numbers that you own.
  • purchase to purchase an inbound number.
  • purchasedev to purchase an inbound number during development. This will not return a real number.

The module will also ask for the Aculab Cloud region ID (for example 0-2-0 for Europe); and your Aculab Cloud username and password.

In addition, when run from the command line, this module will read a configuration file manage_telephone_numbers.cfg. The configuration file has arguments for each of the above tasks, for instance, the list_states task takes a country name. Please see the configuration file for more details.

delete_numbers(connection, headers, numbers)

Delete one or more of your numbers.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • numbers
    The numbers you want to delete. A string of comma separated telephone numbers.

Prints the result of each delete task.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_telephone_numbers import delete_numbers

connection, headers = ws_connect("username", "password", "1-2-0")
delete_numbers(connection, headers, '123456789')

Output example:

Your numbers were successfully deleted.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_telephone_numbers import delete_numbers

connection, headers = ws_connect("username", "password", "1-2-0")
delete_numbers(connection, headers, '123456789, 123456799')

Output example:

The following numbers were not deleted:
123456799 : Telephone number 123456799 does not belong to you. see https://cloud.aculab.com/documents/cnws_errors?error=0300 for more information : Code 0300
list_countries(connection, headers, did_type='geographic')

List the countries for which numbers can be bought.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
Optional argument:
  • did_type
    The type of number required - geographic, national or tollfree.

Prints the list of countries.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_telephone_numbers import list_countries

connection, headers = ws_connect("username", "password", "1-2-0")
list_countries(connection, headers)

Output example:

Argentina, Australia, Belgium, Brazil, Bulgaria, Canada, Chile, Croatia,
Cyprus, Czech Republic, Denmark, Dominican Republic, El Salvador, Finland,
France, Georgia, Germany, Greece, Hungary, Ireland, Israel, Italy, Japan,
Latvia, Lithuania, Luxembourg, Mexico, Netherlands, New Zealand, Norway, Peru,
Poland, Puerto Rico, Romania, Slovakia, Slovenia, South Africa, Spain, Sweden,
Switzerland, United Kingdom, United States
list_numbers(connection, headers, country=None, state=None, region=None)

List your numbers. Can be filtered by country, state and region.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
Optional arguments:
  • country
    The country for which to list the numbers.
  • state
    The state for which to list the numbers.
  • region
    The region for which to list the numbers.

Prints the list of numbers along with the country, region, date purchased and cost per month in US Dollars.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_telephone_numbers import list_numbers

connection, headers = ws_connect("username", "password", "1-2-0")
list_numbers(connection, headers)

Output example:

19722849999     United States   DALLAS          2013-04-15 3.00
46844680555     Sweden          STOCKHOLM       2013-04-15 3.00

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_telephone_numbers import list_numbers

connection, headers = ws_connect("username", "password", "1-2-0")
list_numbers(connection, headers, "Sweden", region="Stockholm")

Output example:

46844680555     Sweden          STOCKHOLM       2013-04-15 3.00

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_telephone_numbers import list_numbers

connection, headers = ws_connect("username", "password", "1-2-0")
list_numbers(connection, headers, "United States", "Texas", "Dallas")

Output example:

19722849999     United States   DALLAS          2013-04-15 3.00
list_regions(connection, headers, country, state=None, did_type='geographic')

For a given country and state, list the regions for which numbers can be bought.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • country
    The country for which to list the regions.
Optional arguments:
  • state
    The state for which to list the regions. Not all countries have states.
  • did_type
    The type of number required - geographic, national or tollfree.

Prints the list of regions.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_telephone_numbers import list_regions

connection, headers = ws_connect("username", "password", "1-2-0")
list_regions(connection, headers, "France")

Output example:

Aix-En-Provence, Amiens, Angers, Annecy, Arles, Auray, Avignon, Beauvais, Belfort,
Besancon, Beziers, Blois, Bobigny, Bordeaux, Boulogne-Billancourt, Bourges, Brest,
Caen, Calais, Cannes, Carhaix-Plouguer, Cergy, Chalon-Sur-Saone, Chambery,
Charleville-Mezieres, Cholet, Clermont-Ferrand, Colmar, Corbeil-Essones, Corse,
Creteil, Dijon, Dreux, Dunkerque, Enghien-Les-Bains, Evreux, Grenoble,
La Roche-Sur Yon, Laval, Le Havre, Le Mans, Le Raincy, Lille, Limoges, Lyon,
Marseille, Meaux, Metz, Moissac, Montauban, Montpellier, Mulhouse, Nancy, Nanterre,
Nantes, Nice, Nimes, Niort, Orleans, Paris, Pau, Perpignan, Poitiers, Reims, Rennes,
Rouen, Saint-Etienne, Saint-Germain-En-Laye, Saint-Malo, Saint-Nazaire,
Saint-Quentin, Sarcelles, Strasbourg, Toulon, Toulouse, Tours, Troyes, Tulle, Vannes,
Versailles, Vesoul

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_telephone_numbers import list_regions

connection, headers = ws_connect("username", "password", "1-2-0")
list_regions(connection, headers, "United States", "Michigan")

Output example:

Ann Arbor, Auburn Heights, Battle Creek, Belleville, Birmingham, Center Line,
Commerce, Detroit Zone 01, Detroit Zone 02, Detroit Zone 03, Detroit Zone 04,
Detroit Zone 06, Farmington, Flint, Grand Rapids, Howell, Pontiac, Port Huron,
Romulus, Roseville, Royal Oak, Trenton, Troy, Utica
list_regulation_addresses(connection, headers)

List your regulation addresses.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.

Prints your regulation addresses.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_telephone_numbers import list_regulation_addresses

connection, headers = ws_connect("username", "password", "1-2-0")
list_regulation_addresses(connection, headers)

Output example:

My French Place      Paris          France
My German Cottage    Berlin         Germany
list_states(connection, headers, country)

For a given country, list the states for which numbers can be bought.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • country
    The country for which to list the states.

Prints the list of states.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_telephone_numbers import list_states

connection, headers = ws_connect("username", "password", "1-2-0")
list_states(connection, headers, "Canada")

Output example:

Alberta, British Columbia, Manitoba, New Brunswick, Newfoundland And Labrador,
Nova Scotia, Ontario, Prince Edward Island, Quebec, Saskatchewan
purchase_development_number(connection, headers, country, state=None, region=None, quantity=1, allow_partial=False, base_on_service=None, regulation_address=None, did_type='geographic', allow_landline=False, allow_cellular=False, allow_payphone=False)

Purchase an inbound number. This is to help with development and will not return a real telephone number

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • country
Optional arguments:
  • state
    To restrict the number to a particular state.
  • region
    To restrict the number to a particular region.
  • quantity
    How many numbers to buy. Defaults to 1.
  • allow_partial
    Determines whether the purchase succeeds even if the requested quantity of telephone numbers is not available. Defaults to False.
  • base_on_service
    The name of an existing inbound service. If set, a new inbound service will be created for each new number purchased, based on the settings of this service.
  • regulation_address
    The name of a regulation address that exists on the cloud account used for the purchase. Some countries require a regulation address to be specified.
  • did_type
    The type of each new number - geographic, national or tollfree.
  • allow_landline
    For toll free numbers only, allow calls from landlines. Otherwise calls from landlines are blocked.
  • allow_cellular
    For toll free numbers only, allow calls from mobile phones. Otherwise calls from mobile phones are blocked.
  • allow_payphone
    For toll free numbers only, allow calls from payphones. Otherwise calls from payphones are blocked.

Prints the result of the purchasing task.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_telephone_numbers import purchase_development_number

connection, headers = ws_connect("username", "password", "1-2-0")
purchase_development_number(connection, headers, country="United States", region="Dallas")

Output example:

Number: 19725877455

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_telephone_numbers import purchase_development_number

connection, headers = ws_connect("username", "password", "1-2-0")
purchase_development_number(connection, headers, country="Sweden", region="Stockholm", quantity=2)
Output example::
Number: 33249880328 Number: 33249880410
purchase_number(connection, headers, country, state=None, region=None, quantity=1, allow_partial=False, base_on_service=None, regulation_address=None, did_type='geographic', allow_landline=False, allow_cellular=False, allow_payphone=False)

Purchase an inbound number.

Please see purchase_development_number for further details.

The manage conferences sample

The web-services API provides the ability to manage conference participants and to reserve large conferences. For more information regarding conferences please have a look at the sample and also consult the online documentation.

This python module provides a sample for the web services API that is used to manage your conferences.

The following tasks are available:

  • Reserve a large conference.
  • List your conferences.
  • List a conference’s participants.
  • Mute or unmute a conference participant.
  • Enable or disable DTMF handling for a conference participant.
  • Eject a conference participant.
  • Extend a conference reservation by a number of minutes.
  • Remove a conference reservation.

Note: The ability to reserve a large conference is available upon request only. If you’d like to use it, please ask - email us at cloud.support@aculabcloud.net

Each of the above tasks is wrapped in its own function.

When run from the command line, this module takes a single argument that identifies which task (function) to run. The argument can be one of the following:

  • reserve to reserve a large conference.
  • list_conferences to list the conference reservation tokens.
  • list_participants to list details of the participants in a particular conference.
  • set_participant_options to set a participant’s options, e.g., mute or unmute.
  • eject_participant to eject a conference participant.
  • modify to extend a conference reservation by a number of minutes.
  • remove to remove a conference reservation, reservations can only be removed if the conference has not already started, and is not due to start within the next 5 minutes.

The module will also ask for the Aculab Cloud region ID (for example 0-2-0 for Europe); and your Aculab Cloud username and password.

In addition, when run from the command line, this module will read a configuration file manage_conferences.cfg. The configuration file has arguments for each of the above tasks, for instance, the reserve task takes a conference name. Please see the configuration file for more details.

conference_reservation_modify(connection, headers, reservation_token, minutes_extend_duration)

Modify the duration of an existing reservation by the given number of minutes.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • reservation_token
    The reservation token of the conference to remove.
  • minutes_extend_duration
    The number of minutes to add to the conference duration, must be 15 to 60 and cannot take the total beyond 480.

Returns True or False.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_conferences import conference_reservation_modify

connection, headers = ws_connect("username", "password", "1-2-0")
if conference_reservation_modify(connection, headers, "GIYDCNBNGEYC2MRZFUYDSLJVGBPU26KDN5XGMZLSMVXGGZKOMFWWKX3SN5RGK4TUFZZXIYLQMVZHIQDBMN2WYYLCFZRW63I8", 30) is False:
     print("Reservation modify failed")
eject_conference_participant(connection, headers, conference_name, participant_id)

Eject a given participant from the conference.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • conference_name
    The name of the conference in which to set the participant’s options.
  • participant_id
    The id of the participant for which to set the options.

Returns True or False.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_conferences import eject_conference_participant

connection, headers = ws_connect("username", "password", "1-2-0")
if eject_conference_participant(connection, headers, "MyConference", "012345671a1b1c1d.12345x0") is False:
    print("Eject participant failed")
list_conference_participants(connection, headers, conference_name)

List details of the participants in a given conference.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • conference_name
    The name of the conference for which to list the participant details.

Prints details for all the conference participants. Returns a list of the participant ids.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_conferences import list_conference_participants

connection, headers = ws_connect("username", "password", "1-2-0")
participant_ids = list_conference_participants(connection, headers, "MyConference")

Output example:

Conference status: ACTIVE
-----------------
participant_id   : 01234567a1b1c1c1.12345x0
muted            : True
dtmf_enabled     : False
-----------------
participant_id   : 01234567a1b1c1c2.234
muted            : False
dtmf_enabled     : True
list_conferences(connection, headers)

Return a list of your reservation tokens.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.

Prints conference details for all your conferences. Returns a list of your conference reservation tokens.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_conferences import list_conferences

connection, headers = ws_connect("username", "password", "1-2-0")
conference_list = list_conferences(connection, headers)

Output example:

-----------------
conference_name  : AnotherConf2
max_participants : 40
status           : ACTIVE
-----------------
-----------------
conference_name  : MyConf1
max_participants : 40
status           : HOLDING
-----------------
-----------------
reservation_token: GIYDCMZNGA2C2MRVFUYTKLJRGVPXE33CONZG633NL5ZG6YTFOJ2C443UMFYGK4TUIBQWG5LMMFRC4Y3PNU888888
conference_name  : MyConferenceRoom"
max_participants : 130
start_time       : 2013-04-25-15-15
duration         : 30
divert           : MyEarlyAnnouncement
status           : RESERVED
-----------------
remove_a_conference_reservation(connection, headers, reservation_token)

Remove a conference reservation.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • reservation_token
    The reservation token of the conference to remove.

Returns True or False.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_conferences import remove_a_conference_reservation

connection, headers = ws_connect("username", "password", "1-2-0")
if remove_a_conference_reservation(connection, headers, "GIYDCNBNGEYC2MRZFUYDSLJVGBPU26KDN5XGMZLSMVXGGZKOMFWWKX3SN5RGK4TUFZZXIYLQMVZHIQDBMN2WYYLCFZRW63I8") is False:
    print("Reservation removal failed")
reserve_a_conference(connection, headers, conference_name, participants, start_time, minutes_duration, divert=None)

Reserve a large conference.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • conference_name
    The conference name which will consist of alphanumeric characters only, and should be unique to your account.
  • participants
    The number of conference participants, this must be more than 40 and not more than 350.
  • start_time
    The start time for the conference, this must be UTC in the format YYYY-MM-DD-HH-MM where each field is digits only. The start time must be at least five minutes away, and at most 24 hours away.
  • minutes_duration
    How long the conference will last, the duration will be an integer representing minutes and will not be less than 15 or more than 480.
Optional argument:
  • divert
    The inbound service to bounce early participants to.

Returns the reservation token.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_conferences import reserve_a_conference

connection, headers = ws_connect("username", "password", "1-2-0")
token = reserve_a_conference(connection, headers, "MyConference", 45, "2014-10-29-09-50", 60)
print("Reservation token: {0}".format(token))
set_conference_participant_options(connection, headers, conference_name, participant_id, mute=None, dtmf_enable=None)

Adjust muting and DTMF key handling for a given conference participant.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • conference_name
    The name of the conference in which to set the participant’s options.
  • participant_id
    The id of the participant for which to set the options.
Optional arguments:
  • mute
    True or False, to mute or unmute the conference participant.
  • dtmf_enable
    True to enable DTMF key actions for the participant, False to disable these.

Returns True or False.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_conferences import set_conference_participant_options

connection, headers = ws_connect("username", "password", "1-2-0")
if set_conference_participant_options(connection, headers, "MyConference", "012345671a1b1c1d.12345x0", mute=True) is False:
    print("Set participant options failed")

The manage SMS messages sample

The web-services API provides the ability to send and receive SMS messages on Aculab Cloud. For more information regarding SMS messaging please have a look at the sample and also view the online documentation.

This python module provides a sample for the web-services API that is used to manage SMS messages.

The following tasks are available:

  • Send an SMS message.
  • Cancel an SMS message.
  • Get the status of an SMS message.
  • Get the blocked numbers list.

Each of the above tasks is wrapped in its own function.

When run from the command line, this module takes a single argument that identifies which task (function) to run. The argument can be one of the following:

  • message_send to send an SMS message.
  • message_cancel to cancel an SMS message.
  • message_status to get the status of an SMS message.
  • message_list_blocked to get the blocked numbers list.

The module will also ask for the Aculab Cloud region ID (for example 0-2-0 for Europe); and your Aculab Cloud username and password.

In addition, when run from the command line, this module will read a configuration file manage_sms_messages.cfg. The configuration file has arguments for each of the above tasks, for instance, the message_cancel task takes a list of references. Please see the configuration file for more details.

message_cancel(connection, headers, references)

Cancel one or more SMS messages.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • references
    A list of message reference IDs separated by a space.

Prints the result. Returns the result.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_sms_messages import message_cancel

connection, headers = ws_connect("username", "password", "1-2-0")
reference = message_cancel(connection, headers, "2e891aea_0.1366641192.77832 2e891aea_0.1366641192.77834")

Output example:

2e891aea_0.1366641192.77832 : success
2e891aea_0.1366641192.77834 : unknown
message_list_blocked(connection, headers, call_to=None, call_from=None)

List the numbers to and from which you’re currently blocked from sending SMS messages.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
Optional arguments:
  • call_to
    A mobile number. The list will contain all your numbers that are blocked from sending to this number.
  • call_from
    One of your numbers. The list will contain all the mobile numbers to which this number is blocked from sending messages.

Note: One of call_to or call_from must be supplied.

Prints the number you’re blocked sending to, the number you’re blocked sending from, and the date on which the block was implemented. Returns the result.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_sms_messages import message_list_blocked

connection, headers = ws_connect("username", "password", "1-2-0")
reference = message_list_blocked(connection, headers, call_to="441908123456")

Output example:

To: 441908123456 From: 441908273800 Time: 2014-10-21_10:51:23
message_send(connection, headers, call_to, call_from, content, request_delivery_report=None, status_page=None, status_method=None, status_authentication_name=None, status_authentication_password=None, status_ssl_check=None)

Send an SMS message.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • call_to
    The number of the phone to which you’d like to send the message.
  • call_from
    One of your numbers. The number from which you’d like to send the message.
  • content
    The content of your message.
Optional arguments:
  • request_delivery_report
    True or False, to request a delivery report. Default is False.
  • status_page
    The URL of a page to which message status updates will be sent.
  • status_method
    The method by which status_page will be accessed, “POST” or “GET”.
  • status_authentication_name
    Perform basic authentication with this username when accessing status_page.
  • status_authentication_password
    Basic authentication password.
  • status_ssl_check
    If using HTTPS, set to True if you’d like Aculab Cloud to check your SSL certificate when accessing status_page.

Returns a list of message reference Ids.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_sms_messages import message_send

connection, headers = ws_connect("username", "password", "1-2-0")
reference = message_send(connection, headers, "123456789", "123456799", "My message to you")
message_status(connection, headers, references)

Get the status of one or more SMS messages.

Required arguments:
  • connection
    The connection to Aculab Cloud. As provided by ws_connect.
  • headers
    The HTTP headers. As provided by ws_connect.
  • references
    A list of message reference IDs separated by a space.

Prints the status of each message. Returns the result.

Usage example:

from samples_ws.ws_connect import ws_connect
from samples_ws.manage_sms_messages import message_status

connection, headers = ws_connect("username", "password", "1-2-0")
reference = message_status(connection, headers, "2e891aea_0.1366641192.77832 2e891aea_0.1366641192.77834")

Output example:

2e891aea_0.1366641192.77832 : sent
2e891aea_0.1366641192.77834 : queued