openapi

package
v0.1.6-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Overview

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient struct {

	// 各个模块的服务
	Issues       *IssuesService
	PullRequests *PullRequestsService
	Repository   *RepositoryService
	User         *UserService
	// contains filtered or unexported fields
}

APIClient 一个客户端,管理与 GitCode OpenAPI 的通信

func NewAPIClientWithAuthorization

func NewAPIClientWithAuthorization(token []byte) *APIClient

func (*APIClient) BareDo

func (c *APIClient) BareDo(ctx context.Context, req *http.Request) (*http.Response, error)

func (*APIClient) Do

func (c *APIClient) Do(ctx context.Context, req *http.Request, receiver any) (*http.Response, error)

type Branch

type Branch struct {
	Name      *string           `json:"name,omitempty"`
	Commit    *RepositoryCommit `json:"commit,omitempty"`
	Protected *bool             `json:"protected,omitempty"`
}

Branch represents a repository branch

type Commit

type Commit struct {
	SHA         *string     `json:"sha,omitempty"`
	Author      *CommitUser `json:"author,omitempty"`
	Committer   *CommitUser `json:"committer,omitempty"`
	Message     *string     `json:"message,omitempty"`
	Parents     *Commit     `json:"parents,omitempty"`
	HTMLURL     *string     `json:"html_url,omitempty"`
	URL         *string     `json:"url,omitempty"`
	CommentsURL *int        `json:"comments_url,omitempty"`
}

type CommitFile

type CommitFile struct {
	SHA              *string `json:"sha,omitempty"`
	Filename         *string `json:"filename,omitempty"`
	Additions        *int    `json:"additions,omitempty"`
	Deletions        *int    `json:"deletions,omitempty"`
	Changes          *int    `json:"changes,omitempty"`
	Status           *string `json:"status,omitempty"`
	Patch            *string `json:"patch,omitempty"`
	BlobURL          *string `json:"blob_url,omitempty"`
	RawURL           *string `json:"raw_url,omitempty"`
	ContentsURL      *string `json:"contents_url,omitempty"`
	PreviousFilename *string `json:"previous_filename,omitempty"`
}

type CommitUser added in v0.2.0

type CommitUser struct {
	Login *string    `json:"login,omitempty"`
	Name  *string    `json:"name,omitempty"`
	Email *string    `json:"email,omitempty"`
	Date  *timestamp `json:"date,omitempty"`
}

type Contributor

type Contributor struct {
	Contributions *int64  `json:"contributions,omitempty"`
	Name          *string `json:"name,omitempty"`
	Email         *string `json:"email,omitempty"`
}

Contributor represents a repository contributor

type Issue

type Issue struct {
	ID               *int64            `json:"id,omitempty"`
	HTMLURL          *string           `json:"html_url,omitempty"`
	Number           *string           `json:"number,omitempty"`
	State            *string           `json:"state,omitempty"`
	IssueState       *string           `json:"issue_state,omitempty"`
	IssueStateDetail *IssueStateDetail `json:"issue_state_detail,omitempty"`
	Priority         *int              `json:"priority,omitempty"`
	Title            *string           `json:"title,omitempty"`
	Body             *string           `json:"body,omitempty"`
	User             *User             `json:"user,omitempty"`
	Assignee         *User             `json:"assignee,omitempty"`
	Repository       *Repository       `json:"repository,omitempty"`
	Labels           []*Label          `json:"labels,omitempty"`
	CreatedAt        *timestamp        `json:"created_at,omitempty"`
	UpdatedAt        *timestamp        `json:"updated_at,omitempty"`
	ClosedAt         *timestamp        `json:"finished_at,omitempty"`
	ClosedBy         *User             `json:"closed_by,omitempty"`

	PullRequestLinks *PullRequestLinks `json:"pull_request,omitempty"`
}

type IssueComment

type IssueComment struct {
	ID        *int64     `json:"id,omitempty"`
	Body      *string    `json:"body,omitempty"`
	User      *User      `json:"user,omitempty"`
	CreatedAt *timestamp `json:"created_at,omitempty"`
	UpdatedAt *timestamp `json:"updated_at,omitempty"`
	Target    *Issue     `json:"target,omitempty"`
}

