diff --git a/domain.go b/domain.go index 5d06971..cd31705 100644 --- a/domain.go +++ b/domain.go @@ -34,6 +34,33 @@ type Domain struct { Username string `json:"username" yaml:"username"` } +// AddDomainIP (user) adds an additional IP to a domain. +func (c *UserContext) AddDomainIP(domain string, ip string, createDNSRecords bool) error { + var response apiGenericResponse + + body := url.Values{} + body.Set("action", "multi_ip") + body.Set("add", "yes") + body.Set("domain", domain) + body.Set("ip", ip) + + if createDNSRecords { + body.Set("dns", "yes") + } else { + body.Set("dns", "no") + } + + if _, err := c.makeRequestOld(http.MethodPost, "DOMAIN", body, &response); err != nil { + return fmt.Errorf("failed to add IP to domain: %v", err) + } + + if response.Success != "IP Added" { + return fmt.Errorf("failed to add IP to domain: %v", response.Result) + } + + return nil +} + // CheckDomainExists (user) checks if the given domain exists on the server func (c *UserContext) CheckDomainExists(domain string) error { return c.checkObjectExists(url.Values{ diff --git a/reseller.go b/reseller.go index ba95b31..4723fe6 100644 --- a/reseller.go +++ b/reseller.go @@ -28,6 +28,26 @@ func (c *ResellerContext) CheckUserExists(username string) error { }) } +// AddUserIP (reseller) adds an additional IP to a user's account. +func (c *ResellerContext) AddUserIP(username string, ip string) error { + var response apiGenericResponse + + body := url.Values{} + body.Set("action", "multi_ip") + body.Set("extra_ip", ip) + body.Set("user", username) + + if _, err := c.makeRequestOld(http.MethodPost, "MODIFY_USER", body, &response); err != nil { + return fmt.Errorf("failed to add IP to user account: %v", err) + } + + if response.Success != "IP Added" { + return fmt.Errorf("failed to add IP to user account: %v", response.Result) + } + + return nil +} + // CreateUser (reseller) create a user. // // The following fields must be populated: Domain, Email, IpAddresses, Package, Username