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


Golang OpsGenieClient.Heartbeat方法代碼示例

本文整理匯總了Golang中github.com/opsgenie/opsgenie-go-sdk/client.OpsGenieClient.Heartbeat方法的典型用法代碼示例。如果您正苦於以下問題:Golang OpsGenieClient.Heartbeat方法的具體用法?Golang OpsGenieClient.Heartbeat怎麽用?Golang OpsGenieClient.Heartbeat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/opsgenie/opsgenie-go-sdk/client.OpsGenieClient的用法示例。


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

示例1: main

func main() {
	cli := new(ogcli.OpsGenieClient)
	cli.SetAPIKey(constants.APIKey)

	hbCli, cliErr := cli.Heartbeat()

	if cliErr != nil {
		panic(cliErr)
	}

	// create the hb
	req := hb.AddHeartbeatRequest{Name: samples.RandStringWithPrefix("Test", 4)}
	response, hbErr := hbCli.Add(req)

	if hbErr != nil {
		panic(hbErr)
	}

	fmt.Printf("Heartbeat added\n")
	fmt.Printf("---------------\n")
	fmt.Printf("name: %s\n", response.Name)
	fmt.Printf("status: %s\n", response.Status)
	fmt.Printf("code: %d\n", response.Code)

	// update the newly created heart beat, change description
	updateReq := hb.UpdateHeartbeatRequest{Name: response.Name, Description: "new description"}
	updateResp, updateErr := hbCli.Update(updateReq)

	if updateErr != nil {
		panic(updateErr)
	}

	fmt.Printf("Heartbeat updated\n")
	fmt.Printf("-----------------\n")
	fmt.Printf("name: %s\n", updateResp.Name)
	fmt.Printf("status: %s\n", updateResp.Status)
	fmt.Printf("code: %d\n", updateResp.Code)

	getReq := hb.GetHeartbeatRequest{Name: response.Name}
	getResp, getErr := hbCli.Get(getReq)
	if getErr != nil {
		panic(getErr)
	}

	fmt.Printf("Heartbeat details\n")
	fmt.Printf("-----------------\n")
	fmt.Printf("Name: %s\n", getResp.Name)
	fmt.Printf("Description: %s\n", getResp.Description)
}
開發者ID:tablexi,項目名稱:opsgenie-go-sdk,代碼行數:49,代碼來源:heartbeat_create_and_update.go

示例2: main

func main() {
	cli := new(ogcli.OpsGenieClient)
	cli.SetAPIKey(constants.APIKey)

	hbCli, cliErr := cli.Heartbeat()

	if cliErr != nil {
		panic(cliErr)
	}

	// create the hb
	req := hb.AddHeartbeatRequest{Name: samples.RandStringWithPrefix("Test", 4)}
	response, hbErr := hbCli.Add(req)

	if hbErr != nil {
		panic(hbErr)
	}

	fmt.Printf("Heartbeat created\n")
	fmt.Printf("-----------------\n")
	fmt.Printf("id: %s\n", response.ID)
	fmt.Printf("status: %s\n", response.Status)
	fmt.Printf("code: %d\n", response.Code)

	// list the HBs
	listReq := hb.ListHeartbeatsRequest{}
	listResp, listErr := hbCli.List(listReq)
	if listErr != nil {
		panic(listErr)
	}

	fmt.Printf("Heartbeats\n")
	fmt.Printf("-----------------\n")
	beats := listResp.Heartbeats
	for _, beat := range beats {
		fmt.Printf("Id: %s\n", beat.ID)
		fmt.Printf("Name: %s\n", beat.Name)
		fmt.Printf("Status %s\n", beat.Status)
		fmt.Printf("Description: %s\n", beat.Description)
		fmt.Printf("Enabled?: %t\n", beat.Enabled)
		fmt.Printf("Last Heartbeat: %d\n", beat.LastHeartbeat)
		fmt.Printf("Interval: %d\n", beat.Interval)
		fmt.Printf("Interval Unit: %s\n", beat.IntervalUnit)
		fmt.Printf("Expired?: %t\n", beat.Expired)
		fmt.Printf("-----------------\n")
	}
}
開發者ID:victortrac,項目名稱:opsgenie-go-sdk,代碼行數:47,代碼來源:heartbeat_list.go

示例3: main