type IssueRequest

type IssueRequest struct {
	Repository    string `json:"repo,omitempty"  required:"true"` // 仓库地址
	Title         string `json:"title,omitempty"`
	Body          string `json:"body,omitempty"`
	Labels        string `json:"labels,omitempty"`   // 用逗号分开的标签
	Assignee      string `json:"assignee,omitempty"` // Issue负责人的 username
	State         string `json:"state,omitempty"`
	Milestone     int64  `json:"milestone,omitempty"`
	SecurityHole  string `json:"security_hole,omitempty"`  // 是否是私有issue(默认为false)
	IssueStage    string `json:"issue_stage,omitempty"`    // 严重程序(Accepted,Coding,Completed,New,Rejected,Revising,Testing,Verified)
	IssueSeverity string `json:"issue_severity,omitempty"` // 优先级 (Suggestion,Minor,Major,Fatal)
}

type IssueStateDetail

type IssueStateDetail struct {
	Title  *string `json:"title,omitempty"`
	Serial *int    `json:"serial,omitempty"`
}

type IssuesService

type IssuesService service

func (*IssuesService) AddLabelsToIssue

func (s *IssuesService) AddLabelsToIssue(ctx context.Context, owner, repo, number string, labelNameList []string) ([]*Label, bool, error)

AddLabelsToIssue 创建Issue标签

api Docs: https://docs.gitcode.com/docs/openapi/repos/issues/#9%e5%88%9b%e5%bb%baissue%e6%a0%87%e7%ad%be

func (*IssuesService) CreateIssueComment

func (s *IssuesService) CreateIssueComment(ctx context.Context, owner, repo, number string, comment *IssueComment) (*IssueComment, bool, error)

CreateIssueComment 创建Issue评论

api Docs: https://docs.gitcode.com/docs/openapi/repos/issues/#11%e5%88%9b%e5%bb%baissue%e8%af%84%e8%ae%ba

func (*IssuesService) CreateRepoIssueLabel

func (s *IssuesService) CreateRepoIssueLabel(ctx context.Context, owner, repo string, newLabel *Label) (*Label, bool, error)

CreateRepoIssueLabel 创建仓库任务标签

api Docs: https://docs.gitcode.com/docs/openapi/repos/labels/#3-%e5%88%9b%e5%bb%ba%e4%bb%93%e5%ba%93%e4%bb%bb%e5%8a%a1%e6%a0%87%e7%ad%be

func (*IssuesService) DeleteRepoIssueLabel

func (s *IssuesService) DeleteRepoIssueLabel(ctx context.Context, owner, repo, name string) (bool, error)

DeleteRepoIssueLabel 删除一个仓库任务标签

api Docs: https://docs.gitcode.com/docs/openapi/repos/labels/#4-%e5%88%a0%e9%99%a4%e4%b8%80%e4%b8%aa%e4%bb%93%e5%ba%93%e4%bb%bb%e5%8a%a1%e6%a0%87%e7%ad%be

func (*IssuesService) ListIssueLinkingPullRequests

func (s *IssuesService) ListIssueLinkingPullRequests(ctx context.Context, owner, repo, number string) ([]*PullRequest, bool, error)

ListIssueLinkingPullRequests 获取 issue 关联的 pull requests

api Docs: https://docs.gitcode.com/docs/openapi/repos/issues/#7-%e8%8e%b7%e5%8f%96-issue-%e5%85%b3%e8%81%94%e7%9a%84-pull-requests

func (*IssuesService) ListRepoIssueLabels

func (s *IssuesService) ListRepoIssueLabels(ctx context.Context, owner, repo string) ([]*Label, bool, error)

ListRepoIssueLabels 获取仓库所有任务标签

api Docs: https://docs.gitcode.com/docs/openapi/repos/labels/#2-%e8%8e%b7%e5%8f%96%e4%bb%93%e5%ba%93%e6%89%80%e6%9c%89%e4%bb%bb%e5%8a%a1%e6%a0%87%e7%ad%be

func (*IssuesService) RemoveLabelsFromIssue

