diff --git a/access.go b/access.go index 933bf3b..11c1ad2 100644 --- a/access.go +++ b/access.go @@ -59,11 +59,10 @@ func (c *Client) Password(userid, password string) error { } // NewDomain create a new domain with the required two parameters pull it and use domain.Update to configure -// t is an enum: ad, ldap, openid, pam, pve -func (c *Client) NewDomain(realm, t string) error { +func (c *Client) NewDomain(realm string, domainType DomainType) error { return c.Post("/access/domains", map[string]string{ "realm": realm, - "type": t, + "type": string(domainType), }, nil) } diff --git a/types.go b/types.go index 28ecb39..14c31d2 100644 --- a/types.go +++ b/types.go @@ -275,11 +275,11 @@ type Time struct { type Timeframe string const ( - HOUR = Timeframe("hour") - DAY = Timeframe("day") - WEEK = Timeframe("week") - MONTH = Timeframe("month") - YEAR = Timeframe("year") + TimeframeHour = Timeframe("hour") + TimeframeDay = Timeframe("day") + TimeframeWeek = Timeframe("week") + TimeframeMonth = Timeframe("month") + TimeframeYear = Timeframe("year") ) type ConsolidationFunction string @@ -975,6 +975,16 @@ type PoolUpdateOption struct { VirtualMachines string `json:"vms,omitempty"` } +type DomainType string + +const ( + DomainTypeAD = DomainType("ad") + DomainTypeLDAP = DomainType("ldap") + DomainTypeOpenID = DomainType("openid") + DomainTypePam = DomainType("pam") + DomainTypePVE = DomainType("pve") +) + type Domains []*Domain type Domain struct { client *Client diff --git a/virtual_machine_test.go b/virtual_machine_test.go index 456fff2..fd5f4eb 100644 --- a/virtual_machine_test.go +++ b/virtual_machine_test.go @@ -32,7 +32,7 @@ func TestVirtualMachine_RRDData(t *testing.T) { Node: "node1", } - rdddata, err := vm.RRDData(HOUR) + rdddata, err := vm.RRDData(TimeframeHour) assert.Nil(t, err) assert.Len(t, rdddata, 70) }