gogs

package module
v0.0.0-...-c74d21f Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: MIT Imports: 10 Imported by: 0

README

Gogs API client in Go

This package is still in experiment, see Wiki for documentation.

License

This project is under the MIT License. See the LICENSE file for the full license text.

Documentation

Index

Constants

View Source
const (
	MediaApplicationSHA = "application/vnd.gogs.sha"
)

Variables

View Source
var (
	ErrInvalidReceiveHook = errors.New("invalid JSON payload received over webhook")
)

Functions

func BasicAuthEncode

func BasicAuthEncode(user, pass string) string

func Bool

func Bool(v bool) *bool

func Int64

func Int64(v int64) *int64

func String

func String(v string) *string

func Version

func Version() string

Types

type AccessToken

type AccessToken struct {
	Name string `json:"name"`
	Sha1 string `json:"sha1"`
}

AccessToken represents a API access token.

type AddCollaboratorOption

type AddCollaboratorOption struct {
	Permission *string `json:"permission"`
}

type AddOrgMembershipOption

type AddOrgMembershipOption struct {
	Role string `json:"role" binding:"Required"`
}

type AutoMergeRequest

type AutoMergeRequest struct {
	BaseBranch        string `json:"baseBranch"`
	HeadBranch        string `json:"headBranch"`
	MergeStyle        string `json:"mergeStyle"`
	CommitDescription string `json:"commitDescription"`
}

type AutoMergeResponse

type AutoMergeResponse struct {
	MergedCommit string `json:"mergedCommit"`
	Result       string `json:"result"` // MergeSuccess|MergeFailed|PushSuccess|PushFailed
	Msg          string `json:"msg"`
}

type Branch

type Branch struct {
	Name   string         `json:"name"`
	Commit *PayloadCommit `json:"commit"`
}

Branch represents a repository branch.

type BranchList

type BranchList struct {
	BranchList []ProjectBranch
}

type ChangesFromPayload

type ChangesFromPayload struct {
	From string `json:"from"`
}

type ChangesPayload

type ChangesPayload struct {
	Title *ChangesFromPayload `json:"title,omitempty"`
	Body  *ChangesFromPayload `json:"body,omitempty"`
}

type Client

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

Client represents a Gogs API client.

func NewClient

func NewClient(url, token string) *Client

NewClient initializes and returns an API client.

func (*Client) AddCollaborator

func (c *Client) AddCollaborator(user, repo, collaborator string, opt AddCollaboratorOption) error

func (*Client) AddEmail

func (c *Client) AddEmail(opt CreateEmailOption) ([]*Email, error)

func (*Client) AddIssueLabels

func (c *Client) AddIssueLabels(owner, repo string, index int64, opt IssueLabelsOption) ([]*Label, error)

func (*Client) AddOrgMembership

func (c *Client) AddOrgMembership(org, user string, opt AddOrgMembershipOption) error

func (*Client) AdminAddTeamMembership

func (c *Client) AdminAddTeamMembership(teamID int64, user string) error

func (*Client) AdminAddTeamRepository

func (c *Client) AdminAddTeamRepository(teamID int64, repo string) error

func (*Client) AdminCreateOrg

func (c *Client) AdminCreateOrg(user string, opt CreateOrgOption) (*Organization, error)

func (*Client) AdminCreateRepo

func (c *Client) AdminCreateRepo(user string, opt CreateRepoOption) (*Repository, error)

func (*Client) AdminCreateTeam

func (c *Client) AdminCreateTeam(user string, opt CreateTeamOption) (*Team, error)

func (*Client) AdminCreateUser

func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, error)

func (*Client) AdminCreateUserPublicKey

func (c *Client) AdminCreateUserPublicKey(user string, opt CreateKeyOption) (*PublicKey, error)

func (*Client) AdminDeleteUser

func (c *Client) AdminDeleteUser(user string) error

func (*Client) AdminEditUser

func (c *Client) AdminEditUser(user string, opt EditUserOption) error

func (*Client) AdminRemoveTeamMembership

func (c *Client) AdminRemoveTeamMembership(teamID int64, user string) error

func (*Client) AutoMerge

func (c *Client) AutoMerge(user, repo string, opt AutoMergeRequest) (*AutoMergeResponse, error)

func (*Client) ClearIssueLabels

func (c *Client) ClearIssueLabels(owner, repo string, index int64) error

func (*Client) CreateAccessToken

func (c *Client) CreateAccessToken(user, pass string, opt CreateAccessTokenOption) (*AccessToken, error)

func (*Client) CreateBranch

func (c *Client) CreateBranch(user, repo string, opt CreateBranchOption) (*Branch, error)

func (*Client) CreateDeployKey

func (c *Client) CreateDeployKey(user, repo string, opt CreateKeyOption) (*DeployKey, error)

func (*Client) CreateIssue