func (s *IssuesService) RemoveLabelsFromIssue(ctx context.Context, owner, repo, number, label string) (bool, error)

RemoveLabelsFromIssue 删除Issue标签

api Docs: https://docs.gitcode.com/docs/openapi/repos/issues/#10%e5%88%a0%e9%99%a4issue%e6%a0%87%e7%ad%be

func (*IssuesService) UpdateIssue

func (s *IssuesService) UpdateIssue(ctx context.Context, owner, number string, issueContent *IssueRequest) (*Issue, bool, error)

UpdateIssue 更新Issue

api Docs: https://docs.gitcode.com/docs/openapi/repos/issues/#2-%e6%9b%b4%e6%96%b0issue

func (*IssuesService) UpdateRepoIssueLabel

func (s *IssuesService) UpdateRepoIssueLabel(ctx context.Context, owner, repo, originalName, newName, color string) (*Label, bool, error)

UpdateRepoIssueLabel 更新一个仓库的任务标签

api Docs: https://docs.gitcode.com/docs/openapi/repos/labels/#1-%e6%9b%b4%e6%96%b0%e4%b8%80%e4%b8%aa%e4%bb%93%e5%ba%93%e7%9a%84%e4%bb%bb%e5%8a%a1%e6%a0%87%e7%ad%be

type Label

type Label struct {
	Name  string `json:"name,omitempty"`
	Color string `json:"color,omitempty"`
	Title string `json:"title,omitempty"`
}

Label represents a GitCode label on an Issue

func (*Label) Form

func (l *Label) Form() *url.Values

type MergeAbleState

type MergeAbleState struct {
	MergeRequestID *int64 `json:"merge_request_id,omitempty"`
	State          *bool  `json:"state,omitempty"`
}

type Organization

type Organization struct {
	Login        *string    `json:"login,omitempty"`
	ID           *int64     `json:"id,omitempty"`
	AvatarURL    *string    `json:"avatar_url,omitempty"`
	HTMLURL      *string    `json:"html_url,omitempty"`
	Name         *string    `json:"name,omitempty"`
	Company      *string    `json:"company,omitempty"`
	Description  *string    `json:"description,omitempty"`
	PublicRepos  *int       `json:"public_repos,omitempty"`
	PrivateRepos *int       `json:"private_repos,omitempty"`
	Followers    *int       `json:"followers,omitempty"`
	FollowCount  *int       `json:"follow_count,omitempty"`
	CreatedAt    *timestamp `json:"created_at,omitempty"`
	UpdatedAt    *timestamp `json:"updated_at,omitempty"`
	Members      *string    `json:"members,omitempty"`
	Public       *bool      `json:"public,omitempty"`
	Type         *string    `json:"type,omitempty"`
}

Organization represents a GitHub organization account.

type Permission

type Permission struct {
	Admin *bool `json:"admin,omitempty"`
}

type PullRequest

type PullRequest struct {
	ID             *int64          `json:"id,omitempty"`
	Number         *int64          `json:"number,omitempty"`
	State          *string         `json:"state,omitempty"`
	Title          *string         `json:"title,omitempty"`
	Body           *string         `json:"body,omitempty"`
	CreatedAt      *timestamp      `json:"created_at,omitempty"`
	UpdatedAt      *timestamp      `json:"updated_at,omitempty"`
	ClosedAt       *timestamp      `json:"closed_at,omitempty"`
	MergedAt       *timestamp      `json:"merged_at,omitempty"`
	Labels         []*Label        `json:"labels,omitempty"`
	User           *User           `json:"user,omitempty"`
	Draft          *bool           `json:"draft,omitempty"`
	CanMergeCheck  *bool           `json:"can_merge_check,omitempty"`
	Merged         *bool           `json:"merged,omitempty"`
	MergeAble      *bool           `json:"mergeable,omitempty"`
	MergeAbleState *MergeAbleState `json:"mergeable_state,omitempty"`
	MergedBy       *User           `json:"merged_by,omitempty"`
	PruneBranch    *bool           `json:"prune_branch,omitempty"`

	Head *PullRequestBranch `json:"head,omitempty"`
	Base *PullRequestBranch `json:"base,omitempty"`

	URL                 *string `json:"url,omitempty"`
	HTMLURL             *string `json:"html_url,omitempty"`
	IssueURL            *string `json:"issue_url,omitempty"`
	StatusesURL         *string `json:"statuses_url,omitempty"`
	DiffURL             *string `json:"diff_url,omitempty"`
	PatchURL            *string `json:"patch_url,omitempty"`
	CommitsURL          *string `json:"commits_url,omitempty"`
	CommentsURL         *string `json:"comments_url,omitempty"`
	ReviewCommentsURL   *string `json:"review_comments_url,omitempty"`
	ReviewCommentURL    *string `json:"review_comment_url,omitempty"`
	ReviewComments      *int    `json:"review_comments,omitempty"`
	Assignee            *User   `json:"assignee,omitempty"`
	Assignees           []*User `json:"assignees,omitempty"`
	MaintainerCanModify *bool   `json:"maintainer_can_modify,omitempty"`
	AuthorAssociation   *string `json:"author_association,omitempty"`
	NodeID              *string `json:"node_id,omitempty"`
	RequestedReviewers  []*User `json:"requested_reviewers,omitempty"`
}

