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)
}
Exemplo n.º 2
0
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")
	}
}
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)
}
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)
}
Exemplo n.º 5
0
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)
}
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)
}