Get self-description description of your connector

Example: Get self-descriptions of your TSG Connector

Last update: 2024-01-27

This request retrieves and prints information about your connector’s self-description (aka self-self-description) and displays the parsed result in a simple Python dictionary.

The following operations are demonstrated:

  1. Load environment variables (your connector configs) from a .env file.

  2. Establish a connection to your TSG connector.

  3. Retrieve and print information about your connector’s self-description

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 get your connector self-description.

 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    # Connect to our TSG connector:
14    conn = TSGController(
15        api_key=config['API_KEY'],
16        connector_id=config['CONNECTOR_ID'],
17        access_url=config['ACCESS_URL'],
18        agent_id=config['AGENT_ID']
19    )
20
21    # Get internal connector info (self self-description):
22    self_description = conn.get_connector_self_selfdescription()
23
24    print("-" * 79)
25    print("> Connector Self Self Description:")
26    pprint(self_description.to_dict())
27
28    # Get artifacts list of your connector self-description:
29    # Note: you can refine search using the filters below
30    resource_type = "ids:ContractOffer"
31    artifacts = conn.parse_catalog_artifacts(
32        self_description,
33        catalog_id=self_description.catalogs[0].id,
34        resource_type=resource_type,
35        creation_date_gt="2021-08-10T00:00:00.000Z",
36        creation_date_lt="2030-01-01T00:00:00.000Z",
37        return_last_artifact=True,
38        valid_contract_only=False
39    )
40
41    print("-" * 79)
42    print(f"> Connector {config['CONNECTOR_ID']} in "
43          f"catalog {self_description.catalogs[0].id} with "
44          f"resource type {resource_type} has this list artifacts:")
45    pprint(artifacts)