python-openhab-rest-client 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. openhab/Actions.py +43 -0
  2. openhab/Addons.py +163 -0
  3. openhab/Audio.py +66 -0
  4. openhab/Auth.py +105 -0
  5. openhab/ChannelTypes.py +54 -0
  6. openhab/Client.py +197 -0
  7. openhab/ConfigDescriptions.py +44 -0
  8. openhab/Discovery.py +28 -0
  9. openhab/Events.py +302 -0
  10. openhab/Iconsets.py +21 -0
  11. openhab/Inbox.py +64 -0
  12. openhab/Items.py +264 -0
  13. openhab/Links.py +98 -0
  14. openhab/Logging.py +55 -0
  15. openhab/ModuleTypes.py +47 -0
  16. openhab/Persistence.py +103 -0
  17. openhab/ProfileTypes.py +32 -0
  18. openhab/Rules.py +206 -0
  19. openhab/Services.py +78 -0
  20. openhab/Sitemaps.py +88 -0
  21. openhab/Systeminfo.py +34 -0
  22. openhab/Tags.py +82 -0
  23. openhab/Templates.py +38 -0
  24. openhab/ThingTypes.py +42 -0
  25. openhab/Things.py +199 -0
  26. openhab/Transformations.py +58 -0
  27. openhab/UI.py +75 -0
  28. openhab/UUID.py +18 -0
  29. openhab/Voice.py +147 -0
  30. openhab/__init__.py +66 -0
  31. python_openhab_rest_client-0.1.0.dist-info/LICENSE +21 -0
  32. python_openhab_rest_client-0.1.0.dist-info/METADATA +2391 -0
  33. python_openhab_rest_client-0.1.0.dist-info/RECORD +70 -0
  34. python_openhab_rest_client-0.1.0.dist-info/WHEEL +5 -0
  35. python_openhab_rest_client-0.1.0.dist-info/top_level.txt +2 -0
  36. tests/__init__.py +0 -0
  37. tests/actions.py +55 -0
  38. tests/addons.py +96 -0
  39. tests/audio.py +16 -0
  40. tests/auth.py +45 -0
  41. tests/channel_events.py +14 -0
  42. tests/channel_types.py +29 -0
  43. tests/config_descriptions.py +23 -0
  44. tests/discovery.py +23 -0
  45. tests/events.py +41 -0
  46. tests/iconsets.py +19 -0
  47. tests/inbox.py +53 -0
  48. tests/inbox_events.py +15 -0
  49. tests/item_events.py +38 -0
  50. tests/items.py +120 -0
  51. tests/link_events.py +14 -0
  52. tests/links.py +74 -0
  53. tests/logging_test.py +43 -0
  54. tests/module_types.py +14 -0
  55. tests/persistence.py +78 -0
  56. tests/profile_types.py +13 -0
  57. tests/rules.py +151 -0
  58. tests/services.py +52 -0
  59. tests/sitemaps.py +65 -0
  60. tests/systeminfo.py +14 -0
  61. tests/tags.py +53 -0
  62. tests/templates.py +28 -0
  63. tests/test.py +11 -0
  64. tests/thing_events.py +17 -0
  65. tests/thing_types.py +28 -0
  66. tests/things.py +75 -0
  67. tests/transformations.py +38 -0
  68. tests/ui.py +70 -0
  69. tests/uuid.py +18 -0
  70. tests/voice.py +119 -0