PullRequest represents a GitHub pull request on a repository.

type PullRequestBranch

type PullRequestBranch struct {
	Label *string     `json:"label,omitempty"`
	Ref   *string     `json:"ref,omitempty"`
	SHA   *string     `json:"sha,omitempty"`
	Repo  *Repository `json:"repo,omitempty"`
	User  *User       `json:"user,omitempty"`
}

PullRequestBranch represents a base or head branch in a GitHub pull request.

type PullRequestComment

type PullRequestComment struct {
	ID        *string    `json:"id,omitempty"`
	Body      *string    `json:"body,omitempty"`
	User      *User      `json:"user,omitempty"`
	CreatedAt *timestamp `json:"created_at,omitempty"`
	UpdatedAt *timestamp `json:"updated_at,omitempty"`
}

type PullRequestCommentRequest

type PullRequestCommentRequest struct {
	Body     string `json:"body,omitempty"`
	Path     string `json:"path,omitempty"`
	Position string `json:"position,omitempty"`
}
type PullRequestLinks struct {
	URL      *string    `json:"url,omitempty"`
	HTMLURL  *string    `json:"html_url,omitempty"`
	DiffURL  *string    `json:"diff_url,omitempty"`
	PatchURL *string    `json:"patch_url,omitempty"`
	MergedAt *timestamp `json:"merged_at,omitempty"`
}

type PullRequestMergedResult

type PullRequestMergedResult struct {
	SHA     *string `json:"sha,omitempty"`
	Merged  *string `json:"merged,omitempty"`
	Message *string `json:"message,omitempty"`
}

type PullRequestOperationLog

type PullRequestOperationLog struct {
	Project        *string    `json:"project,omitempty"`
	CreatedAt      *timestamp `json:"created_at,omitempty"`
	DiscussionID   *int64     `json:"discussion_id,omitempty"`
	ID             *int64     `json:"id,omitempty"`
	Content        *string    `json:"content,omitempty"`
	Action         *string    `json:"action,omitempty"`
	MergeRequestId *int64     `json:"merge_request_id,omitempty"`
	UpdatedAt      *timestamp `json:"updated_at,omitempty"`
	User           *User      `json:"user,omitempty"`
}

PullRequestOperationLog represents a comment in a GitHub DiscussionCommentEvent.

type PullRequestRequest

type PullRequestRequest struct {
	ID              int64       `json:"id,omitempty"`
	Title           string      `json:"title,omitempty" required:"true"`
	Body            string      `json:"body,omitempty" required:"true"`
	State           string      `json:"state,omitempty"`
	Labels          string      `json:"labels,omitempty"`
	MilestoneNumber string      `json:"milestone_number,omitempty"`
	Draft           string      `json:"draft,omitempty"`
	User            User        `json:"user,omitempty"`
	Target          PullRequest `json:"target,omitempty"`
}

type PullRequestsService

type PullRequestsService service

func (*PullRequestsService) AddLabelsToPullRequest

