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 argumentfrom 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.
Logging is set up in taskcluster/__init__.py
. If the special DEBUG_TASKCLUSTER_CLIENT
environment variable is set, the __init__.py
module will set the logging
module's level
for its logger to logging.DEBUG
and if there are no existing handlers, add a
logging.StreamHandler()
instance. This is meant to assist those who do not wish to bother
figuring out how to configure the python logging module but do want debug messages
// Create Auth client instance
import taskcluster
auth = taskcluster.Auth(options)
auth.listClients() -> result
auth.client(clientId) -> result
auth.client(clientId='value') -> result
auth.createClient(clientId, payload) -> result
auth.createClient(payload, clientId='value') -> result
auth.resetAccessToken(clientId) -> result
auth.resetAccessToken(clientId='value') -> result
auth.updateClient(clientId, payload) -> result
auth.updateClient(payload, clientId='value') -> result
auth.deleteClient(clientId) -> None
auth.deleteClient(clientId='value') -> None
auth.listRoles() -> result
auth.role(roleId) -> result
auth.role(roleId='value') -> result
auth.createRole(roleId, payload) -> result
auth.createRole(payload, roleId='value') -> result
auth.updateRole(roleId, payload) -> result
auth.updateRole(payload, roleId='value') -> result
auth.deleteRole(roleId) -> None
auth.deleteRole(roleId='value') -> None
auth.awsS3Credentials(level, bucket, prefix) -> result
auth.awsS3Credentials(level='value', bucket='value', prefix='value') -> result
auth.azureTableSAS(account, table) -> result
auth.azureTableSAS(account='value', table='value') -> result
auth.authenticateHawk(payload) -> result
auth.importClients(payload) -> None
auth.ping() -> None
// Create AwsProvisioner client instance
import taskcluster
awsProvisioner = taskcluster.AwsProvisioner(options)
awsProvisioner.createWorkerType(workerType, payload) -> result
awsProvisioner.createWorkerType(payload, workerType='value') -> result
awsProvisioner.updateWorkerType(workerType, payload) -> result
awsProvisioner.updateWorkerType(payload, workerType='value') -> result
awsProvisioner.workerType(workerType) -> result
awsProvisioner.workerType(workerType='value') -> result
awsProvisioner.removeWorkerType(workerType) -> None
awsProvisioner.removeWorkerType(workerType='value') -> None
awsProvisioner.listWorkerTypes() -> result
awsProvisioner.createSecret(token, payload) -> None
awsProvisioner.createSecret(payload, token='value') -> None
awsProvisioner.getSecret(token) -> result
awsProvisioner.getSecret(token='value') -> result
awsProvisioner.instanceStarted(instanceId, token) -> None
awsProvisioner.instanceStarted(instanceId='value', token='value') -> None
awsProvisioner.removeSecret(token) -> None
awsProvisioner.removeSecret(token='value') -> None
awsProvisioner.getLaunchSpecs(workerType) -> result
awsProvisioner.getLaunchSpecs(workerType='value') -> result
awsProvisioner.awsState() -> None
awsProvisioner.state(workerType) -> None
awsProvisioner.state(workerType='value') -> None
awsProvisioner.ping() -> None
awsProvisioner.apiReference() -> None
// Create AwsProvisionerEvents client instance
import taskcluster
awsProvisionerEvents = taskcluster.AwsProvisionerEvents(options)
awsProvisionerEvents.workerTypeCreated(routingKeyPattern) -> routingKey
- routingKeyKind is constant of
primary
is required Description: Identifier for the routing-key kind. This is always'primary'
for the formalized routing key. - workerType is required Description: WorkerType that this message concerns.
- reserved Description: Space reserved for future routing-key entries, you should always match this entry with
#
. As automatically done by our tooling, if not specified.
- routingKeyKind is constant of
awsProvisionerEvents.workerTypeUpdated(routingKeyPattern) -> routingKey
- routingKeyKind is constant of
primary
is required Description: Identifier for the routing-key kind. This is always'primary'
for the formalized routing key. - workerType is required Description: WorkerType that this message concerns.
- reserved Description: Space reserved for future routing-key entries, you should always match this entry with
#
. As automatically done by our tooling, if not specified.
- routingKeyKind is constant of
awsProvisionerEvents.workerTypeRemoved(routingKeyPattern) -> routingKey
- routingKeyKind is constant of
primary
is required Description: Identifier for the routing-key kind. This is always'primary'
for the formalized routing key. - workerType is required Description: WorkerType that this message concerns.
- reserved Description: Space reserved for future routing-key entries, you should always match this entry with
#
. As automatically done by our tooling, if not specified.
- routingKeyKind is constant of
// Create Index client instance
import taskcluster
index = taskcluster.Index(options)
index.findTask(namespace) -> result
index.findTask(namespace='value') -> result
index.listNamespaces(namespace, payload) -> result
index.listNamespaces(payload, namespace='value') -> result
index.listTasks(namespace, payload) -> result
index.listTasks(payload, namespace='value') -> result
index.insertTask(namespace, payload) -> result
index.insertTask(payload, namespace='value') -> result
index.findArtifactFromTask(namespace, name) -> None
index.findArtifactFromTask(namespace='value', name='value') -> None
index.ping() -> None
// Create PurgeCache client instance
import taskcluster
purgeCache = taskcluster.PurgeCache(options)
purgeCache.purgeCache(provisionerId, workerType, payload) -> None
purgeCache.purgeCache(payload, provisionerId='value', workerType='value') -> None
purgeCache.ping() -> None
// Create PurgeCacheEvents client instance
import taskcluster
purgeCacheEvents = taskcluster.PurgeCacheEvents(options)
purgeCacheEvents.purgeCache(routingKeyPattern) -> routingKey
- routingKeyKind is constant of
primary
is required Description: Identifier for the routing-key kind. This is always'primary'
for the formalized routing key. - provisionerId is required Description:
provisionerId
under which to purge cache. - workerType is required Description:
workerType
for which to purge cache.
- routingKeyKind is constant of
// Create Queue client instance
import taskcluster
queue = taskcluster.Queue(options)
queue.task(taskId) -> result
queue.task(taskId='value') -> result
queue.status(taskId) -> result
queue.status(taskId='value') -> result
queue.createTask(taskId, payload) -> result
queue.createTask(payload, taskId='value') -> result
queue.defineTask(taskId, payload) -> result
queue.defineTask(payload, taskId='value') -> result
queue.scheduleTask(taskId) -> result
queue.scheduleTask(taskId='value') -> result
queue.rerunTask(taskId) -> result
queue.rerunTask(taskId='value') -> result
queue.cancelTask(taskId) -> result
queue.cancelTask(taskId='value') -> result
queue.pollTaskUrls(provisionerId, workerType) -> result
queue.pollTaskUrls(provisionerId='value', workerType='value') -> result
queue.claimTask(taskId, runId, payload) -> result
queue.claimTask(payload, taskId='value', runId='value') -> result
queue.reclaimTask(taskId, runId) -> result
queue.reclaimTask(taskId='value', runId='value') -> result
queue.reportCompleted(taskId, runId) -> result
queue.reportCompleted(taskId='value', runId='value') -> result
queue.reportFailed(taskId, runId) -> result
queue.reportFailed(taskId='value', runId='value') -> result
queue.reportException(taskId, runId, payload) -> result
queue.reportException(payload, taskId='value', runId='value') -> result
queue.createArtifact(taskId, runId, name, payload) -> result
queue.createArtifact(payload, taskId='value', runId='value', name='value') -> result
queue.getArtifact(taskId, runId, name) -> None
queue.getArtifact(taskId='value', runId='value', name='value') -> None
queue.getLatestArtifact(taskId, name) -> None
queue.getLatestArtifact(taskId='value', name='value') -> None
queue.listArtifacts(taskId, runId) -> result
queue.listArtifacts(taskId='value', runId='value') -> result
queue.listLatestArtifacts(taskId) -> result
queue.listLatestArtifacts(taskId='value') -> result
queue.pendingTasks(provisionerId, workerType) -> result
queue.pendingTasks(provisionerId='value', workerType='value') -> result
queue.ping() -> None
// Create QueueEvents client instance
import taskcluster
queueEvents = taskcluster.QueueEvents(options)
queueEvents.taskDefined(routingKeyPattern) -> routingKey
- routingKeyKind is constant of
primary
is required Description: Identifier for the routing-key kind. This is always'primary'
for the formalized routing key. - taskId is required Description:
taskId
for the task this message concerns - runId Description:
runId
of latest run for the task,_
if no run is exists for the task. - workerGroup Description:
workerGroup
of latest run for the task,_
if no run is exists for the task. - workerId Description:
workerId
of latest run for the task,_
if no run is exists for the task. - provisionerId is required Description:
provisionerId
this task is targeted at. - workerType is required Description:
workerType
this task must run on. - schedulerId is required Description:
schedulerId
this task was created by. - taskGroupId is required Description:
taskGroupId
this task was created in. - reserved Description: Space reserved for future routing-key entries, you should always match this entry with
#
. As automatically done by our tooling, if not specified.
- routingKeyKind is constant of
queueEvents.taskPending(routingKeyPattern) -> routingKey
- routingKeyKind is constant of
primary
is required Description: Identifier for the routing-key kind. This is always'primary'
for the formalized routing key. - taskId is required Description:
taskId
for the task this message concerns - runId is required Description:
runId
of latest run for the task,_
if no run is exists for the task. - workerGroup Description:
workerGroup
of latest run for the task,_
if no run is exists for the task. - workerId Description:
workerId
of latest run for the task,_
if no run is exists for the task. - provisionerId is required Description:
provisionerId
this task is targeted at. - workerType is required Description:
workerType
this task must run on. - schedulerId is required Description:
schedulerId
this task was created by. - taskGroupId is required Description:
taskGroupId
this task was created in. - reserved Description: Space reserved for future routing-key entries, you should always match this entry with
#
. As automatically done by our tooling, if not specified.
- routingKeyKind is constant of
queueEvents.taskRunning(routingKeyPattern) -> routingKey
- routingKeyKind is constant of
primary
is required Description: Identifier for the routing-key kind. This is always'primary'
for the formalized routing key. - taskId is required Description:
taskId
for the task this message concerns - runId is required Description:
runId
of latest run for the task,_
if no run is exists for the task. - workerGroup is required Description:
workerGroup
of latest run for the task,_
if no run is exists for the task. - workerId is required Description:
workerId
of latest run for the task,_
if no run is exists for the task. - provisionerId is required Description:
provisionerId
this task is targeted at. - workerType is required Description:
workerType
this task must run on. - schedulerId is required Description:
schedulerId
this task was created by. - taskGroupId is required Description:
taskGroupId
this task was created in. - reserved Description: Space reserved for future routing-key entries, you should always match this entry with
#
. As automatically done by our tooling, if not specified.
- routingKeyKind is constant of
queueEvents.artifactCreated(routingKeyPattern) -> routingKey
- routingKeyKind is constant of
primary
is required Description: Identifier for the routing-key kind. This is always'primary'
for the formalized routing key. - taskId is required Description:
taskId
for the task this message concerns - runId is required Description:
runId
of latest run for the task,_
if no run is exists for the task. - workerGroup is required Description:
workerGroup
of latest run for the task,_
if no run is exists for the task. - workerId is required Description:
workerId
of latest run for the task,_
if no run is exists for the task. - provisionerId is required Description:
provisionerId
this task is targeted at. - workerType is required Description:
workerType
this task must run on. - schedulerId is required Description:
schedulerId
this task was created by. - taskGroupId is required Description:
taskGroupId
this task was created in. - reserved Description: Space reserved for future routing-key entries, you should always match this entry with
#
. As automatically done by our tooling, if not specified.
- routingKeyKind is constant of
queueEvents.taskCompleted(routingKeyPattern) -> routingKey
- routingKeyKind is constant of
primary
is required Description: Identifier for the routing-key kind. This is always'primary'
for the formalized routing key. - taskId is required Description:
taskId
for the task this message concerns - runId is required Description:
runId
of latest run for the task,_
if no run is exists for the task. - workerGroup is required Description:
workerGroup
of latest run for the task,_
if no run is exists for the task. - workerId is required Description:
workerId
of latest run for the task,_
if no run is exists for the task. - provisionerId is required Description:
provisionerId
this task is targeted at. - workerType is required Description:
workerType
this task must run on. - schedulerId is required Description:
schedulerId
this task was created by. - taskGroupId is required Description:
taskGroupId
this task was created in. - reserved Description: Space reserved for future routing-key entries, you should always match this entry with
#
. As automatically done by our tooling, if not specified.
- routingKeyKind is constant of
queueEvents.taskFailed(routingKeyPattern) -> routingKey
- routingKeyKind is constant of
primary
is required Description: Identifier for the routing-key kind. This is always'primary'
for the formalized routing key. - taskId is required Description:
taskId
for the task this message concerns - runId Description:
runId
of latest run for the task,_
if no run is exists for the task. - workerGroup Description:
workerGroup
of latest run for the task,_
if no run is exists for the task. - workerId Description:
workerId
of latest run for the task,_
if no run is exists for the task. - provisionerId is required Description:
provisionerId
this task is targeted at. - workerType is required Description:
workerType
this task must run on. - schedulerId is required Description:
schedulerId
this task was created by. - taskGroupId is required Description:
taskGroupId
this task was created in. - reserved Description: Space reserved for future routing-key entries, you should always match this entry with
#
. As automatically done by our tooling, if not specified.
- routingKeyKind is constant of
queueEvents.taskException(routingKeyPattern) -> routingKey
- routingKeyKind is constant of
primary
is required Description: Identifier for the routing-key kind. This is always'primary'
for the formalized routing key. - taskId is required Description:
taskId
for the task this message concerns - runId Description:
runId
of latest run for the task,_
if no run is exists for the task. - workerGroup Description:
workerGroup
of latest run for the task,_
if no run is exists for the task. - workerId Description:
workerId
of latest run for the task,_
if no run is exists for the task. - provisionerId is required Description:
provisionerId
this task is targeted at. - workerType is required Description:
workerType
this task must run on. - schedulerId is required Description:
schedulerId
this task was created by. - taskGroupId is required Description:
taskGroupId
this task was created in. - reserved Description: Space reserved for future routing-key entries, you should always match this entry with
#
. As automatically done by our tooling, if not specified.
- routingKeyKind is constant of
// Create Scheduler client instance
import taskcluster
scheduler = taskcluster.Scheduler(options)
scheduler.createTaskGraph(taskGraphId, payload) -> result
scheduler.createTaskGraph(payload, taskGraphId='value') -> result
scheduler.extendTaskGraph(taskGraphId, payload) -> result
scheduler.extendTaskGraph(payload, taskGraphId='value') -> result
scheduler.status(taskGraphId) -> result
scheduler.status(taskGraphId='value') -> result
scheduler.info(taskGraphId) -> result
scheduler.info(taskGraphId='value') -> result
scheduler.inspect(taskGraphId) -> result
scheduler.inspect(taskGraphId='value') -> result
scheduler.inspectTask(taskGraphId, taskId) -> result
scheduler.inspectTask(taskGraphId='value', taskId='value') -> result
scheduler.ping() -> None
// Create SchedulerEvents client instance
import taskcluster
schedulerEvents = taskcluster.SchedulerEvents(options)
schedulerEvents.taskGraphRunning(routingKeyPattern) -> routingKey
- routingKeyKind is constant of
primary
is required Description: Identifier for the routing-key kind. This is always'primary'
for the formalized routing key. - taskId Description: Always takes the value
_
- runId Description: Always takes the value
_
- workerGroup Description: Always takes the value
_
- workerId Description: Always takes the value
_
- provisionerId Description: Always takes the value
_
- workerType Description: Always takes the value
_
- schedulerId is required Description: Identifier for the task-graphs scheduler managing the task-graph this message concerns. Usually
task-graph-scheduler
in production. - taskGraphId is required Description: Identifier for the task-graph this message concerns
- reserved Description: Space reserved for future routing-key entries, you should always match this entry with
#
. As automatically done by our tooling, if not specified.
- routingKeyKind is constant of
schedulerEvents.taskGraphExtended(routingKeyPattern) -> routingKey
- routingKeyKind is constant of
primary
is required Description: Identifier for the routing-key kind. This is always'primary'
for the formalized routing key. - taskId Description: Always takes the value
_
- runId Description: Always takes the value
_
- workerGroup Description: Always takes the value
_
- workerId Description: Always takes the value
_
- provisionerId Description: Always takes the value
_
- workerType Description: Always takes the value
_
- schedulerId is required Description: Identifier for the task-graphs scheduler managing the task-graph this message concerns. Usually
task-graph-scheduler
in production. - taskGraphId is required Description: Identifier for the task-graph this message concerns
- reserved Description: Space reserved for future routing-key entries, you should always match this entry with
#
. As automatically done by our tooling, if not specified.
- routingKeyKind is constant of
schedulerEvents.taskGraphBlocked(routingKeyPattern) -> routingKey
- routingKeyKind is constant of
primary
is required Description: Identifier for the routing-key kind. This is always'primary'
for the formalized routing key. - taskId Description: Always takes the value
_
- runId Description: Always takes the value
_
- workerGroup Description: Always takes the value
_
- workerId Description: Always takes the value
_
- provisionerId Description: Always takes the value
_
- workerType Description: Always takes the value
_
- schedulerId is required Description: Identifier for the task-graphs scheduler managing the task-graph this message concerns. Usually
task-graph-scheduler
in production. - taskGraphId is required Description: Identifier for the task-graph this message concerns
- reserved Description: Space reserved for future routing-key entries, you should always match this entry with
#
. As automatically done by our tooling, if not specified.
- routingKeyKind is constant of
schedulerEvents.taskGraphFinished(routingKeyPattern) -> routingKey
- routingKeyKind is constant of
primary
is required Description: Identifier for the routing-key kind. This is always'primary'
for the formalized routing key. - taskId Description: Always takes the value
_
- runId Description: Always takes the value
_
- workerGroup Description: Always takes the value
_
- workerId Description: Always takes the value
_
- provisionerId Description: Always takes the value
_
- workerType Description: Always takes the value
_
- schedulerId is required Description: Identifier for the task-graphs scheduler managing the task-graph this message concerns. Usually
task-graph-scheduler
in production. - taskGraphId is required Description: Identifier for the task-graph this message concerns
- reserved Description: Space reserved for future routing-key entries, you should always match this entry with
#
. As automatically done by our tooling, if not specified.
- routingKeyKind is constant of
// Create Secrets client instance
import taskcluster
secrets = taskcluster.Secrets(options)
secrets.set(name, payload) -> None
secrets.set(payload, name='value') -> None
secrets.update(name, payload) -> None
secrets.update(payload, name='value') -> None
secrets.remove(name) -> None
secrets.remove(name='value') -> None
secrets.get(name) -> result
secrets.get(name='value') -> result
secrets.ping() -> None