<commit_before>package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"os"

	"github.com/grafov/autograf/client"
)

/* This is a simple example of usage of Grafana client
for copying dashboards and saving them to a disk.
Usage:
  backup-dashboards http://grafana.host:3000 api-key-string-here
*/

func main() {
	var (
		boards        []client.FoundBoard
		boardWithMeta client.BoardWithMeta
		data          []byte
		err           error
	)
	if len(os.Args) != 2 {
		fmt.Fprint(os.Stderr, "Usage:  backup-dashboards http://grafana.host:3000 api-key-string-here\n")
		os.Exit(0)
	}
	c := client.New(os.Args[1], os.Args[2])
	if boards, err = c.SearchDashboards("", false); err != nil {
		fmt.Fprintf(os.Stderr, fmt.Sprintf("%s\n", err))
		os.Exit(1)
	}
	for _, link := range boards {
		if boardWithMeta, err = c.GetDashboard(link.URI); err != nil {
			fmt.Fprintf(os.Stderr, fmt.Sprintf("%s for %s\n", err, link.URI))
			continue
		}
		if data, err = json.MarshalIndent(boardWithMeta.Board, "", "  "); err != nil {
			fmt.Fprintf(os.Stderr, fmt.Sprintf("%s for %s\n", err, boardWithMeta.Board.Title))
			continue
		}
		if err = ioutil.WriteFile(fmt.Sprintf("%s.json", boardWithMeta.Meta.Slug), data, os.FileMode(int(0666))); err != nil {
			fmt.Fprintf(os.Stderr, fmt.Sprintf("%s for %s\n", err, boardWithMeta.Meta.Slug))
		}
	}
}<commit_msg>Update utility code for reflect changed API.<commit_after>package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"os"

	"github.com/grafov/autograf/client"
	"github.com/grafov/autograf/grafana"
)

/* This is a simple example of usage of Grafana client
for copying dashboards and saving them to a disk.
Usage:
  backup-dashboards http://grafana.host:3000 api-key-string-here
*/

func main() {
	var (
		boards []client.FoundBoard
		board  grafana.Board
		meta   client.BoardProperties
		data   []byte
		err    error
	)
	if len(os.Args) != 2 {
		fmt.Fprint(os.Stderr, "Usage:  backup-dashboards http://grafana.host:3000 api-key-string-here\n")
		os.Exit(0)
	}
	c := client.New(os.Args[1], os.Args[2])
	if boards, err = c.SearchDashboards("", false); err != nil {
		fmt.Fprintf(os.Stderr, fmt.Sprintf("%s\n", err))
		os.Exit(1)
	}
	for _, link := range boards {
		if board, meta, err = c.GetDashboard(link.URI); err != nil {
			fmt.Fprintf(os.Stderr, fmt.Sprintf("%s for %s\n", err, link.URI))
			continue
		}
		if data, err = json.MarshalIndent(board, "", "  "); err != nil {
			fmt.Fprintf(os.Stderr, fmt.Sprintf("%s for %s\n", err, board.Title))
			continue
		}
		if err = ioutil.WriteFile(fmt.Sprintf("%s.json", meta.Slug), data, os.FileMode(int(0666))); err != nil {
			fmt.Fprintf(os.Stderr, fmt.Sprintf("%s for %s\n", err, meta.Slug))
		}
	}
}
{'fraction_non_alphanumeric': 0.16951038575667657, 'fraction_numerical': 0.012611275964391691, 'mean_word_length': 3.5100334448160537, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4306103', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1037, 'n_words': 228}