webhookpayload

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEventNotSpecifiedToParse = errors.New("no Event specified to parse")
	ErrInvalidHTTPMethod        = errors.New("invalid HTTP Method")
	ErrMissingHookUUIDHeader    = errors.New("missing X-Hook-UUID Header")
	ErrMissingEventKeyHeader    = errors.New("missing X-Event-Key Header")
	ErrEventNotFound            = errors.New("event not defined to be parsed")
	ErrParsingPayload           = errors.New("error parsing payload")
	ErrUUIDVerificationFailed   = errors.New("UUID verification failed")
)

parse errors

View Source
var Options = WebhookOptions{}

Options is a namespace var for configuration options

Functions

This section is empty.

Types

type Comment

type Comment struct {
	ID     int64 `json:"id"`
	Parent struct {
		ID int64 `json:"id"`
	} `json:"parent"`
	Content struct {
		Raw    string `json:"raw"`
		HTML   string `json:"html"`
		Markup string `json:"markup"`
	} `json:"content"`
	Inline struct {
		Path string `json:"path"`
		From *int64 `json:"from"`
		To   int64  `json:"to"`
	} `json:"inline"`
	CreatedOn time.Time `json:"created_on"`
	UpdatedOn time.Time `json:"updated_on"`
	Links     struct {
		Self struct {
			Href string `json:"href"`
		} `json:"self"`
		HTML struct {
			Href string `json:"href"`
		} `json:"html"`
	} `json:"links"`
}

Comment is the common Bitbucket Comment Sub Entity

type Event

type Event string

Event defines a Bitbucket hook event type

const (
	RepoPushEvent                  Event = "repo:push"
	RepoForkEvent                  Event = "repo:fork"
	RepoUpdatedEvent               Event = "repo:updated"
	RepoCommitCommentCreatedEvent  Event = "repo:commit_comment_created"
	RepoCommitStatusCreatedEvent   Event = "repo:commit_status_created"
	RepoCommitStatusUpdatedEvent   Event = "repo:commit_status_updated"
	IssueCreatedEvent              Event = "issue:created"
	IssueUpdatedEvent              Event = "issue:updated"
	IssueCommentCreatedEvent       Event = "issue:comment_created"
	PullRequestCreatedEvent        Event = "pullrequest:created"
	PullRequestUpdatedEvent        Event = "pullrequest:updated"
	PullRequestApprovedEvent       Event = "pullrequest:approved"
	PullRequestUnapprovedEvent     Event = "pullrequest:unapproved"
	PullRequestMergedEvent         Event = "pullrequest:fulfilled"
	PullRequestDeclinedEvent       Event = "pullrequest:rejected"
	PullRequestCommentCreatedEvent Event = "pullrequest:comment_created"
	PullRequestCommentUpdatedEvent Event = "pullrequest:comment_updated"
	PullRequestCommentDeletedEvent Event = "pullrequest:comment_deleted"
)

Bitbucket hook types

type Issue

type Issue struct {
	ID        int64  `json:"id"`
	Component string `json:"component"`
	Title     string `json:"title"`
	Content   struct {
		Raw    string `json:"raw"`
		HTML   string `json:"html"`
		Markup string `json:"markup"`
	} `json:"content"`
	Priority  string `json:"priority"`
	State     string `json:"state"`
	Type      string `json:"type"`
	Milestone struct {
		Name string `json:"name"`
	} `json:"milestone"`
	Version struct {
		Name string `json:"name"`
	} `json:"version"`
	CreatedOn time.Time `json:"created_on"`
	Reporter  Owner     `json:"reporter"`
	UpdatedOn time.Time `json:"updated_on"`
	Links     struct {
		Self struct {
			Href string `json:"href"`
		} `json:"self"`
		HTML struct {
			Href string `json:"href"`
		} `json:"html"`
	} `json:"links"`
}

Issue is the common Bitbucket Issue Sub Entity

type IssueChanges