func (c *Client) CreateIssue(owner, repo string, opt CreateIssueOption) (*Issue, error)

func (*Client) CreateIssueComment

func (c *Client) CreateIssueComment(owner, repo string, index int64, opt CreateIssueCommentOption) (*Comment, error)

CreateIssueComment create comment on an issue.

func (*Client) CreateLabel

func (c *Client) CreateLabel(owner, repo string, opt CreateLabelOption) (*Label, error)

func (*Client) CreateMilestone

func (c *Client) CreateMilestone(owner, repo string, opt CreateMilestoneOption) (*Milestone, error)

func (*Client) CreateOrg

func (c *Client) CreateOrg(opt CreateOrgOption) (*Organization, error)

func (*Client) CreateOrgRepo

func (c *Client) CreateOrgRepo(org string, opt CreateRepoOption) (*Repository, error)

CreateOrgRepo creates an organization repository for authenticated user.

func (*Client) CreatePublicKey

func (c *Client) CreatePublicKey(opt CreateKeyOption) (*PublicKey, error)

func (*Client) CreateRepo

func (c *Client) CreateRepo(opt CreateRepoOption) (*Repository, error)

CreateRepo creates a repository for authenticated user.

func (*Client) CreateRepoHook

func (c *Client) CreateRepoHook(user, repo string, opt CreateHookOption) (*Hook, error)

func (*Client) DeleteBranch

func (c *Client) DeleteBranch(user, repo, branch string, force bool) error

func (*Client) DeleteCollaborator

func (c *Client) DeleteCollaborator(user, repo, collaborator string) error

func (*Client) DeleteDeployKey

func (c *Client) DeleteDeployKey(owner, repo string, keyID int64) error

func (*Client) DeleteEmail

func (c *Client) DeleteEmail(opt CreateEmailOption) error

func (*Client) DeleteIssueComment

func (c *Client) DeleteIssueComment(owner, repo string, index, commentID int64) error

DeleteIssueComment deletes an issue comment.

func (*Client) DeleteIssueLabel

func (c *Client) DeleteIssueLabel(owner, repo string, index, label int64) error

func (*Client) DeleteLabel

func (c *Client) DeleteLabel(owner, repo string, id int64) error

func (*Client) DeleteMilestone

func (c *Client) DeleteMilestone(owner, repo string, id int64) error

func (*Client) DeletePublicKey

func (c *Client) DeletePublicKey(keyID int64) error

func (*Client) DeleteRepo

func (c *Client) DeleteRepo(owner, repo string) error

DeleteRepo deletes a repository of user or organization.

func (*Client) DeleteRepoHook

func (c *Client) DeleteRepoHook(user, repo string, id int64) error

func (*Client) EditIssue

func (c *Client) EditIssue(owner, repo string, index int64, opt EditIssueOption) (*Issue, error)

func (*Client) EditIssueComment

func (c *Client) EditIssueComment(owner, repo string, index, commentID int64, opt EditIssueCommentOption) (*Comment, error)

EditIssueComment edits an issue comment.

func (*Client) EditIssueTracker

func (c *Client) EditIssueTracker(owner, repo string, opt EditIssueTrackerOption) error

EditIssueTracker updates issue tracker options of the repository.

func (*Client) EditLabel

func (c *Client) EditLabel(owner, repo string, id int64, opt EditLabelOption) (*Label, error)

func (*Client) EditMilestone

func (c *Client) EditMilestone(owner, repo string, id int64, opt EditMilestoneOption) (*Milestone, error)

func (*Client) EditOrg

func (c *Client) EditOrg(orgname string, opt EditOrgOption) error

func (*Client) EditRepoHook

func (c *Client) EditRepoHook(user, repo string, id int64, opt EditHookOption) error

func (*Client) EditWiki

func (c *Client) EditWiki(owner, repo string, opt EditWikiOption) error

EditWiki updates wiki options of the repository.

func (*Client) Follow

func (c *Client) Follow(target string) error

func (*Client) GetArchive

func (c *Client) GetArchive(user, repo, ref, format string) ([]byte, error)

GetArchive downloads the full contents of a repository. Ref can be a branch/tag/commit.

func (*Client) GetBranchDiff

func (c *Client) GetBranchDiff(user, repo, branch1 string, branch2 string) (*DiffBranchInfo, error)

func (*Client) GetBranchsDiff

func (c *Client) GetBranchsDiff(projectList []ProjectBranch) (*[]DiffBranchInfo, error)

func (*Client) GetBranchsDiffFile

func (c *Client) GetBranchsDiffFile(fileList []DiffFileList) (*[]ReturnDiffFile, error)

func (*Client) GetCommitsOfBranch

func (c *Client) GetCommitsOfBranch(user, repo, branch, pagesize string) (*[]CommitResponse, error)