func (s *PullRequestsService) AddLabelsToPullRequest(ctx context.Context, owner, repo, number string, labelNameList []string) ([]*Label, bool, error)

AddLabelsToPullRequest 创建 Pull Request 标签

api Docs: https://docs.gitcode.com/docs/openapi/repos/pulls/#12-%e5%88%9b%e5%bb%ba-pull-request-%e6%a0%87%e7%ad%be

func (*PullRequestsService) CreatePullRequestComment

func (s *PullRequestsService) CreatePullRequestComment(ctx context.Context, owner, repo, number string, comment *PullRequestCommentRequest) (*PullRequestComment, bool, error)

CreatePullRequestComment 提交 pull request 评论

api Docs: https://docs.gitcode.com/docs/openapi/repos/pulls/#4-%e6%8f%90%e4%ba%a4pull-request-%e8%af%84%e8%ae%ba

func (*PullRequestsService) GetPullRequest

func (s *PullRequestsService) GetPullRequest(ctx context.Context, owner, repo, number string) (*PullRequest, bool, error)

GetPullRequest 获取单个Pull Requests

api Docs: https://docs.gitcode.com/docs/openapi/repos/pulls/#10-%e8%8e%b7%e5%8f%96%e5%8d%95%e4%b8%aapull-request

func (*PullRequestsService) ListPullRequestCommits added in v0.2.0

func (s *PullRequestsService) ListPullRequestCommits(ctx context.Context, owner, repo, number string) ([]*RepositoryCommit, bool, error)

ListPullRequestCommits 获取某Pull Request的所有Commit信息

api Docs: https://docs.gitcode.com/docs/openapi/repos/pulls/#10-%e8%8e%b7%e5%8f%96%e6%9f%90pull-request%e7%9a%84%e6%89%80%e6%9c%89commit%e4%bf%a1%e6%81%af

func (*PullRequestsService) ListPullRequestLinkingIssues

func (s *PullRequestsService) ListPullRequestLinkingIssues(ctx context.Context, owner, repo, number string) ([]*Issue, bool, error)

ListPullRequestLinkingIssues 获取pr关联的issue

api Docs: https://docs.gitcode.com/docs/openapi/repos/pulls/#3-%e8%8e%b7%e5%8f%96pr%e5%85%b3%e8%81%94%e7%9a%84issue

func (*PullRequestsService) RemoveLabelsFromPullRequest

func (s *PullRequestsService) RemoveLabelsFromPullRequest(ctx context.Context, owner, repo, number string, labels []string) (bool, error)

RemoveLabelsFromPullRequest 删除 Pull Request 标签

api Docs: https://docs.gitcode.com/docs/openapi/repos/pulls/#13-%e5%88%a0%e9%99%a4-pull-request-%e6%a0%87%e7%ad%be

func (*PullRequestsService) UpdatePullRequest

func (s *PullRequestsService) UpdatePullRequest(ctx context.Context, owner, repo, number string, prContent *PullRequestRequest) (*PullRequest, bool, error)

UpdatePullRequest 更新Pull Request信息

api Docs: https://docs.gitcode.com/docs/openapi/repos/pulls/#8-%e6%9b%b4%e6%96%b0pull-request%e4%bf%a1%e6%81%af

type Repository

