Question

Export the connection from one control hub and import to another control hub using sdk python script

  • 3 May 2023
  • 0 replies
  • 32 views

Export script :  ( please ignore the api key and token being provided as hard coded value , this can be parameterized )

 

from streamsets.sdk import ControlHub
import json
API_CREDENTIAL_ID = "**"
API_TOKEN = "**"
sch = ControlHub(API_CREDENTIAL_ID, API_TOKEN)
connections = sch.connections.get_all()
for connection in connections:
    filename = connection.name.lower().replace(' ', '_') + '.json'
    file= open(filename, "a")
    file.write(str(connection))
    file.close()

 


With above code we are able to export the connection of pipeline from one control hub in Json file

 

Now to import the connection in another control hub . I am not sure if its feasible to do so? as we are not having enough information in json file. It carries only  (Connection id , name and type) . But it don't have Connection URL  and credential. Without that how can the connection be imported to another control hub ? Any suggestion please help . Also incase if I want to import the connection directly without bringing the details in json file then , is this right way?

 

 

connections = sch.connections.get_all()
for connection in onnections:
new_connection = t_sch.connections.add_connection(connection.name, connection.connection_type, connection.configuration)
print(f"Created new connection with ID {new_connection.id} on the target platform.")


0 replies

Be the first to reply!

Reply