pyegeria 0.2.4__py3-none-any.whl → 0.3.1__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,1075 @@
1
+ """
2
+ SPDX-License-Identifier: Apache-2.0
3
+ Copyright Contributors to the ODPi Egeria project.
4
+
5
+ OMAG Server configuration functions. These functions add definitions to an OMAG server's configuration document.
6
+ This class encompasses the full set of configuration methods.
7
+ """
8
+
9
+ from pyegeria._validators import validate_name, validate_url
10
+ from pyegeria import (
11
+ InvalidParameterException
12
+ )
13
+ from pyegeria._globals import enable_ssl_check
14
+ from pyegeria import Client
15
+ from .core_omag_server_config import CoreServerConfig
16
+ import json
17
+
18
+ class FullServerConfig(CoreServerConfig):
19
+ """
20
+ This class represents a client for configuring the OMAG Server.
21
+
22
+ Parameters
23
+ ----------
24
+ server_name : str
25
+ The name of the server to connect to.
26
+ platform_url : str
27
+ The URL of the platform where the server is running.
28
+ user_id : str
29
+ The user ID for authentication.
30
+ user_pwd : str, optional
31
+ The password for authentication (default: None).
32
+ verify_flag : bool, optional
33
+ Flag to enable/disable SSL certificate verification (default: enable_ssl_check).
34
+
35
+ """
36
+
37
+ def __init__(
38
+ self,
39
+ server_name: str,
40
+ platform_url: str,
41
+ user_id: str,
42
+ user_pwd: str = None,
43
+ verify_flag: bool = enable_ssl_check,
44
+ ):
45
+ self.admin_command_root: str
46
+ Client.__init__(self, server_name, platform_url, user_id, user_pwd, verify_flag)
47
+ self.admin_command_root = (
48
+ self.platform_url
49
+ + "/open-metadata/admin-services/users/"
50
+ + user_id
51
+ )
52
+
53
+ def get_access_services_topic_names(self, access_service_name: str, server_name: str = None) -> list[str]:
54
+ if server_name is None:
55
+ server_name = self.server_name
56
+ validate_name(access_service_name)
57
+ url = (self.admin_command_root + "/servers/" + server_name + "/access-services/"
58
+ + access_service_name + "/topic-names")
59
+ response = self.make_request("GET", url)
60
+
61
+ related_code = response.json().get("relatedHTTPCode")
62
+ if related_code == 200:
63
+ return response.json() # todo fix
64
+ else:
65
+ raise InvalidParameterException(response.content)
66
+
67
+ def get_all_access_services_topic_names(self, server_name: str = None) -> str:
68
+ if server_name is None:
69
+ server_name = self.server_name
70
+
71
+ url = (self.admin_command_root + "/servers/" + server_name + "/access-services/topic-names")
72
+ response = self.make_request("GET", url)
73
+
74
+ related_code = response.json().get("relatedHTTPCode")
75
+ if related_code == 200:
76
+ return response.json() # todo fix
77
+ else:
78
+ raise InvalidParameterException(response.content)
79
+
80
+ def set_access_services_configuration(self, access_services_body: str, server_name: str = None):
81
+ if server_name is None:
82
+ server_name = self.server_name
83
+
84
+ url = self.admin_command_root + "/servers/" + server_name + "/access-services/configuration"
85
+ response = self.make_request("POST", url, access_services_body)
86
+
87
+ related_code = response.json().get("relatedHTTPCode")
88
+ if related_code == 200:
89
+ return
90
+ else:
91
+ raise InvalidParameterException(response.content)
92
+
93
+ def override_access_service_in_topic_name(self, access_service_name: str, new_topic_name: str,
94
+ server_name: str = None):
95
+ if server_name is None:
96
+ server_name = self.server_name
97
+
98
+ url = (self.admin_command_root + "/servers/" + server_name + "/access-services/" +
99
+ access_service_name + "/topic-names/in-topic")
100
+ response = self.make_request("POST", url, new_topic_name)
101
+
102
+ related_code = response.json().get("relatedHTTPCode")
103
+ if related_code == 200:
104
+ return response.json() # todo fix
105
+ else:
106
+ raise InvalidParameterException(response.content)
107
+
108
+ def override_access_service_out_topic_name(self, access_service_name: str, new_topic_name: str,
109
+ server_name: str = None):
110
+ if server_name is None:
111
+ server_name = self.server_name
112
+
113
+ url = (self.admin_command_root + "/servers/" + server_name + "/access-services/" +
114
+ access_service_name + "/topic-names/out-topic")
115
+ response = self.make_request("POST", url, new_topic_name)
116
+
117
+ related_code = response.json().get("relatedHTTPCode")
118
+ if related_code == 200:
119
+ return response.json() # todo fix
120
+ else:
121
+ raise InvalidParameterException(response.content)
122
+
123
+ def set_audit_log_destinations(self, audit_dest_body: str, server_name: str = None):
124
+ """ Sets the audit log destinations for a server
125
+
126
+ /open-metadata/admin-services/users/{userId}/servers/{serverName}/audit-log-destinations
127
+
128
+ Parameters
129
+ ----------
130
+
131
+ audit_dest_body : str
132
+ A JSON document describing the audit destinations for this server.
133
+
134
+ server_name : str
135
+ Name of the server to update.
136
+
137
+ Returns
138
+ -------
139
+ JSON string containing the status of the request.
140
+
141
+ Raises
142
+ ------
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
+ """
152
+ if server_name is None:
153
+ server_name = self.server_name
154
+
155
+ url = self.admin_command_root + "/servers/" + server_name + "/audit-log-destinations"
156
+ response = self.make_request("POST", url, audit_dest_body)
157
+
158
+ related_code = response.json().get("relatedHTTPCode")
159
+ if related_code == 200:
160
+ return
161
+ else:
162
+ raise InvalidParameterException(response.content)
163
+
164
+ def update_audit_log_destination(self, connection_name: str, audit_dest_body: str, server_name: str = None):
165
+ """
166
+ Parameters
167
+ ----------
168
+ connection_name : str
169
+ The name of the connection for the audit log destination.
170
+ audit_dest_body : str
171
+ The body of the audit log destination.
172
+ server_name : str, optional
173
+ The name of the server. If not provided, the server name associated with the instance will be used.
174
+
175
+ Returns
176
+ -------
177
+ None
178
+
179
+ Raises
180
+ ------
181
+ InvalidParameterException
182
+ If the response status code is not 200 and the related HTTP code is not 200.
183
+
184
+ """
185
+ if server_name is None:
186
+ server_name = self.server_name
187
+
188
+ url = self.admin_command_root + "/servers/" + server_name + "/audit-log-destinations/connection/" + connection_name
189
+ response = self.make_request("POST", url, audit_dest_body)
190
+
191
+ related_code = response.json().get("relatedHTTPCode")
192
+ if related_code == 200:
193
+ return
194
+ else:
195
+ raise InvalidParameterException(response.content)
196
+
197
+ def add_audit_log_destination(self, connection_body: str, server_name: str = None):
198
+ """ Adds an audit log destination to a server.
199
+
200
+ /open-metadata/admin-services/users/{userId}/servers/{serverName}/audit-log-destinations/connection
201
+
202
+ Parameters
203
+ ----------
204
+ connection_body : str
205
+ JSON string containing the connection properties for the audit log destination.
206
+ server_name : str
207
+ Name of the server to update.
208
+
209
+ Returns
210
+ -------
211
+ Void
212
+
213
+ Raises
214
+ ------
215
+ InvalidParameterException:
216
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
217
+ PropertyServerException:
218
+ Raised by the server when an issue arises in processing a valid request
219
+ NotAuthorizedException:
220
+ The principle specified by the user_id does not have authorization for the requested action
221
+ ConfigurationErrorException:
222
+ Raised when configuration parameters passed on earlier calls turn out to be
223
+ invalid or make the new call invalid.
224
+
225
+ """
226
+ if server_name is None:
227
+ server_name = self.server_name
228
+
229
+ url = self.admin_command_root + "/servers/" + server_name + "/audit-log-destinations/connection"
230
+ response = self.make_request("POST", url, connection_body)
231
+
232
+ related_code = response.json().get("relatedHTTPCode")
233
+ if related_code == 200:
234
+ return
235
+ else:
236
+ raise InvalidParameterException(response.content)
237
+
238
+ def set_cohort_config(self, cohort_name: str, cohort_config_body: str, server_name: str = None):
239
+ if server_name is None:
240
+ server_name = self.server_name
241
+ validate_name(cohort_name)
242
+ if cohort_config_body is None:
243
+ raise InvalidParameterException(cohort_config_body)
244
+
245
+ url = self.admin_command_root + "/servers/" + server_name + "/cohorts/" + cohort_name + "/configuration"
246
+ response = self.make_request("POST", url, cohort_config_body)
247
+
248
+ related_code = response.json().get("relatedHTTPCode")
249
+ if related_code != 200:
250
+ raise InvalidParameterException(response.content)
251
+
252
+ def clear_cohort_configuration(self, cohort_name: str, server_name: str = None) -> None:
253
+ """ Retrieves the stored configurations for a server
254
+ Parameters
255
+ ----------
256
+ cohort_name : str
257
+
258
+ server_name : str, optional
259
+
260
+ Returns
261
+ -------
262
+
263
+ Raises
264
+ ------
265
+ InvalidParameterException
266
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
267
+ PropertyServerException
268
+ Raised by the server when an issue arises in processing a valid request
269
+ NotAuthorizedException
270
+ The principle specified by the user_id does not have authorization for the requested action
271
+
272
+ """
273
+ if server_name is None:
274
+ server_name = self.server_name
275
+ url = f"{self.admin_command_root}/servers/{server_name}/cohorts/{cohort_name}"
276
+ validate_name(cohort_name)
277
+
278
+ self.make_request("DELETE", url)
279
+
280
+ def get_dedicated_cohort_topic_names(self, cohort_name: str, server_name: str = None) -> [str]:
281
+ if server_name is None:
282
+ server_name = self.server_name
283
+
284
+ validate_name(cohort_name)
285
+
286
+ url = self.admin_command_root + "/servers/" + server_name + "/cohorts/" + cohort_name + "/dedicated-topic-names"
287
+ response = self.make_request("POST", url)
288
+
289
+ related_code = response.json().get("relatedHTTPCode")
290
+ if related_code != 200:
291
+ raise InvalidParameterException(response.content)
292
+ else:
293
+ return (response.json().get("topicNames"))
294
+
295
+ def get_cohort_topic_name(self, cohort_name: str, server_name: str = None) -> str:
296
+ if server_name is None:
297
+ server_name = self.server_name
298
+ validate_name(cohort_name)
299
+
300
+ url = f"{self.admin_command_root}/servers/{server_name}/cohorts/{cohort_name}/topic-name"
301
+ response = self.make_request("GET", url)
302
+
303
+ related_code = response.json().get("relatedHTTPCode")
304
+ if related_code != 200:
305
+ raise InvalidParameterException(response.content)
306
+ else:
307
+ return (response.json().get("topicName"))
308
+
309
+ def override_cohort_topic_name(self, cohort_name: str, topic_override: str, server_name: str = None) -> None:
310
+ if server_name is None:
311
+ server_name = self.server_name
312
+ validate_name(cohort_name)
313
+ validate_name(topic_override)
314
+
315
+ url = self.admin_command_root + "/servers/" + server_name + "/cohorts/" + cohort_name + "/topic-name-override"
316
+ response = self.make_request("POST", url, topic_override)
317
+
318
+ related_code = response.json().get("relatedHTTPCode")
319
+ if related_code != 200:
320
+ raise InvalidParameterException(response.content)
321
+
322
+ def override_instances_cohort_topic_name(self, cohort_name: str, topic_override: str,
323
+ server_name: str = None) -> None:
324
+ if server_name is None:
325
+ server_name = self.server_name
326
+ validate_name(cohort_name)
327
+ validate_name(topic_override)
328
+
329
+ url = self.admin_command_root + "/servers/" + server_name + "/cohorts/" + cohort_name + "/topic-name-override/instances"
330
+ response = self.make_request("POST", url, topic_override)
331
+
332
+ related_code = response.json().get("relatedHTTPCode")
333
+ if related_code != 200:
334
+ raise InvalidParameterException(response.content)
335
+
336
+ def override_registration_cohort_topic_name(self, cohort_name: str, topic_override: str,
337
+ server_name: str = None) -> None:
338
+ if server_name is None:
339
+ server_name = self.server_name
340
+ validate_name(cohort_name)
341
+ validate_name(topic_override)
342
+
343
+ url = self.admin_command_root + "/servers/" + server_name + "/cohorts/" + cohort_name + "/topic-name-override/registration"
344
+ response = self.make_request("POST", url, topic_override)
345
+
346
+ related_code = response.json().get("relatedHTTPCode")
347
+ if related_code != 200:
348
+ raise InvalidParameterException(response.content)
349
+
350
+ def override_types_cohort_topic_name(self, cohort_name: str, topic_override: str, server_name: str = None) -> None:
351
+ if server_name is None:
352
+ server_name = self.server_name
353
+ validate_name(cohort_name)
354
+ validate_name(topic_override)
355
+
356
+ url = self.admin_command_root + "/servers/" + server_name + "/cohorts/" + cohort_name + "/topic-name-override/types"
357
+ response = self.make_request("POST", url, topic_override)
358
+
359
+ related_code = response.json().get("relatedHTTPCode")
360
+ if related_code != 200:
361
+ raise InvalidParameterException(response.content)
362
+
363
+ def add_cohort_registration(self, cohort_name: str, topic_structure: str, server_name: str = None) -> None:
364
+ """ add a cohort registration
365
+
366
+ Parameters
367
+ ----------
368
+ cohort_name : str
369
+ Name of the cohort to be registered.
370
+ topic_structure : str
371
+ Topic structure for the cohort. This is a string from an enumerated list.
372
+ 'Dedicated Cohort Topics', description='The cohort members use three topics to exchange information. One for
373
+ registration requests, one for type validation and one for exchange of instances stored by the cohort members.
374
+ This is the preferred and optimal approach
375
+ 'Single Topic', description='All asynchronous communication between cohort members is via a single topic.
376
+ This is the original design and may still be used when communicating with back level cohort members.
377
+ 'Both Single and Dedicated Topics', description='Both the single cohort topic and the dedicated topics are
378
+ set up and used. This is necessary when the cohort has members with different capabilities.
379
+ This configuration may cause some events to be processed twice.'
380
+ server_name : str, optional
381
+ Name of the server to which the cohort should be added. Defaults to None.
382
+
383
+ Returns
384
+ -------
385
+ None
386
+
387
+ Raises
388
+ ------
389
+ InvalidParameterException
390
+ If the response code is not 200 after making the POST request.
391
+
392
+ """
393
+ if server_name is None:
394
+ server_name = self.server_name
395
+ validate_name(cohort_name)
396
+
397
+ url = f"{self.admin_command_root}/servers/{server_name}/cohorts/{cohort_name}/topic-structure/{topic_structure}"
398
+ self.make_request("POST", url)
399
+
400
+ def set_server_configuration(self, config_body: str, server_name: str = None) -> None | str:
401
+ """ Sets the configurations for a server
402
+ Parameters
403
+ ----------
404
+
405
+ Returns
406
+ -------
407
+ str
408
+ The stored configurations for the given server.
409
+
410
+ Raises
411
+ ------
412
+ InvalidParameterException
413
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
414
+ PropertyServerException
415
+ Raised by the server when an issue arises in processing a valid request
416
+ NotAuthorizedException
417
+ The principle specified by the user_id does not have authorization for the requested action
418
+ ConfigurationErrorException
419
+ Raised when configuration parameters passed on earlier calls turn out to be
420
+ invalid or make the new call invalid.
421
+
422
+ """
423
+ if server_name is None:
424
+ server_name = self.server_name
425
+ url = self.admin_command_root + "/servers/" + server_name + "/configuration"
426
+ response = self.make_request("POST", url, config_body)
427
+ if response.status_code != 200:
428
+ return str(response.status_code) # should never get here?
429
+
430
+ related_code = response.json().get("relatedHTTPCode")
431
+ if related_code == 200:
432
+ return
433
+ else:
434
+ raise InvalidParameterException(response.content)
435
+
436
+ def clear_stored_configuration(self, server_name: str = None) -> None | str:
437
+ """ Retrieves the stored configurations for a server
438
+ Parameters
439
+ ----------
440
+
441
+ Returns
442
+ -------
443
+ str
444
+ The stored configurations for the given server.
445
+
446
+ Raises
447
+ ------
448
+ InvalidParameterException
449
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
450
+ PropertyServerException
451
+ Raised by the server when an issue arises in processing a valid request
452
+ NotAuthorizedException
453
+ The principle specified by the user_id does not have authorization for the requested action
454
+ ConfigurationErrorException
455
+ Raised when configuration parameters passed on earlier calls turn out to be
456
+ invalid or make the new call invalid.
457
+
458
+ """
459
+ if server_name is None:
460
+ server_name = self.server_name
461
+ url = self.admin_command_root + "/servers/" + server_name + "/configuration"
462
+ response = self.make_request("DELETE", url)
463
+ if response.status_code != 200:
464
+ return str(response.status_code) # should never get here?
465
+
466
+ related_code = response.json().get("relatedHTTPCode")
467
+ if related_code == 200:
468
+ return
469
+ else:
470
+ raise InvalidParameterException(response.content)
471
+
472
+ def deploy_stored_configurations(self, target_url_root: str, server_name: str = None) -> None:
473
+ """ Push the configuration for the server to another OMAG Server Platform.
474
+ Parameters
475
+ ----------
476
+ target_url_root : str
477
+ The target URL root where the configurations will be deployed.
478
+ server_name : str, optional
479
+ The name of the server to which the configurations will be deployed.
480
+ If not provided, the default server name will be used.
481
+
482
+ Raises
483
+ ------
484
+ InvalidParameterException
485
+ If the response status code is not 200 and the related HTTP code is also not 200.
486
+ PropertyServerException:
487
+ Raised by the server when an issue arises in processing a valid request
488
+ NotAuthorizedException:
489
+ The principle specified by the user_id does not have authorization for the requested action
490
+
491
+ """
492
+ if server_name is None:
493
+ server_name = self.server_name
494
+
495
+ url = f"{self.admin_command_root}/servers/{server_name}/configuration/deploy"
496
+
497
+ self.make_request("POST", url, target_url_root)
498
+
499
+
500
+ def get_event_bus(self, server_name: str = None) -> dict:
501
+ """ Returns the event bus configuration for the specified server
502
+
503
+ Parameters
504
+ ----------
505
+ server_name: str, optional
506
+ The name of the server to retrieve the event bus configuration from. If not provided, the default
507
+ server name specified in the class instance will be used.
508
+
509
+ Returns
510
+ -------
511
+ The event bus configuration as a JSON dictionary
512
+
513
+ Raises
514
+ ------
515
+ InvalidParameterException
516
+ If the response status code is not 200 and the related HTTP code is also not 200.
517
+ PropertyServerException:
518
+ Raised by the server when an issue arises in processing a valid request
519
+ NotAuthorizedException:
520
+ The principle specified by the user_id does not have authorization for the requested action
521
+
522
+ """
523
+ if server_name is None:
524
+ server_name = self.server_name
525
+ url = f"{self.admin_command_root}/servers/{server_name}/event-bus"
526
+
527
+ response = self.make_request("GET", url)
528
+ return response.json().get("config")
529
+
530
+ def set_event_bus_detailed(self, connector_provider: str, topic_url_root: str, server_name: str = None) -> None:
531
+ """
532
+ Parameters
533
+ ----------
534
+
535
+ connector_provider : str
536
+ Name of the connector provider
537
+
538
+ topic_url_root : str
539
+ URL for the topic
540
+
541
+ server_name : str, optional
542
+ The name of the server to retrieve the event bus configuration from. If not provided, the default server
543
+ name specified in the class instance will be used.
544
+
545
+ Returns
546
+ -------
547
+ None
548
+
549
+ Raises
550
+ ------
551
+ InvalidParameterException
552
+ If the response status code is not 200 and the related HTTP code is also not 200.
553
+
554
+ Description
555
+ -----------
556
+ Set up the default event bus for embedding in event-driven connector.
557
+ The resulting connector will be used for example, in the OMRS Topic Connector for each cohort,
558
+ the in and out topics for each Access Service and possibly the local repository's event mapper.
559
+ When the event bus is configured, it is used only on future configuration.
560
+ It does not affect existing configuration.
561
+
562
+ """
563
+
564
+ if server_name is None:
565
+ server_name = self.server_name
566
+
567
+ url = (f"{self.admin_command_root}/servers/{server_name}/event-bus?connectorProvider="
568
+ f"{connector_provider}&topicURLRoot={topic_url_root}")
569
+ self.make_request("POST", url)
570
+
571
+ def delete_event_bus(self, server_name: str = None) -> None:
572
+ """ Delete the event bus configuration for the given server.
573
+
574
+ Parameters
575
+ ----------
576
+
577
+ server_name : str, optional
578
+ The name of the server to retrieve the event bus configuration from. If not provided, the default server
579
+ name specified in the class instance will be used.
580
+
581
+ Returns
582
+ -------
583
+
584
+ Raises
585
+ ------
586
+ InvalidParameterException
587
+ If the response status code is not 200 and the related HTTP code is also not 200.
588
+
589
+ Description
590
+ -----------
591
+ Delete the current configuration for the event bus. This does not impact that existing configuration for the
592
+ server, only future configuration requests.
593
+ """
594
+
595
+ if server_name is None:
596
+ server_name = self.server_name
597
+
598
+ url = f"{self.admin_command_root}/servers/{server_name}/event-bus"
599
+ self.make_request("DELETE", url)
600
+
601
+ def set_server_url_root(self, url_root: str, server_name: str = None) -> None:
602
+ if server_name is None:
603
+ server_name = self.server_name
604
+ url = f"{self.admin_command_root}/servers/{server_name}/server-url-root-for-caller"
605
+ body = {
606
+ "urlRoot" : url_root
607
+ }
608
+ response = self.make_request("POST", url, payload=body)
609
+ related_code = response.json().get("relatedHTTPCode")
610
+ if related_code != 200:
611
+ raise InvalidParameterException(response.content)
612
+ else:
613
+ return
614
+
615
+ def set_max_page_size(self, max_page_size: int, server_name: str = None) -> None:
616
+ """
617
+ Set the maximum page size for a server.
618
+
619
+ Parameters
620
+ ----------
621
+ max_page_size : int
622
+ The maximum page size to set.
623
+ server_name : str, optional
624
+ The name of the server for which to set the maximum page size. If not specified, the default server name will be used.
625
+
626
+ Returns
627
+ -------
628
+ None
629
+ This method does not return any value.
630
+
631
+ Raises
632
+ ------
633
+ InvalidParameterException
634
+ If the response code is not 200.
635
+ PropertyServerException:
636
+ Raised by the server when an issue arises in processing a valid request
637
+ NotAuthorizedException:
638
+ The principle specified by the user_id does not have authorization for the requested action
639
+
640
+
641
+ """
642
+ if server_name is None:
643
+ server_name = self.server_name
644
+ url = f"{self.admin_command_root}/servers/{server_name}/max-page-size?limit={max_page_size}"
645
+ self.make_request("POST", url)
646
+
647
+ def set_server_user_id(self, server_user_id: str, server_name: str = None) -> None:
648
+ if server_name is None:
649
+ server_name = self.server_name
650
+ url = f"{self.admin_command_root}/servers/{server_name}/server-user-id?id={server_user_id}"
651
+ response = self.make_request("POST", url)
652
+ related_code = response.json().get("relatedHTTPCode")
653
+ if related_code != 200:
654
+ raise InvalidParameterException(response.content)
655
+ else:
656
+ return
657
+
658
+ def set_server_user_password(self, server_user_pwd: str, server_name: str = None) -> None:
659
+ if server_name is None:
660
+ server_name = self.server_name
661
+ url = f"{self.admin_command_root}/servers/{server_name}/server-user-password?password={server_user_pwd}"
662
+ response = self.make_request("POST", url)
663
+ related_code = response.json().get("relatedHTTPCode")
664
+ if related_code != 200:
665
+ raise InvalidParameterException(response.content)
666
+ else:
667
+ return
668
+
669
+ def set_organization_name(self, org_name: str, server_name: str = None) -> None:
670
+ if server_name is None:
671
+ server_name = self.server_name
672
+ url = f"{self.admin_command_root}/servers/{server_name}/organization-name?name={org_name}"
673
+ response = self.make_request("POST", url)
674
+ related_code = response.json().get("relatedHTTPCode")
675
+ if related_code != 200:
676
+ raise InvalidParameterException(response.content)
677
+ else:
678
+ return
679
+
680
+ def set_local_repository_config(self, repository_body: str, server_name: str = None) -> None:
681
+ if server_name is None:
682
+ server_name = self.server_name
683
+ url = self.admin_command_root + "/servers/" + server_name + "/local-repository/configuration"
684
+ response = self.make_request("POST", url, payload=repository_body)
685
+ related_code = response.json().get("relatedHTTPCode")
686
+ if related_code != 200:
687
+ raise InvalidParameterException(response.content)
688
+ else:
689
+ return
690
+
691
+ def set_plug_in_repository_connection(self, repository_connection_body: str, server_name: str = None) -> None:
692
+ if server_name is None:
693
+ server_name = self.server_name
694
+ url = f"{self.admin_command_root}/servers/{server_name}/local-repository/mode/plugin-repository/connection"
695
+ self.make_request("POST", url, payload=repository_connection_body)
696
+
697
+ def set_plug_in_repository_connection_provider(self, repository_connection_provider: str,
698
+ server_name: str = None) -> None:
699
+ """ Set the local repository connection with a user specified connection provider
700
+
701
+ Parameters
702
+ ----------
703
+ repository_connection_provider : str
704
+ The name of the connection provider for the plugin repository.
705
+
706
+ server_name : str, optional
707
+ The name of the server. If not provided, the default server name will be used.
708
+
709
+ Returns
710
+ -------
711
+ None
712
+
713
+ Raises
714
+ ------
715
+ InvalidParameterException
716
+ If the response code is not 200.
717
+ PropertyServerException:
718
+ Raised by the server when an issue arises in processing a valid request
719
+ NotAuthorizedException:
720
+ The principle specified by the user_id does not have authorization for the requested action
721
+
722
+ """
723
+ if server_name is None:
724
+ server_name = self.server_name
725
+ url = (f"{self.admin_command_root}/servers/{server_name}/local-repository/mode/plugin-repository/"
726
+ f"details?connectionProvider={repository_connection_provider}")
727
+ self.make_request("POST", url)
728
+
729
+ def set_open_metadata_archives(self, archives_list_body: str, server_name: str = None) -> None:
730
+ if server_name is None:
731
+ server_name = self.server_name
732
+ url = f"{self.admin_command_root}/servers/{server_name}/open-metadata-archives"
733
+ response = self.make_request("POST", url, payload=archives_list_body)
734
+ related_code = response.json().get("relatedHTTPCode")
735
+ if related_code != 200:
736
+ raise InvalidParameterException(response.content)
737
+ else:
738
+ return
739
+
740
+ def set_descriptive_server_type(self, type_name: str, server_name: str = None) -> None:
741
+ """ Set descriptiveServerType for this OMAG server
742
+
743
+ Parameters
744
+ ----------
745
+ type_name : str
746
+ The name of the descriptive server type to set.
747
+
748
+ server_name : str, optional
749
+ The name of the server for which the descriptive server type is being set. If not provided, the
750
+ default server name associated with the object is used.
751
+
752
+ Returns
753
+ -------
754
+ None
755
+
756
+ Raises
757
+ ------
758
+ InvalidParameterException
759
+ If the response code is not 200.
760
+ PropertyServerException:
761
+ Raised by the server when an issue arises in processing a valid request
762
+ NotAuthorizedException:
763
+ The principle specified by the user_id does not have authorization for the requested action
764
+
765
+ """
766
+ if server_name is None:
767
+ server_name = self.server_name
768
+ url = f"{self.admin_command_root}/servers/{server_name}/server-type?typeName={type_name}"
769
+ self.make_request("POST", url)
770
+
771
+ def set_server_description(self, server_desc: str, server_name: str = None) -> None:
772
+ if server_name is None:
773
+ server_name = self.server_name
774
+ url = f"{self.admin_command_root}/servers/{server_name}/server-description"
775
+ response = self.make_request("POST", url, server_desc)
776
+ related_code = response.json().get("relatedHTTPCode")
777
+ if related_code != 200:
778
+ raise InvalidParameterException(response.content)
779
+ else:
780
+ return
781
+
782
+ def set_server_type(self, server_type: str, server_name: str = None) -> None:
783
+ """ Sets the server type for the given server
784
+
785
+ Parameters
786
+ ----------
787
+ server_type : str
788
+ The type of server to set
789
+
790
+ server_name : str, optional
791
+ The name of the server. If None, the default server name will be used.
792
+
793
+ Returns
794
+ -------
795
+ None
796
+
797
+ Raises
798
+ ------
799
+ InvalidParameterException
800
+ If the response code is not 200.
801
+ PropertyServerException:
802
+ Raised by the server when an issue arises in processing a valid request
803
+ NotAuthorizedException:
804
+ The principle specified by the user_id does not have authorization for the requested action
805
+
806
+ Notes
807
+ -----
808
+
809
+ See https://egeria-project.org/concepts/omag-server/#server-name for details.
810
+
811
+ """
812
+ if server_name is None:
813
+ server_name = self.server_name
814
+
815
+ url = (f"{self.admin_command_root}/servers/{server_name}/"
816
+ f"server-type?typename={server_type}")
817
+ self.make_request("POST", url)
818
+
819
+ def clear_server_type(self, server_name: str = None) -> None:
820
+ """ Clears the server type for the given server
821
+
822
+ Parameters
823
+ ----------
824
+ server_name : str, optional
825
+ The name of the server. If None, the default server name will be used.
826
+
827
+ Returns
828
+ -------
829
+ None
830
+
831
+ Raises
832
+ ------
833
+ InvalidParameterException
834
+ If the response code is not 200.
835
+ PropertyServerException:
836
+ Raised by the server when an issue arises in processing a valid request
837
+ NotAuthorizedException:
838
+ The principle specified by the user_id does not have authorization for the requested action
839
+
840
+ """
841
+ if server_name is None:
842
+ server_name = self.server_name
843
+ url = f"{self.admin_command_root}/servers/{server_name}/server-type?typeName="
844
+ self.make_request("POST", url)
845
+
846
+ def config_view_service(self, service_url_marker: str, view_service_body: dict, server_name: str = None) -> None:
847
+ """ Configure a the view service specified by the service_url_marker using the view_service_body.
848
+
849
+ Parameters
850
+ ----------
851
+ service_url_marker : str
852
+ The service URL marker. A list can be retrieved through the `list_registered_view_svcs` of the
853
+ `registered_info` module.
854
+
855
+ view_service_body : dict
856
+ The body of the view service request.
857
+
858
+ server_name : str, optional
859
+ The name of the server. If not provided, the value of `self.server_name` will be used.
860
+
861
+ Returns
862
+ -------
863
+ None
864
+
865
+ Raises
866
+ ------
867
+ InvalidParameterException
868
+ If the response code is not 200.
869
+ PropertyServerException:
870
+ Raised by the server when an issue arises in processing a valid request
871
+ NotAuthorizedException:
872
+ The principle specified by the user_id does not have authorization for the requested action
873
+
874
+ Notes
875
+ -----
876
+
877
+ Details on view services configuration can be found at:
878
+ https://egeria-project.org/guides/admin/servers/configuring-the-view-services/?h=view#integration-view-services
879
+
880
+ """
881
+
882
+ if server_name is None:
883
+ server_name = self.server_name
884
+ validate_name(service_url_marker)
885
+
886
+ url = f"{self.admin_command_root}/servers/{server_name}/view-services/{service_url_marker}"
887
+ self.make_request("POST", url, view_service_body)
888
+ # todo - this may not be used anymore - old
889
+ def set_view_svcs_config(self, view_svcs_config_body: dict, server_name: str = None) -> None:
890
+ """ Set up the configuration for all the open metadata integration groups. This overrides the current values.
891
+
892
+ Parameters
893
+ ----------
894
+ view_svcs_config_body : dict
895
+ The configuration body for the view services.
896
+
897
+ server_name : str, optional
898
+ The name of the server. If not provided, the default server name will be used.
899
+
900
+ Returns
901
+ -------
902
+ None
903
+ This method does not return any value.
904
+
905
+ Raises
906
+ ------
907
+ InvalidParameterException
908
+ If the response code is not 200.
909
+ PropertyServerException:
910
+ Raised by the server when an issue arises in processing a valid request
911
+ NotAuthorizedException:
912
+ The principle specified by the user_id does not have authorization for the requested action
913
+
914
+ Notes
915
+ -----
916
+
917
+ Details on view services configuration can be found at:
918
+ https://egeria-project.org/guides/admin/servers/configuring-the-view-services/?h=view#integration-view-services
919
+
920
+ """
921
+ if server_name is None:
922
+ server_name = self.server_name
923
+ url = f"{self.admin_command_root}/servers/{server_name}/view-services/configuration"
924
+ self.make_request("POST", url, view_svcs_config_body)
925
+
926
+ def set_integration_groups_config(self, integration_groups_config_body: dict, server_name: str = None) -> None:
927
+ """ Set up the configuration for all the open metadata integration groups. This overrides the current values.
928
+ Parameters
929
+ ----------
930
+ integration_groups_config_body : dict
931
+ The configuration body for the integration groups.
932
+
933
+ server_name : str, optional
934
+ The name of the server. If not provided, the default server name will be used.
935
+
936
+ Returns
937
+ -------
938
+ None
939
+ This method does not return any value.
940
+
941
+ Raises
942
+ ------
943
+ InvalidParameterException
944
+ If the response code is not 200.
945
+ PropertyServerException:
946
+ Raised by the server when an issue arises in processing a valid request
947
+ NotAuthorizedException:
948
+ The principle specified by the user_id does not have authorization for the requested action
949
+
950
+ Notes
951
+ -----
952
+
953
+ Details on integration group configuration can be found at:
954
+ https://egeria-project.org/concepts/integration-group/
955
+
956
+ body format is:
957
+ [
958
+ {
959
+ "integrationGroupQualifiedName": "string",
960
+ "omagserverPlatformRootURL": "string",
961
+ "omagserverName": "string"
962
+ }
963
+ ]
964
+ """
965
+ if server_name is None:
966
+ server_name = self.server_name
967
+ url = f"{self.admin_command_root}/servers/{server_name}/integration-groups/configuration/all"
968
+ self.make_request("POST", url, integration_groups_config_body)
969
+
970
+ # def set_plug_in_repository_connection_from_provider(self, repository_connection: str, server_name: str = None) -> None:
971
+ # if server_name is None:
972
+ # server_name = self.server_name
973
+ # url = f"{self.admin_command_root}/servers/{server_name}/local-repository/mode/plugin-repository/connection"
974
+ # response = self.make_request("POST", url, json= repository_connection)
975
+ # related_code = response.json().get("relatedHTTPCode")
976
+ # if related_code != 200:
977
+ # raise InvalidParameterException(response.content)
978
+ # else:
979
+ # return
980
+
981
+ #
982
+ #
983
+ # %% Repository configurations
984
+ def set_engine_host_services(self):
985
+ # handles an array of engine list - pass in JSON
986
+
987
+ pass
988
+ def set_integration_daemon_services_configuration(self):
989
+ # pass a json list
990
+ pass
991
+
992
+ def config_integration_service(self, remote_omag_server: str, remote_omag_platform_url:str,
993
+ service_url_marker: str, integration_service_options: dict,
994
+ connector_configs: list, server_name: str = None) -> None:
995
+
996
+ if server_name is None:
997
+ server_name = self.server_name
998
+
999
+ if not isinstance(connector_configs, list):
1000
+ exc_msg = ' ==> connector_configs must be a list of dictionaries'
1001
+ raise Exception(exc_msg)
1002
+
1003
+ validate_name(remote_omag_server)
1004
+ validate_url(remote_omag_platform_url)
1005
+
1006
+ validate_name(service_url_marker)
1007
+
1008
+ request_body = {
1009
+ "class": "IntegrationServiceRequestBody",
1010
+ "omagserverPlatformRootURL": remote_omag_platform_url,
1011
+ "omagserverName": remote_omag_server,
1012
+ "integrationServiceOptions": integration_service_options,
1013
+ "integrationConnectorConfigs": connector_configs
1014
+ }
1015
+
1016
+ url = f"{self.admin_command_root}/servers/{server_name}/integration-services/{service_url_marker}"
1017
+ # print(f"URL is : {url}")
1018
+ # print(f"body is : \n{json.dumps(request_body, indent=4)}")
1019
+
1020
+ self.make_request("POST", url, request_body)
1021
+ return
1022
+
1023
+
1024
+ def config_all_integration_services(self, remote_omag_server: str, remote_omag_platform_url:str,
1025
+ integration_service_options: dict,
1026
+ connector_configs: dict, server_name: str = None) -> None:
1027
+
1028
+ if server_name is None:
1029
+ server_name = self.server_name
1030
+ validate_name(remote_omag_server)
1031
+ validate_url(remote_omag_platform_url)
1032
+
1033
+ request_body = {
1034
+ "IntegrationConnectorConfigs" : [
1035
+ {
1036
+ "class": "IntegrationServiceRequestBody",
1037
+ "omagserverPlatformRootURL": remote_omag_platform_url,
1038
+ "omagserverName": remote_omag_server,
1039
+ "integrationServiceOptions": integration_service_options,
1040
+ "integrationConnectorConfigs": connector_configs
1041
+ }
1042
+ ]
1043
+ }
1044
+
1045
+ url = f"{self.admin_command_root}/servers/{server_name}/integration-services"
1046
+ print(f"URL is : {url}")
1047
+ print(f"body is : \n{json.dumps(request_body, indent=4)}")
1048
+
1049
+ self.make_request("POST", url, request_body)
1050
+
1051
+
1052
+ def clear_integration_service(self, service_url_marker:str, server_name:str = None)-> None:
1053
+ if server_name is None:
1054
+ server_name = self.server_name
1055
+ validate_name(service_url_marker)
1056
+
1057
+ url = f"{self.admin_command_root}/servers/{server_name}/integration-services/{service_url_marker}"
1058
+ self.make_request("DELETE", url)
1059
+
1060
+ def get_integration_service_config(self, service_url_marker:str, server_name:str = None)-> dict | str:
1061
+ if server_name is None:
1062
+ server_name = self.server_name
1063
+ validate_name(service_url_marker)
1064
+ url = f"{self.admin_command_root}/servers/{server_name}/integration-services/{service_url_marker}/configuration"
1065
+ response = self.make_request("GET", url)
1066
+ return response.json().get("config","No configuration found")
1067
+
1068
+ def get_integration_services_configs(self, server_name: str = None)-> dict | str:
1069
+ if server_name is None:
1070
+ server_name = self.server_name
1071
+
1072
+ url = f"{self.admin_command_root}/servers/{server_name}/integration-services/configuration"
1073
+ response = self.make_request("GET", url)
1074
+ return response.json().get("services", "No configuration found")
1075
+