public class Hooks extends TaskclusterRequestHandler
Hooks are a mechanism for creating tasks in response to events.
Hooks are identified with a hookGroupId
and a hookId
.
When an event occurs, the resulting task is automatically created. The task is created using the scope assume:hook-id:<hookGroupId>/<hookId>
, which must have scopes to make the createTask call, including satisfying all scopes in task.scopes
. The new task has a taskGroupId
equal to its taskId
, as is the convention for decision tasks.
Hooks can have a “schedule” indicating specific times that new tasks should be created. Each schedule is in a simple cron format, per https://www.npmjs.com/package/cron-parser. For example: * ['0 0 1 * * *']
– daily at 1:00 UTC * ['0 0 9,21 * * 1-5', '0 0 12 * * 0,6']
– weekdays at 9:00 and 21:00 UTC, weekends at noon
The task definition is used as a JSON-e template, with a context depending on how it is fired. See /docs/reference/core/taskcluster-hooks/docs/firing-hooks for more information.
Modifier and Type | Field and Description |
---|---|
protected static String |
defaultBaseURL |
Constructor and Description |
---|
Hooks() |
Hooks(Credentials credentials) |
Hooks(Credentials credentials,
String baseURL) |
Hooks(String baseURL) |
Hooks(String clientId,
String accessToken) |
Hooks(String clientId,
String accessToken,
String certificate) |
Modifier and Type | Method and Description |
---|---|
CallSummary<HookCreationRequest,HookDefinition> |
createHook(String hookGroupId,
String hookId,
HookCreationRequest payload)
This endpoint will create a new hook.
|
CallSummary<EmptyPayload,HookStatusResponse> |
getHookStatus(String hookGroupId,
String hookId)
This endpoint will return the current status of the hook.
|
CallSummary<EmptyPayload,TriggerTokenResponse> |
getTriggerToken(String hookGroupId,
String hookId)
Retrieve a unique secret token for triggering the specified hook.
|
CallSummary<EmptyPayload,HookDefinition> |
hook(String hookGroupId,
String hookId)
This endpoint will return the hook definition for the given
hookGroupId and hookId. |
CallSummary<EmptyPayload,HookGroups> |
listHookGroups()
This endpoint will return a list of all hook groups with at least one hook.
|
CallSummary<EmptyPayload,HookList> |
listHooks(String hookGroupId)
This endpoint will return a list of all the hook definitions within a given hook group.
|
CallSummary<EmptyPayload,EmptyPayload> |
ping()
Respond without doing anything.
|
CallSummary<EmptyPayload,EmptyPayload> |
removeHook(String hookGroupId,
String hookId)
This endpoint will remove a hook definition.
|
CallSummary<EmptyPayload,TriggerTokenResponse> |
resetTriggerToken(String hookGroupId,
String hookId)
Reset the token for triggering a given hook.
|
CallSummary<Object,TaskStatusStructure> |
triggerHook(String hookGroupId,
String hookId,
Object payload)
This endpoint will trigger the creation of a task from a hook definition.
|
CallSummary<Object,TaskStatusStructure> |
triggerHookWithToken(String hookGroupId,
String hookId,
String token,
Object payload)
This endpoint triggers a defined hook with a valid token.
|
CallSummary<HookCreationRequest,HookDefinition> |
updateHook(String hookGroupId,
String hookId,
HookCreationRequest payload)
This endpoint will update an existing hook.
|
apiCall, setBaseURL, uriEncode
protected static final String defaultBaseURL
public Hooks(Credentials credentials)
public Hooks(Credentials credentials, String baseURL)
public Hooks(String baseURL)
public Hooks()
public CallSummary<EmptyPayload,EmptyPayload> ping() throws APICallFailure
Respond without doing anything. This endpoint is used to check that the service is up.
APICallFailure
public CallSummary<EmptyPayload,HookGroups> listHookGroups() throws APICallFailure
This endpoint will return a list of all hook groups with at least one hook.
APICallFailure
public CallSummary<EmptyPayload,HookList> listHooks(String hookGroupId) throws APICallFailure
This endpoint will return a list of all the hook definitions within a given hook group.
APICallFailure
public CallSummary<EmptyPayload,HookDefinition> hook(String hookGroupId, String hookId) throws APICallFailure
This endpoint will return the hook definition for the given hookGroupId
and hookId.
APICallFailure
public CallSummary<EmptyPayload,HookStatusResponse> getHookStatus(String hookGroupId, String hookId) throws APICallFailure
This endpoint will return the current status of the hook. This represents a snapshot in time and may vary from one call to the next.
APICallFailure
public CallSummary<HookCreationRequest,HookDefinition> createHook(String hookGroupId, String hookId, HookCreationRequest payload) throws APICallFailure
This endpoint will create a new hook.
The caller’s credentials must include the role that will be used to create the task. That role must satisfy task.scopes as well as the necessary scopes to add the task to the queue.
Required scopes: All of: * hooks:modify-hook:
APICallFailure
public CallSummary<HookCreationRequest,HookDefinition> updateHook(String hookGroupId, String hookId, HookCreationRequest payload) throws APICallFailure
This endpoint will update an existing hook. All fields except hookGroupId
and hookId
can be modified.
Required scopes: All of: * hooks:modify-hook:
APICallFailure
public CallSummary<EmptyPayload,EmptyPayload> removeHook(String hookGroupId, String hookId) throws APICallFailure
This endpoint will remove a hook definition.
Required scopes: hooks:modify-hook:
APICallFailure
public CallSummary<Object,TaskStatusStructure> triggerHook(String hookGroupId, String hookId, Object payload) throws APICallFailure
This endpoint will trigger the creation of a task from a hook definition.
The HTTP payload must match the hooks triggerSchema
. If it does, it is provided as the payload
property of the JSON-e context used to render the task template.
Required scopes: hooks:trigger-hook:
APICallFailure
public CallSummary<EmptyPayload,TriggerTokenResponse> getTriggerToken(String hookGroupId, String hookId) throws APICallFailure
Retrieve a unique secret token for triggering the specified hook. This token can be deactivated with resetTriggerToken
.
Required scopes: hooks:get-trigger-token:
APICallFailure
public CallSummary<EmptyPayload,TriggerTokenResponse> resetTriggerToken(String hookGroupId, String hookId) throws APICallFailure
Reset the token for triggering a given hook. This invalidates token that may have been issued via getTriggerToken with a new token.
Required scopes: hooks:reset-trigger-token:
APICallFailure
public CallSummary<Object,TaskStatusStructure> triggerHookWithToken(String hookGroupId, String hookId, String token, Object payload) throws APICallFailure
This endpoint triggers a defined hook with a valid token.
The HTTP payload must match the hooks triggerSchema
. If it does, it is provided as the payload
property of the JSON-e context used to render the task template.
APICallFailure
Copyright © 2014–2018 Mozilla. All rights reserved.