func (*Client) GetDeployKey

func (c *Client) GetDeployKey(user, repo string, keyID int64) (*DeployKey, error)

func (*Client) GetFile

func (c *Client) GetFile(user, repo, ref, tree string) ([]byte, error)

GetFile downloads a file of repository, ref can be branch/tag/commit. e.g.: ref -> master, tree -> macaron.go(no leading slash)

func (*Client) GetIssue

func (c *Client) GetIssue(owner, repo string, index int64) (*Issue, error)

func (*Client) GetIssueLabels

func (c *Client) GetIssueLabels(owner, repo string, index int64) ([]*Label, error)

func (*Client) GetMilestone

func (c *Client) GetMilestone(owner, repo string, id int64) (*Milestone, error)

func (*Client) GetOrg

func (c *Client) GetOrg(orgname string) (*Organization, error)

func (*Client) GetPublicKey

func (c *Client) GetPublicKey(keyID int64) (*PublicKey, error)

func (*Client) GetReferenceSHA

func (c *Client) GetReferenceSHA(user, repo, ref string) (string, error)

func (*Client) GetRepo

func (c *Client) GetRepo(owner, reponame string) (*Repository, error)

GetRepo returns information of a repository of given owner.

func (*Client) GetRepoBranch

func (c *Client) GetRepoBranch(user, repo, branch string) (*Branch, error)

func (*Client) GetRepoLabel

func (c *Client) GetRepoLabel(owner, repo string, id int64) (*Label, error)

func (*Client) GetSelfInfo

func (c *Client) GetSelfInfo() (*User, error)

func (*Client) GetSingleCommit

func (c *Client) GetSingleCommit(user, repo, commitID string) (*Commit, error)

func (*Client) GetUserInfo

func (c *Client) GetUserInfo(user string) (*User, error)

func (*Client) IsCollaborator

func (c *Client) IsCollaborator(user, repo, collaborator string) error

func (*Client) IsFollowing

func (c *Client) IsFollowing(target string) bool

func (*Client) IsUserFollowing

func (c *Client) IsUserFollowing(user, target string) bool

func (*Client) ListAccessTokens

func (c *Client) ListAccessTokens(user, pass string) ([]*AccessToken, error)

func (*Client) ListCollaborator

func (c *Client) ListCollaborator(user, repo string) ([]*Collaborator, error)

func (*Client) ListDeployKeys

func (c *Client) ListDeployKeys(user, repo string) ([]*DeployKey, error)

func (*Client) ListEmails

func (c *Client) ListEmails() ([]*Email, error)

func (*Client) ListFollowers

func (c *Client) ListFollowers(user string, page int) ([]*User, error)

func (*Client) ListFollowing

func (c *Client) ListFollowing(user string, page int) ([]*User, error)

func (*Client) ListIssueComments

func (c *Client) ListIssueComments(owner, repo string, index int64) ([]*Comment, error)

ListIssueComments list comments on an issue.

func (*Client) ListIssues

func (c *Client) ListIssues(opt ListIssueOption) ([]*Issue, error)

func (*Client) ListMyFollowers

func (c *Client) ListMyFollowers(page int) ([]*User, error)

func (*Client) ListMyFollowing

func (c *Client) ListMyFollowing(page int) ([]*User, error)

func (*Client) ListMyOrgs

func (c *Client) ListMyOrgs() ([]*Organization, error)

func (*Client) ListMyPublicKeys

func (c *Client) ListMyPublicKeys() ([]*PublicKey, error)

func (*Client) ListMyRepos

func (c *Client) ListMyRepos() ([]*Repository, error)

ListMyRepos lists all repositories for the authenticated user that has access to.

func (*Client) ListOrgRepos

func (c *Client) ListOrgRepos(org string) ([]*Repository, error)

func (*Client) ListPublicKeys

func (c *Client) ListPublicKeys(user string) ([]*PublicKey, error)

func (*Client) ListRepoBranches

func (c *Client) ListRepoBranches(user, repo string) ([]*Branch, error)

func (*Client) ListRepoHooks

func (c *Client) ListRepoHooks(user, repo string) ([]*Hook, error)

func (*Client) ListRepoIssueComments

func (c *Client) ListRepoIssueComments(owner, repo string) ([]*Comment, error)

ListRepoIssueComments list comments for a given repo.

func (*Client) ListRepoIssues

func (c *Client) ListRepoIssues(owner, repo string, opt ListIssueOption) ([]*Issue, error)

func (*Client) ListRepoLabels

func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error)

func (*Client) ListRepoMilestones

func (c *Client) ListRepoMilestones(owner, repo string) ([]*Milestone, error)

func (*Client) ListTeams

func (c *Client) ListTeams(name string) ([]*Team, error)

func (*Client) ListUserIssues

