-
Notifications
You must be signed in to change notification settings - Fork 32
/
user_sessions.go
46 lines (39 loc) · 1.65 KB
/
user_sessions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package quota
import (
"github.com/dynatrace-oss/terraform-provider-dynatrace/terraform/hcl"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
// UserSessions represents user sessions consumption and quota information on environment level. If skipped when editing via PUT method then already set quotas will remain
type UserSessions struct {
TotalAnnualLimit *int64 `json:"totalAnnualLimit"` // Annual total User sessions environment quota. Not set if unlimited. When updating via PUT method, skipping this field will set quota unlimited
TotalMonthlyLimit *int64 `json:"totalMonthlyLimit"` // Monthly total User sessions environment quota. Not set if unlimited. When updating via PUT method, skipping this field will set quota unlimited
}
func (me *UserSessions) IsEmpty() bool {
return me == nil || (me.TotalAnnualLimit == nil && me.TotalMonthlyLimit == nil)
}
func (me *UserSessions) Schema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"annual": {
Type: schema.TypeInt,
Optional: true,
Description: "Annual total User sessions environment quota. Not set if unlimited",
},
"monthly": {
Type: schema.TypeInt,
Optional: true,
Description: "Monthly total User sessions environment quota. Not set if unlimited",
},
}
}
func (me *UserSessions) MarshalHCL(properties hcl.Properties) error {
return properties.EncodeAll(map[string]any{
"monthly": me.TotalMonthlyLimit,
"annual": me.TotalAnnualLimit,
})
}
func (me *UserSessions) UnmarshalHCL(decoder hcl.Decoder) error {
return decoder.DecodeAll(map[string]any{
"monthly": &me.TotalMonthlyLimit,
"annual": &me.TotalAnnualLimit,
})
}