15
15
"""
16
16
17
17
from typing import List , Dict , Any
18
+ from enum import Enum
18
19
19
20
from dynatrace .environment_v2 .schemas import ConfigurationMetadata
20
21
from dynatrace .dynatrace_object import DynatraceObject
26
27
ConditionKeyAttribute ,
27
28
ConditionKeyType ,
28
29
PropagationType ,
29
- RuleType ,
30
30
)
31
31
32
32
33
+ class RuleType (Enum ):
34
+ APPMON_SERVER = "APPMON_SERVER"
35
+ APPMON_SYSTEM_PROFILE = "APPMON_SYSTEM_PROFILE"
36
+ AWS_ACCOUNT = "AWS_ACCOUNT"
37
+ AWS_APPLICATION_LOAD_BALANCER = "AWS_APPLICATION_LOAD_BALANCER"
38
+ AWS_AUTO_SCALING_GROUP = "AWS_AUTO_SCALING_GROUP"
39
+ AWS_CLASSIC_LOAD_BALANCER = "AWS_CLASSIC_LOAD_BALANCER"
40
+ AWS_NETWORK_LOAD_BALANCER = "AWS_NETWORK_LOAD_BALANCER"
41
+ AWS_RELATIONAL_DATABASE_SERVICE = "AWS_RELATIONAL_DATABASE_SERVICE"
42
+ AZURE = "AZURE"
43
+ BROWSER_MONITOR = "BROWSER_MONITOR"
44
+ CLOUD_APPLICATION = "CLOUD_APPLICATION"
45
+ CLOUD_APPLICATION_NAMESPACE = "CLOUD_APPLICATION_NAMESPACE"
46
+ CLOUD_FOUNDRY_FOUNDATION = "CLOUD_FOUNDRY_FOUNDATION"
47
+ CUSTOM_APPLICATION = "CUSTOM_APPLICATION"
48
+ CUSTOM_DEVICE = "CUSTOM_DEVICE"
49
+ CUSTOM_DEVICE_GROUP = "CUSTOM_DEVICE_GROUP"
50
+ DATA_CENTER_SERVICE = "DATA_CENTER_SERVICE"
51
+ ENTERPRISE_APPLICATION = "ENTERPRISE_APPLICATION"
52
+ ESXI_HOST = "ESXI_HOST"
53
+ EXTERNAL_MONITOR = "EXTERNAL_MONITOR"
54
+ HOST = "HOST"
55
+ HOST_GROUP = "HOST_GROUP"
56
+ HTTP_MONITOR = "HTTP_MONITOR"
57
+ KUBERNETES_CLUSTER = "KUBERNETES_CLUSTER"
58
+ KUBERNETES_SERVICE = "KUBERNETES_SERVICE"
59
+ MOBILE_APPLICATION = "MOBILE_APPLICATION"
60
+ MULTIPROTOCOL_MONITOR = "MULTIPROTOCOL_MONITOR"
61
+ OPENSTACK_ACCOUNT = "OPENSTACK_ACCOUNT"
62
+ PROCESS_GROUP = "PROCESS_GROUP"
63
+ QUEUE = "QUEUE"
64
+ SERVICE = "SERVICE"
65
+ WEB_APPLICATION = "WEB_APPLICATION"
66
+ NONE = None
67
+
68
+
33
69
class ManagementZoneService :
34
70
ENDPOINT = "/api/config/v1/managementZones"
35
71
36
72
def __init__ (self , http_client : HttpClient ):
37
73
self .__http_client = http_client
38
74
39
- def list (self , page_size : int = 200 ) -> PaginatedList ["ManagementZoneShortRepresentation" ]:
75
+ def list (
76
+ self , page_size : int = 200
77
+ ) -> PaginatedList ["ManagementZoneShortRepresentation" ]:
40
78
"""
41
79
List all management zones.
42
80
43
81
:param page_size: The number of results per result page. Must be between 1 and 500
44
82
Default value : 200
45
83
"""
46
84
params = {"pageSize" : page_size }
47
- return PaginatedList (ManagementZoneShortRepresentation , self .__http_client , f"{ self .ENDPOINT } " , params , list_item = "values" )
85
+ return PaginatedList (
86
+ ManagementZoneShortRepresentation ,
87
+ self .__http_client ,
88
+ f"{ self .ENDPOINT } " ,
89
+ params ,
90
+ list_item = "values" ,
91
+ )
48
92
49
93
def get (self , management_zone_id : str ) -> "ManagementZone" :
50
94
"""Gets the description of a management zone referenced by ID.
@@ -53,16 +97,22 @@ def get(self, management_zone_id: str) -> "ManagementZone":
53
97
54
98
:returns Event: the requested management zone
55
99
"""
56
- response = self .__http_client .make_request (path = f"{ self .ENDPOINT } /{ management_zone_id } " )
57
- return ManagementZone (raw_element = response .json (), http_client = self .__http_client )
100
+ response = self .__http_client .make_request (
101
+ path = f"{ self .ENDPOINT } /{ management_zone_id } "
102
+ )
103
+ return ManagementZone (
104
+ raw_element = response .json (), http_client = self .__http_client
105
+ )
58
106
59
107
def delete (self , management_zone_id : str ):
60
108
"""Deletes the specified management zone
61
109
62
110
:param networkzone_id: the ID of the management zone
63
111
:return: HTTP response
64
112
"""
65
- return self .__http_client .make_request (path = f"{ self .ENDPOINT } /{ management_zone_id } " , method = "DELETE" )
113
+ return self .__http_client .make_request (
114
+ path = f"{ self .ENDPOINT } /{ management_zone_id } " , method = "DELETE"
115
+ )
66
116
67
117
68
118
class ComparisonBasic (DynatraceObject ):
@@ -76,14 +126,18 @@ def _create_from_raw_data(self, raw_element: Dict[str, Any]):
76
126
77
127
class ConditionKey (DynatraceObject ):
78
128
def _create_from_raw_data (self , raw_element : Dict [str , Any ]):
79
- self .attribute : ConditionKeyAttribute = ConditionKeyAttribute (raw_element .get ("attribute" ))
129
+ self .attribute : ConditionKeyAttribute = ConditionKeyAttribute (
130
+ raw_element .get ("attribute" )
131
+ )
80
132
self .type : ConditionKeyType = ConditionKeyType (raw_element .get ("type" ))
81
133
82
134
83
135
class EntityRuleEngineCondition (DynatraceObject ):
84
136
def _create_from_raw_data (self , raw_element : Dict [str , Any ]):
85
137
self .key : ConditionKey = ConditionKey (raw_element = raw_element .get ("key" ))
86
- self .comparison_info : ComparisonBasic = ComparisonBasic (raw_element = raw_element .get ("comparisonInfo" ))
138
+ self .comparison_info : ComparisonBasic = ComparisonBasic (
139
+ raw_element = raw_element .get ("comparisonInfo" )
140
+ )
87
141
88
142
89
143
class EntitySelectorBasedManagementZoneRule (DynatraceObject ):
@@ -98,21 +152,32 @@ def _create_from_raw_data(self, raw_element: Dict[str, Any]):
98
152
self .type : RuleType = RuleType (raw_element .get ("type" ))
99
153
self .enabled : bool = raw_element .get ("enabled" )
100
154
self .value_format : str = raw_element .get ("valueFormat" )
101
- self .propagation_types : List [PropagationType ] = [PropagationType (prop_type ) for prop_type in (raw_element .get ("propagationTypes" ) or [])]
155
+ self .propagation_types : List [PropagationType ] = [
156
+ PropagationType (prop_type )
157
+ for prop_type in (raw_element .get ("propagationTypes" ) or [])
158
+ ]
102
159
self .conditions : List [EntityRuleEngineCondition ] = [
103
- EntityRuleEngineCondition (raw_element = condition ) for condition in (raw_element .get ("conditions" ) or [])
160
+ EntityRuleEngineCondition (raw_element = condition )
161
+ for condition in (raw_element .get ("conditions" ) or [])
104
162
]
105
163
106
164
107
165
class ManagementZone (DynatraceObject ):
108
166
def _create_from_raw_data (self , raw_element : Dict [str , Any ]):
109
- self .metadata : ConfigurationMetadata = ConfigurationMetadata (self ._http_client , None , raw_element .get ("metadata" ))
167
+ self .metadata : ConfigurationMetadata = ConfigurationMetadata (
168
+ self ._http_client , None , raw_element .get ("metadata" )
169
+ )
110
170
self .id : str = raw_element .get ("id" )
111
171
self .name : str = raw_element .get ("name" )
112
172
self .description : str = raw_element .get ("description" )
113
- self .rules : List [ManagementZoneRule ] = [ManagementZoneRule (raw_element = rule ) for rule in raw_element .get ("rules" )]
114
- self .entity_selector_based_rules : List [EntitySelectorBasedManagementZoneRule ] = [
115
- EntitySelectorBasedManagementZoneRule (raw_element = rule ) for rule in (raw_element .get ("entitySelectorBasedRules" ) or [])
173
+ self .rules : List [ManagementZoneRule ] = [
174
+ ManagementZoneRule (raw_element = rule ) for rule in raw_element .get ("rules" )
175
+ ]
176
+ self .entity_selector_based_rules : List [
177
+ EntitySelectorBasedManagementZoneRule
178
+ ] = [
179
+ EntitySelectorBasedManagementZoneRule (raw_element = rule )
180
+ for rule in (raw_element .get ("entitySelectorBasedRules" ) or [])
116
181
]
117
182
118
183
@@ -121,5 +186,7 @@ def get_full_configuration(self):
121
186
"""
122
187
Get the full configuration for this management zone short representation.
123
188
"""
124
- response = self ._http_client .make_request (f"{ ManagementZoneService .ENDPOINT } /{ self .id } " ).json ()
189
+ response = self ._http_client .make_request (
190
+ f"{ ManagementZoneService .ENDPOINT } /{ self .id } "
191
+ ).json ()
125
192
return ManagementZone (http_client = self ._http_client , raw_element = response )
0 commit comments