Skip to main content

Python wrapper for Oozie Webservice REST API

Project description

This is Python Library for Oozie Web service api.

This project follows the [Oozie 4.2.0 WebServicesAPI](https://oozie.apache.org/docs/4.2.0/WebServicesAPI.html) document.

Usage

Install it:

pip install oozie-webservice-api

Usage:

from oozie import OozieWebService
import json
'''
Ooize Web Service Test

@author: hs_seo
@since: 2019.06.18
'''


if __name__ == "__main__":

    rerun_xml = '''<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <property><name>user.name</name><value>hadoop</value></property>
</configuration>
'''

    submit_xml = '''<?xml version="1.0" encoding="UTF-8"?>
<property><name>user.name</name><value>hadoop</value></property>
</configuration>
'''

    update_xml = """<configuration>
<property><name>user.name</name><value>hadoop</value></property>
</configuration>"""


    # https://oozie.apache.org/docs/4.2.0/WebServicesAPI.html
    oozie = OozieWebService("http://localhost:11000")

    ## Versions - all json return
    return_obj = oozie.version.oozie_versions()

    ## Admin - all json return
    return_obj = oozie.admin.status()
    return_obj = oozie.admin.status('NORMAL')
    return_obj = oozie.admin.os_env()
    return_obj = oozie.admin.java_sys_properties()
    return_obj = oozie.admin.configuration()
    return_obj = oozie.admin.instrumentation()
    return_obj = oozie.admin.metrics()    # if metric enable
    return_obj = oozie.admin.build_version()
    return_obj = oozie.admin.available_timezones()
    return_obj = oozie.admin.queue_dump()
    return_obj = oozie.admin.available_oozie_servers()
    return_obj = oozie.admin.list_sharelib()
    return_obj = oozie.admin.list_sharelib("pig")
    return_obj = oozie.admin.update_sharelib()

    ## Jobs
    #filters = oozie.jobs.Filters()

    # Job Submission
    return_obj = oozie.jobs.submit_job(submit_xml)                           # start ok
    return_obj = oozie.jobs.submit_job(submit_xml, job_type="mapreduce")    # start ok
    return_obj = oozie.jobs.info()
    return_obj = oozie.jobs.info(filters)
    return_obj = oozie.jobs.managing_jobs("kill", "coordinator", filters)

    ## Job
    # Managing a Job
    #co_id = "C-ID"
    #wf_id = "W-ID"
    return_obj = oozie.job.managing_job(wf_id, 'start')                 # start ok
    return_obj = oozie.job.managing_rerun_workflow(wf_id, rerun_xml)    # rerun ok
    return_obj = oozie.job.rerun_coordinator_on_action(co_id, "1")      # rerun ok
    return_obj = oozie.job.rerun_coordinator_on_date(co_id, "2019-05-22T16:00Z", "2019-05-22T16:00Z")    # rerun ok
    return_obj = oozie.job.change_coordinator_concurrency(co_id, 2)
    return_obj = oozie.job.change_coordinator_endtime(co_id, "2019-06-02T16:00Z")
    return_obj = oozie.job.change_coordinator_pausetime(co_id, "2019-06-01T16:00Z")
    return_obj = oozie.job.update_coordinator(co_id, update_xml)

    # filter
    #filters = oozie.job.Filters()
    #filters.len = 100

    # Log Fiter
    #log_filters = oozie.job.LogFilters()

    return_obj = oozie.job.job_info(wf_id)
    return_obj = oozie.job.job_info(co_id)
    return_obj = oozie.job.job_info(co_id, filters)
    return_obj = oozie.job.coordinator_allruns(co_id, "1")
    return_obj = oozie.job.coordinator_allruns(co_id, "1", filters)

    return_obj = oozie.job.job_definition(wf_id)
    return_obj = oozie.job.job_log(wf_id)  # txt return
    return_obj = oozie.job.job_log(wf_id)  # txt return
    return_obj = oozie.job.job_log(wf_id, filters=log_filters)  # txt return
    return_obj = oozie.job.job_log(wf_id, "errorlog")  # txt return
    return_obj = oozie.job.job_log(wf_id, "auditlog")  # txt return
    return_obj = oozie.job.job_status(wf_id)
    return_obj = oozie.job.job_graph(wf_id, file_over_write=True)


    if return_obj.isok:
        print(return_obj.info.url)

        if "Content-Type" in return_obj.headers and "application/json" in return_obj.headers["Content-Type"]:
            json_obj = json.loads(return_obj.body)
            print(json.dumps(json_obj, indent=4, sort_keys=True))
        else:
            print(return_obj.body)
    else:
        print(return_obj.info.filename)
        print(return_obj.info.headers['oozie-error-code'])
        print(return_obj.info.headers['oozie-error-message'])
        print(return_obj.body)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oozie_webservice_api-1.2.0-py2.py3-none-any.whl (8.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file oozie_webservice_api-1.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: oozie_webservice_api-1.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for oozie_webservice_api-1.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 12b8712201564b9bc4454aa173c334f204ddd97ed04c0c104cc3f4867a84eabc
MD5 07e7ad0611993b7b567e08a81de3ef92
BLAKE2b-256 542b9994e636b19bfdeb4c1821f060b9ba71e0787b40d4bdfcec1fd892b7a282

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page