November 23, 2017


List standard firewalls

This script will display a list of Virtual Servers that have a firewall configuration. On this
example we'll call to SoftLayer_Account::getVirtualGuests method with a filter in order to get all
servers with "firewallServiceComponent".

Important manual pages:

@Author: SoftLayer Technologies, Inc. <>
package main

import (

func main() {
	// SoftLayer API username and key
	username := "set me"
	apikey   := "set me"

	// Create SoftLayer API session
	sess := session.New(username, apikey)

	// Get SoftLayer_Account service
	service := services.GetAccountService(sess)

	// Declare the filter that will be used to find Virtual Guests with firewall
	filter := filter.Path("virtualGuests.firewallServiceComponent").NotNull().Build()

	// Declare object-mask in order to retrieve specific data
	mask := "id;hostname;domain;firewallServiceComponent"

	// Call to SoftLayer_Account::getVirtualGuests method to retrieve virtual servers
	// according to filter.
	servers, err := service.Mask(mask).Filter(filter).GetVirtualGuests()
	if err != nil {
		fmt.Printf("\n Unable to get virtual servers with firewall:\n - %s\n", err)

	// Following helps to print the result in json format.
	for _, guest := range servers {
		jsonFormat, jsonErr := json.Marshal(guest)
		if jsonErr != nil {


If this article contains any error, or leaves any of your questions unanswered, please help us out by opening up a github issue.
Open an issue