type Repository struct {
	ID                        *int64                 `json:"id,omitempty"`
	NodeID                    *string                `json:"node_id,omitempty"`
	Owner                     *User                  `json:"owner,omitempty"`
	Name                      *string                `json:"name,omitempty"`
	Path                      *string                `json:"path,omitempty"`
	FullName                  *string                `json:"full_name,omitempty"`
	Description               *string                `json:"description,omitempty"`
	Homepage                  *string                `json:"homepage,omitempty"`
	DefaultBranch             *string                `json:"default_branch,omitempty"`
	MasterBranch              *string                `json:"master_branch,omitempty"`
	CreatedAt                 *timestamp             `json:"created_at,omitempty"`
	PushedAt                  *timestamp             `json:"pushed_at,omitempty"`
	UpdatedAt                 *timestamp             `json:"updated_at,omitempty"`
	HTMLURL                   *string                `json:"html_url,omitempty"`
	CloneURL                  *string                `json:"clone_url,omitempty"`
	GitURL                    *string                `json:"git_url,omitempty"`
	MirrorURL                 *string                `json:"mirror_url,omitempty"`
	SSHURL                    *string                `json:"ssh_url,omitempty"`
	SVNURL                    *string                `json:"svn_url,omitempty"`
	Language                  *string                `json:"language,omitempty"`
	Fork                      *bool                  `json:"fork,omitempty"`
	ForksCount                *int                   `json:"forks_count,omitempty"`
	NetworkCount              *int                   `json:"network_count,omitempty"`
	OpenIssuesCount           *int                   `json:"open_issues_count,omitempty"`
	OpenIssues                *int                   `json:"open_issues,omitempty"` // Deprecated: Replaced by OpenIssuesCount. For backward compatibility OpenIssues is still populated.
	StargazersCount           *int                   `json:"stargazers_count,omitempty"`
	SubscribersCount          *int                   `json:"subscribers_count,omitempty"`
	WatchersCount             *int                   `json:"watchers_count,omitempty"` // Deprecated: Replaced by StargazersCount. For backward compatibility WatchersCount is still populated.
	Watchers                  *int                   `json:"watchers,omitempty"`       // Deprecated: Replaced by StargazersCount. For backward compatibility Watchers is still populated.
	Size                      *int                   `json:"size,omitempty"`
	AutoInit                  *bool                  `json:"auto_init,omitempty"`
	Parent                    *Repository            `json:"parent,omitempty"`
	Source                    *Repository            `json:"source,omitempty"`
	TemplateRepository        *Repository            `json:"template_repository,omitempty"`
	Organization              *Organization          `json:"organization,omitempty"`
	Permissions               map[string]bool        `json:"permissions,omitempty"`
	AllowRebaseMerge          *bool                  `json:"allow_rebase_merge,omitempty"`
	AllowUpdateBranch         *bool                  `json:"allow_update_branch,omitempty"`
	AllowSquashMerge          *bool                  `json:"allow_squash_merge,omitempty"`
	AllowMergeCommit          *bool                  `json:"allow_merge_commit,omitempty"`
	AllowAutoMerge            *bool                  `json:"allow_auto_merge,omitempty"`
	AllowForking              *bool                  `json:"allow_forking,omitempty"`
	WebCommitSignoffRequired  *bool                  `json:"web_commit_signoff_required,omitempty"`
	DeleteBranchOnMerge       *bool                  `json:"delete_branch_on_merge,omitempty"`
	UseSquashPRTitleAsDefault *bool                  `json:"use_squash_pr_title_as_default,omitempty"`
	SquashMergeCommitTitle    *string                `json:"squash_merge_commit_title,omitempty"`   // Can be one of: "PR_TITLE", "COMMIT_OR_PR_TITLE"
	SquashMergeCommitMessage  *string                `json:"squash_merge_commit_message,omitempty"` // Can be one of: "PR_BODY", "COMMIT_MESSAGES", "BLANK"
	MergeCommitTitle          *string                `json:"merge_commit_title,omitempty"`          // Can be one of: "PR_TITLE", "MERGE_MESSAGE"
	MergeCommitMessage        *string                `json:"merge_commit_message,omitempty"`        // Can be one of: "PR_BODY", "PR_TITLE", "BLANK"
	Topics                    []string               `json:"topics,omitempty"`
	CustomProperties          map[string]interface{} `json:"custom_properties,omitempty"`
	Archived                  *bool                  `json:"archived,omitempty"`
	Disabled                  *bool                  `json:"disabled,omitempty"`

	// Additional mutable fields when creating and editing a repository
	Private           *bool   `json:"private,omitempty"`
	HasIssues         *bool   `json:"has_issues,omitempty"`
	HasWiki           *bool   `json:"has_wiki,omitempty"`
	HasPages          *bool   `json:"has_pages,omitempty"`
	HasProjects       *bool   `json:"has_projects,omitempty"`
	HasDownloads      *bool   `json:"has_downloads,omitempty"`
	HasDiscussions    *bool   `json:"has_discussions,omitempty"`
	IsTemplate        *bool   `json:"is_template,omitempty"`
	LicenseTemplate   *string `json:"license_template,omitempty"`
	GitignoreTemplate *string `json:"gitignore_template,omitempty"`

	// Creating an organization repository. Required for non-owners.
	TeamID *int64 `json:"team_id,omitempty"`

	// api URLs
	URL              *string `json:"url,omitempty"`
	ArchiveURL       *string `json:"archive_url,omitempty"`
	AssigneesURL     *string `json:"assignees_url,omitempty"`
	BlobsURL         *string `json:"blobs_url,omitempty"`
	BranchesURL      *string `json:"branches_url,omitempty"`
	CollaboratorsURL *string `json:"collaborators_url,omitempty"`
	CommentsURL      *string `json:"comments_url,omitempty"`
	CommitsURL       *string `json:"commits_url,omitempty"`
	CompareURL       *string `json:"compare_url,omitempty"`
	ContentsURL      *string `json:"contents_url,omitempty"`
	ContributorsURL  *string `json:"contributors_url,omitempty"`
	DeploymentsURL   *string `json:"deployments_url,omitempty"`
	DownloadsURL     *string `json:"downloads_url,omitempty"`
	EventsURL        *string `json:"events_url,omitempty"`
	ForksURL         *string `json:"forks_url,omitempty"`
	GitCommitsURL    *string `json:"git_commits_url,omitempty"`
	GitRefsURL       *string `json:"git_refs_url,omitempty"`
	GitTagsURL       *string `json:"git_tags_url,omitempty"`
	HooksURL         *string `json:"hooks_url,omitempty"`
	IssueCommentURL  *string `json:"issue_comment_url,omitempty"`
	IssueEventsURL   *string `json:"issue_events_url,omitempty"`
	IssuesURL        *string `json:"issues_url,omitempty"`
	KeysURL          *string `json:"keys_url,omitempty"`
	LabelsURL        *string `json:"labels_url,omitempty"`
	LanguagesURL     *string `json:"languages_url,omitempty"`
	MergesURL        *string `json:"merges_url,omitempty"`
	MilestonesURL    *string `json:"milestones_url,omitempty"`
	NotificationsURL *string `json:"notifications_url,omitempty"`
	PullsURL         *string `json:"pulls_url,omitempty"`
	ReleasesURL      *string `json:"releases_url,omitempty"`
	StargazersURL    *string `json:"stargazers_url,omitempty"`
	StatusesURL      *string `json:"statuses_url,omitempty"`
	SubscribersURL   *string `json:"subscribers_url,omitempty"`
	SubscriptionURL  *string `json:"subscription_url,omitempty"`
	TagsURL          *string `json:"tags_url,omitempty"`
	TreesURL         *string `json:"trees_url,omitempty"`
	TeamsURL         *string `json:"teams_url,omitempty"`

	// Visibility is only used for Create and Edit endpoints. The visibility field
	// overrides the field parameter when both are used.
	// Can be one of public, private or internal.
	Visibility *string `json:"visibility,omitempty"`

	// RoleName is only returned by the api 'check team permissions for a repository'.
	// See: teams.go (IsTeamRepoByID) https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-repository
	RoleName *string `json:"role_name,omitempty"`
}

