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