|
8 | 8 | from indykite_sdk.model.authorization_policy_config_status import Status
|
9 | 9 | from indykite_sdk.indykite.config.v1beta1 import model_pb2
|
10 | 10 | from indykite_sdk.model.token_status import ExternalTokenStatus
|
| 11 | +from indykite_sdk.model.entity_matching_status import Status as EntityMatchingStatus |
11 | 12 | from indykite_sdk.model.external_data_resolver_config_content_type import ContentType
|
12 | 13 | import indykite_sdk.utils.logger as logger
|
13 | 14 |
|
@@ -564,6 +565,141 @@ def external_data_resolver_config(self,
|
564 | 565 | return logger.logger_error(exception)
|
565 | 566 |
|
566 | 567 |
|
| 568 | +def create_entity_matching_pipeline_config_node(self, |
| 569 | + location, |
| 570 | + name, |
| 571 | + display_name, |
| 572 | + description, |
| 573 | + entity_matching_pipeline_config, |
| 574 | + bookmarks=[]): |
| 575 | + """ |
| 576 | + create entity matching pipeline config node |
| 577 | + :param self: |
| 578 | + :param location: string gid id |
| 579 | + :param name: string pattern: ^[a-z](?:[-a-z0-9]{0,61}[a-z0-9])$ |
| 580 | + :param display_name: string |
| 581 | + :param description: string |
| 582 | + :param entity_matching_pipeline_config: EntityMatchingPipelineConfig object |
| 583 | + :param bookmarks: list of strings with pattern: ^[a-zA-Z0-9_-]{40,}$ |
| 584 | + :return: deserialized CreateConfigNode instance |
| 585 | + """ |
| 586 | + sys.excepthook = logger.handle_excepthook |
| 587 | + try: |
| 588 | + if entity_matching_pipeline_config and not isinstance( |
| 589 | + entity_matching_pipeline_config, |
| 590 | + model_pb2.EntityMatchingPipelineConfig): |
| 591 | + raise TypeError("EntityMatchingPipelineConfig must be an object") |
| 592 | + |
| 593 | + response = self.stub.CreateConfigNode( |
| 594 | + pb2.CreateConfigNodeRequest( |
| 595 | + location=location, |
| 596 | + name=name, |
| 597 | + display_name=wrappers.StringValue(value=display_name), |
| 598 | + description=wrappers.StringValue(value=description), |
| 599 | + entity_matching_pipeline_config=entity_matching_pipeline_config, |
| 600 | + bookmarks=bookmarks |
| 601 | + ) |
| 602 | + ) |
| 603 | + except Exception as exception: |
| 604 | + return logger.logger_error(exception) |
| 605 | + |
| 606 | + if not response: |
| 607 | + return None |
| 608 | + return CreateConfigNode.deserialize(response) |
| 609 | + |
| 610 | + |
| 611 | +def update_entity_matching_pipeline_config_node(self, |
| 612 | + config_node_id, |
| 613 | + etag, |
| 614 | + display_name, |
| 615 | + description, |
| 616 | + entity_matching_pipeline_config, |
| 617 | + bookmarks=[]): |
| 618 | + """ |
| 619 | + update entity matching pipeline |
| 620 | + :param self: |
| 621 | + :param config_node_id: string gid id |
| 622 | + :param display_name: string |
| 623 | + :param description: string |
| 624 | + :param entity_matching_pipeline_config: EntityMatchingPipelineConfig object |
| 625 | + :param bookmarks: list of strings with pattern: ^[a-zA-Z0-9_-]{40,}$ |
| 626 | + :return: deserialized UpdateConfigNode instance |
| 627 | + """ |
| 628 | + sys.excepthook = logger.handle_excepthook |
| 629 | + try: |
| 630 | + if entity_matching_pipeline_config and not isinstance( |
| 631 | + entity_matching_pipeline_config, |
| 632 | + model_pb2.EntityMatchingPipelineConfig): |
| 633 | + raise TypeError("EntityMatchingPipelineConfig must be an object") |
| 634 | + response = self.stub.UpdateConfigNode( |
| 635 | + pb2.UpdateConfigNodeRequest( |
| 636 | + id=config_node_id, |
| 637 | + etag=wrappers.StringValue(value=etag), |
| 638 | + display_name=wrappers.StringValue(value=display_name), |
| 639 | + description=wrappers.StringValue(value=description), |
| 640 | + entity_matching_pipeline_config=entity_matching_pipeline_config, |
| 641 | + bookmarks=bookmarks |
| 642 | + ) |
| 643 | + ) |
| 644 | + except Exception as exception: |
| 645 | + return logger.logger_error(exception) |
| 646 | + |
| 647 | + if not response: |
| 648 | + return None |
| 649 | + return UpdateConfigNode.deserialize(response) |
| 650 | + |
| 651 | + |
| 652 | +def entity_matching_pipeline_config(self, |
| 653 | + node_filter, |
| 654 | + similarity_score_cutoff=None, |
| 655 | + property_mapping_status=None, |
| 656 | + property_mapping_message=None, |
| 657 | + entity_matching_status=None, |
| 658 | + entity_matching_message=None, |
| 659 | + property_mappings=None, |
| 660 | + rerun_interval=None, |
| 661 | + last_run_time=None, |
| 662 | + report_url=None, |
| 663 | + report_type=None): |
| 664 | + |
| 665 | + """ |
| 666 | + create EntityMatchingPipelineConfig |
| 667 | + :param self: |
| 668 | + :param node_filter: EntityMatchingPipelineConfig.NodeFilter object |
| 669 | + :param similarity_score_cutoff: float |
| 670 | + :param property_mapping_status: EntityMatchingPipelineConfig.Status object |
| 671 | + :param property_mapping_message: google.protobuf.StringValue |
| 672 | + :param entity_matching_status: EntityMatchingPipelineConfig.Status |
| 673 | + :param entity_matching_message: google.protobuf.StringValue |
| 674 | + :param property_mappings: array of EntityMatchingPipelineConfig.PropertyMapping |
| 675 | + :param rerun_interval: string |
| 676 | + :param last_run_time: google.protobuf.Timestamp |
| 677 | + :param report_url: google.protobuf.StringValue |
| 678 | + :param report_type: google.protobuf.StringValue |
| 679 | + :return: EntityMatchingPipelineConfig object |
| 680 | + """ |
| 681 | + sys.excepthook = logger.handle_excepthook |
| 682 | + try: |
| 683 | + property_mapping_status = self.validate_entity_matching_status(property_mapping_status) |
| 684 | + entity_matching_status = self.validate_entity_matching_status(entity_matching_status) |
| 685 | + external_config = model_pb2.EntityMatchingPipelineConfig( |
| 686 | + node_filter=node_filter, |
| 687 | + similarity_score_cutoff=similarity_score_cutoff, |
| 688 | + property_mapping_status=property_mapping_status, |
| 689 | + property_mapping_message=wrappers.StringValue(value=property_mapping_message), |
| 690 | + entity_matching_status=entity_matching_status, |
| 691 | + entity_matching_message=wrappers.StringValue(value=entity_matching_message), |
| 692 | + property_mappings=property_mappings, |
| 693 | + rerun_interval=rerun_interval, |
| 694 | + last_run_time=last_run_time, |
| 695 | + report_url=wrappers.StringValue(value=report_url), |
| 696 | + report_type=wrappers.StringValue(value=report_type) |
| 697 | + ) |
| 698 | + return external_config |
| 699 | + except Exception as exception: |
| 700 | + return logger.logger_error(exception) |
| 701 | + |
| 702 | + |
567 | 703 | def validate_data_points(self, data_points):
|
568 | 704 | """
|
569 | 705 | validate data_points requirement
|
@@ -641,6 +777,24 @@ def validate_external_data_resolver_content_type(self, content_type):
|
641 | 777 | return logger.logger_error(exception)
|
642 | 778 |
|
643 | 779 |
|
| 780 | +def validate_entity_matching_status(self, status): |
| 781 | + """ |
| 782 | + validate entity matching status requirement |
| 783 | + :param self: |
| 784 | + :param status: number |
| 785 | + :return: status, none or error |
| 786 | + """ |
| 787 | + try: |
| 788 | + if not status: |
| 789 | + return None |
| 790 | + statuses = [s.value for s in EntityMatchingStatus] |
| 791 | + if status and status not in statuses: |
| 792 | + raise TypeError("status must be a member of EntityMatchingPipelineConfig.Status") |
| 793 | + return status |
| 794 | + except Exception as exception: |
| 795 | + return logger.logger_error(exception) |
| 796 | + |
| 797 | + |
644 | 798 | def list_config_node_versions(self, id_config_node):
|
645 | 799 | """
|
646 | 800 | list config nodes versions of the specified config node
|
|
0 commit comments