How to change labels of jobs using python SDK?

  • 19 April 2022
  • 0 replies
  • 23 views

  • Please make sure all the jobs are in inactive state.
  • Changes following parameters as per the environment:-
  1. <CONTROL_HUB_URL> = Controlhub URL
  2. <USERNAME> =  admin username
  3. <PASSWORD> = password
  4. <OLD_LABEL> = old label
  5. <NEW_LABEL>= new label 
from streamsets.sdk import ControlHub,DataCollector


DataCollector.VERIFY_SSL_CERTIFICATES = False
sch = ControlHub('<CONTROL_HUB_URL>',
username='USERNAME',

password='PASSWORD')


jobs_with_existing_label = sch.jobs.get_all(data_collector_labels=['<OLD_LABEL>'])
print(f'jobs_with_existing_label = \n {jobs_with_existing_label}')



for job in jobs_with_existing_label:
job.data_collector_labels = ['<NEW_LABEL>']
sch.update_job(job)

 

 


0 replies

Be the first to reply!

Reply