Get external self description
Example - Get self-descriptions of an external connector
Last update: 2024-01-27
- This request retrieves and prints information about an external connector’s
self-description using a connection to a custom connector. It loads external connector configs from a ‘EXTERNAL_CONNECTOR’ variable, establishes a connection to your TSG connector, and then retrieves and prints the self-description information from the external connector.
The following operations are demonstrated:
Load environment variables (your connector configs) from a .env file.
Establish a connection to your TSG connector.
Retrieve and print information about external connector self-descriptions
Important
Ensure that the required environment variables (Your Connector API_KEY, CONNECTOR_ID, ACCESS_URL and AGENT_ID) are set in the .env file before using this request.
The connector API_KEY can be retrieved by loging into the TSG connector UI and navigating to the ‘API Keys’ tab.
Execute the code below to request the self-description of an external connector.
1if __name__ == "__main__":
2 from pprint import pprint
3 from loguru import logger
4 from dotenv import dotenv_values
5 from tsg_client.controllers import TSGController
6
7 # Comment the line below to enable internal logger:
8 logger.disable("")
9
10 # Load environment variables:
11 config = dotenv_values('.env')
12
13 # Example of external connector configs (TNO Playground)
14 EXTERNAL_CONNECTOR = {
15 "CONNECTOR_ID": 'urn:playground:tsg:connectors:TestConnector',
16 "ACCESS_URL": 'https://test-connector.playground.dataspac.es',
17 "AGENT_ID": 'urn:playground:tsg:TNO'
18 }
19
20 # Connect to our TSG connector:
21 conn = TSGController(
22 api_key=config['API_KEY'],
23 connector_id=config['CONNECTOR_ID'],
24 access_url=config['ACCESS_URL'],
25 agent_id=config['AGENT_ID']
26 )
27
28 # Get external connector info (self-descriptions):
29 self_description = conn.get_connector_selfdescription(
30 access_url=EXTERNAL_CONNECTOR['ACCESS_URL'],
31 connector_id=EXTERNAL_CONNECTOR['CONNECTOR_ID'],
32 agent_id=EXTERNAL_CONNECTOR['AGENT_ID']
33 )
34
35 print("-" * 79)
36 print(f"> Connector {EXTERNAL_CONNECTOR['CONNECTOR_ID']} Self Description:")
37 pprint(self_description.to_dict())