|
49 | 49 | COMPLIANCE_FRAMEWORK_ITEM, |
50 | 50 | LIST_COLLECTION_RESULTS, |
51 | 51 | GET_RAW_DATA_DOWNLOAD_URL, |
| 52 | + FIND_INTEGRATION_DEFINITION, |
| 53 | + INTEGRATION_INSTANCES, |
| 54 | + INTEGRATION_INSTANCE, |
| 55 | + UPDATE_INTEGRATION_INSTANCE, |
52 | 56 | ) |
53 | 57 |
|
54 | 58 |
|
@@ -443,7 +447,10 @@ def delete_relationship(self, relationship_id: str = None): |
443 | 447 | response = self._execute_query(DELETE_RELATIONSHIP, variables=variables) |
444 | 448 | return response["data"]["deleteRelationship"] |
445 | 449 |
|
446 | | - def create_integration_instance(self, instance_name: str = None, instance_description: str = None, integration_definition_id: str = "8013680b-311a-4c2e-b53b-c8735fd97a5c"): |
| 450 | + def create_custom_integration_instance(self, |
| 451 | + instance_name: str = None, |
| 452 | + instance_description: str = None, |
| 453 | + integration_definition_id: str = "8013680b-311a-4c2e-b53b-c8735fd97a5c"): |
447 | 454 | """Creates a new Custom Integration Instance. |
448 | 455 |
|
449 | 456 | args: |
@@ -649,6 +656,91 @@ def fetch_integration_job_events(self, instance_id: str = None, instance_job_id: |
649 | 656 |
|
650 | 657 | return response['data']['integrationEvents'] |
651 | 658 |
|
| 659 | + def get_integration_definition_details(self, integration_type: str = None): |
| 660 | + """Fetch the Integration Definition Details for a given integration type. |
| 661 | +
|
| 662 | + """ |
| 663 | + variables = { |
| 664 | + "integrationType": integration_type, |
| 665 | + "includeConfig": True |
| 666 | + } |
| 667 | + |
| 668 | + response = self._execute_query(FIND_INTEGRATION_DEFINITION, variables=variables) |
| 669 | + return response |
| 670 | + |
| 671 | + def fetch_integration_instances(self, definition_id: str = None): |
| 672 | + """Fetch all configured Instances for a given integration type. |
| 673 | +
|
| 674 | + """ |
| 675 | + variables = { |
| 676 | + "definitionId": definition_id, |
| 677 | + "limit": 100 |
| 678 | + } |
| 679 | + |
| 680 | + response = self._execute_query(INTEGRATION_INSTANCES, variables=variables) |
| 681 | + return response |
| 682 | + |
| 683 | + def get_integration_instance_details(self, instance_id: str = None): |
| 684 | + """Fetch configuration details for a single configured Integration Instance. |
| 685 | +
|
| 686 | + """ |
| 687 | + variables = { |
| 688 | + "integrationInstanceId": instance_id |
| 689 | + } |
| 690 | + |
| 691 | + response = self._execute_query(INTEGRATION_INSTANCE, variables=variables) |
| 692 | + return response |
| 693 | + |
| 694 | + def update_integration_instance_config_value(self, |
| 695 | + instance_id: str = None, |
| 696 | + config_key: str = None, |
| 697 | + config_value: str = None): |
| 698 | + """Update a single config k:v pair existing on a configured Integration Instance. |
| 699 | +
|
| 700 | + """ |
| 701 | + |
| 702 | + # fetch existing instnace configuration |
| 703 | + instance_config = self.get_integration_instance_details(instance_id=instance_id) |
| 704 | + config_dict = instance_config['data']['integrationInstance']['config'] |
| 705 | + |
| 706 | + if str(config_dict.get(config_key, "Not Found")) != "Not Found": |
| 707 | + |
| 708 | + # update config key value with new provided value |
| 709 | + config_dict[config_key] = config_value |
| 710 | + instance_config['data']['integrationInstance']['config'] = config_dict |
| 711 | + |
| 712 | + # remove externalId to not include in update payload |
| 713 | + del instance_config['data']['integrationInstance']['config']['externalId'] |
| 714 | + |
| 715 | + # prepare variables GraphQL payload for updating config |
| 716 | + instance_details = instance_config['data']['integrationInstance'] |
| 717 | + |
| 718 | + variables = { |
| 719 | + "id": instance_details['id'], |
| 720 | + "update": { |
| 721 | + "pollingInterval": instance_details['pollingInterval'], |
| 722 | + "config": instance_details['config'], |
| 723 | + "description": instance_details['description'], |
| 724 | + "name": instance_details['name'], |
| 725 | + "collectorPoolId": instance_details['collectorPoolId'], |
| 726 | + "pollingIntervalCronExpression": instance_details['pollingIntervalCronExpression'], |
| 727 | + "ingestionSourcesOverrides": instance_details['ingestionSourcesOverrides'] |
| 728 | + } |
| 729 | + } |
| 730 | + |
| 731 | + # remove problem fields from previous response |
| 732 | + del variables['update']['pollingIntervalCronExpression']['__typename'] |
| 733 | + |
| 734 | + for ingestion_source in instance_details['ingestionSourcesOverrides']: |
| 735 | + ingestion_source.pop("__typename", None) # Removes key if it exists, ignores if not |
| 736 | + |
| 737 | + response = self._execute_query(UPDATE_INTEGRATION_INSTANCE, variables=variables) |
| 738 | + |
| 739 | + return response |
| 740 | + |
| 741 | + else: |
| 742 | + return "Provided 'config_key' not found in existing Integration Instance config" |
| 743 | + |
652 | 744 | def create_smartclass(self, smartclass_name: str = None, smartclass_description: str = None): |
653 | 745 | """Creates a new Smart Class within Assets. |
654 | 746 |
|
|
0 commit comments