Beispiel #1
0
func (client *Client) List(parameters url.Values) (types.Fleet, error) {

	c := make(chan []types.Ship, len(client.region))
	var final []types.Ship

	for _, value := range client.region {
		go client.ListRegion(c, parameters, value)
	}

	for i := 1; i <= len(client.region); i++ {
		final = append(final, <-c...)
	}

	fmt.Printf("\n%#v\n", final)
	return types.NewFleet(final), nil
}
Beispiel #2
0
func (client *Client) List(parameters url.Values) (types.Fleet, error) {
	output := client.Get(client.endpoint + "/krane/ships")

	var jsonShips types.Ships
	json.Unmarshal(output, &jsonShips)

	var final []types.Ship

	if parameters.Get("state") != "" {
		for _, ship := range jsonShips.Ships {
			if parameters.Get("state") == ship.State {
				final = append(final, ship)
			}
		}
	} else {
		final = jsonShips.Ships
	}

	return types.NewFleet(final), nil
}