當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ei.BuildClient類代碼示例

本文整理匯總了Golang中github.com/nightrune/wrench/ei.BuildClient的典型用法代碼示例。如果您正苦於以下問題:Golang BuildClient類的具體用法?Golang BuildClient怎麽用?Golang BuildClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了BuildClient類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: StartDeviceLogging

func StartDeviceLogging(client *ei.BuildClient, device_id string) {
	logs, poll_url, err := client.GetDeviceLogs(device_id)
	if err != nil {
		logging.Fatal("Failed to get device logs %s", err.Error())
		return
	}

	logging.Debug("Poll Url %s", poll_url)
	for _, entry := range logs {
		fmt.Printf("%s: %s: %s\n", entry.Timestamp, entry.Type, entry.Message)
	}

	for {
		logs, err = client.ContinueDeviceLogs(poll_url)
		if err != nil {
			if _, ok := err.(*ei.Timeout); ok == false {
				logging.Fatal("Failed to get device logs %s", err.Error())
				return
			} else {
				logging.Debug("Long poll timed out...")
			}
		} else {
			for _, entry := range logs {
				fmt.Printf("%s: %s: %s\n", entry.Timestamp, entry.Type, entry.Message)
			}
		}
	}
}
開發者ID:jamesbjackson,項目名稱:wrench,代碼行數:28,代碼來源:device.go

示例2: RestartDevice

func RestartDevice(client *ei.BuildClient, device_id string) {
	err := client.RestartDevice(device_id)
	if err != nil {
		logging.Fatal("Failed to restart device %s with error %s", device_id, err.Error())
		return
	}
	fmt.Printf("Successfully restarted device and agent")
}
開發者ID:nightrune,項目名稱:wrench,代碼行數:8,代碼來源:device.go

示例3: ListDevices

func ListDevices(client *ei.BuildClient) {
	device_list, err := client.GetDeviceList()
	if err != nil {
		logging.Fatal("Failed to get device list %s", err.Error())
		return
	}

	for _, model := range device_list {
		fmt.Printf("Id: %s, Name: %s\n", model.Id, model.Name)
	}
}
開發者ID:jamesbjackson,項目名稱:wrench,代碼行數:11,代碼來源:device.go

示例4: ListModels

func ListModels(client *ei.BuildClient) {
	model_list, err := client.ListModels()
	if err != nil {
		logging.Fatal("Failed to get model list %s", err.Error())
		return
	}

	for _, model := range model_list.Models {
		fmt.Printf("Id: %s, Name: %s\n", model.Id, model.Name)
	}
}
開發者ID:jamesbjackson,項目名稱:wrench,代碼行數:11,代碼來源:model.go

示例5: AssignDeviceToModel

func AssignDeviceToModel(client *ei.BuildClient, device_id string, model_id string) {
	device, err := client.GetDevice(device_id)
	if err != nil {
		logging.Fatal("Failed to retrieve current model for model id: %s", model_id)
		return
	}

	// Don't do anything if its already the same
	if device.ModelId == model_id {
		return
	}

	device.ModelId = model_id
	updated_device, err := client.UpdateDevice(&device, device_id)
	logging.Debug("Model and new Devices: %s", updated_device)
}
開發者ID:jamesbjackson,項目名稱:wrench,代碼行數:16,代碼來源:device.go


注:本文中的github.com/nightrune/wrench/ei.BuildClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。