type IssueChanges struct {
	Assignee IssueChangesAssignee `json:"assignee"`
	Status   IssueChangesStatus   `json:"status"`
}

IssueChanges is a part of the Bitbucket issue:updated payload

type IssueChangesAssignee

type IssueChangesAssignee struct {
	Old Owner `json:"old"`
	New Owner `json:"new"`
}

IssueChangesAssignee is a part of the Bitbucket issue:updated payload

type IssueChangesStatus

type IssueChangesStatus struct {
	Old string `json:"old"`
	New string `json:"new"`
}

IssueChangesStatus is a part of the Bitbucket issue:updated payload

type IssueCommentCreatedPayload

type IssueCommentCreatedPayload struct {
	Actor      Owner      `json:"actor"`
	Repository Repository `json:"repository"`
	Issue      Issue      `json:"issue"`
	Comment    Comment    `json:"comment"`
}

IssueCommentCreatedPayload is the Bitbucket pullrequest:created payload

func (IssueCommentCreatedPayload) GetActor

func (pl IssueCommentCreatedPayload) GetActor() Owner

func (IssueCommentCreatedPayload) GetRepository

func (pl IssueCommentCreatedPayload) GetRepository() Repository

type IssueCreatedPayload

type IssueCreatedPayload struct {
	Actor      Owner      `json:"actor"`
	Issue      Issue      `json:"issue"`
	Repository Repository `json:"repository"`
}

IssueCreatedPayload is the Bitbucket issue:created payload

func (IssueCreatedPayload) GetActor

func (pl IssueCreatedPayload) GetActor() Owner

func (IssueCreatedPayload) GetRepository

func (pl IssueCreatedPayload) GetRepository() Repository

type IssueUpdatedPayload

type IssueUpdatedPayload struct {
	Actor      Owner        `json:"actor"`
	Issue      Issue        `json:"issue"`
	Repository Repository   `json:"repository"`
	Comment    Comment      `json:"comment"`
	Changes    IssueChanges `json:"changes"`
}

IssueUpdatedPayload is the Bitbucket issue:updated payload

func (IssueUpdatedPayload) GetActor

func (pl IssueUpdatedPayload) GetActor() Owner

func (IssueUpdatedPayload) GetRepository

func (pl IssueUpdatedPayload) GetRepository() Repository

type Option

type Option func(*Webhook) error

Option is a configuration option for the webhook

type Owner

type Owner struct {
	Type        string `json:"type"`
	NickName    string `json:"nickname"`
	DisplayName string `json:"display_name"`
	AccountID   string `json:"account_id"`
	UUID        string `json:"uuid"`
	Links       struct {
		Self struct {
			Href string `json:"href"`
		} `json:"self"`
		HTML struct {
			Href string `json:"href"`
		} `json:"html"`
		Avatar struct {
			Href string `json:"href"`
		} `json:"avatar"`
	} `json:"links"`
}

Owner is the common Bitbucket Owner Sub Entity

type Payload

type Payload interface {
	GetRepository() Repository
	GetActor() Owner
}

type Project

type Project struct {
	Type    string `json:"type"`
	Project string `json:"project"`
	UUID    string `json:"uuid"`
	Links   struct {
		HTML struct {
			Href string `json:"href"`
		} `json:"html"`
		Avatar struct {
			Href string `json:"href"`
		} `json:"avatar"`
	} `json:"links"`
	Key string `json:"key"`
}

Project is the common Bitbucket Project Sub Entity

type PullRequest

