Example #1
0
func getItem(client rollbar.Client) int {
	if len(os.Args) < 3 {
		fmt.Fprintf(os.Stderr, "Usage: %s %s <identifier>\n", os.Args[0], os.Args[1])
		return 1
	}
	identifier, err := strconv.ParseUint(os.Args[2], 10, 64)
	if err != nil {
		fmt.Printf("%s\n", err)
		return 1
	}

	response, err := client.GetItem(identifier)
	if err != nil {
		fmt.Printf("%s\n", err)
		return 1
	}
	if response.IsError() {
		fmt.Printf("Got error: %s\n", response.Message)
		return 1
	}

	fmt.Printf("Got item: %s\n", response.Item.AsPrettyJSON())

	return 0
}
Example #2
0
func getItemOccurrences(client rollbar.Client) int {
	var page uint64 = 1
	var err error

	if len(os.Args) < 3 || len(os.Args) > 4 {
		fmt.Fprintf(os.Stderr, "Usage: %s %s <item_id> [<page>]\n", os.Args[0], os.Args[1])
		return 1
	}

	item_id, err := strconv.ParseUint(os.Args[2], 10, 0)
	if err != nil {
		fmt.Printf("%s\n", err)
		return 1
	}

	if len(os.Args) == 4 {
		page, err = strconv.ParseUint(os.Args[3], 10, 0)
		if err != nil {
			fmt.Printf("%s\n", err)
			return 1
		}
	}

	response, err := client.GetItemOccurrencesWithPage(item_id, page)
	if err != nil {
		fmt.Printf("%s\n", err)
		return 1
	}
	if response.IsError() {
		fmt.Printf("Got error: %s\n", response.Message)
		return 1
	}
	fmt.Printf("Got occurrences: %s\n", response.AsPrettyJSON())
	return 0
}