-
Notifications
You must be signed in to change notification settings - Fork 33
/
ddu_pool.go
119 lines (110 loc) · 2.91 KB
/
ddu_pool.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package ddulimit
import (
"github.com/dynatrace-oss/terraform-provider-dynatrace/terraform/hcl"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func (me *DDUPool) Deprecated() string {
return "This resource API endpoint has been deprecated."
}
// DDUPool TODO: documentation
type DDUPool struct {
MetricsPool DDUPoolConfig `json:"metrics"`
LogMonitoringPool DDUPoolConfig `json:"logMonitoring"`
ServerlessPool DDUPoolConfig `json:"serverless"`
EventsPool DDUPoolConfig `json:"events"`
TracesPool DDUPoolConfig `json:"traces"`
}
func (me *DDUPool) Name() string {
return "ddupool"
}
func (me *DDUPool) Schema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"metrics": {
Type: schema.TypeList,
Optional: true,
MinItems: 1,
MaxItems: 1,
Description: "DDU pool settings for Metrics",
Elem: &schema.Resource{
Schema: new(DDUPoolConfig).Schema(),
},
},
"log_monitoring": {
Type: schema.TypeList,
Optional: true,
MinItems: 1,
MaxItems: 1,
Description: "DDU pool settings for Log Monitoring",
Elem: &schema.Resource{
Schema: new(DDUPoolConfig).Schema(),
},
},
"serverless": {
Type: schema.TypeList,
Optional: true,
MinItems: 1,
MaxItems: 1,
Description: "DDU pool settings for Serverless",
Elem: &schema.Resource{
Schema: new(DDUPoolConfig).Schema(),
},
},
"events": {
Type: schema.TypeList,
Optional: true,
MinItems: 1,
MaxItems: 1,
Description: "DDU pool settings for Events",
Elem: &schema.Resource{
Schema: new(DDUPoolConfig).Schema(),
},
},
"traces": {
Type: schema.TypeList,
Optional: true,
MinItems: 1,
MaxItems: 1,
Description: "DDU pool settings for Traces",
Elem: &schema.Resource{
Schema: new(DDUPoolConfig).Schema(),
},
},
}
}
func (me *DDUPool) MarshalHCL(properties hcl.Properties) error {
if me.MetricsPool.LimitEnabled {
if err := properties.Encode("metrics", &me.MetricsPool); err != nil {
return err
}
}
if me.LogMonitoringPool.LimitEnabled {
if err := properties.Encode("log_monitoring", &me.LogMonitoringPool); err != nil {
return err
}
}
if me.ServerlessPool.LimitEnabled {
if err := properties.Encode("serverless", &me.ServerlessPool); err != nil {
return err
}
}
if me.EventsPool.LimitEnabled {
if err := properties.Encode("events", &me.EventsPool); err != nil {
return err
}
}
if me.TracesPool.LimitEnabled {
if err := properties.Encode("traces", &me.TracesPool); err != nil {
return err
}
}
return nil
}
func (me *DDUPool) UnmarshalHCL(decoder hcl.Decoder) error {
return decoder.DecodeAll(map[string]interface{}{
"metrics": &me.MetricsPool,
"log_monitoring": &me.LogMonitoringPool,
"serverless": &me.ServerlessPool,
"events": &me.EventsPool,
"traces": &me.TracesPool,
})
}