コード例 #1
0
// makeBasicAPICall demonstrates using a basic type
func makeBasicAPICall(client slapi.Client) {
	req := slapi.Request{
		Service: "SoftLayer_Account",
		Method:  "getObject",
		Mask:    `mask[id,companyName]`,
	}

	// Make API call with basic account type
	basicAccount := &types.SoftLayer_Account{}
	err := client.Call(req, basicAccount)
	if err != nil {
		log.Fatal(err)
	}
	log.Println("Basic:")
	log.Println(basicAccount.Id)
	log.Println(basicAccount.CompanyName)
}
コード例 #2
0
// makeCustomAPICall demonstrates using a user-defined type
func makeCustomAPICall(client slapi.Client) {

	req := slapi.Request{
		Service: "SoftLayer_Account",
		Method:  "getObject",
		Mask:    `mask[id,virtualGuests,companyName]`,
	}

	// Make API call with custom type based on the basic account type
	customAccount := &CustomAccount{}
	err := client.Call(req, customAccount)
	if err != nil {
		log.Fatal(err)
	}
	log.Println("Custom Extended:")
	log.Println(customAccount.Id)
	log.Println(customAccount.CompanyName)
	log.Println(customAccount.VirtualGuests)
}