当前位置: 首页>>代码示例>>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;未经允许,请勿转载。