@@ -88,12 +88,63 @@ def delete_user_current_organization(self, user_id):
88
88
r = self .client .DELETE (delete_user_current_organization_path )
89
89
return r
90
90
91
+ def get_preferences (self ):
92
+ """
93
+ Retrieve preferences of current organization.
94
+
95
+ :return:
96
+ """
97
+ update_preference = "/org/preferences"
98
+ r = self .client .GET (update_preference )
99
+ return r
100
+
101
+ def update_preferences (self , preferences : PersonalPreferences ):
102
+ """
103
+ Update preferences of current organization as a whole.
104
+
105
+ From the `preferences` instance, only attributes with values `not None` will be submitted.
106
+ However, Grafana will reset all undefined attributes to its internal defaults.
107
+
108
+ If you want to update specific preference attributes, without touching the others,
109
+ please use the `patch_preferences` method.
110
+
111
+ :param preferences:
112
+ :return:
113
+ """
114
+ update_preference = "/org/preferences"
115
+ data = preferences .asdict (filter_none = True )
116
+
117
+ r = self .client .PUT (
118
+ update_preference ,
119
+ json = data ,
120
+ )
121
+ return r
122
+
123
+ def patch_preferences (self , preferences : PersonalPreferences ):
124
+ """
125
+ Update specific preferences of current organization.
126
+
127
+ From the `preferences` instance, only attributes with values `not None` will be submitted
128
+ and updated.
129
+
130
+ :param preferences:
131
+ :return:
132
+ """
133
+ update_preference = "/org/preferences"
134
+ data = preferences .asdict (filter_none = True )
135
+
136
+ r = self .client .PATCH (
137
+ update_preference ,
138
+ json = data ,
139
+ )
140
+ return r
141
+
91
142
92
143
class Organizations (Base ):
93
- def __init__ (self , client ):
144
+ def __init__ (self , client , api ):
94
145
super (Organizations , self ).__init__ (client )
95
146
self .client = client
96
- self .path = "/users"
147
+ self .api = api
97
148
98
149
def update_organization (self , organization_id , organization ):
99
150
"""
@@ -183,8 +234,8 @@ def organization_preference_get(self):
183
234
"""
184
235
:return:
185
236
"""
186
- warnings .warn ("This method is deprecated, please use `get_preferences`" , DeprecationWarning )
187
- return self .get_preferences ()
237
+ warnings .warn ("This method is deprecated, please use `organization. get_preferences`" , DeprecationWarning )
238
+ return self .api . organization . get_preferences ()
188
239
189
240
def organization_preference_update (self , theme = "" , home_dashboard_id = 0 , timezone = "utc" ):
190
241
"""
@@ -194,57 +245,6 @@ def organization_preference_update(self, theme="", home_dashboard_id=0, timezone
194
245
:param timezone:
195
246
:return:
196
247
"""
197
- warnings .warn ("This method is deprecated, please use `update_preferences`" , DeprecationWarning )
248
+ warnings .warn ("This method is deprecated, please use `organization. update_preferences`" , DeprecationWarning )
198
249
preferences = PersonalPreferences (theme = theme , homeDashboardId = home_dashboard_id , timezone = timezone )
199
- return self .update_preferences (preferences )
200
-
201
- def get_preferences (self ):
202
- """
203
- Retrieve preferences of current organization.
204
-
205
- :return:
206
- """
207
- update_preference = "/org/preferences"
208
- r = self .client .GET (update_preference )
209
- return r
210
-
211
- def update_preferences (self , preferences : PersonalPreferences ):
212
- """
213
- Update preferences of current organization as a whole.
214
-
215
- From the `preferences` instance, only attributes with values `not None` will be submitted.
216
- However, Grafana will reset all undefined attributes to its internal defaults.
217
-
218
- If you want to update specific preference attributes, without touching the others,
219
- please use the `patch_preferences` method.
220
-
221
- :param preferences:
222
- :return:
223
- """
224
- update_preference = "/org/preferences"
225
- data = preferences .asdict (filter_none = True )
226
-
227
- r = self .client .PUT (
228
- update_preference ,
229
- json = data ,
230
- )
231
- return r
232
-
233
- def patch_preferences (self , preferences : PersonalPreferences ):
234
- """
235
- Update specific preferences of current organization.
236
-
237
- From the `preferences` instance, only attributes with values `not None` will be submitted
238
- and updated.
239
-
240
- :param preferences:
241
- :return:
242
- """
243
- update_preference = "/org/preferences"
244
- data = preferences .asdict (filter_none = True )
245
-
246
- r = self .client .PATCH (
247
- update_preference ,
248
- json = data ,
249
- )
250
- return r
250
+ return self .api .organization .update_preferences (preferences )
0 commit comments