Skip to content

Commit 4d5255e

Browse files
committed
feat(extensions): Adds scope parameter
1 parent d13a690 commit 4d5255e

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

dynatrace/api/v2/hub/extension/config/service.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func (me *service) Get(ctx context.Context, id string, v *extension_config.Setti
9393

9494
injectScope(response.Scope, v)
9595
v.Name = name
96+
v.Scope = response.Scope
9697

9798
// Try to replace placeholders only if stateConfig and response.Value are valid
9899
if stateConfig != nil && response.Value != nil {
@@ -299,6 +300,9 @@ func injectScope(scope string, v *extension_config.Settings) {
299300
}
300301

301302
func extractScope(v *extension_config.Settings) string {
303+
if v.Scope != "" {
304+
return v.Scope
305+
}
302306
if len(v.ActiveGateGroup) > 0 {
303307
return fmt.Sprintf("ag_group-%s", v.ActiveGateGroup)
304308
}

dynatrace/api/v2/hub/extension/config/settings/settings.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131

3232
type Settings struct {
3333
Name string `json:"-"`
34+
Scope string `json:"-"`
3435
Value string `json:"-"`
3536
Host string `json:"-"`
3637
HostGroup string `json:"-"`
@@ -48,6 +49,12 @@ func (me *Settings) Schema() map[string]*schema.Schema {
4849
ForceNew: true,
4950
Required: true,
5051
},
52+
"scope": {
53+
Type: schema.TypeString,
54+
Description: "The scope this monitoring configuration will be defined for",
55+
ForceNew: true,
56+
Optional: true,
57+
},
5158
"host": {
5259
Type: schema.TypeString,
5360
Description: "The ID of the host this monitoring configuration will be defined for",
@@ -187,6 +194,7 @@ func (me *Settings) MarshalHCL(properties hcl.Properties) error {
187194
return properties.EncodeAll(map[string]any{
188195
"name": me.Name,
189196
"value": me.Value,
197+
"scope": me.Scope,
190198
"host": me.Host,
191199
"host_group": me.HostGroup,
192200
"active_gate_group": me.ActiveGateGroup,
@@ -198,6 +206,7 @@ func (me *Settings) UnmarshalHCL(decoder hcl.Decoder) error {
198206
return decoder.DecodeAll(map[string]any{
199207
"name": &me.Name,
200208
"value": &me.Value,
209+
"scope": &me.Scope,
201210
"host": &me.Host,
202211
"host_group": &me.HostGroup,
203212
"active_gate_group": &me.ActiveGateGroup,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
resource "dynatrace_hub_extension_config" "com_dynatrace_extension_jmx-weblogic-cp2" {
2+
name = "com.dynatrace.extension.jmx-weblogic-cp"
3+
scope = "environment"
4+
value = jsonencode(
5+
{
6+
"enabled" : true,
7+
"description" : "jj",
8+
"version" : "2.0.4",
9+
"featureSets" : [
10+
"cache",
11+
"connections",
12+
"capacity"
13+
]
14+
}
15+
)
16+
}

0 commit comments

Comments
 (0)