in pkg/client/gerrit/group.go [102:130]
func (gc *Client) CreateGroup(name, description string, visibleToAll bool) (*Group, error) {
resp, err := gc.resty.R().
SetHeader(acceptHeader, applicationJson).
SetHeader(contentType, applicationJson).
SetBody(map[string]interface{}{
"description": description,
"name": name,
"visible_to_all": visibleToAll,
}).
Put(fmt.Sprintf("groups/%s", name))
if err != nil {
return nil, errors.Wrap(err, "unable to create group")
}
if resp.IsError() {
if resp.StatusCode() == http.StatusConflict {
return nil, AlreadyExistsError("already exists")
}
return nil, errors.Errorf("status: %s, body: %s", resp.Status(), resp.String())
}
var gr Group
if err := decodeGerritResponse(resp.String(), &gr); err != nil {
return nil, errors.Wrap(err, "unable to unmarshal group response")
}
return &gr, nil
}