func (c *Client) ListUserIssues(opt ListIssueOption) ([]*Issue, error)

func (*Client) ListUserOrgs

func (c *Client) ListUserOrgs(user string) ([]*Organization, error)

func (*Client) ListUserRepos

func (c *Client) ListUserRepos(user string) ([]*Repository, error)

func (*Client) MigrateRepo

func (c *Client) MigrateRepo(opt MigrateRepoOption) (*Repository, error)

MigrateRepo migrates a repository from other Git hosting sources for the authenticated user.

To migrate a repository for a organization, the authenticated user must be a owner of the specified organization.

func (*Client) MirrorSync

func (c *Client) MirrorSync(owner, repo string) error

func (*Client) ReplaceIssueLabels

func (c *Client) ReplaceIssueLabels(owner, repo string, index int64, opt IssueLabelsOption) ([]*Label, error)

func (*Client) SetHTTPClient

func (c *Client) SetHTTPClient(client *http.Client)

SetHTTPClient replaces default http.Client with user given one.

func (*Client) TestPatch

func (c *Client) TestPatch(user, repo string, opt TestPatchRequest) (*TestPatchResponse, error)

func (*Client) Unfollow

func (c *Client) Unfollow(target string) error

func (*Client) UpdatePatch

func (c *Client) UpdatePatch(user, repo, base, head string) (*DiffBinaryInfo, error)

type Collaborator

type Collaborator struct {
	*User
	Permissions Permission `json:"permissions"`
}

type Comment

type Comment struct {
	ID      int64     `json:"id"`
	HTMLURL string    `json:"html_url"`
	Poster  *User     `json:"user"`
	Body    string    `json:"body"`
	Created time.Time `json:"created_at"`
	Updated time.Time `json:"updated_at"`
}

Comment represents a comment in commit and issue page.

type Commit

type Commit struct {
	*CommitMeta
	HTMLURL    string        `json:"html_url"`
	RepoCommit *RepoCommit   `json:"commit"`
	Author     *User         `json:"author"`
	Committer  *User         `json:"committer"`
	Parents    []*CommitMeta `json:"parents"`
}

Commit contains information generated from a Git commit.

type CommitMeta

type CommitMeta struct {
	URL string `json:"url"`
	SHA string `json:"sha"`
}

CommitMeta contains meta information of a commit in terms of API.

type CommitResponse

type CommitResponse struct {
	ID        string             `json:"id"`
	Author    CommitUserResponse `json:"author"`
	Committer CommitUserResponse `json:"committer"`
	Message   string             `json:"message"`
}

type CommitUser

type CommitUser struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	Date  string `json:"date"`
}

CommitUser contains information of a user in the context of a commit.

type CommitUserResponse

type CommitUserResponse struct {
	Name  string    `json:"Name"`
	Email string    `json:"Email"`
	When  time.Time `json:"When"`
}

type CreateAccessTokenOption

type CreateAccessTokenOption struct {
	Name string `json:"name" binding:"Required"`
}

type CreateBranchOption

type CreateBranchOption struct {
	BranchName string `json:"branchname" binding:"Required"`
	Base       string `json:"base" binding:"Required"`
}

type CreateEmailOption

type CreateEmailOption struct {
	Emails []string `json:"emails"`
}

type CreateHookOption

type CreateHookOption struct {
	Type   string            `json:"type" binding:"Required"`
	Config map[string]string `json:"config" binding:"Required"`
	Events []string          `json:"events"`
	Active bool              `json:"active"`
}

type CreateIssueCommentOption

type CreateIssueCommentOption struct {
	Body string `json:"body" binding:"Required"`
}

CreateIssueCommentOption is option when creating an issue comment.

type CreateIssueOption

type CreateIssueOption struct {
	Title     string  `json:"title" binding:"Required"`
	Body      string  `json:"body"`
	Assignee  string  `json:"assignee"`
	Milestone int64   `json:"milestone"`
	Labels    []int64 `json:"labels"`
	Closed    bool    `json:"closed"`
}

type CreateKeyOption

type CreateKeyOption struct {
	Title string `json:"title" binding:"Required"`
	Key   string `json:"key" binding:"Required"`
}

type CreateLabelOption

type CreateLabelOption struct {
	Name  string `json:"name" binding:"Required"`
	Color string `json:"color" binding:"Required;Size(7)"`
}

type CreateMilestoneOption

type CreateMilestoneOption struct {
	Title       string     `json:"title"`
	Description string     `json:"description"`
	Deadline    *time.Time `json:"due_on"`
}

type CreateOrgOption

type CreateOrgOption struct {
	UserName    string `json:"username" binding:"Required"`
	FullName    string `json:"full_name"`
	Description string `json:"description"`
	Website     string `json:"website"`
	Location    string `json:"location"`
}

type CreatePayload