type PullRequest struct {
	ID          int64  `json:"id"`
	Title       string `json:"title"`
	Description string `json:"description"`
	State       string `json:"state"`
	Author      Owner  `json:"author"`
	Source      struct {
		Branch struct {
			Name string `json:"name"`
		} `json:"branch"`
		Commit struct {
			Hash string `json:"hash"`
		} `json:"commit"`
		Repository Repository `json:"repository"`
	} `json:"source"`
	Destination struct {
		Branch struct {
			Name string `json:"name"`
		} `json:"branch"`
		Commit struct {
			Hash string `json:"hash"`
		} `json:"commit"`
		Repository Repository `json:"repository"`
	} `json:"destination"`
	MergeCommit struct {
		Hash string `json:"hash"`
	} `json:"merge_commit"`
	Participants      []Owner `json:"participants"`
	Reviewers         []Owner `json:"reviewers"`
	CloseSourceBranch bool    `json:"close_source_branch"`
	ClosedBy          Owner   `json:"closed_by"`
	Reason            string  `json:"reason"`
	Rendered          struct {
		Description struct {
			HTML string `json:"html"`
		} `json:"description"`
	} `json:"rendered"`
	CreatedOn time.Time `json:"created_on"`
	UpdatedOn time.Time `json:"updated_on"`
	Links     struct {
		Self struct {
			Href string `json:"href"`
		} `json:"self"`
		HTML struct {
			Href string `json:"href"`
		} `json:"html"`
	} `json:"links"`
}

PullRequest is the common Bitbucket Pull Request Sub Entity

type PullRequestApprovedPayload

type PullRequestApprovedPayload struct {
	Actor       Owner       `json:"actor"`
	PullRequest PullRequest `json:"pullrequest"`
	Repository  Repository  `json:"repository"`
	Approval    struct {
		Date time.Time `json:"date"`
		User Owner     `json:"user"`
	} `json:"approval"`
}

PullRequestApprovedPayload is the Bitbucket pullrequest:approved payload

func (PullRequestApprovedPayload) GetActor

func (pl PullRequestApprovedPayload) GetActor() Owner

func (PullRequestApprovedPayload) GetRepository

func (pl PullRequestApprovedPayload) GetRepository() Repository

type PullRequestCommentCreatedPayload

type PullRequestCommentCreatedPayload struct {
	Actor       Owner       `json:"actor"`
	Repository  Repository  `json:"repository"`
	PullRequest PullRequest `json:"pullrequest"`
	Comment     Comment     `json:"comment"`
}

PullRequestCommentCreatedPayload is the Bitbucket pullrequest:comment_updated payload

func (PullRequestCommentCreatedPayload) GetActor

func (PullRequestCommentCreatedPayload) GetRepository

func (pl PullRequestCommentCreatedPayload) GetRepository() Repository

type PullRequestCommentDeletedPayload

type PullRequestCommentDeletedPayload struct {
	Actor       Owner       `json:"actor"`
	Repository  Repository  `json:"repository"`
	PullRequest PullRequest `json:"pullrequest"`
	Comment     Comment     `json:"comment"`
}

PullRequestCommentDeletedPayload is the Bitbucket pullrequest:comment_deleted payload

func (PullRequestCommentDeletedPayload) GetActor

func (PullRequestCommentDeletedPayload) GetRepository

func (pl PullRequestCommentDeletedPayload) GetRepository() Repository

type PullRequestCommentUpdatedPayload

type PullRequestCommentUpdatedPayload struct {
	Actor       Owner       `json:"actor"`
	Repository  Repository  `json:"repository"`
	PullRequest PullRequest `json:"pullrequest"`
	Comment     Comment     `json:"comment"`
}

PullRequestCommentUpdatedPayload is the Bitbucket pullrequest:comment_created payload

func (PullRequestCommentUpdatedPayload) GetActor

func (PullRequestCommentUpdatedPayload) GetRepository

func (pl PullRequestCommentUpdatedPayload) GetRepository() Repository

type PullRequestCreatedPayload

type PullRequestCreatedPayload struct {
	Actor       Owner       `json:"actor"`
	PullRequest PullRequest `json:"pullrequest"`
	Repository  Repository  `json:"repository"`
}

PullRequestCreatedPayload is the Bitbucket pullrequest:created payload

func (PullRequestCreatedPayload) GetActor

func (pl PullRequestCreatedPayload) GetActor() Owner

func (PullRequestCreatedPayload) GetRepository

func (pl PullRequestCreatedPayload) GetRepository() Repository

type PullRequestDeclinedPayload

