gitlink

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

README

go-gitlink

基于 go 语言的 gitlink SDK

License-Anti Link-996 QQ群

基于 go 语言的 gitlink SDK

为简化开发工作、提高生产率、解决常见问题而生

更新文档

开发命令

get

go env -w GOPROXY=https://goproxy.cn,direct
# go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/
go get -u github.com/google/go-querystring
go get -u github.com/hashicorp/go-cleanhttp
go get -u github.com/hashicorp/go-retryablehttp

mod

go mod tidy
go mod download

test

go test ./... -v

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

Types

type AttachmentsData

type AttachmentsData struct {
	Status   int    `json:"status,omitempty"`
	Message  string `json:"message,omitempty"`
	Id       int64  `json:"id,omitempty"`
	Filesize int64  `json:"filesize,omitempty"`
}

type AttachmentsService

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

func (*AttachmentsService) PostAttachments

func (s *AttachmentsService) PostAttachments(filePath string) (*AttachmentsData, *Response, error)

PostAttachments 上传文件 https://apifox.com/apidoc/shared-da30afb0-9d2e-429b-a4bc-a83209e06021/api-128323479

type Author

type Author struct {
	Id       int32  `json:"id"`
	Login    string `json:"login"`
	Name     string `json:"name"`
	Type     string `json:"type"`
	ImageUrl string `json:"image_url"`
}

type Client

type Client struct {
	UserAgent string

	Projects    *ProjectsService
	Attachments *AttachmentsService
	Tag         *TagService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(token string) (*Client, error)

func (*Client) BaseURL

func (c *Client) BaseURL() *url.URL

func (*Client) Do

func (c *Client) Do(req *retryablehttp.Request, v interface{}) (*Response, error)

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, requestQuery interface{}, requestBody interface{}) (*retryablehttp.Request, error)

func (*Client) UploadRequest

func (c *Client) UploadRequest(method, path string, content io.Reader, filename string) (*retryablehttp.Request, error)

type Commit added in v0.2.0

type Commit struct {
	Sha           string    `json:"sha"`
	Message       string    `json:"message"`
	TimeAgo       string    `json:"time_ago"`
	CreatedAtUnix int       `json:"created_at_unix"`
	Committer     Committer `json:"committer"`
	Author        Author    `json:"author"`
}

type Committer added in v0.2.0

type Committer struct {
	Id       int32  `json:"id"`
	Login    string `json:"login"`
	Name     string `json:"name"`
	Type     string `json:"type"`
	ImageUrl string `json:"image_url"`
}

type DeleteTag added in v0.1.0

type DeleteTag struct {
	Status  int    `json:"status,omitempty"`
	Message string `json:"message,omitempty"`
}

type DeleteTagRequest added in v0.1.0

type DeleteTagRequest struct {
	Owner string // 必需
	Repo  string // 必需
	Tag   string // 标签名称、必需
}

type ErrorResponse

type ErrorResponse struct {
	Body     []byte
	Response *http.Response
	Message  string
}

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

type GetProjectsRequest

type GetProjectsRequest struct {
	SortBy        SortByValue        `url:"sort_by,omitempty" json:"sort_by,omitempty"`               // 排序方式
	SortDirection SortDirectionValue `url:"sort_direction,omitempty" json:"sort_direction,omitempty"` // 排序字段
	Search        string             `url:"search,omitempty" json:"search,omitempty"`                 // 搜索关键词
	CategoryId    string             `url:"category_id,omitempty" json:"category_id,omitempty"`       // 项目分类id
	LanguageId    string             `url:"language_id,omitempty" json:"language_id,omitempty"`       // 项目语言id
	ProjectType   ProjectTypeValue   `url:"project_type,omitempty" json:"project_type,omitempty"`     // 项目类型
	ListOptions
}

type GetTagsData added in v0.2.0

type GetTagsData struct {
	Status     int    `json:"status,omitempty"`
	Message    string `json:"message,omitempty"`
	TotalCount int    `json:"total_count"`
	Tags       []Tag  `json:"tags"`
}

type GetTagsRequestPath added in v1.0.0

type GetTagsRequestPath struct {
	Owner string // 必需
	Repo  string // 必需
}

