Skip to content

Commit

Permalink
adding domain type, renamed timeframe const (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
luthermonson authored Aug 31, 2023
1 parent a2abbc3 commit 29b2e77
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
5 changes: 2 additions & 3 deletions access.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
20 changes: 15 additions & 5 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion virtual_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 29b2e77

Please sign in to comment.