type PullRequestDeclinedPayload struct {
	Actor       Owner       `json:"actor"`
	PullRequest PullRequest `json:"pullrequest"`
	Repository  Repository  `json:"repository"`
}

PullRequestDeclinedPayload is the Bitbucket pullrequest:rejected payload

func (PullRequestDeclinedPayload) GetActor

func (pl PullRequestDeclinedPayload) GetActor() Owner

func (PullRequestDeclinedPayload) GetRepository

func (pl PullRequestDeclinedPayload) GetRepository() Repository

type PullRequestMergedPayload

type PullRequestMergedPayload struct {
	Actor       Owner       `json:"actor"`
	PullRequest PullRequest `json:"pullrequest"`
	Repository  Repository  `json:"repository"`
}

PullRequestMergedPayload is the Bitbucket pullrequest:fulfilled payload

func (PullRequestMergedPayload) GetActor

func (pl PullRequestMergedPayload) GetActor() Owner

func (PullRequestMergedPayload) GetRepository

func (pl PullRequestMergedPayload) GetRepository() Repository

type PullRequestUnapprovedPayload

type PullRequestUnapprovedPayload struct {
	Actor       Owner       `json:"actor"`
	PullRequest PullRequest `json:"pullrequest"`
	Repository  Repository  `json:"repository"`
	Approval    struct {
		Date time.Time `json:"date"`
		User Owner     `json:"user"`
	} `json:"approval"`
}

PullRequestUnapprovedPayload is the Bitbucket pullrequest:unapproved payload

func (PullRequestUnapprovedPayload) GetActor

func (pl PullRequestUnapprovedPayload) GetActor() Owner

func (PullRequestUnapprovedPayload) GetRepository

func (pl PullRequestUnapprovedPayload) GetRepository() Repository

type PullRequestUpdatedPayload

type PullRequestUpdatedPayload struct {
	Actor       Owner       `json:"actor"`
	PullRequest PullRequest `json:"pullrequest"`
	Repository  Repository  `json:"repository"`
}

PullRequestUpdatedPayload is the Bitbucket pullrequest:updated payload

func (PullRequestUpdatedPayload) GetActor

func (pl PullRequestUpdatedPayload) GetActor() Owner

func (PullRequestUpdatedPayload) GetRepository

func (pl PullRequestUpdatedPayload) GetRepository() Repository

type RepoCommitCommentCreatedPayload

type RepoCommitCommentCreatedPayload struct {
	Actor      Owner      `json:"actor"`
	Comment    Comment    `json:"comment"`
	Repository Repository `json:"repository"`
	Commit     struct {
		Hash string `json:"hash"`
	} `json:"commit"`
}

RepoCommitCommentCreatedPayload is the Bitbucket repo:commit_comment_created payload

func (RepoCommitCommentCreatedPayload) GetActor

func (pl RepoCommitCommentCreatedPayload) GetActor() Owner

func (RepoCommitCommentCreatedPayload) GetRepository

func (pl RepoCommitCommentCreatedPayload) GetRepository() Repository

type RepoCommitStatusCreatedPayload

type RepoCommitStatusCreatedPayload struct {
	Actor        Owner      `json:"actor"`
	Repository   Repository `json:"repository"`
	CommitStatus struct {
		Name        string    `json:"name"`
		Description string    `json:"description"`
		State       string    `json:"state"`
		Key         string    `json:"key"`
		URL         string    `json:"url"`
		Type        string    `json:"type"`
		CreatedOn   time.Time `json:"created_on"`
		UpdatedOn   time.Time `json:"updated_on"`
		Links       struct {
			Commit struct {
				Href string `json:"href"`
			} `json:"commit"`
			Self struct {
				Href string `json:"href"`
			} `json:"self"`
		} `json:"links"`
	} `json:"commit_status"`
}

RepoCommitStatusCreatedPayload is the Bitbucket repo:commit_status_created payload

func (RepoCommitStatusCreatedPayload) GetActor

