Skip to content

mshal/taskcluster-client.py

 
 

Repository files navigation

Taskcluster Client Library in Python

Build Status

This is a library used to interact with Taskcluster within Python programs. It presents the entire REST API to consumers as well as being able to generate URLs Signed by Hawk credentials. It can also generate routing keys for listening to pulse messages from Taskcluster.

The library builds the REST API methods from the same API Reference format as the Javascript client library.

'NOTE:' Temporary credentials are implemented, but they don't work from this library right now

The REST API methods are documented on http://docs.taskcluster.net/

  • Here's a simple command:

    import taskcluster
    index = taskcluster.Index({'credentials': {'clientId': 'id', 'accessToken': 'accessToken'}})
    index.ping()
  • Keyword arguments for API methods are supported. The javascript client accepts only positional arguments. You may use either positional arguments or keyword, never both. If the method requires an input payload, you must specify it as the last positional argument. If you are using keyword arguments, the payload is the first argument.

    import taskcluster
    api = taskcluster.api()
    api.method('1', '2', '3', {'data': 'here'})

    Assuming apiMethod has a route of /method/<arg1>/<arg2>/<arg3>, this will result in a calle to /method/pie/2/3

    The same call can be achieved using keyword arguments of:

    import taskcluster
    api = taskcluster.api()
    api.method({'data': 'here'}, arg1='1', arg2='2', arg3='3')
  • Options for the topic exchange methods can be in the form of either a single dictionary argument or keyword arguments. Only one form is allowed

    from taskcluster import client
    qEvt = client.QueueEvents()
    # The following calls are equivalent
    qEvt.taskCompleted({'taskId': 'atask'})
    qEvt.taskCompleted(taskId='atask')
  • Method Payloads are specified through the payload keyword passed to the API method. When using positional arguments, it's the last argument. When using keyword arguments, the payload is the first and only positional argument

    from taskcluster import client
    index = client.index()
    index.listNamespaces('mozilla-central', payload={'continuationToken': 'a_token'})

There is a bug in the PyHawk library (as of 0.1.3) which breaks bewit generation for URLs that do not have a query string. This is being addressed in PyHawk PR 27.

About

A python implementation of the Taskcluster Client Library

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 76.1%
  • Makefile 11.7%
  • Shell 10.0%
  • JavaScript 2.2%