type CreatePayload struct {
	Ref           string      `json:"ref"`
	RefType       string      `json:"ref_type"`
	Sha           string      `json:"sha"`
	DefaultBranch string      `json:"default_branch"`
	Repo          *Repository `json:"repository"`
	Sender        *User       `json:"sender"`
}

func ParseCreateHook

func ParseCreateHook(raw []byte) (*CreatePayload, error)

ParseCreateHook parses create event hook content.

func (*CreatePayload) JSONPayload

func (p *CreatePayload) JSONPayload() ([]byte, error)

type CreateRepoOption

type CreateRepoOption struct {
	Name        string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
	Description string `json:"description" binding:"MaxSize(255)"`
	Private     bool   `json:"private"`
	Unlisted    bool   `json:"unlisted"`
	AutoInit    bool   `json:"auto_init"`
	Gitignores  string `json:"gitignores"`
	License     string `json:"license"`
	Readme      string `json:"readme"`
}

type CreateTeamOption

type CreateTeamOption struct {
	Name        string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"`
	Description string `json:"description" binding:"MaxSize(255)"`
	Permission  string `json:"permission"`
}

type CreateUserOption

type CreateUserOption struct {
	SourceID   int64  `json:"source_id"`
	LoginName  string `json:"login_name"`
	Username   string `json:"username" binding:"Required;AlphaDashDot;MaxSize(35)"`
	FullName   string `json:"full_name" binding:"MaxSize(100)"`
	Email      string `json:"email" binding:"Required;Email;MaxSize(254)"`
	Password   string `json:"password" binding:"MaxSize(255)"`
	SendNotify bool   `json:"send_notify"`
}

type DeletePayload

type DeletePayload struct {
	Ref        string      `json:"ref"`
	RefType    string      `json:"ref_type"`
	PusherType PusherType  `json:"pusher_type"`
	Repo       *Repository `json:"repository"`
	Sender     *User       `json:"sender"`
}

func (*DeletePayload) JSONPayload

func (p *DeletePayload) JSONPayload() ([]byte, error)

type DeployKey

type DeployKey struct {
	ID       int64     `json:"id"`
	Key      string    `json:"key"`
	URL      string    `json:"url"`
	Title    string    `json:"title"`
	Created  time.Time `json:"created_at"`
	ReadOnly bool      `json:"read_only"`
}

type DiffBinaryInfo

type DiffBinaryInfo struct {
	Head         string `json:"head"`
	BaseCommit   string `json:"baseCommit"`
	HeadCommit   string `json:"headCommit"`
	PatchContent []byte `json:"patchContent"`
}

type DiffBranchChangeList

type DiffBranchChangeList struct {
	File     string
	IsBinary bool
}

type DiffBranchInfo

type DiffBranchInfo struct {
	ChangeInfo      string
	Owner           string
	Repo            string
	Branch1         string
	Branch2         string
	Branch1CommitId string
	Branch2CommitId string
	FileList        []DiffBranchChangeList
	Error           string
}

type DiffFileList

type DiffFileList struct {
	File                   string `json:"file"`
	IsBinary               bool   `json:"isBinary"`
	Project                string `json:"project"`
	ProjectOwner           string `json:"projectOwner"`
	BaseDiffBranchCommitID string `json:"baseDiffBranchCommitId"`
	DeployBranchCommitID   string `json:"deployBranchCommitId"`
}

type EditHookOption

type EditHookOption struct {
	Config map[string]string `json:"config"`
	Events []string          `json:"events"`
	Active *bool             `json:"active"`
}

type EditIssueCommentOption

type EditIssueCommentOption struct {
	Body string `json:"body" binding:"Required"`
}

EditIssueCommentOption is option when editing an issue comment.

type EditIssueOption

type EditIssueOption struct {
	Title     string  `json:"title"`
	Body      *string `json:"body"`
	Assignee  *string `json:"assignee"`
	Milestone *int64  `json:"milestone"`
	State     *string `json:"state"`
}

type EditIssueTrackerOption

type EditIssueTrackerOption struct {
	EnableIssues          *bool   `json:"enable_issues"`
	EnableExternalTracker *bool   `json:"enable_external_tracker"`
	ExternalTrackerURL    *string `json:"external_tracker_url"`
	TrackerURLFormat      *string `json:"tracker_url_format"`
	TrackerIssueStyle     *string `json:"tracker_issue_style"`
}

type EditLabelOption

type EditLabelOption struct {
	Name  *string `json:"name"`
	Color *string `json:"color"`
}

type EditMilestoneOption

type EditMilestoneOption struct {
	Title       string     `json:"title"`
	Description *string    `json:"description"`
	State       *string    `json:"state"`
	Deadline    *time.Time `json:"due_on"`
}

type EditOrgOption

type EditOrgOption struct {
	FullName    string `json:"full_name"`
	Description string `json:"description"`
	Website     string `json:"website"`
	Location    string `json:"location"`
}

