def print_job_response(title, job):
    print()
    print(title)
    print("    job_id: {}".format(job.job_id))
    print("    type: {}".format(job.type))
    print("    start_time: {}".format(job.start_time))
    print("    max_execution_time_in_seconds: {}".format(job.max_execution_time_in_seconds))
    print("    update_twin: {}".format(job.update_twin))
    print("    query_condition: {}".format(job.query_condition))


try:
    # Create IoTHubJobManager
    iothub_job_manager = IoTHubJobManager(iothub_connection_str)

    # Get all export/import jobs
    export_import_jobs = iothub_job_manager.get_import_export_jobs()
    if export_import_jobs:
        print_export_import_jobs("Get all export/import jobs", export_import_jobs)
    else:
        print("No export/import job found")

    # Create export/import job
    new_export_import_job = iothub_job_manager.create_import_export_job(
        create_export_import_job_properties()
    )
    print_export_import_job("Create export/import job result: ", new_export_import_job)

    # Get export/import job
Beispiel #2
0
def print_export_import_jobs(title, export_import_jobs):
    print("")
    x = 1
    if len([export_import_jobs]) > 0:
        for j in range(len(export_import_jobs)):
            print_export_import_job("{0}: {1}".format(title, x),
                                    export_import_jobs[j])
            x += 1
    else:
        print("No item found")


try:
    # Create IoTHubJobManager
    iothub_job_manager = IoTHubJobManager.from_connection_string(
        iothub_connection_str)

    # Get all export/import jobs
    export_import_jobs = iothub_job_manager.get_import_export_jobs()
    if export_import_jobs:
        print_export_import_jobs("Get all export/import jobs",
                                 export_import_jobs)
    else:
        print("No export/import job found")

    # Create export/import job
    new_export_import_job = iothub_job_manager.create_import_export_job(
        create_export_import_job_properties())
    print_export_import_job("Create export/import job result: ",
                            new_export_import_job)