November 23, 2017


Remove association between Vlan and Gateway device.

Important manual pages:

Author: SoftLayer Technologies, Inc. <>
package main

import (

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

	// The id of gateway you wish to remove the association.
	gatewayId := 61522

	// The id of vlan you wish to remove the association. This should be associated to the
	// gateway above. You can execute the method SoftLayer_Network_Gateway_Vlan::getInsideVlans
	// to verify it.
	vlanId := 1502997

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

	// Get SoftLayer_Network_Gateway and SoftLayer_Network_Gateway_Vlan services
	gatewayService := services.GetNetworkGatewayService(sess)
	gatewayVlanService := services.GetNetworkGatewayVlanService(sess)

	// Use filter to get the Network_Gateway_Vlan object
	filter := filter.Path("insideVlans").In("networkVlanId").Eq(vlanId).Build()

	// Call method getInsideVlans() method to get the Network_Gateway_Vlan object
	gatewayVlans, err := gatewayService.Id(gatewayId).Filter(filter).GetInsideVlans()
	if err != nil {
		fmt.Printf("\n Unable to get inside vlans:\n - %s\n", err)

	// Call to deleteObject() method to remove the association
	deleteErr := gatewayVlanService.Id(*gatewayVlans[0].Id).DeleteObject()
	if deleteErr != nil {
		fmt.Printf("\n Unable to remove association:\n - %s\n", deleteErr)

	fmt.Println("\n Selected Vlan was removed from association !!")


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