pyegeria 0.2.4__py3-none-any.whl → 0.3.2__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.
@@ -0,0 +1,976 @@
1
+ """
2
+
3
+ This module contains the MyProfile class and its methods.
4
+
5
+ """
6
+ import asyncio
7
+
8
+ import json
9
+ from pyegeria._client import Client
10
+ from pyegeria._globals import enable_ssl_check
11
+ from pyegeria._validators import validate_name, validate_search_string
12
+
13
+
14
+ class MyProfile(Client):
15
+ """A class representing the profile of a user.
16
+
17
+ This class provides methods for retrieving the profile details
18
+ of a user associated with a token.
19
+
20
+ Parameters
21
+ ----------
22
+ server_name : str
23
+ The name of the server to configure.
24
+ platform_url : str
25
+ The URL of the platform.
26
+ token : str, optional
27
+ The token associated with the user. Default is None.
28
+ user_id : str, optional
29
+ The user ID. Default is None.
30
+ user_pwd : str, optional
31
+ The user password. Default is None.
32
+ verify_flag : bool, optional
33
+ The flag indicating whether to enable SSL check. Default is
34
+ enable_ssl_check.
35
+ sync_mode : bool, optional
36
+ The flag indicating whether to use synchronous mode. Default
37
+ is True.
38
+ """
39
+
40
+ def __init__(
41
+ self,
42
+ server_name: str,
43
+ platform_url: str,
44
+ token: str = None,
45
+ user_id: str = None,
46
+ user_pwd: str = None,
47
+ verify_flag: bool = enable_ssl_check,
48
+ sync_mode: bool = True
49
+ ):
50
+
51
+ Client.__init__(self, server_name, platform_url, user_id=user_id, token=token, async_mode=sync_mode)
52
+ self.my_profile_command_root: str = f"{platform_url}/servers"
53
+
54
+ #
55
+ # MyProfile
56
+ #
57
+
58
+ async def _async_get_my_profile(self, server_name: str = None) -> dict | str:
59
+ """ Get the profile of the user associated with the token used.
60
+
61
+ Parameters
62
+ ----------
63
+ server_name : str, optional
64
+ The name of the server to configure.
65
+ If not provided, the server name associated with the instance is used.
66
+
67
+ Returns
68
+ -------
69
+ List | str
70
+
71
+ Profile details as a dict.
72
+
73
+ Raises
74
+ ------
75
+
76
+ InvalidParameterException
77
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
78
+ PropertyServerException
79
+ Raised by the server when an issue arises in processing a valid request
80
+ NotAuthorizedException
81
+ The principle specified by the user_id does not have authorization for the requested action
82
+ """
83
+ if server_name is None:
84
+ server_name = self.server_name
85
+ url = f"{self.my_profile_command_root}/{server_name}/api/open-metadata/my-profile"
86
+
87
+ response = await self._async_make_request("GET", url)
88
+ return response
89
+
90
+ def get_my_profile(self, server_name: str = None) -> dict | str:
91
+ """ Get the profile of the user associated with the token used.
92
+
93
+ Parameters
94
+ ----------
95
+ server_name : str, optional
96
+ The name of the server to configure.
97
+ If not provided, the server name associated with the instance is used.
98
+
99
+ Returns
100
+ -------
101
+ List | str
102
+
103
+ Profile details as a dict.
104
+
105
+ Raises
106
+ ------
107
+
108
+ InvalidParameterException
109
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
110
+ PropertyServerException
111
+ Raised by the server when an issue arises in processing a valid request
112
+ NotAuthorizedException
113
+ The principle specified by the user_id does not have authorization for the requested action
114
+ """
115
+ loop = asyncio.get_event_loop()
116
+ response = loop.run_until_complete(self._async_get_my_profile(server_name))
117
+
118
+ return response.json().get("personalProfile", "No one found")
119
+
120
+ async def _async_get_assigned_actions(self, actor_guid: str, status: str = "OPEN", server_name: str = None,
121
+ start_from: int = 0, page_size: int = 100) -> list | str:
122
+ """ Get assigned actions for the actor. Async version.
123
+
124
+ Parameters
125
+ ----------
126
+ actor_guid: str
127
+ The GUID of the actor whose assigned actions are to be retrieved.
128
+ status: str
129
+ The status of teh action to filter on. Default value is "OPEN".
130
+ server_name: str, optional
131
+ The name of the server. If not provided, the value of self.server_name will be used.
132
+ start_from: int, optional
133
+ The index from which to start retrieving the assigned actions. Default is 0.
134
+ page_size: int, optional
135
+ The number of assigned actions to retrieve per page. Default is 100.
136
+
137
+ Returns
138
+ -------
139
+ list or str
140
+ A list of assigned actions is returned. If there aren't any, a string is returned indicating that.
141
+
142
+ Raises
143
+ ------
144
+ InvalidParameterException
145
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
146
+ PropertyServerException
147
+ Raised by the server when an issue arises in processing a valid request
148
+ NotAuthorizedException
149
+ The principle specified by the user_id does not have authorization for the requested action
150
+ """
151
+ if server_name is None:
152
+ server_name = self.server_name
153
+
154
+ if page_size is None:
155
+ page_size = self.page_size
156
+
157
+ body = {"status": status}
158
+
159
+ url = (f"{self.my_profile_command_root}/{server_name}/api/open-metadata/my-profile/actors/{actor_guid}"
160
+ f"/assigned/to-dos?startFrom={start_from}&pageSize={page_size}&")
161
+
162
+ response = await self._async_make_request("POST", url, body)
163
+
164
+ return response.json().get("toDoElements", "No entries found")
165
+
166
+ def get_assigned_actions(self, actor_guid: str, status: str = "OPEN", server_name: str = None, start_from: int = 0,
167
+ page_size: int = 100) -> list | str:
168
+ """ Get assigned actions for the actor.
169
+ Parameters
170
+ ----------
171
+ actor_guid: str
172
+ The GUID of the actor whose assigned actions are to be retrieved.
173
+ status: str
174
+ The status of teh action to filter on. Default value is "OPEN".
175
+ server_name: str, optional
176
+ The name of the server. If not provided, the value of self.server_name will be used.
177
+ start_from: int, optional
178
+ The index from which to start retrieving the assigned actions. Default is 0.
179
+ page_size: int, optional
180
+ The number of assigned actions to retrieve per page. Default is 100.
181
+
182
+ Returns
183
+ -------
184
+ list or str
185
+ A list of assigned actions is returned. If there aren't any, a string is returned indicating that.
186
+
187
+ Raises
188
+ ------
189
+ InvalidParameterException
190
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
191
+ PropertyServerException
192
+ Raised by the server when an issue arises in processing a valid request
193
+ NotAuthorizedException
194
+ The principle specified by the user_id does not have authorization for the requested action
195
+ """
196
+ loop = asyncio.get_event_loop()
197
+ response = loop.run_until_complete(
198
+ self._async_get_assigned_actions(actor_guid, status, server_name,
199
+ start_from, page_size)
200
+ )
201
+
202
+ return response
203
+
204
+ async def _async_get_actions_for_action_target(self, element_guid: str, status: str = "OPEN",
205
+ server_name: str = None,
206
+ start_from: int = 0, page_size: int = 100) -> list | str:
207
+ """ Get actions assigned to the action target. Async version.
208
+
209
+ Parameters
210
+ ----------
211
+ element_guid: str
212
+ The GUID of the target whose assigned actions are to be retrieved.
213
+ status: str
214
+ The status of teh action to filter on. Default value is "OPEN".
215
+ server_name: str, optional
216
+ The name of the server. If not provided, the value of self.server_name will be used.
217
+ start_from: int, optional
218
+ The index from which to start retrieving the assigned actions. Default is 0.
219
+ page_size: int, optional
220
+ The number of assigned actions to retrieve per page. Default is 100.
221
+
222
+ Returns
223
+ -------
224
+ list or str
225
+ A list of assigned actions is returned. If there aren't any, a string is returned indicating that.
226
+
227
+ Raises
228
+ ------
229
+ InvalidParameterException
230
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
231
+ PropertyServerException
232
+ Raised by the server when an issue arises in processing a valid request
233
+ NotAuthorizedException
234
+ The principle specified by the user_id does not have authorization for the requested action
235
+ """
236
+ if server_name is None:
237
+ server_name = self.server_name
238
+
239
+ validate_name(element_guid)
240
+
241
+ body = {"status": status}
242
+
243
+ url = (f"{self.my_profile_command_root}/{server_name}/api/open-metadata/my-profile/elements/{element_guid}"
244
+ f"/action-targets/to-dos?start-from={start_from}&page-size={page_size}")
245
+
246
+ response = await self._async_make_request("POST", url, body)
247
+ return response.json() if response is not None else "No Results"
248
+
249
+ def get_actions_for_action_target(self, element_guid: str, status: str = "OPEN", server_name: str = None,
250
+ start_from: int = 0, page_size: int = 100) -> list | str:
251
+ """ Get actions assigned to the action target.
252
+
253
+ Parameters
254
+ ----------
255
+ element_guid: str
256
+ The GUID of the target whose assigned actions are to be retrieved.
257
+ status: str
258
+ The status of teh action to filter on. Default value is "OPEN"
259
+ server_name: str, optional
260
+ The name of the server. If not provided, the value of self.server_name will be used.
261
+ start_from: int, optional
262
+ The index from which to start retrieving the assigned actions. Default is 0.
263
+ page_size: int, optional
264
+ The number of assigned actions to retrieve per page. Default is 100.
265
+
266
+ Returns
267
+ -------
268
+ list or str
269
+ A list of assigned actions is returned. If there aren't any, a string is returned indicating that.
270
+
271
+ Raises
272
+ ------
273
+ InvalidParameterException
274
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
275
+ PropertyServerException
276
+ Raised by the server when an issue arises in processing a valid request
277
+ NotAuthorizedException
278
+ The principle specified by the user_id does not have authorization for the requested action
279
+ """
280
+ loop = asyncio.get_event_loop()
281
+ response = loop.run_until_complete(
282
+ self._async_get_actions_for_action_target(element_guid, status, server_name,
283
+ start_from, page_size)
284
+ )
285
+
286
+ return response
287
+
288
+ async def _async_get_actions_for_sponsor(self, element_guid: str, status: str = "", server_name: str = None,
289
+ start_from: int = 0, page_size: int = 100) -> list | str:
290
+ """ Get actions assigned to an owner. Async version.
291
+
292
+ Parameters
293
+ ----------
294
+ element_guid: str
295
+ The GUID of the target whose assigned actions are to be retrieved.
296
+ status: str
297
+ The status of the action to filter on. Default value is "OPEN".
298
+ server_name: str, optional
299
+ The name of the server. If not provided, the value of self.server_name will be used.
300
+ start_from: int, optional
301
+ The index from which to start retrieving the assigned actions. Default is 0.
302
+ page_size: int, optional
303
+ The number of assigned actions to retrieve per page. Default is 100.
304
+
305
+ Returns
306
+ -------
307
+ list or str
308
+ A list of assigned actions is returned. If there aren't any, a string is returned indicating that.
309
+
310
+ Raises
311
+ ------
312
+ InvalidParameterException
313
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
314
+ PropertyServerException
315
+ Raised by the server when an issue arises in processing a valid request
316
+ NotAuthorizedException
317
+ The principle specified by the user_id does not have authorization for the requested action
318
+ """
319
+ if server_name is None:
320
+ server_name = self.server_name
321
+
322
+ validate_name(element_guid)
323
+
324
+ body = {"status": status}
325
+
326
+ url = (f"{self.my_profile_command_root}/{server_name}/api/open-metadata/my-profile/elements/{element_guid}"
327
+ f"/sponsored/to-dos?startFrom={start_from}&pageSize={page_size}")
328
+
329
+ response = await self._async_make_request("POST", url, body)
330
+ return response.json() if response is not None else "No Results"
331
+
332
+ def get_actions_for_sponsor(self, element_guid: str, status: str = "OPEN", server_name: str = None,
333
+ start_from: int = 0, page_size: int = 100) -> list | str:
334
+ """ Get actions assigned to an owner.
335
+ Parameters
336
+ ----------
337
+ element_guid: str
338
+ The GUID of the target whose assigned actions are to be retrieved.
339
+ status: str
340
+ The status of teh action to filter on. Default value is "OPEN".
341
+ server_name: str, optional
342
+ The name of the server. If not provided, the value of self.server_name will be used.
343
+ start_from: int, optional
344
+ The index from which to start retrieving the assigned actions. Default is 0.
345
+ page_size: int, optional
346
+ The number of assigned actions to retrieve per page. Default is 100.
347
+
348
+ Returns
349
+ -------
350
+ list or str
351
+ A list of assigned actions is returned. If there aren't any, a string is returned indicating that.
352
+
353
+ Raises
354
+ ------
355
+ InvalidParameterException
356
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
357
+ PropertyServerException
358
+ Raised by the server when an issue arises in processing a valid request
359
+ NotAuthorizedException
360
+ The principle specified by the user_id does not have authorization for the requested action
361
+ """
362
+ loop = asyncio.get_event_loop()
363
+ response = loop.run_until_complete(self._async_get_actions_for_sponsor(
364
+ element_guid, status, server_name, start_from, page_size)
365
+ )
366
+ return response
367
+
368
+ async def _async_create_to_do(self, body: dict, server_name: str = None) -> str:
369
+ """ Create a To-Do item. Async version.
370
+ Parameters
371
+ ----------
372
+ body : dict
373
+ The dictionary containing the details of the to-do item.
374
+ server_name : str, optional
375
+ The name of the server where the to-do item will be created. If not provided,
376
+ the default server name associated with the instance of the class will be used.
377
+
378
+ Returns
379
+ -------
380
+ None
381
+ This method does not return any value.
382
+
383
+ Raises
384
+ ------
385
+ InvalidParameterException
386
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
387
+ PropertyServerException
388
+ Raised by the server when an issue arises in processing a valid request
389
+ NotAuthorizedException
390
+ The principle specified by the user_id does not have authorization for the requested action
391
+ """
392
+ if server_name is None:
393
+ server_name = self.server_name
394
+
395
+ url = f"{self.my_profile_command_root}/{server_name}/api/open-metadata/my-profile/to-dos"
396
+ response = await self._async_make_request("POST", url, body)
397
+ return response.json().get("guid", "No guid returned")
398
+
399
+ def create_to_do(self, body: dict, server_name: str = None) -> None:
400
+ """ Create a To-Do item.
401
+ Parameters
402
+ ----------
403
+ body : dict
404
+ The dictionary containing the details of the to-do item.
405
+ server_name : str, optional
406
+ The name of the server where the to-do item will be created. If not provided,
407
+ the default server name associated with the instance of the class will be used.
408
+
409
+ Returns
410
+ -------
411
+ None
412
+ This method does not return any value.
413
+
414
+ Raises
415
+ ------
416
+ InvalidParameterException
417
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
418
+ PropertyServerException
419
+ Raised by the server when an issue arises in processing a valid request
420
+ NotAuthorizedException
421
+ The principle specified by the user_id does not have authorization for the requested action
422
+
423
+ Notes
424
+ -----
425
+
426
+ Here is a typical body:
427
+ body = {
428
+ "properties": {
429
+ "class" : "ToDoProperties",
430
+ "qualifiedName": f"Test-To-Do-{time.asctime()}",
431
+ "name": to_do,
432
+ "description": to_do_desc,
433
+ "toDoType": to_do_type,
434
+ "priority": 0,
435
+ "dueTime": "2024-03-11T15:42:11.307Z",
436
+ "status": "OPEN"
437
+ },
438
+ "assignToActorGUID": erins_guid
439
+ }
440
+ """
441
+ loop = asyncio.get_event_loop()
442
+ response = loop.run_until_complete(
443
+ self._async_create_to_do(body, server_name)
444
+ )
445
+ return response
446
+
447
+ async def _async_get_to_do(self, todo_guid: str, server_name: str = None) -> dict | str:
448
+ """ Get a To-Do item. Async version.
449
+ Parameters
450
+ ----------
451
+ todo_guid: str
452
+ Identifier of the To-Do item.
453
+ server_name : str, optional
454
+ The name of the server where the to-do item will be created. If not provided,
455
+ the default server name associated with the instance of the class will be used.
456
+
457
+ Returns
458
+ -------
459
+ None
460
+ This method does not return any value.
461
+
462
+ Raises
463
+ ------
464
+ InvalidParameterException
465
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
466
+ PropertyServerException
467
+ Raised by the server when an issue arises in processing a valid request
468
+ NotAuthorizedException
469
+ The principle specified by the user_id does not have authorization for the requested action
470
+ """
471
+ if server_name is None:
472
+ server_name = self.server_name
473
+
474
+ validate_name(todo_guid)
475
+
476
+ url = f"{self.my_profile_command_root}/{server_name}/api/open-metadata/my-profile/to-dos/{todo_guid}"
477
+
478
+ response = await self._async_make_request("GET", url)
479
+ # return response.text if response is not None else "No Results"
480
+ return json.loads(response.text).get("toDoElement", "No TODO returned")
481
+
482
+ def get_to_do(self, todo_guid: str, server_name: str = None) -> dict | str:
483
+ """ Get a To-Do item. Async version.
484
+ Parameters
485
+ ----------
486
+ todo_guid: str
487
+ Identifier of the To-Do item.
488
+ server_name : str, optional
489
+ The name of the server where the to-do item will be created. If not provided,
490
+ the default server name associated with the instance of the class will be used.
491
+
492
+ Returns
493
+ -------
494
+ None
495
+ This method does not return any value.
496
+
497
+ Raises
498
+ ------
499
+ InvalidParameterException
500
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
501
+ PropertyServerException
502
+ Raised by the server when an issue arises in processing a valid request
503
+ NotAuthorizedException
504
+ The principle specified by the user_id does not have authorization for the requested action
505
+ """
506
+ loop = asyncio.get_event_loop()
507
+ response = loop.run_until_complete(self._async_get_to_do(todo_guid, server_name))
508
+
509
+ return response
510
+
511
+ async def _async_update_to_do(self, todo_guid: str, body: dict, is_merge_update: bool = True,
512
+ server_name: str = None) -> None:
513
+ """ Update a To-Do item. Async version.
514
+ Parameters
515
+ ----------
516
+ todo_guid: str
517
+ Identifier of the To-Do item.
518
+ body: str
519
+ The details to update the to-do item with.
520
+ server_name : str, optional
521
+ The name of the server where the to-do item will be created. If not provided,
522
+ the default server name associated with the instance of the class will be used.
523
+
524
+ Returns
525
+ -------
526
+ None
527
+ This method does not return any value.
528
+
529
+ Raises
530
+ ------
531
+ InvalidParameterException
532
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
533
+ PropertyServerException
534
+ Raised by the server when an issue arises in processing a valid request
535
+ NotAuthorizedException
536
+ The principle specified by the user_id does not have authorization for the requested action
537
+ """
538
+ if server_name is None:
539
+ server_name = self.server_name
540
+
541
+ validate_name(todo_guid)
542
+
543
+ url = (f"{self.my_profile_command_root}/{server_name}/api/open-metadata/my-profile/to-dos/"
544
+ f"{todo_guid}?merge-update={is_merge_update}")
545
+
546
+ await self._async_make_request("POST", url, body)
547
+ return
548
+
549
+ def update_to_do(self, todo_guid: str, body: dict, is_merge_update: bool = True,
550
+ server_name: str = None) -> None:
551
+ """ Update a To-Do item.
552
+ Parameters
553
+ ----------
554
+ todo_guid: str
555
+ Identifier of the To-Do item.
556
+ body: str
557
+ The details to update the to-do item with.
558
+ is_merge_update: bool [default: True]
559
+ If true then merges the updated information, otherwise replace the existing information.
560
+ server_name : str, optional
561
+ The name of the server where the to-do item will be created. If not provided,
562
+ the default server name associated with the instance of the class will be used.
563
+
564
+ Returns
565
+ -------
566
+ None
567
+ This method does not return any value.
568
+
569
+ Raises
570
+ ------
571
+ InvalidParameterException
572
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
573
+ PropertyServerException
574
+ Raised by the server when an issue arises in processing a valid request
575
+ NotAuthorizedException
576
+ The principle specified by the user_id does not have authorization for the requested action
577
+ """
578
+
579
+ loop = asyncio.get_event_loop()
580
+ loop.run_until_complete(self._async_update_to_do(todo_guid, body, is_merge_update, server_name))
581
+ return
582
+
583
+ async def _async_delete_to_do(self, todo_guid: str, status: str = "OPEN", server_name: str = None) -> None:
584
+ """ Delete a To-Do item. Async version.
585
+ Parameters
586
+ ----------
587
+ todo_guid: str
588
+ Identifier of the To-Do item.
589
+ status: str
590
+ Filter items to match this status. Defaults to "OPEN"
591
+ server_name : str, optional
592
+ The name of the server where the to-do item will be created. If not provided,
593
+ the default server name associated with the instance of the class will be used.
594
+
595
+ Returns
596
+ -------
597
+ None
598
+ This method does not return any value.
599
+
600
+ Raises
601
+ ------
602
+ InvalidParameterException
603
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
604
+ PropertyServerException
605
+ Raised by the server when an issue arises in processing a valid request
606
+ NotAuthorizedException
607
+ The principle specified by the user_id does not have authorization for the requested action
608
+ """
609
+ if server_name is None:
610
+ server_name = self.server_name
611
+
612
+ validate_name(todo_guid)
613
+ body = {"status": status}
614
+
615
+ url = f"{self.my_profile_command_root}/{server_name}/api/open-metadata/my-profile/to-dos/{todo_guid}"
616
+
617
+ await self._async_make_request("POST", url, body)
618
+ return
619
+
620
+ def delete_to_do(self, todo_guid: str, status: str = "OPEN", server_name: str = None) -> None:
621
+ """ Delete a To-Do item.
622
+ Parameters
623
+ ----------
624
+ todo_guid: str
625
+ Identifier of the To-Do item.
626
+ status: str
627
+ Filter items to match this status. Defaults to "OPEN"
628
+ server_name : str, optional
629
+ The name of the server where the to-do item will be created. If not provided,
630
+ the default server name associated with the instance of the class will be used.
631
+
632
+ Returns
633
+ -------
634
+ None
635
+ This method does not return any value.
636
+
637
+ Raises
638
+ ------
639
+ InvalidParameterException
640
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
641
+ PropertyServerException
642
+ Raised by the server when an issue arises in processing a valid request
643
+ NotAuthorizedException
644
+ The principle specified by the user_id does not have authorization for the requested action
645
+ """
646
+ loop = asyncio.get_event_loop()
647
+ loop.run_until_complete(self._async_delete_to_do(todo_guid, status, server_name))
648
+ return
649
+
650
+ async def _async_reassign_to_do(self, todo_guid: str, actor_guid: str, status: str = "OPEN",
651
+ server_name: str = None) -> None:
652
+ """ Reassign a To-Do item. Async version.
653
+ Parameters
654
+ ----------
655
+ todo_guid: str
656
+ Identifier of the To-Do item.
657
+ actor_guid: str
658
+ The actor to receive the reassigned to-do item.
659
+ status: str [default = "OPEN"]
660
+ Filter items to match this status.
661
+ server_name : str, optional
662
+ The name of the server where the to-do item will be created. If not provided,
663
+ the default server name associated with the instance of the class will be used.
664
+
665
+ Returns
666
+ -------
667
+ None
668
+ This method does not return any value.
669
+
670
+ Raises
671
+ ------
672
+ InvalidParameterException
673
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
674
+ PropertyServerException
675
+ Raised by the server when an issue arises in processing a valid request
676
+ NotAuthorizedException
677
+ The principle specified by the user_id does not have authorization for the requested action
678
+ """
679
+ if server_name is None:
680
+ server_name = self.server_name
681
+
682
+ validate_name(todo_guid)
683
+ validate_name(actor_guid)
684
+ body = {"status": status}
685
+
686
+ url = (f"{self.my_profile_command_root}/{server_name}/api/open-metadata/my-profile/to-dos/"
687
+ f"{todo_guid}/reassign/{actor_guid}")
688
+
689
+ await self._async_make_request("POST", url, body)
690
+ return
691
+
692
+ def reassign_to_do(self, todo_guid: str, actor_guid: str, status: str = "OPEN", server_name: str = None) -> None:
693
+ """ Reassign a To-Do item.
694
+ Parameters
695
+ ----------
696
+ todo_guid: str
697
+ Identifier of the To-Do item.
698
+ actor_guid: str
699
+ The actor to receive the reassigned to-do item.
700
+ status: str [default = "OPEN"]
701
+ Filter items to match this status.
702
+ server_name : str, optional
703
+ The name of the server where the to-do item will be created. If not provided,
704
+ the default server name associated with the instance of the class will be used.
705
+
706
+ Returns
707
+ -------
708
+ None
709
+ This method does not return any value.
710
+
711
+ Raises
712
+ ------
713
+ InvalidParameterException
714
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
715
+ PropertyServerException
716
+ Raised by the server when an issue arises in processing a valid request
717
+ NotAuthorizedException
718
+ The principle specified by the user_id does not have authorization for the requested action
719
+ """
720
+ loop = asyncio.get_event_loop()
721
+ loop.run_until_complete(self._async_reassign_to_do(todo_guid, actor_guid, status, server_name))
722
+ return
723
+
724
+ async def _async_find_to_do(self, search_string: str = "*", server_name: str = "None", status: str = None,
725
+ starts_with: bool = False, ends_with: bool = False, ignore_case: bool = True,
726
+ start_from: int = 0, page_size: int = 100) -> list | str:
727
+ """ find To-Do items. Async version.
728
+ Parameters
729
+ ----------
730
+ search_string: str
731
+ String to search against. If '*' then all to-do items will match.
732
+ server_name : str, optional
733
+ The name of the server where the to-do item will be created. If not provided,
734
+ the default server name associated with the instance of the class will be used.
735
+ status: str
736
+ Filter items to match this status. Defaults to "OPEN"
737
+ starts_with : bool, [default=False], optional
738
+ Starts with the supplied string.
739
+ ends_with : bool, [default=False], optional
740
+ Ends with the supplied string
741
+ ignore_case : bool, [default=False], optional
742
+ Ignore case when searching
743
+ Returns
744
+ -------
745
+ None
746
+ List of To-Do items that match the criteria
747
+
748
+ Raises
749
+ ------
750
+ InvalidParameterException
751
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
752
+ PropertyServerException
753
+ Raised by the server when an issue arises in processing a valid request
754
+ NotAuthorizedException
755
+ The principle specified by the user_id does not have authorization for the requested action
756
+ """
757
+ if server_name is None:
758
+ server_name = self.server_name
759
+
760
+ starts_with_s = str(starts_with).lower()
761
+ ends_with_s = str(ends_with).lower()
762
+ ignore_case_s = str(ignore_case).lower()
763
+
764
+ if search_string is '*':
765
+ search_string = " "
766
+
767
+ body = {
768
+ "status": status,
769
+ "searchString": search_string
770
+ }
771
+
772
+ validate_search_string(search_string)
773
+
774
+ url = (f"{self.my_profile_command_root}/{server_name}/api/open-metadata/my-profile/to-dos/"
775
+ f"find-by-search-string?startFrom={start_from}&pageSize={page_size}&"
776
+ f"startsWith={starts_with_s}&endsWith={ends_with_s}&ignoreCase={ignore_case_s}")
777
+
778
+ response = await self._async_make_request("POST", url, body)
779
+ # return response.text
780
+ return response.json().get("toDoElements", "No guid returned")
781
+
782
+ def find_to_do(self, search_string: str, server_name: str = None, status: str = "OPEN",
783
+ starts_with: bool = True, ends_with: bool = False, ignore_case: bool = False,
784
+ start_from: int = 0, page_size: int = 100) -> list | str:
785
+ """ find To-Do items.
786
+ Parameters
787
+ ----------
788
+ search_string: str
789
+ String to search against. If '*' then all to-do items will match.
790
+ server_name : str, optional
791
+ The name of the server where the to-do item will be created. If not provided,
792
+ the default server name associated with the instance of the class will be used.
793
+ status: str
794
+ Filter items to match this status. Defaults to "OPEN"
795
+ starts_with : bool, [default=False], optional
796
+ Starts with the supplied string.
797
+ ends_with : bool, [default=False], optional
798
+ Ends with the supplied string
799
+ ignore_case : bool, [default=False], optional
800
+ Ignore case when searching
801
+ start_from: int, [default=0], optional
802
+ When multiple pages of results are available, the page number to start from.
803
+ page_size: int, [default=None]
804
+ The number of items to return in a single page. If not specified, the default will be taken from
805
+ the class instance.
806
+ Returns
807
+ -------
808
+ None
809
+ List of To-Do items that match the criteria
810
+
811
+ Raises
812
+ ------
813
+ InvalidParameterException
814
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
815
+ PropertyServerException
816
+ Raised by the server when an issue arises in processing a valid request
817
+ NotAuthorizedException
818
+ The principle specified by the user_id does not have authorization for the requested action
819
+ """
820
+ loop = asyncio.get_event_loop()
821
+ response = loop.run_until_complete(self._async_find_to_do(search_string, server_name, status, starts_with,
822
+ ends_with, ignore_case, start_from, page_size))
823
+ return response
824
+
825
+ async def _async_get_to_dos_by_type(self, todo_type: str, server_name: str = None, status: str = "OPEN",
826
+ start_from: int = 0, page_size: int = 100) -> list | str:
827
+ """ Get To-Do items by type. Async version
828
+ Parameters
829
+ ----------
830
+ todo_type: str
831
+ Type of to-do to find
832
+ server_name : str, optional
833
+ The name of the server where the to-do item will be created. If not provided,
834
+ the default server name associated with the instance of the class will be used.
835
+ status: str
836
+ Filter items to match this status. Defaults to "OPEN"
837
+ start_from: int, [default=0], optional
838
+ When multiple pages of results are available, the page number to start from.
839
+ page_size: int, [default=None]
840
+ The number of items to return in a single page. If not specified, the default will be taken from
841
+ the class instance.
842
+ Returns
843
+ -------
844
+ List of To-Do items that match the criteria
845
+
846
+ Raises
847
+ ------
848
+ InvalidParameterException
849
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
850
+ PropertyServerException
851
+ Raised by the server when an issue arises in processing a valid request
852
+ NotAuthorizedException
853
+ The principle specified by the user_id does not have authorization for the requested action
854
+ """
855
+ if server_name is None:
856
+ server_name = self.server_name
857
+
858
+ validate_name(todo_type)
859
+ body = {
860
+ "status": status,
861
+
862
+ }
863
+
864
+ url = (f"{self.my_profile_command_root}/{server_name}/api/open-metadata/my-profile/to-dos/types/"
865
+ f"{todo_type}?startFrom={start_from}&pageSize={page_size}")
866
+
867
+ response = await self._async_make_request("POST", url, body)
868
+ return response.text if response is not None else "No Results"
869
+
870
+ def get_to_dos_by_type(self, todo_type: str, server_name: str = None, status: str = "OPEN",
871
+ start_from: int = 0, page_size: int = 100) -> list | str:
872
+ """ Get To-Do items by type.
873
+ Parameters
874
+ ----------
875
+ todo_type: str
876
+ Type of to-do to find
877
+ server_name : str, optional
878
+ The name of the server where the to-do item will be created. If not provided,
879
+ the default server name associated with the instance of the class will be used.
880
+ status: str
881
+ Filter items to match this status. Defaults to "OPEN"
882
+ start_from: int, [default=0], optional
883
+ When multiple pages of results are available, the page number to start from.
884
+ page_size: int, [default=None]
885
+ The number of items to return in a single page. If not specified, the default will be taken from
886
+ the class instance.
887
+ Returns
888
+ -------
889
+ List of To-Do items that match the criteria
890
+
891
+ Raises
892
+ ------
893
+ InvalidParameterException
894
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
895
+ PropertyServerException
896
+ Raised by the server when an issue arises in processing a valid request
897
+ NotAuthorizedException
898
+ The principle specified by the user_id does not have authorization for the requested action
899
+ """
900
+ loop = asyncio.get_event_loop()
901
+ response = loop.run_until_complete(self._async_get_to_dos_by_type(todo_type, server_name, status,
902
+ start_from, page_size))
903
+ return response
904
+
905
+ async def _async_update_action_target_properties(self, action_target_guid: str, body: dict,
906
+ is_merge_update: bool = True, server_name: str = None) -> None:
907
+ """ Get To-Do items by type. Async version
908
+ Parameters
909
+ ----------
910
+ action_target_guid: str
911
+ Identity of the action target to update.
912
+ body: dict
913
+ Details of the updates to make.
914
+ is_merge_update : bool, [default=True], optional
915
+ indicates if the update should be a merge or replacement.
916
+ server_name : str, optional
917
+ The name of the server where the to-do item will be created. If not provided,
918
+ the default server name associated with the instance of the class will be used.
919
+ Returns
920
+ -------
921
+ None
922
+
923
+ Raises
924
+ ------
925
+ InvalidParameterException
926
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
927
+ PropertyServerException
928
+ Raised by the server when an issue arises in processing a valid request
929
+ NotAuthorizedException
930
+ The principle specified by the user_id does not have authorization for the requested action
931
+ """
932
+ if server_name is None:
933
+ server_name = self.server_name
934
+
935
+ is_merge_update_t = str(is_merge_update).lower()
936
+
937
+ validate_name(action_target_guid)
938
+
939
+ url = (f"{self.my_profile_command_root}/{server_name}/api/open-metadata/my-profile/to-dos/"
940
+ f"action-targets/{action_target_guid}?is_merge_update={is_merge_update_t}")
941
+
942
+ await self._async_make_request("POST", url, body)
943
+ return
944
+
945
+ def update_action_target_properties(self, action_target_guid: str, body: dict,
946
+ is_merge_update: bool = True, server_name: str = None) -> None:
947
+ """ Get To-Do items by type.
948
+ Parameters
949
+ ----------
950
+ action_target_guid: str
951
+ Identity of the action target to update.
952
+ body: dict
953
+ Details of the updates to make.
954
+ is_merge_update : bool, [default=True], optional
955
+ indicates if the update should be a merge or replacement.
956
+ server_name : str, optional
957
+ The name of the server where the to-do item will be created. If not provided,
958
+ the default server name associated with the instance of the class will be used.
959
+ Returns
960
+ -------
961
+ None
962
+
963
+ Raises
964
+ ------
965
+ InvalidParameterException
966
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
967
+ PropertyServerException
968
+ Raised by the server when an issue arises in processing a valid request
969
+ NotAuthorizedException
970
+ The principle specified by the user_id does not have authorization for the requested action
971
+ """
972
+ loop = asyncio.get_event_loop()
973
+ loop.run_until_complete(self._async_update_action_target_properties(action_target_guid,
974
+ body, is_merge_update,
975
+ server_name))
976
+ return