func (pl RepoCommitStatusCreatedPayload) GetActor() Owner

func (RepoCommitStatusCreatedPayload) GetRepository

func (pl RepoCommitStatusCreatedPayload) GetRepository() Repository

type RepoCommitStatusUpdatedPayload

type RepoCommitStatusUpdatedPayload struct {
	Actor        Owner      `json:"actor"`
	Repository   Repository `json:"repository"`
	CommitStatus struct {
		Name        string    `json:"name"`
		Description string    `json:"description"`
		State       string    `json:"state"`
		Key         string    `json:"key"`
		URL         string    `json:"url"`
		Type        string    `json:"type"`
		CreatedOn   time.Time `json:"created_on"`
		UpdatedOn   time.Time `json:"updated_on"`
		Links       struct {
			Commit struct {
				Href string `json:"href"`
			} `json:"commit"`
			Self struct {
				Href string `json:"href"`
			} `json:"self"`
		} `json:"links"`
	} `json:"commit_status"`
}

RepoCommitStatusUpdatedPayload is the Bitbucket repo:commit_status_updated payload

func (RepoCommitStatusUpdatedPayload) GetActor

func (pl RepoCommitStatusUpdatedPayload) GetActor() Owner

func (RepoCommitStatusUpdatedPayload) GetRepository

func (pl RepoCommitStatusUpdatedPayload) GetRepository() Repository

type RepoForkPayload

type RepoForkPayload struct {
	Actor      Owner      `json:"actor"`
	Repository Repository `json:"repository"`
	Fork       Repository `json:"fork"`
}

RepoForkPayload is the Bitbucket repo:fork payload

func (RepoForkPayload) GetActor

func (pl RepoForkPayload) GetActor() Owner

func (RepoForkPayload) GetRepository

func (pl RepoForkPayload) GetRepository() Repository

type RepoPushChange

type RepoPushChange struct {
	New       RepoPushChangeState    `json:"new"`
	Old       RepoPushChangeState    `json:"old"`
	Links     RepoPushChangeLinks    `json:"links"`
	Created   bool                   `json:"created"`
	Forced    bool                   `json:"forced"`
	Closed    bool                   `json:"closed"`
	Commits   []RepoPushChangeCommit `json:"commits"`
	Truncated bool                   `json:"truncated"`
}

RepoPushChange is a part of the Bitbucket repo:push payload

type RepoPushChangeCommit

type RepoPushChangeCommit struct {
	Hash    string `json:"hash"`
	Type    string `json:"type"`
	Message string `json:"message"`
	Author  struct {
		User Owner `json:"user"`
	} `json:"author"`
	Links struct {
		Self struct {
			Href string `json:"href"`
		} `json:"self"`
		HTML struct {
			Href string `json:"href"`
		} `json:"html"`
	} `json:"links"`
}

RepoPushChangeCommit is a part of the Bitbucket repo:push payload

type RepoPushChangeLinks struct {
	HTML struct {
		Href string `json:"href"`
	} `json:"html"`
	Diff struct {
		Href string `json:"href"`
	} `json:"diff"`
	Commits struct {
		Href string `json:"href"`
	} `json:"commits"`
}

RepoPushChangeLinks is a part of the Bitbucket repo:push payload

type RepoPushChangeState

type RepoPushChangeState struct {
	Type   string `json:"type"`
	Name   string `json:"name"`
	Target struct {
		Type    string    `json:"type"`
		Hash    string    `json:"hash"`
		Author  Owner     `json:"author"`
		Message string    `json:"message"`
		Date    time.Time `json:"date"`
		Parents []struct {
			Type  string `json:"type"`
			Hash  string `json:"hash"`
			Links struct {
				Self struct {
					Href string `json:"href"`
				} `json:"self"`
				HTML struct {
					Href string `json:"href"`
				} `json:"html"`
			} `json:"links"`
		} `json:"parents"`
		Links struct {
			Self struct {
				Href string `json:"href"`
			} `json:"self"`
			HTML struct {
				Href string `json:"href"`
			} `json:"html"`
		} `json:"links"`
	} `json:"target"`
	Links RepoPushChangeStateLinks `json:"links"`
}