type EditUserOption

type EditUserOption struct {
	SourceID         int64  `json:"source_id"`
	LoginName        string `json:"login_name"`
	FullName         string `json:"full_name" binding:"MaxSize(100)"`
	Email            string `json:"email" binding:"Required;Email;MaxSize(254)"`
	Password         string `json:"password" binding:"MaxSize(255)"`
	Website          string `json:"website" binding:"MaxSize(50)"`
	Location         string `json:"location" binding:"MaxSize(50)"`
	Active           *bool  `json:"active"`
	Admin            *bool  `json:"admin"`
	AllowGitHook     *bool  `json:"allow_git_hook"`
	AllowImportLocal *bool  `json:"allow_import_local"`
	MaxRepoCreation  *int   `json:"max_repo_creation"`
}

type EditWikiOption

type EditWikiOption struct {
	EnableWiki         *bool   `json:"enable_wiki"`
	AllowPublicWiki    *bool   `json:"allow_public_wiki"`
	EnableExternalWiki *bool   `json:"enable_external_wiki"`
	ExternalWikiURL    *string `json:"external_wiki_url"`
}

type Email

type Email struct {
	Email    string `json:"email"`
	Verified bool   `json:"verified"`
	Primary  bool   `json:"primary"`
}

type ForkPayload

type ForkPayload struct {
	Forkee *Repository `json:"forkee"`
	Repo   *Repository `json:"repository"`
	Sender *User       `json:"sender"`
}

func (*ForkPayload) JSONPayload

func (p *ForkPayload) JSONPayload() ([]byte, error)

type Hook

type Hook struct {
	ID      int64             `json:"id"`
	Type    string            `json:"type"`
	URL     string            `json:"-"`
	Config  map[string]string `json:"config"`
	Events  []string          `json:"events"`
	Active  bool              `json:"active"`
	Updated time.Time         `json:"updated_at"`
	Created time.Time         `json:"created_at"`
}

type HookIssueAction

type HookIssueAction string
const (
	HOOK_ISSUE_OPENED        HookIssueAction = "opened"
	HOOK_ISSUE_CLOSED        HookIssueAction = "closed"
	HOOK_ISSUE_REOPENED      HookIssueAction = "reopened"
	HOOK_ISSUE_EDITED        HookIssueAction = "edited"
	HOOK_ISSUE_ASSIGNED      HookIssueAction = "assigned"
	HOOK_ISSUE_UNASSIGNED    HookIssueAction = "unassigned"
	HOOK_ISSUE_LABEL_UPDATED HookIssueAction = "label_updated"
	HOOK_ISSUE_LABEL_CLEARED HookIssueAction = "label_cleared"
	HOOK_ISSUE_MILESTONED    HookIssueAction = "milestoned"
	HOOK_ISSUE_DEMILESTONED  HookIssueAction = "demilestoned"
	HOOK_ISSUE_SYNCHRONIZED  HookIssueAction = "synchronized"
)

type HookIssueCommentAction

type HookIssueCommentAction string
const (
	HOOK_ISSUE_COMMENT_CREATED HookIssueCommentAction = "created"
	HOOK_ISSUE_COMMENT_EDITED  HookIssueCommentAction = "edited"
	HOOK_ISSUE_COMMENT_DELETED HookIssueCommentAction = "deleted"
)

type HookReleaseAction

type HookReleaseAction string
const (
	HOOK_RELEASE_PUBLISHED HookReleaseAction = "published"
)

type Issue

type Issue struct {
	ID        int64      `json:"id"`
	Index     int64      `json:"number"`
	Poster    *User      `json:"user"`
	Title     string     `json:"title"`
	Body      string     `json:"body"`
	Labels    []*Label   `json:"labels"`
	Milestone *Milestone `json:"milestone"`
	Assignee  *User      `json:"assignee"`
	State     StateType  `json:"state"`
	Comments  int        `json:"comments"`
	Created   time.Time  `json:"created_at"`
	Updated   time.Time  `json:"updated_at"`

	PullRequest *PullRequestMeta `json:"pull_request"`
}

type IssueCommentPayload

type IssueCommentPayload struct {
	Action     HookIssueCommentAction `json:"action"`
	Issue      *Issue                 `json:"issue"`
	Comment    *Comment               `json:"comment"`
	Changes    *ChangesPayload        `json:"changes,omitempty"`
	Repository *Repository            `json:"repository"`
	Sender     *User                  `json:"sender"`
}

IssueCommentPayload represents a payload information of issue comment event.

func (*IssueCommentPayload) JSONPayload

func (p *IssueCommentPayload) JSONPayload() ([]byte, error)

type IssueLabelsOption

type IssueLabelsOption struct {
	Labels []int64 `json:"labels"`
}