Repository represents a GitHub repository.

type RepositoryCommit

type RepositoryCommit struct {
	SHA         *string     `json:"sha,omitempty"`
	Commit      *Commit     `json:"commit,omitempty"`
	Author      *CommitUser `json:"author,omitempty"`
	Committer   *CommitUser `json:"committer,omitempty"`
	Parents     *Commit     `json:"parents,omitempty"`
	HTMLURL     *string     `json:"html_url,omitempty"`
	URL         *string     `json:"url,omitempty"`
	CommentsURL *string     `json:"comments_url,omitempty"`
}

type RepositoryContent

type RepositoryContent struct {
	Type *string `json:"type,omitempty"`
	// Target is only set if the type is "symlink" and the target is not a normal file.
	// If Target is set, Path will be the symlink path.
	Target   *string `json:"target,omitempty"`
	Encoding *string `json:"encoding,omitempty"`
	Size     *int    `json:"size,omitempty"`
	Name     *string `json:"name,omitempty"`
	Path     *string `json:"path,omitempty"`
	// Content contains the actual file content, which may be encoded.
	// Callers should call GetContent which will decode the content if
	// necessary.
	Content         *string `json:"content,omitempty"`
	SHA             *string `json:"sha,omitempty"`
	URL             *string `json:"url,omitempty"`
	GitURL          *string `json:"git_url,omitempty"`
	HTMLURL         *string `json:"html_url,omitempty"`
	DownloadURL     *string `json:"download_url,omitempty"`
	SubmoduleGitURL *string `json:"submodule_git_url,omitempty"`
}

