November 23, 2017


Retrieve VLAN details such as router hostname, vlanNumber, primary router and subnet.

Retrieve the vlan's information by calling to the getObject() method in the SoftLayer_Network_Vlan
API service, and we using an object mask to retrieve associated subnets and primary router records.
See below for more details.

Important manual pages:

Author: SoftLayer Technologies, Inc. <>

package main

import (

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

	// Vlan id you wish to get its details
	vlanId := 1054267

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

	// Get SoftLayer_Network_Vlan service
	service := services.GetNetworkVlanService(sess)

	// Object-Mask to get specific vlan's information
	mask := "id;name;vlanNumber;primaryRouter[id;hostname];subnets[id;ipAddresses[id;ipAddress]]"

	// Call to getObject() in order to retrieve vlan's details.
	vlan, err := service.Id(vlanId).Mask(mask).GetObject()
	if err != nil {
		fmt.Printf("\n Unable to get Vlan's information:\n - %s\n", err)

	// Following helps to print the result in json format.
	jsonFormat, jsonErr := json.MarshalIndent(vlan,"","    ")
	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