Add method to create site

This commit is contained in:
Kurt McAlpine
2020-10-10 14:48:14 +13:00
committed by Paul Tyng
parent df937016b0
commit de011d682d

View File

@@ -29,3 +29,25 @@ func (c *Client) ListSites(ctx context.Context) ([]Site, error) {
return respBody.Data, nil
}
func (c *Client) CreateSite(ctx context.Context, Description string) ([]Site, error) {
reqBody := struct {
Cmd string `json:"cmd"`
Desc string `json:"desc"`
}{
Cmd: "add-site",
Desc: Description,
}
var respBody struct {
Meta meta `json:"meta"`
Data []Site `json:"data"`
}
err := c.do(ctx, "POST", "s/default/cmd/sitemgr", reqBody, &respBody)
if err != nil {
return nil, err
}
return respBody.Data, nil
}