File: service_networks.go

package info (click to toggle)
golang-github-joyent-gosdc 0.0~git20161202.ec8b350-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 472 kB
  • sloc: makefile: 3
file content (34 lines) | stat: -rw-r--r-- 692 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package cloudapi

import (
	"fmt"
	"strings"

	"github.com/joyent/gosdc/cloudapi"
)

// Networks API

// ListNetworks returns a list of networks that the double knows about
func (c *CloudAPI) ListNetworks() ([]cloudapi.Network, error) {
	if err := c.ProcessFunctionHook(c); err != nil {
		return nil, err
	}

	return c.networks, nil
}

// GetNetwork gets a network by ID
func (c *CloudAPI) GetNetwork(networkID string) (*cloudapi.Network, error) {
	if err := c.ProcessFunctionHook(c, networkID); err != nil {
		return nil, err
	}

	for _, n := range c.networks {
		if strings.EqualFold(n.Id, networkID) {
			return &n, nil
		}
	}

	return nil, fmt.Errorf("Network %s not found", networkID)
}