Documentation ¶
Overview ¶
The following code is AUTO-GENERATED. Please DO NOT edit. To update this generated code, run the following command: in the /codegenerator/model subdirectory of this project, making sure that `${GOPATH}/bin` is in your `PATH`:
go install && go generate
This package was generated from the schema defined at /references/hooks/v1/api.json The hooks service provides a mechanism for creating tasks in response to events.
See:
How to use this package ¶
First create a Hooks object:
hooks := tchooks.New(nil)
and then call one or more of hooks's methods, e.g.:
err := hooks.Ping(.....)
handling any errors...
if err != nil { // handle error... }
Taskcluster Schema ¶
The source code of this go package was auto-generated from the API definition at <rootUrl>/references/hooks/v1/api.json together with the input and output schemas it references,
Index ¶
- type Binding
- type FailedFire
- type HookCreationRequest
- type HookDefinition
- type HookGroups
- type HookList
- type HookMetadata
- type HookStatusResponse
- type Hooks
- func (hooks *Hooks) CreateHook(hookGroupId, hookId string, payload *HookCreationRequest) (*HookDefinition, error)
- func (hooks *Hooks) GetHookStatus(hookGroupId, hookId string) (*HookStatusResponse, error)
- func (hooks *Hooks) GetTriggerToken(hookGroupId, hookId string) (*TriggerTokenResponse, error)
- func (hooks *Hooks) GetTriggerToken_SignedURL(hookGroupId, hookId string, duration time.Duration) (*url.URL, error)
- func (hooks *Hooks) Hook(hookGroupId, hookId string) (*HookDefinition, error)
- func (hooks *Hooks) ListHookGroups() (*HookGroups, error)
- func (hooks *Hooks) ListHooks(hookGroupId string) (*HookList, error)
- func (hooks *Hooks) ListLastFires(hookGroupId, hookId string) (*LastFiresList, error)
- func (hooks *Hooks) Ping() error
- func (hooks *Hooks) RemoveHook(hookGroupId, hookId string) error
- func (hooks *Hooks) ResetTriggerToken(hookGroupId, hookId string) (*TriggerTokenResponse, error)
- func (hooks *Hooks) TriggerHook(hookGroupId, hookId string, payload *TriggerHookRequest) (*TriggerHookResponse, error)
- func (hooks *Hooks) TriggerHookWithToken(hookGroupId, hookId, token string, payload *TriggerHookRequest) (*TriggerHookResponse, error)
- func (hooks *Hooks) UpdateHook(hookGroupId, hookId string, payload *HookCreationRequest) (*HookDefinition, error)
- type LastFiresList
- type NoFire
- type RunInformation
- type Status
- type SuccessfulFire
- type TaskStatusStructure
- type TriggerHookRequest
- type TriggerHookResponse
- type TriggerHookResponse1
- type TriggerTokenResponse
- type Var
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Binding ¶
type Binding struct { // Min length: 1 Exchange string `json:"exchange"` // Min length: 1 RoutingKeyPattern string `json:"routingKeyPattern"` }
Exchange and RoutingKeyPattern for each binding
type FailedFire ¶
type FailedFire struct { // The error that occurred when firing the task. This is typically, // but not always, an API error message. // // Additional properties allowed Error json.RawMessage `json:"error"` // Possible values: // * "error" Result string `json:"result"` // The time the task was created. This will not necessarily match `task.created`. Time tcclient.Time `json:"time"` }
Information about an unsuccessful firing of the hook
type HookCreationRequest ¶
type HookCreationRequest struct { Bindings []Binding `json:"bindings,omitempty"` // Syntax: ^([a-zA-Z0-9-_]*)$ // Min length: 1 // Max length: 64 HookGroupID string `json:"hookGroupId,omitempty"` // Syntax: ^([a-zA-Z0-9-_/]*)$ // Min length: 1 // Max length: 64 HookID string `json:"hookId,omitempty"` Metadata HookMetadata `json:"metadata"` // Definition of the times at which a hook will result in creation of a task. // If several patterns are specified, tasks will be created at any time // specified by one or more patterns. // // Default: [] // // Array items: // Cron-like specification for when tasks should be created. The pattern is // parsed in a UTC context. // See [cron-parser on npm](https://www.npmjs.com/package/cron-parser). // Note that tasks may not be created at exactly the time specified. Schedule []string `json:"schedule,omitempty"` // Template for the task definition. This is rendered using [JSON-e](https://taskcluster.github.io/json-e/) // as described in [firing hooks](/docs/reference/core/hooks/firing-hooks) to produce // a task definition that is submitted to the Queue service. // // Additional properties allowed Task json.RawMessage `json:"task"` // Default: { // "additionalProperties": false, // "type": "object" // } // // Additional properties allowed TriggerSchema json.RawMessage `json:"triggerSchema,omitempty"` }
Definition of a hook that can create tasks at defined times.
type HookDefinition ¶
type HookDefinition struct { Bindings []Binding `json:"bindings,omitempty"` // Syntax: ^([a-zA-Z0-9-_]*)$ // Min length: 1 // Max length: 64 HookGroupID string `json:"hookGroupId"` // Syntax: ^([a-zA-Z0-9-_/]*)$ // Min length: 1 // Max length: 64 HookID string `json:"hookId"` Metadata HookMetadata `json:"metadata"` // A list of cron-style definitions to represent a set of moments in (UTC) time. // If several patterns are specified, a given moment in time represented by // more than one pattern is considered only to be counted once, in other words // it is allowed for the cron patterns to overlap; duplicates are redundant. // // Default: [] // // Array items: // Cron-like specification for when tasks should be created. The pattern is // parsed in a UTC context. // See [cron-parser on npm](https://www.npmjs.com/package/cron-parser). Schedule []string `json:"schedule"` // Template for the task definition. This is rendered using [JSON-e](https://taskcluster.github.io/json-e/) // as described in [firing hooks](/docs/reference/core/hooks/firing-hooks) to produce // a task definition that is submitted to the Queue service. // // Additional properties allowed Task json.RawMessage `json:"task"` // Additional properties allowed TriggerSchema json.RawMessage `json:"triggerSchema"` }
Definition of a hook that will create tasks when defined events occur.
type HookGroups ¶
type HookGroups struct { // Array items: Groups []string `json:"groups"` }
List of `hookGroupIds`.
type HookMetadata ¶
type HookMetadata struct { // Long-form of the hook's purpose and behavior // // Max length: 32768 Description string `json:"description"` // Whether to email the owner on an error creating the task. // // Default: true EmailOnError bool `json:"emailOnError,omitempty"` // Human readable name of the hook // // Max length: 255 Name string `json:"name"` // Email of the person or group responsible for this hook. // // Max length: 255 Owner string `json:"owner"` }
type HookStatusResponse ¶
type HookStatusResponse struct { // Information about the last time this hook fired. This property is only present // if the hook has fired at least once. // // One of: // * SuccessfulFire // * FailedFire // * NoFire LastFire json.RawMessage `json:"lastFire"` // The next time this hook's task is scheduled to be created. This property // is only present if there is a scheduled next time. Some hooks don't have // any schedules. NextScheduledDate tcclient.Time `json:"nextScheduledDate,omitempty"` }
A snapshot of the current status of a hook.
type Hooks ¶
func New ¶
func New(credentials *tcclient.Credentials, rootURL string) *Hooks
New returns a Hooks client, configured to run against production. Pass in nil credentials to create a client without authentication. The returned client is mutable, so returned settings can be altered.
hooks := tchooks.New( nil, // client without authentication "http://localhost:1234/my/taskcluster", // taskcluster hosted at this root URL on local machine ) err := hooks.Ping(.....) // for example, call the Ping(.....) API endpoint (described further down)... if err != nil { // handle errors... }
func NewFromEnv ¶
func NewFromEnv() *Hooks
NewFromEnv returns a *Hooks configured from environment variables.
The root URL is taken from TASKCLUSTER_PROXY_URL if set to a non-empty string, otherwise from TASKCLUSTER_ROOT_URL if set, otherwise the empty string.
The credentials are taken from environment variables:
TASKCLUSTER_CLIENT_ID TASKCLUSTER_ACCESS_TOKEN TASKCLUSTER_CERTIFICATE
If TASKCLUSTER_CLIENT_ID is empty/unset, authentication will be disabled.
func (*Hooks) CreateHook ¶
func (hooks *Hooks) CreateHook(hookGroupId, hookId string, payload *HookCreationRequest) (*HookDefinition, error)
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:<hookGroupId>/<hookId> * assume:hook-id:<hookGroupId>/<hookId>
See #createHook
func (*Hooks) GetHookStatus ¶
func (hooks *Hooks) GetHookStatus(hookGroupId, hookId string) (*HookStatusResponse, error)
Stability: *** DEPRECATED ***
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.
This method is deprecated in favor of listLastFires.
See #getHookStatus
func (*Hooks) GetTriggerToken ¶
func (hooks *Hooks) GetTriggerToken(hookGroupId, hookId string) (*TriggerTokenResponse, error)
Retrieve a unique secret token for triggering the specified hook. This token can be deactivated with `resetTriggerToken`.
Required scopes:
hooks:get-trigger-token:<hookGroupId>/<hookId>
See #getTriggerToken
func (*Hooks) GetTriggerToken_SignedURL ¶
func (hooks *Hooks) GetTriggerToken_SignedURL(hookGroupId, hookId string, duration time.Duration) (*url.URL, error)
Returns a signed URL for GetTriggerToken, valid for the specified duration.
Required scopes:
hooks:get-trigger-token:<hookGroupId>/<hookId>
See GetTriggerToken for more details.
func (*Hooks) Hook ¶
func (hooks *Hooks) Hook(hookGroupId, hookId string) (*HookDefinition, error)
This endpoint will return the hook definition for the given `hookGroupId` and hookId.
See #hook
func (*Hooks) ListHookGroups ¶
func (hooks *Hooks) ListHookGroups() (*HookGroups, error)
This endpoint will return a list of all hook groups with at least one hook.
See #listHookGroups
func (*Hooks) ListHooks ¶
This endpoint will return a list of all the hook definitions within a given hook group.
See #listHooks
func (*Hooks) ListLastFires ¶
func (hooks *Hooks) ListLastFires(hookGroupId, hookId string) (*LastFiresList, error)
This endpoint will return information about the the last few times this hook has been fired, including whether the hook was fired successfully or not
See #listLastFires
func (*Hooks) Ping ¶
Respond without doing anything. This endpoint is used to check that the service is up.
See #ping
func (*Hooks) RemoveHook ¶
This endpoint will remove a hook definition.
Required scopes:
hooks:modify-hook:<hookGroupId>/<hookId>
See #removeHook
func (*Hooks) ResetTriggerToken ¶
func (hooks *Hooks) ResetTriggerToken(hookGroupId, hookId string) (*TriggerTokenResponse, error)
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:<hookGroupId>/<hookId>
See #resetTriggerToken
func (*Hooks) TriggerHook ¶
func (hooks *Hooks) TriggerHook(hookGroupId, hookId string, payload *TriggerHookRequest) (*TriggerHookResponse, error)
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:<hookGroupId>/<hookId>
See #triggerHook
func (*Hooks) TriggerHookWithToken ¶
func (hooks *Hooks) TriggerHookWithToken(hookGroupId, hookId, token string, payload *TriggerHookRequest) (*TriggerHookResponse, error)
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.
See #triggerHookWithToken
func (*Hooks) UpdateHook ¶
func (hooks *Hooks) UpdateHook(hookGroupId, hookId string, payload *HookCreationRequest) (*HookDefinition, error)
This endpoint will update an existing hook. All fields except `hookGroupId` and `hookId` can be modified.
Required scopes:
All of: * hooks:modify-hook:<hookGroupId>/<hookId> * assume:hook-id:<hookGroupId>/<hookId>
See #updateHook
type LastFiresList ¶
type LastFiresList struct {
LastFires []Var `json:"lastFires"`
}
List of lastFires
type NoFire ¶
type NoFire struct { // Possible values: // * "no-fire" Result string `json:"result"` }
Information about no firing of the hook (e.g., a new hook)
type RunInformation ¶
type RunInformation struct { // Reason for the creation of this run, // **more reasons may be added in the future**. // // Possible values: // * "scheduled" // * "retry" // * "task-retry" // * "rerun" // * "exception" ReasonCreated string `json:"reasonCreated"` // Reason that run was resolved, this is mainly // useful for runs resolved as `exception`. // Note, **more reasons may be added in the future**, also this // property is only available after the run is resolved. // // Possible values: // * "completed" // * "failed" // * "deadline-exceeded" // * "canceled" // * "superseded" // * "claim-expired" // * "worker-shutdown" // * "malformed-payload" // * "resource-unavailable" // * "internal-error" // * "intermittent-task" ReasonResolved string `json:"reasonResolved,omitempty"` // Date-time at which this run was resolved, ie. when the run changed // state from `running` to either `completed`, `failed` or `exception`. // This property is only present after the run as been resolved. Resolved tcclient.Time `json:"resolved,omitempty"` // Id of this task run, `run-id`s always starts from `0` // // Mininum: 0 // Maximum: 1000 RunID int64 `json:"runId"` // Date-time at which this run was scheduled, ie. when the run was // created in state `pending`. Scheduled tcclient.Time `json:"scheduled"` // Date-time at which this run was claimed, ie. when the run changed // state from `pending` to `running`. This property is only present // after the run has been claimed. Started tcclient.Time `json:"started,omitempty"` // State of this run // // Possible values: // * "pending" // * "running" // * "completed" // * "failed" // * "exception" State string `json:"state"` // Time at which the run expires and is resolved as `failed`, if the // run isn't reclaimed. Note, only present after the run has been // claimed. TakenUntil tcclient.Time `json:"takenUntil,omitempty"` // Identifier for group that worker who executes this run is a part of, // this identifier is mainly used for efficient routing. // Note, this property is only present after the run is claimed. // // Syntax: ^([a-zA-Z0-9-_]*)$ // Min length: 1 // Max length: 38 WorkerGroup string `json:"workerGroup,omitempty"` // Identifier for worker evaluating this run within given // `workerGroup`. Note, this property is only available after the run // has been claimed. // // Syntax: ^([a-zA-Z0-9-_]*)$ // Min length: 1 // Max length: 38 WorkerID string `json:"workerId,omitempty"` }
JSON object with information about a run
type Status ¶
type Status struct { // Deadline of the task, `pending` and `running` runs are // resolved as **exception** if not resolved by other means // before the deadline. Note, deadline cannot be more than // 5 days into the future Deadline tcclient.Time `json:"deadline"` // Task expiration, time at which task definition and // status is deleted. Notice that all artifacts for the task // must have an expiration that is no later than this. Expires tcclient.Time `json:"expires"` // Unique identifier for the provisioner that this task must be scheduled on // // Syntax: ^([a-zA-Z0-9-_]*)$ // Min length: 1 // Max length: 38 ProvisionerID string `json:"provisionerId"` // Number of retries left for the task in case of infrastructure issues // // Mininum: 0 // Maximum: 999 RetriesLeft int64 `json:"retriesLeft"` // List of runs, ordered so that index `i` has `runId == i` Runs []RunInformation `json:"runs"` // Identifier for the scheduler that _defined_ this task. // // Syntax: ^([a-zA-Z0-9-_]*)$ // Min length: 1 // Max length: 38 SchedulerID string `json:"schedulerId"` // State of this task. This is just an auxiliary property derived from state // of latests run, or `unscheduled` if none. // // Possible values: // * "unscheduled" // * "pending" // * "running" // * "completed" // * "failed" // * "exception" State string `json:"state"` // Identifier for a group of tasks scheduled together with this task, by // scheduler identified by `schedulerId`. For tasks scheduled by the // task-graph scheduler, this is the `taskGraphId`. // // Syntax: ^[A-Za-z0-9_-]{8}[Q-T][A-Za-z0-9_-][CGKOSWaeimquy26-][A-Za-z0-9_-]{10}[AQgw]$ TaskGroupID string `json:"taskGroupId"` // Unique task identifier, this is UUID encoded as // [URL-safe base64](http://tools.ietf.org/html/rfc4648#section-5) and // stripped of `=` padding. // // Syntax: ^[A-Za-z0-9_-]{8}[Q-T][A-Za-z0-9_-][CGKOSWaeimquy26-][A-Za-z0-9_-]{10}[AQgw]$ TaskID string `json:"taskId"` // Identifier for worker type within the specified provisioner // // Syntax: ^([a-zA-Z0-9-_]*)$ // Min length: 1 // Max length: 38 WorkerType string `json:"workerType"` }
type SuccessfulFire ¶
type SuccessfulFire struct { // Possible values: // * "success" Result string `json:"result"` // The task created // // Syntax: ^[A-Za-z0-9_-]{8}[Q-T][A-Za-z0-9_-][CGKOSWaeimquy26-][A-Za-z0-9_-]{10}[AQgw]$ TaskID string `json:"taskId"` // The time the task was created. This will not necessarily match `task.created`. Time tcclient.Time `json:"time"` }
Information about a successful firing of the hook
type TaskStatusStructure ¶
type TaskStatusStructure struct {
Status Status `json:"status"`
}
A representation of **task status** as known by the queue
type TriggerHookRequest ¶
type TriggerHookRequest json.RawMessage
A request to trigger a hook. The payload must be a JSON object, and is used as the context for a JSON-e rendering of the hook's task template, as described in "Firing Hooks".
Additional properties allowed
func (*TriggerHookRequest) MarshalJSON ¶
func (this *TriggerHookRequest) MarshalJSON() ([]byte, error)
MarshalJSON calls json.RawMessage method of the same name. Required since TriggerHookRequest is of type json.RawMessage...
func (*TriggerHookRequest) UnmarshalJSON ¶
func (this *TriggerHookRequest) UnmarshalJSON(data []byte) error
UnmarshalJSON is a copy of the json.RawMessage implementation.
type TriggerHookResponse ¶
type TriggerHookResponse json.RawMessage
Response to a `triggerHook` or `triggerHookWithToken` call.
In most cases, this is a task status, but in cases where the hook template does not generate a task, it is an empty object with no `status` property.
Any of:
- TaskStatusStructure
- TriggerHookResponse1
func (*TriggerHookResponse) MarshalJSON ¶
func (this *TriggerHookResponse) MarshalJSON() ([]byte, error)
MarshalJSON calls json.RawMessage method of the same name. Required since TriggerHookResponse is of type json.RawMessage...
func (*TriggerHookResponse) UnmarshalJSON ¶
func (this *TriggerHookResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON is a copy of the json.RawMessage implementation.
type TriggerHookResponse1 ¶
type TriggerHookResponse1 struct { }
Empty response indicating no task was created
type TriggerTokenResponse ¶
type TriggerTokenResponse struct {
Token string `json:"token"`
}
Secret token for a trigger
type Var ¶
type Var struct { // The error that occurred when firing the task. This is typically, // but not always, an API error message. Error string `json:"error"` // Possible values: // * "schedule" // * "triggerHook" // * "triggerHookWithToken" // * "pulseMessage" FiredBy string `json:"firedBy"` // Syntax: ^([a-zA-Z0-9-_]*)$ // Min length: 1 // Max length: 64 HookGroupID string `json:"hookGroupId"` // Syntax: ^([a-zA-Z0-9-_/]*)$ // Min length: 1 // Max length: 64 HookID string `json:"hookId"` // Information about success or failure of firing of the hook // // Possible values: // * "success" // * "error" Result string `json:"result"` // Time when the task was created TaskCreateTime tcclient.Time `json:"taskCreateTime"` // Unique task identifier, this is UUID encoded as // [URL-safe base64](http://tools.ietf.org/html/rfc4648#section-5) and // stripped of `=` padding. // // Syntax: ^[A-Za-z0-9_-]{8}[Q-T][A-Za-z0-9_-][CGKOSWaeimquy26-][A-Za-z0-9_-]{10}[AQgw]$ TaskID string `json:"taskId"` }