type IssuesPayload

type IssuesPayload struct {
	Action     HookIssueAction `json:"action"`
	Index      int64           `json:"number"`
	Issue      *Issue          `json:"issue"`
	Changes    *ChangesPayload `json:"changes,omitempty"`
	Repository *Repository     `json:"repository"`
	Sender     *User           `json:"sender"`
}

IssuesPayload represents a payload information of issues event.

func (*IssuesPayload) JSONPayload

func (p *IssuesPayload) JSONPayload() ([]byte, error)

type Label

type Label struct {
	ID    int64  `json:"id"`
	Name  string `json:"name"`
	Color string `json:"color"`
	URL   string `json:"url"`
}

type ListIssueOption

type ListIssueOption struct {
	Page  int
	State string
}

type MarkdownOption

type MarkdownOption struct {
	Text    string
	Context string
}

type MigrateRepoOption

type MigrateRepoOption struct {
	CloneAddr    string `json:"clone_addr" binding:"Required"`
	AuthUsername string `json:"auth_username"`
	AuthPassword string `json:"auth_password"`
	UID          int    `json:"uid" binding:"Required"`
	RepoName     string `json:"repo_name" binding:"Required"`
	Mirror       bool   `json:"mirror"`
	Private      bool   `json:"private"`
	Unlisted     bool   `json:"unlisted"`
	Description  string `json:"description"`
}

type Milestone

type Milestone struct {
	ID           int64      `json:"id"`
	Title        string     `json:"title"`
	Description  string     `json:"description"`
	State        StateType  `json:"state"`
	OpenIssues   int        `json:"open_issues"`
	ClosedIssues int        `json:"closed_issues"`
	Closed       *time.Time `json:"closed_at"`
	Deadline     *time.Time `json:"due_on"`
}

type Organization

type Organization struct {
	ID          int64  `json:"id"`
	UserName    string `json:"username"`
	FullName    string `json:"full_name"`
	AvatarUrl   string `json:"avatar_url"`
	Description string `json:"description"`
	Website     string `json:"website"`
	Location    string `json:"location"`
}

type PayloadCommit

type PayloadCommit struct {
	ID        string       `json:"id"`
	Message   string       `json:"message"`
	URL       string       `json:"url"`
	Author    *PayloadUser `json:"author"`
	Committer *PayloadUser `json:"committer"`

	Added    []string `json:"added"`
	Removed  []string `json:"removed"`
	Modified []string `json:"modified"`

	Timestamp time.Time `json:"timestamp"`
}

FIXME: consider use same format as API when commits API are added.

type PayloadUser

type PayloadUser struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	UserName string `json:"username"`
}

type Payloader

type Payloader interface {
	JSONPayload() ([]byte, error)
}

type Permission

type Permission struct {
	Admin bool `json:"admin"`
	Push  bool `json:"push"`
	Pull  bool `json:"pull"`
}

Permission represents a API permission.

type ProjectBranch

type ProjectBranch struct {
	Owner   string `json:"owner"`
	Repo    string `json:"repo"`
	Branch1 string `json:"branch1"`
	Branch2 string `json:"branch2"`
}

type PublicKey

type PublicKey struct {
	ID      int64     `json:"id"`
	Key     string    `json:"key"`
	URL     string    `json:"url,omitempty"`
	Title   string    `json:"title,omitempty"`
	Created time.Time `json:"created_at,omitempty"`
}

type PullRequest

type PullRequest struct {
	// Copied from issue.go
	ID        int64      `json:"id"`
	Index     int64      `json:"number"`
	Poster    *User      `json:"user"`
	Title     string     `json:"title"`
	Body      string     `json:"body"`
	Labels    []*Label   `json:"labels"`
	Milestone *Milestone `json:"milestone"`
	Assignee  *User      `json:"assignee"`
	State     StateType  `json:"state"`
	Comments  int        `json:"comments"`

	HeadBranch string      `json:"head_branch"`
	HeadRepo   *Repository `json:"head_repo"`
	BaseBranch string      `json:"base_branch"`
	BaseRepo   *Repository `json:"base_repo"`

	HTMLURL string `json:"html_url"`

	Mergeable      *bool      `json:"mergeable"`
	HasMerged      bool       `json:"merged"`
	Merged         *time.Time `json:"merged_at"`
	MergedCommitID *string    `json:"merge_commit_sha"`
	MergedBy       *User      `json:"merged_by"`
}

PullRequest represents a pull reqesut API object.

type PullRequestMeta

type PullRequestMeta struct {
	HasMerged bool       `json:"merged"`
	Merged    *time.Time `json:"merged_at"`
}

type PullRequestPayload

