cm15/examples/rsssh/main.go
func serverArray(client *cm15.API, name string) []*cm15.Instance {
	serverArrayLocator := client.ServerArrayLocator("/api/server_arrays")
	serverArrays, err := serverArrayLocator.Index(rsapi.APIParams{"view": "default", "filter": []string{"name==" + name}})
	if err != nil {
		fail("Failed to retrieve server array: %v\n", err.Error())
	}
	if len(serverArrays) == 0 {
		fail("Could not find server array with name: %v\n", name)
	} else if len(serverArrays) != 1 {
		fail("More than one server array found with name: %v\n", name)
	}
	array := serverArrays[0]
	var instancesHref string
	for _, l := range array.Links {
		if l["rel"] == "current_instances" {
			instancesHref = l["href"]
			break
		}
	}
	instanceLocator := client.InstanceLocator(instancesHref)
	instances, err := instanceLocator.Index(rsapi.APIParams{})
	if err != nil {
		fail("Failed to retrieve current instances of the server array: %v\n", err.Error())
	}
	if len(instances) == 0 {
		fail("No instances found in server array: %v\n", name)
	}
	return instances
}
func serverArray(client *cm15.API, name string) []*cm15.Instance {
	serverArrayLocator := client.ServerArrayLocator("/api/server_arrays")
	serverArrays, err := serverArrayLocator.Index(rsapi.APIParams{"view": "default", "filter": []string{"name==" + name}})
	if err != nil {
		fail("Failed to retrieve server array: %v\n", err.Error())
	}
	if len(serverArrays) == 0 {
		fail("Could not find server array with name: %v\n", name)
	} else if len(serverArrays) != 1 {
		fail("More than one server array found with name: %v\n", name)
	}
	array := serverArrays[0]
	var instancesHref string
	for _, l := range array.Links {
		if l["rel"] == "current_instances" {
			instancesHref = l["href"]
			break
		}
	}
	instanceLocator := client.InstanceLocator(instancesHref)
	instances, err := instanceLocator.Index(rsapi.APIParams{})
	if err != nil {
		fail("Failed to retrieve current instances of the server array: %v\n", err.Error())
	}
	if len(instances) == 0 {
		fail("No instances found in server array: %v\n", name)
	}
	return instances
}
// Makes a GET call on the given server array and returns all its current instances.