RepositoryContent represents a file or directory in a github repository.

type RepositoryService

type RepositoryService service

func (*RepositoryService) CheckUserIsRepoMember

func (s *RepositoryService) CheckUserIsRepoMember(ctx context.Context, owner, repo, username string) (bool, bool, error)

CheckUserIsRepoMember 判断用户是否为仓库成员

api Docs: https://docs.gitcode.com/docs/openapi/repos/member/#4-%e5%88%a4%e6%96%ad%e7%94%a8%e6%88%b7%e6%98%af%e5%90%a6%e4%b8%ba%e4%bb%93%e5%ba%93%e6%88%90%e5%91%98

func (*RepositoryService) GetRepoAllMember

func (s *RepositoryService) GetRepoAllMember(ctx context.Context, owner, repo, page string) ([]*User, bool, error)

GetRepoAllMember 获取仓库的所有成员

api Docs: https://docs.gitcode.com/docs/openapi/repos/member/#3-%e8%8e%b7%e5%8f%96%e4%bb%93%e5%ba%93%e7%9a%84%e6%89%80%e6%9c%89%e6%88%90%e5%91%98

func (*RepositoryService) GetRepoContributors

func (s *RepositoryService) GetRepoContributors(ctx context.Context, owner, repo, category string) ([]*Contributor, bool, error)

GetRepoContributors 获取仓库贡献者

api Docs: https://docs.gitcode.com/docs/openapi/repos/#9-%e8%8e%b7%e5%8f%96%e4%bb%93%e5%ba%93%e8%b4%a1%e7%8c%ae%e8%80%85

func (*RepositoryService) GetRepoMemberPermission

func (s *RepositoryService) GetRepoMemberPermission(ctx context.Context, owner, repo, login string) (*User, [2]bool, error)

GetRepoMemberPermission 查看仓库成员的权限

api Docs: https://docs.gitcode.com/docs/openapi/repos/member/#5-%e6%9f%a5%e7%9c%8b%e4%bb%93%e5%ba%93%e6%88%90%e5%91%98%e7%9a%84%e6%9d%83%e9%99%90

type RequestHandler

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

func (*RequestHandler) PostOperate

func (b *RequestHandler) PostOperate(req *http.Request)

func (*RequestHandler) PreOperate

func (b *RequestHandler) PreOperate(uri *url.URL, body any) error

type RequestHandlerType

type RequestHandlerType string
const (
	Json  RequestHandlerType = "json"
	Form  RequestHandlerType = "form"
	Query RequestHandlerType = "query"
)

type User

type User struct {
	Login       *string     `json:"login,omitempty"`
	AvatarURL   *string     `json:"avatar_url,omitempty"`
	HTMLURL     *string     `json:"web_url,omitempty"`
	UserName    *string     `json:"username,omitempty"`
	Name        *string     `json:"name,omitempty"`
	Blog        *string     `json:"blog,omitempty"`
	Email       *string     `json:"email,omitempty"`
	Bio         *string     `json:"bio,omitempty"`
	Followers   *int        `json:"followers,omitempty"`
	Following   *int        `json:"following,omitempty"`
	Type        *string     `json:"type,omitempty"`
	Permission  *string     `json:"permission,omitempty"`
	Permissions *Permission `json:"permissions,omitempty"`
}

User represents a GitHub user.

type UserService

type UserService service

Jump to

Keyboard shortcuts

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