本文整理匯總了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)
}
}
}
}
示例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")
}
示例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)
}
}
示例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)
}
}
示例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)
}