Package: ibm-pathfinder-sdk
pathfinder-python-sdkThe open source Pathfinder Python SDK allows you to build connectors for reporting metadata into Pathfinder.Table of ContentsOverviewPrerequisitesInstallationUsing the SDKOpen source @ IBMContributingLicenseOverviewModul NameUsageClass NameeventpublisherPublishing to http registry endpointConMsgObjectModelRegistryeventpublisherPublishing to kafka endpointConMsgObjectKafkaeventpublisherPublishing to stdoutConMsgObjectBasepathfinderconfigconfigurationenv var or application.yamlpfmodelclassesSystemEventSystemEventpfmodelclassesSystemEvent.payloadSystemEntitypfmodelclassesSystemEvent.payloadSystemRelationshippfmodelclasses--Kafka key builder----KafkaKeyEntity--pfmodelclasses--Kafka key builder----KafkaKeyRelationship--Prerequisitesrequirements.txtibm-pathfinder-sdkInstallationTo install, usepip:python -m pip install --upgrade ibm_pathfinder_sdkUsing the SDKSimple create a connector for pathfinder.
Crate your python env and create e.g python my_connector.pyimportuuidimportjsonfromibm_pathfinder_sdkimporteventpublisherasmsgObject,pathfinderconfig,pfmodelclassesclassNULL_NAMESPACE:bytes=b''# if therean existing class model load it like# from pfmodelclasses import pathfinderClass# or create your own classes on your own model you needclassSystemTest(pfmodelclasses.SystemEntity):def__init__(self,edf_id):self.json_schema_ref="urn:demo.for.testonly:systemtest:1.0.0"self.edf_id=edf_iddefsetName(self,name):self.name=namedefsetDescription(self,description):self.description=descriptiondeftoJSON(self):returnjson.dumps(self,default=lambdao:o.__dict__,sort_keys=True,indent=4)classEnvironmentTest(pfmodelclasses.SystemEntity):def__init__(self,edf_id):self.json_schema_ref="urn:demo.for.testonly:environmenttest:1.0.0"self.edf_id=edf_iddefsetName(self,name):self.name=namedefsetDescription(self,description):self.description=descriptiondeftoJSON(self):returnjson.dumps(self,default=lambdao:o.__dict__,sort_keys=True,indent=4)classRelatedTest(pfmodelclasses.SystemRelationship):def__init__(self,from_edf_id,to_edf_id):self.json_schema_ref="urn:demo.for.testonly:relatedtest:1.0.0"self.from_edf_id=from_edf_idself.to_edf_id=to_edf_iddeftoJSON(self):returnjson.dumps(self,default=lambdao:o.__dict__,sort_keys=True,indent=4)UNIQUE_CONNECTOR_ID="my-connector-test01"PATHFINDER_CONNECTOR_STOP_SIGNAL="GO"# use pf-model-registryconMsgObject=msgObject.ConMsgObjectModelRegistry()# If you like to write the events to stdout only,# because you don't have a running Pathfinder backend/registry,# use ConMsgObjectBase() instead.# conMsgObject =  msgObject.ConMsgObjectBase()connectorUuid=str(uuid.uuid3(NULL_NAMESPACE,UNIQUE_CONNECTOR_ID))connectorType="PYTHON_EXAMPLE"event=pfmodelclasses.SystemEvent(connectorUuid,connectorType)environmentName="Server Room 001"environemtEdfId=(str(uuid.uuid3(NULL_NAMESPACE,str(environmentName))))envObj=EnvironmentTest(environemtEdfId)envObj.setName(environmentName)envObj.setDescription("My demo room")event.payload=envObj# event setting, default is upsert# event.event_type = "upsert"# event.event_type = "delete"conMsgObject.publishEvent(event)foriinrange(1,11):systemName=str("System-"+str(i))systemEdfId=(str(uuid.uuid3(NULL_NAMESPACE,systemName)))sysObj=SystemTest(systemEdfId)sysObj.setName(systemName)event.payload=sysObjconMsgObject.publishEvent(event)relatedObj=RelatedTest(systemEdfId,environemtEdfId)event.payload=relatedObjconMsgObject.publishEvent(event)ConfigurationThe configuration can be done in two variants, either environment variables or file-based.To do it with environmental variables, export the variables and start python:export OIDC_CLIENT_ENABLED=False
export K8S_TOKEN_AUTH=False
# if you use msgObject.ConMsgObjectBase(), you dont need this export
export PF_MODEL_REGISTRY_URL=http://<registry-url>:<port>/<api path>
# start your connector
python my_connector.py --envTo use a configuration file instead, create it asconfig/application.yaml.
This are the minimal parameters:stopMode:stoppathfinder:kubernetesUrl:https://<cluster>:<port>url:http://<registry-url>:<port>/<api path>connector:state:type:localk8sauth:enabled:Falseoidc:enabled:FalseFinally you can run the connector :python my_connector.pyOpen source @ IBMFind more open source projects on theIBM Github PageLicenseThis SDK is released under the Apache 2.0 license.
The license's full text can be found inLICENSE.