// BandwidthOfServer retrieves the bandwidth used by a virtual machine
185400
func (c *Client) BandwidthOfServer(id string) (bandwidth []map[string]string, err error) {
	var bandwidthMap map[string][][]string
	if err := c.get(`server/bandwidth?SUBID=`+id, &bandwidthMap); err != nil {
		return nil, err
	}

	// parse incoming bytes
	for _, b := range bandwidthMap["incoming_bytes"] {
		bMap := make(map[string]string)
		bMap["date"] = b[0]
		bMap["incoming"] = b[1]
		bandwidth = append(bandwidth, bMap)
	}

	// parse outgoing bytes (we'll assume that incoming and outgoing dates are always a match)
	for _, b := range bandwidthMap["outgoing_bytes"] {
		for i := range bandwidth {
			if bandwidth[i]["date"] == b[0] {
				bandwidth[i]["outgoing"] = b[1]
				break
			}
		}
	}

	return bandwidth, nil
}
651781
func (r Network_Bandwidth_Version1_Allotment) ReassignServers(templateObjects []datatypes.Hardware, newAllotmentId *int) (resp bool, err error) {
	params := []interface{}{
		templateObjects,
		newAllotmentId,
	}
	err = r.Session.DoRequest("SoftLayer_Network_Bandwidth_Version1_Allotment", "reassignServers", params, &r.Options, &resp)
	return
}
214901
func GetProcNFSFSServers() (map[string]ProcNFSFSServer, error) {
	// read in the file
	data, err := ioutil.ReadFile(fmt.Sprintf(procDir+"fs/nfsfs/%s", procNFSFSServersFile))
	if err != nil {
		return nil, err
	}

	servers := make(map[string]ProcNFSFSServer)
	scanner := bufio.NewScanner(strings.NewReader(string(data)))
	linenum := 0
	for scanner.Scan() {
		line := scanner.Text()

		linenum++
		glog.V(4).Infof("%d: %s", linenum, line)
		if linenum < 2 {
			continue
		} else if strings.HasPrefix(line, "#") {
			continue
		}

		fields := strings.Fields(line)
		switch len(fields) {
		case 5:
			break
		case 0:
			continue
		default:
			return nil, fmt.Errorf("expected 5 fields, got %d: %s", len(fields), line)
		}
		svr := ProcNFSFSServer{
			Version:  fields[0],
			ServerID: fields[1],
			Port:     fields[2],
			Hostname: fields[4],
		}
		key := fmt.Sprintf("%s:%s:%s", svr.Version, svr.ServerID, svr.Port)
		servers[key] = svr
	}
	glog.V(4).Infof("nfsfs servers: %+v", servers)
	return servers, nil
}
658848
func (c *Client) GetServerInfo() (*RpbGetServerInfoResp, error) {
	opts := []byte{}

	response, err := c.ReqResp(opts, "RpbGetServerInfoReq", true)
	if err != nil {
		return nil, err
	}

	return response.(*RpbGetServerInfoResp), nil
}
45535
func (s *VPCRouterSetting) FindDHCPServer(nicIndex int) (int, *VPCRouterDHCPServerConfig) {
	for i, c := range s.DHCPServer.Config {
		if c.InterfaceIndex() == nicIndex {
			return i, c
		}
	}
	return -1, nil
}
1198305
func (fw *Framework) ProvisioningServers(ctx context.Context) ([]srvcache.Server, error) {
	return provtarget.Targets(ctx, fw.Logger("provtarget"))
}
999484
func ServerFromDisk(client APIClient, name string, sourceDiskID int64) CommonServerBuilder {
	b := newServerBuilder(client, name)
	b.hasCommonProperty = true
	b.hasNetworkInterfaceProperty = true
	b.hasDiskProperty = true
	b.hasDiskSourceProperty = true
	b.hasDiskEditProperty = true
	b.hasServerEventProperty = true
	b.hasDiskEventProperty = true
	b.hasAdditionalDiskProperty = true

	b.serverFromDisk(sourceDiskID)
	return b
}
13947
func (api *API) GetServerHdd(server_id string, hdd_id string) (*Hdd, error) {
	result := new(Hdd)
	url := createUrl(api, serverPathSegment, server_id, "hardware/hdds", hdd_id)
	err := api.Client.Get(url, &result, http.StatusOK)
	if err != nil {
		return nil, err
	}
	result.api = api
	return result, nil
}
185939
func (r Network_Bandwidth_Version1_Allotment) GetBackendBandwidthUse(startDate *datatypes.Time, endDate *datatypes.Time) (resp []datatypes.Network_Bandwidth_Version1_Usage_Detail, err error) {
	params := []interface{}{
		startDate,
		endDate,
	}
	err = r.Session.DoRequest("SoftLayer_Network_Bandwidth_Version1_Allotment", "getBackendBandwidthUse", params, &r.Options, &resp)
	return
}
948938
func (r *Registry) RegisterServerFunc(stream string, f func(*Peer, string, bool) (Server, error)) {
	r.serverMu.Lock()
	defer r.serverMu.Unlock()

	r.serverFuncs[stream] = f
}
1028822
func (r Virtual_Guest) GetCurrentBandwidthSummary() (resp datatypes.Metric_Tracking_Object_Bandwidth_Summary, err error) {
	err = r.Session.DoRequest("SoftLayer_Virtual_Guest", "getCurrentBandwidthSummary", nil, &r.Options, &resp)
	return
}
546553
func httpServer() http.Handler {
	r := mux.NewRouter()

	// Ping Resource
	r.HandleFunc(clients.ApiPingRoute, pingHandler).Methods(http.MethodGet)

	// Configuration
	r.HandleFunc(clients.ApiConfigRoute, configHandler).Methods(http.MethodGet)

	// Metrics
	r.HandleFunc(clients.ApiMetricsRoute, metricsHandler).Methods(http.MethodGet)

	// Registration
	r.HandleFunc(clients.ApiRegistrationRoute, getAllReg).Methods(http.MethodGet)
	r.HandleFunc(clients.ApiRegistrationRoute, addReg).Methods(http.MethodPost)
	r.HandleFunc(clients.ApiRegistrationRoute, updateReg).Methods(http.MethodPut)
	reg := r.PathPrefix(clients.ApiRegistrationRoute).Subrouter()
	reg.HandleFunc("/{id}", getRegByID).Methods(http.MethodGet)
	reg.HandleFunc("/reference/{type}", getRegList).Methods(http.MethodGet)
	reg.HandleFunc("/name/{name}", getRegByName).Methods(http.MethodGet)
	reg.HandleFunc("/id/{id}", delRegByID).Methods(http.MethodDelete)
	reg.HandleFunc("/name/{name}", delRegByName).Methods(http.MethodDelete)

	r.Use(correlation.ManageHeader)
	r.Use(correlation.OnResponseComplete)
	r.Use(correlation.OnRequestBegin)

	return r
}
267968
func main5() {
	api, _ := bandwidth.New(os.Getenv("CATAPULT_USER_ID"), os.Getenv("CATAPULT_API_TOKEN"), os.Getenv("CATAPULT_API_SECRET"))
	fromNumber := os.Args[1]
	toNumber := os.Args[2]
	text := os.Args[3]
	id, err := api.CreateMessage(&bandwidth.CreateMessageData{From: fromNumber, To: toNumber, Text: text})
	if err != nil {
		fmt.Printf("Error: %s", err.Error())
		return
	}
	fmt.Printf("Message ID is %s", id)
}
336066
func (client *peerRESTClient) CPULoadInfo() (info ServerCPULoadInfo, err error) {
	respBody, err := client.call(peerRESTMethodCPULoadInfo, nil, nil, -1)
	if err != nil {
		return
	}
	defer http.DrainBody(respBody)
	err = gob.NewDecoder(respBody).Decode(&info)
	return info, err
}
1111934
func (c *cluster) NumberOfServers(ctx context.Context) (NumberOfServersResponse, error) {
	req, err := c.conn.NewRequest("GET", "_admin/cluster/numberOfServers")
	if err != nil {
		return NumberOfServersResponse{}, WithStack(err)
	}
	applyContextSettings(ctx, req)
	resp, err := c.conn.Do(ctx, req)
	if err != nil {
		return NumberOfServersResponse{}, WithStack(err)
	}
	if err := resp.CheckStatus(200); err != nil {
		return NumberOfServersResponse{}, WithStack(err)
	}
	var result NumberOfServersResponse
	if err := resp.ParseBody("", &result); err != nil {
		return NumberOfServersResponse{}, WithStack(err)
	}
	return result, nil
}
1018516
func (s *LoadBalancerSetting) AddServer(server *LoadBalancerServer) {
	if s.Servers == nil {
		s.Servers = []*LoadBalancerServer{}
	}
	s.Servers = append(s.Servers, server)
}
739769
func RegisterServer(s *grpc.Server, m throttler.Manager) {
	throttlerservicepb.RegisterThrottlerServer(s, NewServer(m))
}