type GetTagsRequestQuery added in v1.0.0

type GetTagsRequestQuery struct {
	Name string // 搜索关键词,可选
	ListOptions
}

type Language

type Language struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

type ListOptions

type ListOptions struct {
	Page  int `url:"page,omitempty" json:"page,omitempty"`   // 当前的页码
	Limit int `url:"limit,omitempty" json:"limit,omitempty"` // 每页的数量
}

type Project

type Project struct {
	Id                  int         `json:"id"`
	RepoId              int         `json:"repo_id"`
	Identifier          string      `json:"identifier"`
	Name                string      `json:"name"`
	Description         string      `json:"description"`
	Visits              int         `json:"visits"`
	PraisesCount        int         `json:"praises_count"`
	ForkedCount         int         `json:"forked_count"`
	IsPublic            bool        `json:"is_public"`
	MirrorUrl           string      `json:"mirror_url"`
	Type                int         `json:"type"`
	LastUpdateTime      int         `json:"last_update_time"`
	TimeAgo             string      `json:"time_ago"`
	ForkedFromProjectId int         `json:"forked_from_project_id"`
	OpenDevops          bool        `json:"open_devops"`
	Platform            string      `json:"platform"`
	Author              Author      `json:"author"`
	Category            interface{} `json:"category"`
	Language            Language    `json:"language"`
	Topics              []Topic     `json:"topics"`
}

type ProjectTypeValue

type ProjectTypeValue string // 项目类型
const (
	ProjectTypeCommon     ProjectTypeValue = "common"      // 普通项目
	ProjectTypeMirror     ProjectTypeValue = "mirror"      // 授权用户为仓库成员
	ProjectTypeSyncMirror ProjectTypeValue = "sync_mirror" // 授权用户为仓库所在组织并有访问仓库权限
)

type ProjectsData

type ProjectsData struct {
	Status     int       `json:"status,omitempty"`
	Message    string    `json:"message,omitempty"`
	TotalCount int       `json:"total_count"`
	Projects   []Project `json:"projects"`
}

type ProjectsService

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

type Response

type Response struct {
	*http.Response
}

type SortByValue

type SortByValue string // 排序方式
const (
	SortByDesc SortByValue = "desc" // 倒序
	SortByAsc  SortByValue = "asc"  // 正序
)

type SortDirectionValue

type SortDirectionValue string // 排序字段
const (
	SortDirectionUpdatedOn    SortDirectionValue = "updated_on"   // 公开
	SortDirectionCreatedOn    SortDirectionValue = "created_on"   // 私有
	SortDirectionForkedCount  SortDirectionValue = "forked_count" // 所有
	SortDirectionPraisesCount SortDirectionValue = "praises_count"
)

type Tag added in v0.2.0

type Tag struct {
	Name          string `json:"name"`
	Id            string `json:"id"`
	ZipballUrl    string `json:"zipball_url"`
	TarballUrl    string `json:"tarball_url"`
	Tagger        Tagger `json:"tagger"`
	TimeAgo       string `json:"time_ago"`
	CreatedAtUnix int    `json:"created_at_unix"`
	Message       string `json:"message"`
	Commit        Commit `json:"commit"`
}

type TagService added in v0.1.0

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

func (*TagService) DeleteTag added in v0.1.0

func (s *TagService) DeleteTag(request *DeleteTagRequest) (*DeleteTag, *Response, error)

DeleteTag 删除一个标签 https://apifox.com/apidoc/shared-da30afb0-9d2e-429b-a4bc-a83209e06021/api-118749620

func (*TagService) GetTags added in v0.2.0

func (s *TagService) GetTags(request *GetTagsRequestPath, requestQuery *GetTagsRequestQuery) (*GetTagsData, *Response, error)

GetTags 获取仓库标签列表 https://apifox.com/apidoc/shared-da30afb0-9d2e-429b-a4bc-a83209e06021/api-118749619

type Tagger added in v0.2.0

type Tagger struct {
	Id       int32  `json:"id"`
	Login    string `json:"login"`
	Name     string `json:"name"`
	Type     string `json:"type"`
	ImageUrl string `json:"image_url"`
}

type Topic

type Topic struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

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