RepoPushChangeState is a part of the Bitbucket repo:push payload

type RepoPushChangeStateLinks struct {
	Self struct {
		Href string `json:"href"`
	} `json:"self"`
	Commits struct {
		Href string `json:"href"`
	} `json:"commits"`
	HTML struct {
		Href string `json:"href"`
	} `json:"html"`
}

RepoPushChangeStateLinks is a part of the Bitbucket repo:push payload

type RepoPushPayload

type RepoPushPayload struct {
	Actor      Owner      `json:"actor"`
	Repository Repository `json:"repository"`
	Push       struct {
		Changes []RepoPushChange `json:"changes"`
	} `json:"push"`
}

RepoPushPayload is the Bitbucket repo:push payload

func (RepoPushPayload) GetActor

func (pl RepoPushPayload) GetActor() Owner

func (RepoPushPayload) GetRepository

func (pl RepoPushPayload) GetRepository() Repository

type RepoUpdatedPayload

type RepoUpdatedPayload struct {
	Actor      Owner      `json:"actor"`
	Repository Repository `json:"repository"`
	Changes    struct {
		Name struct {
			New string `json:"new"`
			Old string `json:"old"`
		} `json:"name"`
		Website struct {
			New string `json:"new"`
			Old string `json:"old"`
		} `json:"website"`
		Language struct {
			New string `json:"new"`
			Old string `json:"old"`
		} `json:"language"`
		Links struct {
			New struct {
				Avatar struct {
					Href string `json:"href"`
				} `json:"avatar"`
				Self struct {
					Href string `json:"href"`
				} `json:"self"`
				HTML struct {
					Href string `json:"href"`
				} `json:"html"`
			} `json:"new"`
			Old struct {
				Avatar struct {
					Href string `json:"href"`
				} `json:"avatar"`
				Self struct {
					Href string `json:"href"`
				} `json:"self"`
				HTML struct {
					Href string `json:"href"`
				} `json:"html"`
			} `json:"old"`
		} `json:"links"`
		Description struct {
			New string `json:"new"`
			Old string `json:"old"`
		} `json:"description"`
		FullName struct {
			New string `json:"new"`
			Old string `json:"old"`
		} `json:"full_name"`
	} `json:"changes"`
}

RepoUpdatedPayload is the Bitbucket repo:updated payload

func (RepoUpdatedPayload) GetActor

func (pl RepoUpdatedPayload) GetActor() Owner

func (RepoUpdatedPayload) GetRepository

func (pl RepoUpdatedPayload) GetRepository() Repository

type Repository

type Repository struct {
	Type  string `json:"type"`
	Links struct {
		Self struct {
			Href string `json:"href"`
		} `json:"self"`
		HTML struct {
			Href string `json:"href"`
		} `json:"html"`
		Avatar struct {
			Href string `json:"href"`
		} `json:"avatar"`
	} `json:"links"`
	UUID      string  `json:"uuid"`
	Project   Project `json:"project"`
	FullName  string  `json:"full_name"`
	Name      string  `json:"name"`
	Website   string  `json:"website"`
	Owner     Owner   `json:"owner"`
	Scm       string  `json:"scm"`
	IsPrivate bool    `json:"is_private"`
}

Repository is the common Bitbucket Repository Sub Entity

type Webhook

type Webhook struct {
	// contains filtered or unexported fields
}

Webhook instance contains all methods needed to process events

func New

func New(options ...Option) (*Webhook, error)

New creates and returns a WebHook instance denoted by the Provider type

func (Webhook) Parse

func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)

Parse verifies and parses the events specified and returns the payload object or an error

type WebhookOptions

type WebhookOptions struct{}

WebhookOptions is a namespace for configuration option methods

func (WebhookOptions) UUID

func (WebhookOptions) UUID(uuid string) Option

UUID registers the BitBucket secret

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL