// Copyright 2021 The go-github AUTHORS. All rights reserved.//// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package githubimport ()// HookDelivery represents the data that is received from GitHub's Webhook Delivery API//// GitHub API docs:// - https://docs.github.com/rest/webhooks/repo-deliveries#list-deliveries-for-a-repository-webhook// - https://docs.github.com/rest/webhooks/repo-deliveries#get-a-delivery-for-a-repository-webhooktypeHookDeliverystruct { ID *int64`json:"id,omitempty"` GUID *string`json:"guid,omitempty"` DeliveredAt *Timestamp`json:"delivered_at,omitempty"` Redelivery *bool`json:"redelivery,omitempty"` Duration *float64`json:"duration,omitempty"` Status *string`json:"status,omitempty"` StatusCode *int`json:"status_code,omitempty"` Event *string`json:"event,omitempty"` Action *string`json:"action,omitempty"` InstallationID *int64`json:"installation_id,omitempty"` RepositoryID *int64`json:"repository_id,omitempty"`// Request is populated by GetHookDelivery. Request *HookRequest`json:"request,omitempty"`// Response is populated by GetHookDelivery. Response *HookResponse`json:"response,omitempty"`}func ( HookDelivery) () string {returnStringify()}// HookRequest is a part of HookDelivery that contains// the HTTP headers and the JSON payload of the webhook request.typeHookRequeststruct { Headers map[string]string`json:"headers,omitempty"` RawPayload *json.RawMessage`json:"payload,omitempty"`}func ( HookRequest) () string {returnStringify()}// HookResponse is a part of HookDelivery that contains// the HTTP headers and the response body served by the webhook endpoint.typeHookResponsestruct { Headers map[string]string`json:"headers,omitempty"` RawPayload *json.RawMessage`json:"payload,omitempty"`}func ( HookResponse) () string {returnStringify()}// ListHookDeliveries lists webhook deliveries for a webhook configured in a repository.//// GitHub API docs: https://docs.github.com/rest/repos/webhooks#list-deliveries-for-a-repository-webhook////meta:operation GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveriesfunc ( *RepositoriesService) ( context.Context, , string, int64, *ListCursorOptions) ([]*HookDelivery, *Response, error) { := fmt.Sprintf("repos/%v/%v/hooks/%v/deliveries", , , ) , := addOptions(, )if != nil {returnnil, nil, } , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, } := []*HookDelivery{} , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}// GetHookDelivery returns a delivery for a webhook configured in a repository.//// GitHub API docs: https://docs.github.com/rest/repos/webhooks#get-a-delivery-for-a-repository-webhook////meta:operation GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}func ( *RepositoriesService) ( context.Context, , string, , int64) (*HookDelivery, *Response, error) { := fmt.Sprintf("repos/%v/%v/hooks/%v/deliveries/%v", , , , ) , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, } := new(HookDelivery) , := .client.Do(, , )if != nil {returnnil, , }return , , nil}// RedeliverHookDelivery redelivers a delivery for a webhook configured in a repository.//// GitHub API docs: https://docs.github.com/rest/repos/webhooks#redeliver-a-delivery-for-a-repository-webhook////meta:operation POST /repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}/attemptsfunc ( *RepositoriesService) ( context.Context, , string, , int64) (*HookDelivery, *Response, error) { := fmt.Sprintf("repos/%v/%v/hooks/%v/deliveries/%v/attempts", , , , ) , := .client.NewRequest("POST", , nil)if != nil {returnnil, nil, } := new(HookDelivery) , := .client.Do(, , )if != nil {returnnil, , }return , , nil}// ParseRequestPayload parses the request payload. For recognized event types,// a value of the corresponding struct type will be returned.func ( *HookDelivery) () (interface{}, error) { , := messageToTypeName[.GetEvent()]if ! {returnnil, fmt.Errorf("unsupported event type %q", .GetEvent()) } := &Event{Type: &, RawPayload: .Request.RawPayload}return .ParsePayload()}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.