func main() {
	cli := new(ogcli.OpsGenieClient)
	cli.SetAPIKey(constants.APIKey)

	hbCli, cliErr := cli.Heartbeat()

	if cliErr != nil {
		panic(cliErr)
	}

	// create the hb
	req := hb.AddHeartbeatRequest{Name: samples.RandStringWithPrefix("Test", 4)}
	response, hbErr := hbCli.Add(req)

	if hbErr != nil {
		panic(hbErr)
	}

	fmt.Printf("Heartbeat created\n")
	fmt.Printf("-----------------\n")
	fmt.Printf("id: %s\n", response.ID)
	fmt.Printf("status: %s\n", response.Status)
	fmt.Printf("code: %d\n", response.Code)

	// enable the hb
	getReq := hb.GetHeartbeatRequest{ID: response.ID}
	getResp, getErr := hbCli.Get(getReq)
	if getErr != nil {
		panic(getErr)
	}

	fmt.Printf("Heartbeat details\n")
	fmt.Printf("-----------------\n")
	fmt.Printf("Id: %s\n", getResp.ID)
	fmt.Printf("Name: %s\n", getResp.Name)
	fmt.Printf("Status: %s\n", getResp.Status)
	fmt.Printf("Description: %s\n", getResp.Description)
	fmt.Printf("Enabled?: %t\n", getResp.Enabled)
	fmt.Printf("Last Heartbeat: %d\n", getResp.LastHeartbeat)
	fmt.Printf("Interval: %d\n", getResp.Interval)
	fmt.Printf("Interval Unit: %s\n", getResp.IntervalUnit)
	fmt.Printf("Expired?: %t\n", getResp.Expired)
}
開發者ID:victortrac,項目名稱:opsgenie-go-sdk,代碼行數:43,代碼來源:heartbeat_create_and_get.go

示例4: main

func main() {
	cli := new(ogcli.OpsGenieClient)
	cli.SetAPIKey(constants.APIKey)

	hbCli, cliErr := cli.Heartbeat()

	if cliErr != nil {
		panic(cliErr)
	}

	hbName := samples.RandStringWithPrefix("Test", 4)
	// create the hb
	req := hb.AddHeartbeatRequest{Name: hbName}
	response, hbErr := hbCli.Add(req)

	if hbErr != nil {
		panic(hbErr)
	}

	fmt.Printf("Heartbeat added\n")
	fmt.Printf("---------------\n")
	fmt.Printf("id: %s\n", response.ID)
	fmt.Printf("status: %s\n", response.Status)
	fmt.Printf("code: %d\n", response.Code)

	// send heart beat request
	sendReq := hb.SendHeartbeatRequest{Name: hbName}
	sendResp, sendErr := hbCli.Send(sendReq)

	if sendErr != nil {
		panic(sendErr)
	}

	fmt.Printf("Heartbeat request sent\n")
	fmt.Printf("----------------------\n")
	fmt.Printf("Heartbeat: %d\n", sendResp.Heartbeat)
	fmt.Printf("Will expire at: %d\n", sendResp.WillExpireAt)
	fmt.Printf("Status: %s\n", sendResp.Status)
	fmt.Printf("Code: %d\n", sendResp.Code)
}
開發者ID:victortrac,項目名稱:opsgenie-go-sdk,代碼行數:40,代碼來源:heartbeat_create_and_send.go

示例5: main

func main() {
	cli := new(ogcli.OpsGenieClient)
	cli.SetAPIKey(constants.APIKey)

	hbCli, cliErr := cli.Heartbeat()

	if cliErr != nil {
		panic(cliErr)
	}

	// create the hb
	req := hb.AddHeartbeatRequest{Name: samples.RandStringWithPrefix("Test", 4)}
	response, hbErr := hbCli.Add(req)

	if hbErr != nil {
		panic(hbErr)
	}

	fmt.Printf("name: %s\n", response.Name)
	fmt.Printf("status: %s\n", response.Status)
	fmt.Printf("code: %d\n", response.Code)
}
開發者ID:tablexi,項目名稱:opsgenie-go-sdk,代碼行數:22,代碼來源:heartbeat_create.go

示例6: main

func main() {
	cli := new(ogcli.OpsGenieClient)
	cli.SetAPIKey(constants.APIKey)

	hbCli, cliErr := cli.Heartbeat()

	if cliErr != nil {
		panic(cliErr)
	}

	// create the hb
	req := hb.AddHeartbeatRequest{Name: samples.RandStringWithPrefix("Test", 4)}
	response, hbErr := hbCli.Add(req)

	if hbErr != nil {
		panic(hbErr)
	}

	fmt.Printf("Heartbeat created\n")
	fmt.Printf("-----------------\n")
	fmt.Printf("id: %s\n", response.ID)
	fmt.Printf("status: %s\n", response.Status)
	fmt.Printf("code: %d\n", response.Code)

	// enable the hb
	disableReq := hb.DisableHeartbeatRequest{ID: response.ID}
	disableResp, disableErr := hbCli.Disable(disableReq)
	if disableErr != nil {
		panic(disableErr)
	}

	fmt.Printf("Heartbeat disabled\n")
	fmt.Printf("-----------------\n")
	fmt.Printf("Status: %s\n", disableResp.Status)
	fmt.Printf("Code: %d\n", disableResp.Code)
}
開發者ID:victortrac,項目名稱:opsgenie-go-sdk,代碼行數:36,代碼來源:heartbeat_create_and_disable.go


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