openhab/Discovery.py ADDED
@@ -0,0 +1,28 @@
1
+ from .Client import OpenHABClient
2
+
3
+ class Discovery:
4
+ def __init__(self, client: OpenHABClient):
5
+ """
6
+ Initializes the Discovery class with an OpenHABClient object.
7
+
8
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
9
+ """
10
+ self.client = client
11
+
12
+ def getAllDiscoveryBindings(self) -> list:
13
+ """
14
+ Gets all bindings that support discovery.
15
+
16
+ :return: Eine Liste der Bindings als Strings.
17
+ """
18
+ return self.client.get("/discovery")
19
+
20
+ def startBindingScan(self, bindingID: str) -> int:
21
+ """
22
+ Starts asynchronous discovery process for a binding and returns the timeout in seconds of the discovery operation.
23
+
24
+ :param bindingID: The ID of the binding for which the discovery is to be started.
25
+
26
+ :return: Timeout duration of the discovery operation in seconds.
27
+ """
28
+ return self.client.post(f"/discovery/bindings/{bindingID}/scan")
openhab/Events.py ADDED
@@ -0,0 +1,302 @@
1
+ from .Client import OpenHABClient
2
+ import json
3
+
4
+ class Events:
5
+ def __init__(self, client: OpenHABClient):
6
+ """
7
+ Initializes the Events class with an OpenHABClient object.
8
+
9
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
10
+ """
11
+ self.client = client
12
+
13
+ def getAllEvents(self, topics: str = None) -> list:
14
+ """
15
+ Get all available events, optionally filtered by topic.
16
+
17
+ :param topics: A comma-separated list of topics to filter the events by.
18
+
19
+ :return: A SSE stream of events.
20
+ """
21
+ return self.client._OpenHABClient__executeSSE(
22
+ self.client.url + f"/rest/events" + (f"?topics={topics}" if topics else "")
23
+ )
24
+
25
+ def initiateStateTracker(self) -> str:
26
+ """
27
+ Initiates a new item state tracker connection.
28
+
29
+ :return: The connection ID as a string.
30
+ """
31
+
32
+ return self.client._OpenHABClient__executeSSE(self.client.url + "/rest/events/states", header={"Accept": "*/*"} )
33
+
34
+ def updateSseConnectionItems(self, connectionId: str, items: list) -> str:
35
+ """
36
+ Changes the list of items a SSE connection will receive state updates for.
37
+
38
+ :param connectionId: The ID of the existing connection.
39
+ :param items: A SSE stream of item names to subscribe to for state updates.
40
+
41
+ :return: A success message when the update is completed.
42
+ """
43
+
44
+ return self.client.post(f"/rest/events/states/{connectionId}", data=json.dumps(items), header={"Content-Type": "application/json"})
45
+
46
+ class ItemEvents:
47
+ def __init__(self, client: OpenHABClient):
48
+ """
49
+ Initializes the ItemEvents class with an OpenHABClient object.
50
+
51
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
52
+ """
53
+ self.client = client
54
+
55
+ def ItemEvent(self):
56
+ """
57
+ Get all item-related events.
58
+
59
+ :return: A SSE stream of item events.
60
+ """
61
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/items")
62
+
63
+ def ItemAddedEvent(self, itemName: str = "*"):
64
+ """
65
+ Get events for added items.
66
+
67
+ :param itemName: The name of the item (default is "*").
68
+
69
+ :return: A SSE stream of added item events.
70
+ """
71
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/items/{itemName}/added")
72
+
73
+ def ItemRemovedEvent(self, itemName: str = "*"):
74
+ """
75
+ Get events for removed items.
76
+
77
+ :param itemName: The name of the item (default is "*").
78
+
79
+ :return: A SSE stream of removed item events.
80
+ """
81
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/items/{itemName}/removed")
82
+
83
+ def ItemUpdatedEvent(self, itemName: str = "*"):
84
+ """
85
+ Get events for updated items.
86
+
87
+ :param itemName: The name of the item (default is "*").
88
+
89
+ :return: A SSE stream of updated item events.
90
+ """
91
+
92
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/items/{itemName}/updated")
93
+
94
+ def ItemCommandEvent(self, itemName: str = "*"):
95
+ """
96
+ Get events for item commands.
97
+
98
+ :param itemName: The name of the item (default is "*").
99
+
100
+ :return: A SSE stream of item command events.
101
+ """
102
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/items/{itemName}/command")
103
+
104
+ def ItemStateEvent(self, itemName: str = "*"):
105
+ """
106
+ Get events for item state changes.
107
+
108
+ :param itemName: The name of the item (default is "*").
109
+
110
+ :return: A SSE stream of item state events.
111
+ """
112
+
113
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/items/{itemName}/state")
114
+
115
+ def ItemStatePredictedEvent(self, itemName: str = "*"):
116
+ """
117
+ Get events for predicted item state changes.
118
+
119
+ :param itemName: The name of the item (default is "*").
120
+
121
+ :return: A SSE stream of item state predicted events.
122
+ """
123
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/items/{itemName}/statepredicted")
124
+
125
+ def ItemStateChangedEvent(self, itemName: str = "*"):
126
+ """
127
+ Get events for item state changes.
128
+
129
+ :param itemName: The name of the item (default is "*").
130
+
131
+ :return: A SSE stream of item state changed events.
132
+ """
133
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/items/{itemName}/statechanged")
134
+
135
+ def GroupItemStateChangedEvent(self, itemName: str, memberName: str):
136
+ """
137
+ Get events for state changes of group items.
138
+
139
+ :param itemName: The name of the item.
140
+ :param memberName: The name of the group member.
141
+
142
+ :return: A SSE stream of group item state changed events.
143
+ """
144
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/items/{itemName}/{memberName}/statechanged")
145
+
146
+ class ThingEvents:
147
+ def __init__(self, client: OpenHABClient):
148
+ """
149
+ Initializes the ThingEvents class with an OpenHABClient object.
150
+
151
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
152
+ """
153
+ self.client = client
154
+
155
+ def ThingAddedEvent(self, thingUID: str = "*"):
156
+ """
157
+ Get events for added things.
158
+
159
+ :param thingUID: The UID of the thing (default is "*").
160
+
161
+ :return: A SSE stream of added thing events.
162
+ """
163
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/things/{thingUID}/added")
164
+
165
+ def ThingRemovedEvent(self, thingUID: str = "*"):
166
+ """
167
+ Get events for removed things.
168
+
169
+ :param thingUID: The UID of the thing (default is "*").
170
+
171
+ :return: A SSE stream of removed thing events.
172
+ """
173
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/things/{thingUID}/removed")
174
+
175
+ def ThingUpdatedEvent(self, thingUID: str = "*"):
176
+ """
177
+ Get events for updated things.
178
+
179
+ :param thingUID: The UID of the thing (default is "*").
180
+
181
+ :return: A SSE stream of updated thing events.
182
+ """
183
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/things/{thingUID}/updated")
184
+
185
+ def ThingStatusInfoEvent(self, thingUID: str = "*"):
186
+ """
187
+ Get events for thing status information.
188
+
189
+ :param thingUID: The UID of the thing (default is "*").
190
+
191
+ :return: A SSE stream of thing status information events.
192
+ """
193
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/things/{thingUID}/status")
194
+
195
+ def ThingStatusInfoChangedEvent(self, thingUID: str = "*"):
196
+ """
197
+ Get events for thing status information changes.
198
+
199
+ :param thingUID: The UID of the thing (default is "*").
200
+
201
+ :return: A SSE stream of thing status information changed events.
202
+ """
203
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/things/{thingUID}/statuschanged")
204
+
205
+ class InboxEvents:
206
+ def __init__(self, client: OpenHABClient):
207
+ """
208
+ Initializes the InboxEvents class with an OpenHABClient object.
209
+
210
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
211
+ """
212
+ self.client = client
213
+
214
+ def InboxAddedEvent(self, thingUID: str = "*"):
215
+ """
216
+ Get events for added things in the inbox.
217
+
218
+ :param thingUID: The UID of the thing (default is "*").
219
+
220
+ :return: A SSE stream of added inbox events.
221
+ """
222
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/inbox/{thingUID}/added")
223
+
224
+ def InboxRemovedEvent(self, thingUID: str = "*"):
225
+ """
226
+ Get events for removed things in the inbox.
227
+
228
+ :param thingUID: The UID of the thing (default is "*").
229
+
230
+ :return: A SSE stream of removed inbox events.
231
+ """
232
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/inbox/{thingUID}/removed")
233
+
234
+ def InboxUpdatedEvent(self, thingUID: str = "*"):
235
+ """
236
+ Get events for updated things in the inbox.
237
+
238
+ :param thingUID: The UID of the thing (default is "*").
239
+
240
+ :return: A SSE stream of updated inbox events.
241
+ """
242
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/inbox/{thingUID}/updated")
243
+
244
+ class LinkEvents:
245
+ def __init__(self, client: OpenHABClient):
246
+ """
247
+ Initializes the LinkEvents class with an OpenHABClient object.
248
+
249
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
250
+ """
251
+ self.client = client
252
+
253
+ def ItemChannelLinkAddedEvent(self, itemName: str = "*", channelUID: str = "*"):
254
+ """
255
+ Get events for added item-channel links.
256
+
257
+ :param itemName: The name of the item (default is "*").
258
+ :param channelUID: The UID of the channel (default is "*").
259
+
260
+ :return: A SSE stream of added item-channel link events.
261
+ """
262
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/links/{itemName}-{channelUID}/added")
263
+
264
+ def ItemChannelLinkRemovedEvent(self, itemName: str = "*", channelUID: str = "*"):
265
+ """
266
+ Get events for removed item-channel links.
267
+
268
+ :param itemName: The name of the item (default is "*").
269
+ :param channelUID: The UID of the channel (default is "*").
270
+
271
+ :return: A SSE stream of removed item-channel link events.
272
+ """
273
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/links/{itemName}-{channelUID}/removed")
274
+
275
+ class ChannelEvents:
276
+ def __init__(self, client: OpenHABClient):
277
+ """
278
+ Initializes the ChannelEvents class with an OpenHABClient object.
279
+
280
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
281
+ """
282
+ self.client = client
283
+
284
+ def ChannelDescriptionChangedEvent(self, channelUID: str = "*"):
285
+ """
286
+ Get events for changes in channel descriptions.
287
+
288
+ :param channelUID: The UID of the channel (default is "*").
289
+
290
+ :return: A SSE stream of channel description changed events.
291
+ """
292
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/channels/{channelUID}/descriptionchanged")
293
+
294
+ def ChannelTriggeredEvent(self, channelUID: str = "*"):
295
+ """
296
+ Get events for triggered channels.
297
+
298
+ :param channelUID: The UID of the channel (default is "*").
299
+
300
+ :return: A SSE stream of channel triggered events.
301
+ """
302
+ return self.client._OpenHABClient__executeSSE(self.client.url + f"/rest/events?topics=openhab/channels/{channelUID}/triggered")
openhab/Iconsets.py ADDED
@@ -0,0 +1,21 @@
1
+ from .Client import OpenHABClient
2
+
3
+ class Iconsets:
4
+ def __init__(self, client: OpenHABClient):
5
+ """
6
+ Initializes the Iconsets class with an OpenHABClient object.
7
+
8
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
9
+ """
10
+ self.client = client
11
+
12
+ def getAllIconsets(self, language: str = None) -> list:
13
+ """
14
+ Gets all icon sets.
15
+
16
+ :param language: Optional language preference for the response (e.g. 'en', 'de').
17
+
18
+ :return: A list of icon sets with details such as ID, label, description and supported formats.
19
+ """
20
+
21
+ return self.client.get("/iconsets", header={"Accept-Language": language} if language else {})
openhab/Inbox.py ADDED
@@ -0,0 +1,64 @@
1
+ from .Client import OpenHABClient
2
+ import json
3
+
4
+ class Inbox:
5
+ def __init__(self, client: OpenHABClient):
6
+ """
7
+ Initializes the Inbox class with an OpenHABClient object.
8
+
9
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
10
+ """
11
+ self.client = client
12
+
13
+ def getAllDiscoveredThings(self, includeIgnored: bool = True) -> list:
14
+ """
15
+ Get all discovered things.
16
+
17
+ :param includeIgnored: Whether ignored entries should also be included (default: True).
18
+
19
+ :return: A list of discovered things with details such as UID, flag, label, and properties.
20
+ """
21
+ return self.client.get("/inbox", params={"includeIgnored": str(includeIgnored).lower()})
22
+
23
+ def removeDiscoveryResult(self, thingUID: str) -> dict:
24
+ """
25
+ Removes the discovery result from the inbox.
26
+
27
+ :param thingUID: The UID of the discovered thing to be removed.
28
+
29
+ :return: The API response to the delete request.
30
+ """
31
+ return self.client.delete(f"/inbox/{thingUID}")
32
+
33
+ def approveDiscoveryResult(self, thingUID: str, thingLabel: str, newThingID: str = None, language: str = None) -> dict:
34
+ """
35
+ Approves the discovery result by adding the thing to the registry.
36
+
37
+ :param thingUID: The UID of the discovered thing.
38
+ :param thingLabel: The new name of the thing.
39
+ :param newThingID: Optional: The new thing ID.
40
+ :param language: Optional: Language preference for the response.
41
+
42
+ :return: The API response to the approval request.
43
+ """
44
+ return self.client.post(f"/inbox/{thingUID}/approve", header={"Accept-Language": language, "Content-Type": "text/plain"} if language else {"Content-Type": "text/plain"}, params={"newThingID": newThingID} if newThingID else {}, data=thingLabel)
45
+
46
+ def ignoreDiscoveryResult(self, thingUID: str) -> dict:
47
+ """
48
+ Flags a discovery result as ignored for further processing.
49
+
50
+ :param thingUID: The UID of the discovered thing.
51
+
52
+ :return: The API response to the ignore request.
53
+ """
54
+ return self.client.post(f"/inbox/{thingUID}/ignore")
55
+
56
+ def unignoreDiscoveryResult(self, thingUID: str) -> dict:
57
+ """
58
+ Removes the ignore flag from a discovery result.
59
+
60
+ :param thingUID: The UID of the discovered thing.
61
+
62
+ :return: The API response to the unignore request.
63
+ """
64
+ return self.client.post(f"/inbox/{thingUID}/unignore")
openhab/Items.py ADDED
@@ -0,0 +1,264 @@
1
+ from .Client import OpenHABClient
2
+ import json
3
+
4
+ class Items:
5
+ def __init__(self, client: OpenHABClient):
6
+ """
7
+ Initializes the Items class with an OpenHABClient object.
8
+
9
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
10
+ """
11
+ self.client = client
12
+
13
+ def getAllItems(
14
+ self,
15
+ language: str = None,
16
+ type: str = None,
17
+ tags: str = None,
18
+ metadata: str = ".*",
19
+ recursive: bool = False,
20
+ fields: str = None,
21
+ staticDataOnly: bool = False,
22
+ ):
23
+ """
24
+ Get all available items.
25
+
26
+ :param language: Optional; Language filter for header "Accept-Language".
27
+ :param type: Optional; Item type filter.
28
+ :param tags: Optional; Item tag filter.
29
+ :param metadata: Optional; Metadata selector (default: .*).
30
+ :param recursive: Optional; Whether to fetch group members recursively (default: False).
31
+ :param fields: Optional; Limit to specific fields (comma-separated).
32
+ :param staticDataOnly: Optional; Only returns cached data (default: False).
33
+
34
+ :return: A dictionary or list containing the item data as returned by the API.
35
+ """
36
+ header = {}
37
+ if language:
38
+ header["Accept-Language"] = language
39
+
40
+ params = {
41
+ "type": type,
42
+ "tags": tags,
43
+ "metadata": metadata,
44
+ "recursive": str(recursive).lower(),
45
+ "fields": fields,
46
+ "staticDataOnly": str(staticDataOnly).lower(),
47
+ }
48
+
49
+ # Remove None values from parameters
50
+ params = {key: value for key, value in params.items() if value is not None}
51
+
52
+ return self.client.get("/items", header=header, params=params)
53
+
54
+ def addOrUpdateItems(self, items: list):
55
+ """
56
+ Adds a list of items to the registry or updates the existing items.
57
+
58
+ :param items: A list of item data (Dictionary).
59
+
60
+ :return: A response object or confirmation that the items were successfully added or updated.
61
+ """
62
+ return self.client.put("/items", data=json.dumps(items), header={"Content-Type": "application/json"})
63
+
64
+ def getItem(self, itemName: str, language: str = None, metadata: str = ".*", recursive: bool = True):
65
+ """
66
+ Gets a single item.
67
+
68
+ :param itemName: The name of the item.
69
+ :param language: Optional; Language filter for header "Accept-Language".
70
+ :param metadata: Optional; Metadata selector (default: .*).
71
+ :param recursive: Optional; Whether to fetch group members recursively (default: True).
72
+
73
+ :return: A dictionary containing the requested item data.
74
+ """
75
+ header = {}
76
+ if language:
77
+ header["Accept-Language"] = language
78
+
79
+ params = {
80
+ "metadata": metadata,
81
+ "recursive": str(recursive).lower(),
82
+ }
83
+
84
+ return self.client.get(f"/items/{itemName}", header=header, params=params)
85
+
86
+ def addOrUpdateItem(self, itemName: str, itemData: dict, language: str = None):
87
+ """
88
+ Adds a new item to the registry or updates the existing item.
89
+
90
+ :param itemName: The name of the item.
91
+ :param itemData: The data of the item (Dictionary).
92
+ :param language: Optional; Language filter for header "Accept-Language".
93
+
94
+ :return: A response object or confirmation that the item was successfully added or updated.
95
+ """
96
+ header = {"Content-Type": "application/json"}
97
+ if language:
98
+ header["Accept-Language"] = language
99
+
100
+ return self.client.put(f"/items/{itemName}", header=header, data=json.dumps(itemData))
101
+
102
+ def sendCommand(self, itemName: str, command: str):
103
+ """
104
+ Sends a command to an item.
105
+
106
+ :param itemName: The name of the item.
107
+ :param command: The command to be sent (e.g., ON, OFF).
108
+
109
+ :return: A response object or confirmation that the command was successfully sent.
110
+ """
111
+ return self.client.post(f"/items/{itemName}", header={"Content-type": "text/plain; charset=utf-8", "Accept": "text/plain"}, data=command)
112
+
113
+ def postUpdate(self, itemName: str, state: str):
114
+ """
115
+ Updates the state of an item.
116
+
117
+ :param itemName: The name of the item.
118
+ :param state: The state to be signaled for the item.
119
+
120
+ :return: A response object or confirmation that the state was successfully updated.
121
+ """
122
+ return self.updateItemState(itemName, state)
123
+
124
+ def deleteItem(self, itemName: str):
125
+ """
126
+ Removes an item from the registry.
127
+
128
+ :param itemName: The name of the item.
129
+
130
+ :return: A response object or confirmation that the item was successfully deleted.
131
+ """
132
+ return self.client.delete(f"/items/{itemName}")
133
+
134
+ def addGroupMember(self, itemName: str, memberItemName: str):
135
+ """
136
+ Adds a new member to a group item.
137
+
138
+ :param itemName: The name of the group item.
139
+ :param memberItemName: The name of the member item.
140
+
141
+ :return: A response object or confirmation that the group member was successfully added.
142
+ """
143
+ return self.client.put(f"/items/{itemName}/members/{memberItemName}")
144
+
145
+ def removeGroupMember(self, itemName: str, memberItemName: str):
146
+ """
147
+ Removes an existing member from a group item.
148
+
149
+ :param itemName: The name of the group item.
150
+ :param memberItemName: The name of the member item.
151
+
152
+ :return: A response object or confirmation that the group member was successfully removed.
153
+ """
154
+ return self.client.delete(f"/items/{itemName}/members/{memberItemName}")
155
+
156
+ def addMetadata(self, itemName: str, namespace: str, metadata: dict):
157
+ """
158
+ Adds metadata to an item.
159
+
160
+ :param itemName: The name of the item.
161
+ :param namespace: The namespace of the metadata.
162
+ :param metadata: A dictionary containing the metadata.
163
+
164
+ :return: A response object or confirmation that the metadata was successfully added.
165
+ """
166
+ return self.client.put(f"/items/{itemName}/metadata/{namespace}", header={"Content-Type": "application/json"}, data=json.dumps(metadata))
167
+
168
+ def removeMetadata(self, itemName: str, namespace: str):
169
+ """
170
+ Removes metadata from an item.
171
+
172
+ :param itemName: The name of the item.
173
+ :param namespace: The namespace of the metadata.
174
+
175
+ :return: A response object or confirmation that the metadata was successfully removed.
176
+ """
177
+ return self.client.delete(f"/items/{itemName}/metadata/{namespace}")
178
+
179
+ def getMetadataNamespaces(self, itemName: str, language: str = None):
180
+ """
181
+ Gets the namespaces of an item.
182
+
183
+ :param itemName: The name of the item.
184
+ :param language: Optional; Language filter for header "Accept-Language".
185
+
186
+ :return: A list of namespaces associated with the item.
187
+ """
188
+ header = {}
189
+ if language:
190
+ header["Accept-Language"] = language
191
+
192
+ return self.client.get(f"/items/{itemName}/metadata/namespaces", header=header)
193
+
194
+ def getSemanticItem(self, itemName: str, semanticClass: str, language: str = None):
195
+ """
196
+ Gets the item that defines the requested semantics of an item.
197
+
198
+ :param itemName: The name of the item.
199
+ :param semanticClass: The requested semantic class.
200
+ :param language: Optional; Language filter for header "Accept-Language".
201
+
202
+ :return: A dictionary containing the semantic item data.
203
+ """
204
+ header = {}
205
+ if language:
206
+ header["Accept-Language"] = language
207
+
208
+ return self.client.get(f"/items/{itemName}/semantic/{semanticClass}", header=header)
209
+
210
+ def getItemState(self, itemName: str):
211
+ """
212
+ Gets the state of an item.
213
+
214
+ :param itemName: The name of the item.
215
+
216
+ :return: A dictionary containing the current state of the item.
217
+ """
218
+ return self.client.get(f"/items/{itemName}/state")
219
+
220
+ def updateItemState(self, itemName: str, state: str, language: str = None):
221
+ """
222
+ Updates the state of an item.
223
+
224
+ :param itemName: The name of the item.
225
+ :param state: The new state of the item.
226
+ :param language: Optional; Language filter for header "Accept-Language".
227
+
228
+ :return: A response object or confirmation that the state was successfully updated.
229
+ """
230
+ header = {"Content-type": "text/plain; charset=utf-8", "Accept": "text/plain"}
231
+ if language:
232
+ header["Accept-Language"] = language
233
+
234
+ return self.client.put(f"/items/{itemName}/state", header=header, data=state)
235
+
236
+ def addTag(self, itemName: str, tag: str):
237
+ """
238
+ Adds a tag to an item.
239
+
240
+ :param itemName: The name of the item.
241
+ :param tag: The tag to be added.
242
+
243
+ :return: A response object or confirmation that the tag was successfully added.
244
+ """
245
+ return self.client.put(f"/items/{itemName}/tags/{tag}")
246
+
247
+ def removeTag(self, itemName: str, tag: str):
248
+ """
249
+ Removes a tag from an item.
250
+
251
+ :param itemName: The name of the item.
252
+ :param tag: The tag to be removed.
253
+
254
+ :return: A response object or confirmation that the tag was successfully removed.
255
+ """
256
+ return self.client.delete(f"/items/{itemName}/tags/{tag}")
257
+
258
+ def purgeOrphanedMetadata(self):
259
+ """
260
+ Remove unused/orphaned metadata.
261
+
262
+ :return: A response object or confirmation that orphaned metadata was successfully purged.
263
+ """
264
+ return self.client.post("/items/metadata/purge")