Solved

Get list of pipeline name using Python SDK

  • 3 October 2023
  • 4 replies
  • 65 views

Hi Team,

I am using below mentioned method to get list of all pipelines.

But it is returning all the values like version, commit id.

I want only pipeline name.

sch = ControlHub(credential_id, token)
pipeline_list = sch.pipelines.get_all()

 

I tried sch.pipeline.name but it is not supporting.

icon

Best answer by Kirti 3 October 2023, 22:37

View original

4 replies

Userlevel 5
Badge +1

@sudarshan_shinde1 

 

can you please give a try with below code snippet 

 

from streamsets.sdk import ControlHub

control_hub = ControlHub(base_url="https://your-control-hub-url", api_key="your-api-token")
pipelines = control_hub.list_pipelines()

for pipeline in pipelines:
print(f"Pipeline Name: {pipeline.name}, ID: {pipeline.id}")

 

Hi @Bikram ,

Thank you for responding.

I am getting below error.

'ControlHub' object has no attribute 'list_pipelines'. Did you mean: 'export_pipelines'?

Please refer the code snippet.


 

Please @sudarshan_shinde1 , replace in @Bikram ‘s code (thanks!)

pipelines = control_hub.list_pipelines()

with

pipelines = sch.pipelines.get_all()

as you originally had.

To have the full list of pipeline names you could use list comprehension:

pipeline_names = [pipeline.name for pipeline in sch.pipelines]

Edited to remove unnecessary code following Kirti’s answer

Userlevel 2
Badge

@sudarshan_shinde1 ,

pipeline_names = [pipeline.name for pipeline in sch.pipelines]

Hope it helps.

Regards-

Kirti

Reply