Skip to content

Commit 9eba535

Browse files
committed
Introduced dynatrace_monitored_technologies_python resource
1 parent 157a58c commit 9eba535

File tree

10 files changed

+207
-0
lines changed

10 files changed

+207
-0
lines changed

.github/workflows/tests.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ jobs:
9999
DT_CLIENT_SECRET: ${{ secrets.DT_CLIENT_SECRET }}
100100
DT_ACCOUNT_ID: ${{ secrets.DT_ACCOUNT_ID }}
101101
run: go test -v ./dynatrace/api/builtin/securitycontext
102+
- name: TestAccMonitoredTechnologiesPython
103+
if: success() || failure()
104+
env:
105+
GOPROXY: "https://proxy.golang.org"
106+
TF_ACC: true
107+
DYNATRACE_DEBUG: true
108+
DT_NO_REPAIR_INPUT: false
109+
DYNATRACE_ENV_URL: ${{ secrets.DYNATRACE_ENV_URL }}
110+
DYNATRACE_API_TOKEN: ${{ secrets.DYNATRACE_API_TOKEN }}
111+
DT_CLIENT_ID: ${{ secrets.DT_CLIENT_ID }}
112+
DT_CLIENT_SECRET: ${{ secrets.DT_CLIENT_SECRET }}
113+
DT_ACCOUNT_ID: ${{ secrets.DT_ACCOUNT_ID }}
114+
run: go test -v ./dynatrace/api/builtin/monitoredtechnologies/python
102115
- name: TestAccWebAppAutoInjection
103116
if: success() || failure()
104117
env:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"allowedScopes": [
3+
"HOST",
4+
"environment"
5+
],
6+
"description": "By default, Python monitoring is disabled on all hosts. If you want to enable Python monitoring on selected hosts, enable it on these hosts via their settings.\n\nIf you want to disable Python monitoring only on selected hosts, enable global Python monitoring and disable it on these hosts via their settings.",
7+
"displayName": "Python",
8+
"documentation": "",
9+
"dynatrace": "1",
10+
"enums": {},
11+
"maxObjects": 1,
12+
"metadata": {
13+
"minAgentVersion": "1.301"
14+
},
15+
"multiObject": false,
16+
"properties": {
17+
"enabled": {
18+
"default": false,
19+
"description": "",
20+
"displayName": "Monitor Python",
21+
"documentation": "",
22+
"maxObjects": 1,
23+
"modificationPolicy": "DEFAULT",
24+
"nullable": false,
25+
"type": "boolean"
26+
}
27+
},
28+
"schemaId": "builtin:monitored-technologies.python",
29+
"types": {},
30+
"version": "1.0.1"
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Dynatrace LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package python
19+
20+
import (
21+
python "github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api/builtin/monitoredtechnologies/python/settings"
22+
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/settings"
23+
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/settings/services/settings20"
24+
)
25+
26+
const SchemaVersion = "1.0.1"
27+
const SchemaID = "builtin:monitored-technologies.python"
28+
29+
func Service(credentials *settings.Credentials) settings.CRUDService[*python.Settings] {
30+
return settings20.Service[*python.Settings](credentials, SchemaID, SchemaVersion)
31+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Dynatrace LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package python_test
19+
20+
import (
21+
"testing"
22+
)
23+
24+
func TestAccMonitoredTechnologiesPython(t *testing.T) {
25+
// Temporarily disabled - not available on test tenant (enable with v310)
26+
// api.TestAcc(t)
27+
t.Skip()
28+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Dynatrace LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package python
19+
20+
import (
21+
"github.com/dynatrace-oss/terraform-provider-dynatrace/terraform/hcl"
22+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
23+
)
24+
25+
type Settings struct {
26+
Enabled bool `json:"enabled"` // This setting is enabled (`true`) or disabled (`false`)
27+
HostID *string `json:"-" scope:"hostId"` // The scope of this settings. If the settings should cover the whole environment, just don't specify any scope.
28+
}
29+
30+
func (me *Settings) Name() string {
31+
return *me.HostID
32+
}
33+
34+
func (me *Settings) Schema() map[string]*schema.Schema {
35+
return map[string]*schema.Schema{
36+
"enabled": {
37+
Type: schema.TypeBool,
38+
Description: "This setting is enabled (`true`) or disabled (`false`)",
39+
Required: true,
40+
},
41+
"host_id": {
42+
Type: schema.TypeString,
43+
Description: "The scope of this settings. If the settings should cover the whole environment, just don't specify any scope.",
44+
Optional: true,
45+
Default: "environment",
46+
},
47+
}
48+
}
49+
50+
func (me *Settings) MarshalHCL(properties hcl.Properties) error {
51+
return properties.EncodeAll(map[string]any{
52+
"enabled": me.Enabled,
53+
"host_id": me.HostID,
54+
})
55+
}
56+
57+
func (me *Settings) UnmarshalHCL(decoder hcl.Decoder) error {
58+
return decoder.DecodeAll(map[string]any{
59+
"enabled": &me.Enabled,
60+
"host_id": &me.HostID,
61+
})
62+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resource "dynatrace_monitored_technologies_python" "#name#" {
2+
enabled = false
3+
host_id = "environment"
4+
}

dynatrace/export/enums.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ var ResourceTypes = struct {
290290
MonitoredTechnologiesNodeJS ResourceType
291291
MonitoredTechnologiesOpenTracing ResourceType
292292
MonitoredTechnologiesPHP ResourceType
293+
MonitoredTechnologiesPython ResourceType
293294
MonitoredTechnologiesVarnish ResourceType
294295
MonitoredTechnologiesWSMB ResourceType
295296
ProcessVisibility ResourceType
@@ -625,6 +626,7 @@ var ResourceTypes = struct {
625626
"dynatrace_monitored_technologies_nodejs",
626627
"dynatrace_monitored_technologies_opentracing",
627628
"dynatrace_monitored_technologies_php",
629+
"dynatrace_monitored_technologies_python",
628630
"dynatrace_monitored_technologies_varnish",
629631
"dynatrace_monitored_technologies_wsmb",
630632
"dynatrace_process_visibility",

dynatrace/export/resource_descriptor.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ import (
179179
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api/builtin/monitoredtechnologies/nodejs"
180180
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api/builtin/monitoredtechnologies/opentracingnative"
181181
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api/builtin/monitoredtechnologies/php"
182+
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api/builtin/monitoredtechnologies/python"
182183
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api/builtin/monitoredtechnologies/varnish"
183184
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api/builtin/monitoredtechnologies/wsmb"
184185
slov2 "github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api/builtin/monitoring/slo"
@@ -929,6 +930,10 @@ var AllResources = map[ResourceType]ResourceDescriptor{
929930
php.Service,
930931
Coalesce(Dependencies.Host),
931932
),
933+
ResourceTypes.MonitoredTechnologiesPython: NewResourceDescriptor(
934+
python.Service,
935+
Coalesce(Dependencies.Host),
936+
),
932937
ResourceTypes.MonitoredTechnologiesVarnish: NewResourceDescriptor(
933938
varnish.Service,
934939
Coalesce(Dependencies.Host),

provider/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ func Provider() *schema.Provider {
393393
"dynatrace_monitored_technologies_nodejs": resources.NewGeneric(export.ResourceTypes.MonitoredTechnologiesNodeJS).Resource(),
394394
"dynatrace_monitored_technologies_opentracing": resources.NewGeneric(export.ResourceTypes.MonitoredTechnologiesOpenTracing).Resource(),
395395
"dynatrace_monitored_technologies_php": resources.NewGeneric(export.ResourceTypes.MonitoredTechnologiesPHP).Resource(),
396+
"dynatrace_monitored_technologies_python": resources.NewGeneric(export.ResourceTypes.MonitoredTechnologiesPython).Resource(),
396397
"dynatrace_monitored_technologies_varnish": resources.NewGeneric(export.ResourceTypes.MonitoredTechnologiesVarnish).Resource(),
397398
"dynatrace_monitored_technologies_wsmb": resources.NewGeneric(export.ResourceTypes.MonitoredTechnologiesWSMB).Resource(),
398399
"dynatrace_process_visibility": resources.NewGeneric(export.ResourceTypes.ProcessVisibility).Resource(),
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
layout: ""
3+
page_title: dynatrace_monitored_technologies_python Resource - terraform-provider-dynatrace"
4+
subcategory: "Monitored Technologies"
5+
description: |-
6+
The resource `dynatrace_monitored_technologies_python` covers configuration to enable/disable Python monitoring
7+
---
8+
9+
# dynatrace_monitored_technologies_python (Resource)
10+
11+
-> This resource requires the API token scopes **Read settings** (`settings.read`) and **Write settings** (`settings.write`)
12+
13+
## Dynatrace Documentation
14+
15+
- Hosts - https://www.dynatrace.com/support/help/platform-modules/infrastructure-monitoring/hosts
16+
17+
- Settings API - https://www.dynatrace.com/support/help/dynatrace-api/environment-api/settings (schemaId: `builtin:monitored-technologies.python`)
18+
19+
## Export Example Usage
20+
21+
- `terraform-provider-dynatrace -export dynatrace_monitored_technologies_python` downloads all existing Python monitoring configuration
22+
23+
The full documentation of the export feature is available [here](https://dt-url.net/h203qmc).
24+
25+
## Resource Example Usage
26+
27+
{{ tffile "dynatrace/api/builtin/monitoredtechnologies/python/testdata/terraform/example_a.tf" }}
28+
29+
{{ .SchemaMarkdown | trimspace }}
30+

0 commit comments

Comments
 (0)