September 19, 2016

Classes
Tags VirtualGuest

Cancel a virtual guest
Example of how to cancel a virtual guest.

package main

import (
    "fmt"
    "log"

    "github.com/softlayer/softlayer-go/services"
    "github.com/softlayer/softlayer-go/session"
)

var guestId = 24438563

func main() {
    // Create a session
    sess := session.New()

    // Get the virtual guest service
    service := services.GetVirtualGuestService(sess)

    // Set the object ID and delete the guest
    success, err := service.Id(guestId).DeleteObject()

    if err != nil {
        log.Fatal(err)
    } else if success == false {
        log.Fatal("Error deleting virtual guest")
    } else {
        fmt.Println("Virtual Guest deleted successfully")
    }
}

Feedback?

We would love to hear it
Open an issue

/go/vm_cancel/