<commit_before><commit_msg>api-client: Broker list client query function implemented<commit_after>package client

import (
	"encoding/json"
	"errors"
	"net/http"

	"github.com/eddyzags/kafkactl/models"
)

type BrokersListResponse struct {
	Brokers []*models.Broker `json:"brokers"`
}

func (c *Client) BrokerList() ([]*models.Broker, error) {
	req, err := http.NewRequest("GET", c.URL, nil)
	if err != nil {
		return nil, err
	}

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		return nil, err
	}

	if resp.Response.StatusCode != 201 && resp.Response.StatusCode != 200 {
		return nil, errors.New("Failed to retreive response")
	}

	body, err := ioutil.ReadAll(resp.Response.Body)
	if err != nil {
		return nil, err
	}

	response := &BrokersListResponse{}
	if err := json.Unmarshal(resp, &response); err != nil {
		return nil, err
	}

	return response.Brokers, nil
}
{'fraction_non_alphanumeric': 0.14927048260381592, 'fraction_numerical': 0.006734006734006734, 'mean_word_length': 4.15606936416185, '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': '3189123', 'n_tokens_mistral': 334, 'n_tokens_neox': 316, 'n_words': 81}