1
- from datetime import datetime
2
- from dynatrace .dynatrace_object import DynatraceObject
3
- from typing import List , Optional , Union , Dict , Any
1
+ from typing import Optional , Dict , Any
4
2
3
+ from dynatrace .dynatrace_object import DynatraceObject
5
4
from dynatrace .http_client import HttpClient
6
5
from dynatrace .pagination import PaginatedList
7
- import json
8
- import logging
9
- from http .client import HTTPConnection # py3
10
6
11
7
12
8
class SettingService :
@@ -15,7 +11,7 @@ class SettingService:
15
11
def __init__ (self , http_client : HttpClient ):
16
12
self .__http_client = http_client
17
13
18
- def list (self ,schema_id : Optional [str ] = None ,
14
+ def list_objects (self ,schema_id : Optional [str ] = None ,
19
15
scope : Optional [str ] = None ,external_ids : Optional [str ] = None ,
20
16
fields : Optional [str ] = None ,
21
17
filter :Optional [str ] = None , sort :Optional [str ] = None , page_size :Optional [str ] = None ) -> PaginatedList ["DynatraceObject" ]:
@@ -34,15 +30,15 @@ def list(self,schema_id: Optional[str] = None,
34
30
}
35
31
return PaginatedList (Settings , self .__http_client , target_url = self .ENDPOINT , list_item = "items" , target_params = params )
36
32
37
- def post (self ,external_id ,object_id ,schema_id ,schema_version ,scope , value ,validate_only ):
33
+ def create_object (self ,external_id ,object_id ,schema_id ,schema_version ,scope , value ,validate_only ):
38
34
"""Creates a new settings object
39
35
40
36
:param external_id: External identifier for the object being created
41
37
:param object_id: The ID of the settings object that should be replaced. Only applicable if an external identifier
42
38
:param object_id: the ID of the object
43
39
:param schema_id: The schema on which the object is based
44
40
:param schema_version: The version of the schema on which the object is based.
45
- :param scope The scope that the object targets. For more details, please see Dynatrace Documentation .
41
+ :param scope The scope that the object targets. For more details, please see Dynatrace Documentation.
46
42
:param value The value of the setting.
47
43
:return: a Settings object
48
44
"""
@@ -63,7 +59,7 @@ def post(self,external_id,object_id,schema_id,schema_version,scope, value,valida
63
59
return response
64
60
65
61
66
- def get (self , object_id : str ):
62
+ def get_object (self , object_id : str ):
67
63
"""Gets parameters of specified settings object
68
64
69
65
:param object_id: the ID of the object
@@ -72,14 +68,15 @@ def get(self, object_id: str):
72
68
response = self .__http_client .make_request (f"{ self .ENDPOINT } /{ object_id } " ).json ()
73
69
return Settings (raw_element = response )
74
70
75
- def update (self , object_id : str , value ):
71
+ def update_object (self , object_id : str , value ):
76
72
"""Updates an existing settings object
73
+
77
74
:param object_id: the ID of the object
78
75
79
76
"""
80
77
return self .__http_client .make_request (path = f"{ self .ENDPOINT } /{ object_id } " , params = value , method = "PUT" )
81
78
82
- def delete (self , object_id : str ):
79
+ def delete_object (self , object_id : str ):
83
80
"""Deletes the specified object
84
81
85
82
:param object_id: the ID of the object
@@ -88,10 +85,7 @@ def delete(self, object_id: str):
88
85
return self .__http_client .make_request (path = f"{ self .ENDPOINT } /{ object_id } " , method = "DELETE" )
89
86
90
87
class Settings (DynatraceObject ):
91
- value = None
92
88
def _create_from_raw_data (self , raw_element : Dict [str , Any ]):
93
89
# Mandatory
94
90
self .objectId : str = raw_element ["objectId" ]
95
91
self .value : str = raw_element ["value" ]
96
- def to_json (self ):
97
- return self .value
0 commit comments