示例#1
0
// Adds a task associated with a flow taken from a board. This method automatically
// handles board prefixes; therefore, you must use the tags exactly as they are defined
// when in the board template.
func (e *PluginHelper) AddTaskWithClosureFromBoardForFlowWithTag(c PluginHelperClosureWithFlow, interval time.Duration, b *gotelemetry.Board, tag string) error {
	flows, err := b.MapWidgetsToFlows()

	if err != nil {
		return err
	}

	return e.AddTaskWithClosureForFlowWithTag(c, interval, flows, tag)
}
示例#2
0
func main() {
	keyPtr := flag.String("api-key", "", "Telemetry API Key")
	boardNamePtr := flag.String("n", "", "Name of board to retrieve")
	boardIdPtr := flag.String("b", "", "ID of board to retrieve")

	flag.Parse()

	key := strings.TrimSpace(*keyPtr)
	boardName := strings.TrimSpace(*boardNamePtr)
	boardId := strings.TrimSpace(*boardIdPtr)

	if key == "" {
		log.Fatal("Missing API Key.")
	}

	credentials, err := gotelemetry.NewCredentials(key)

	if err != nil {
		log.Fatalf("Error reported by the Telemetry API while creating a set of credentials: %s", err.Error())
	}

	if boardName == "" && boardId == "" {
		log.Fatal("You must specify either a board ID or a board name")
	}

	if boardName != "" && boardId != "" {
		log.Fatal("You must specify *either* a board ID or a board name")
	}

	var board *gotelemetry.Board

	if boardName != "" {
		board, err = gotelemetry.GetBoardByName(credentials, boardName)

		if err != nil {
			log.Fatalf("Error reported by the Telemetry API while requesting a board by name: %s", err.Error())
		}

		boardId = board.Id
	}

	board, err = gotelemetry.GetBoard(credentials, boardId)

	if err != nil {
		log.Fatalf("Error reported by the Telemetry API while requesting a board: %s", err.Error())
	}

	exportedBoard, err := board.Export()

	if err != nil {
		log.Fatalf("Error reported by the Telemetry API while exporting a board: %s", err.Error())
	}

	result, err := json.Marshal(exportedBoard)

	if err != nil {
		log.Fatalf("Error while converting a board to JSON: %s", err.Error())
	}

	fmt.Print(string(result))
}