type PullRequestPayload struct {
	Action      HookIssueAction `json:"action"`
	Index       int64           `json:"number"`
	PullRequest *PullRequest    `json:"pull_request"`
	Changes     *ChangesPayload `json:"changes,omitempty"`
	Repository  *Repository     `json:"repository"`
	Sender      *User           `json:"sender"`
}

PullRequestPayload represents a payload information of pull request event.

func (*PullRequestPayload) JSONPayload

func (p *PullRequestPayload) JSONPayload() ([]byte, error)

type PushPayload

type PushPayload struct {
	Ref        string           `json:"ref"`
	Before     string           `json:"before"`
	After      string           `json:"after"`
	CompareURL string           `json:"compare_url"`
	Commits    []*PayloadCommit `json:"commits"`
	Repo       *Repository      `json:"repository"`
	Pusher     *User            `json:"pusher"`
	Sender     *User            `json:"sender"`
}

PushPayload represents a payload information of push event.

func ParsePushHook

func ParsePushHook(raw []byte) (*PushPayload, error)

ParsePushHook parses push event hook content.

func (*PushPayload) Branch

func (p *PushPayload) Branch() string

Branch returns branch name from a payload

func (*PushPayload) JSONPayload

func (p *PushPayload) JSONPayload() ([]byte, error)

type PusherType

type PusherType string
const (
	PUSHER_TYPE_USER PusherType = "user"
)

type Release

type Release struct {
	ID              int64     `json:"id"`
	TagName         string    `json:"tag_name"`
	TargetCommitish string    `json:"target_commitish"`
	Name            string    `json:"name"`
	Body            string    `json:"body"`
	Draft           bool      `json:"draft"`
	Prerelease      bool      `json:"prerelease"`
	Author          *User     `json:"author"`
	Created         time.Time `json:"created_at"`
}

Release represents a release API object.

type ReleasePayload

type ReleasePayload struct {
	Action     HookReleaseAction `json:"action"`
	Release    *Release          `json:"release"`
	Repository *Repository       `json:"repository"`
	Sender     *User             `json:"sender"`
}

ReleasePayload represents a payload information of release event.

func (*ReleasePayload) JSONPayload

func (p *ReleasePayload) JSONPayload() ([]byte, error)

type RepoCommit

type RepoCommit struct {
	URL       string      `json:"url"`
	Author    *CommitUser `json:"author"`
	Committer *CommitUser `json:"committer"`
	Message   string      `json:"message"`
	Tree      *CommitMeta `json:"tree"`
}

RepoCommit contains information of a commit in the context of a repository.

type Repository

type Repository struct {
	ID            int64       `json:"id"`
	Owner         *User       `json:"owner"`
	Name          string      `json:"name"`
	FullName      string      `json:"full_name"`
	Description   string      `json:"description"`
	Private       bool        `json:"private"`
	Unlisted      bool        `json:"unlisted"`
	Fork          bool        `json:"fork"`
	Parent        *Repository `json:"parent"`
	Empty         bool        `json:"empty"`
	Mirror        bool        `json:"mirror"`
	Size          int64       `json:"size"`
	HTMLURL       string      `json:"html_url"`
	SSHURL        string      `json:"ssh_url"`
	CloneURL      string      `json:"clone_url"`
	Website       string      `json:"website"`
	Stars         int         `json:"stars_count"`
	Forks         int         `json:"forks_count"`
	Watchers      int         `json:"watchers_count"`
	OpenIssues    int         `json:"open_issues_count"`
	DefaultBranch string      `json:"default_branch"`
	Created       time.Time   `json:"created_at"`
	Updated       time.Time   `json:"updated_at"`
	Permissions   *Permission `json:"permissions,omitempty"`
}

Repository represents a API repository.

type ReturnDiffFile

type ReturnDiffFile struct {
	BaseInfo       DiffFileList
	BaseDiffFile   string
	BranchDiffFile string
	ErrorInfo      string
}

type StateType

type StateType string
const (
	STATE_OPEN   StateType = "open"
	STATE_CLOSED StateType = "closed"
)

type Team

type Team struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Permission  string `json:"permission"`
}

type TestPatchRequest

type TestPatchRequest struct {
	BaseBranch   string `json:"baseBranch"`
	HeadBranch   string `json:"headBranch"`
	PatchContent string `json:"patchContent"`
}

type TestPatchResponse

type TestPatchResponse struct {
	BaseCommit  string `json:"baseCommit"`
	HeadCommit  string `json:"headCommit"`
	HasConflict bool   `json:"hasConflict"`
}

type User

type User struct {
	ID        int64  `json:"id"`
	UserName  string `json:"username"` // LEGACY [Gogs 1.0]: remove field(s) for backward compatibility
	Login     string `json:"login"`
	FullName  string `json:"full_name"`
	Email     string `json:"email"`
	AvatarUrl string `json:"avatar_url"`
}

User represents a API user.

Jump to

Keyboard shortcuts

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