| 53 | } |
| 54 | |
| 55 | func (c *Client) CreateGroup(ctx context.Context, orgID uuid.UUID, req CreateGroupRequest) (Group, error) { |
| 56 | res, err := c.Request(ctx, http.MethodPost, |
| 57 | fmt.Sprintf("/api/v2/organizations/%s/groups", orgID.String()), |
| 58 | req, |
| 59 | ) |
| 60 | if err != nil { |
| 61 | return Group{}, xerrors.Errorf("make request: %w", err) |
| 62 | } |
| 63 | defer res.Body.Close() |
| 64 | |
| 65 | if res.StatusCode != http.StatusCreated { |
| 66 | return Group{}, ReadBodyAsError(res) |
| 67 | } |
| 68 | var resp Group |
| 69 | return resp, json.NewDecoder(res.Body).Decode(&resp) |
| 70 | } |
| 71 | |
| 72 | // GroupsByOrganization |
| 73 | // Deprecated: use Groups with GroupArguments instead. |