Compare commits

..

1 Commits

Author SHA1 Message Date
Bo-Yi Wu
6b3965a9f7 replace gitter chat with discord. 2017-06-10 21:48:28 +08:00
38 changed files with 236 additions and 872 deletions

View File

@ -2,15 +2,9 @@ workspace:
base: /srv/app base: /srv/app
path: src/code.gitea.io/sdk path: src/code.gitea.io/sdk
clone:
git:
image: plugins/git:1
depth: 50
tags: true
pipeline: pipeline:
testing: testing:
image: webhippie/golang:edge image: webhippie/golang:latest
pull: true pull: true
commands: commands:
- make clean - make clean
@ -19,16 +13,9 @@ pipeline:
- make test - make test
- make build - make build
# coverage: coverage:
# image: plugins/coverage:1 image: plugins/coverage
# pull: true server: https://coverage.gitea.io
# secrets: [ github_token ]
# server: https://coverage.gitea.io
discord: gitter:
image: appleboy/drone-discord:1.0.0 image: plugins/gitter
pull: true
secrets: [ discord_webhook_id, discord_webhook_token ]
when:
event: [ push, tag, pull_request ]
status: [ changed, failure ]

1
.drone.yml.sig Normal file
View File

@ -0,0 +1 @@
eyJhbGciOiJIUzI1NiJ9.d29ya3NwYWNlOgogIGJhc2U6IC9zcnYvYXBwCiAgcGF0aDogc3JjL2NvZGUuZ2l0ZWEuaW8vc2RrCgpwaXBlbGluZToKICB0ZXN0aW5nOgogICAgaW1hZ2U6IHdlYmhpcHBpZS9nb2xhbmc6bGF0ZXN0CiAgICBwdWxsOiB0cnVlCiAgICBjb21tYW5kczoKICAgICAgLSBtYWtlIGNsZWFuCiAgICAgIC0gbWFrZSB2ZXQKICAgICAgLSBtYWtlIGxpbnQKICAgICAgLSBtYWtlIHRlc3QKICAgICAgLSBtYWtlIGJ1aWxkCgogIGNvdmVyYWdlOgogICAgaW1hZ2U6IHBsdWdpbnMvY292ZXJhZ2UKICAgIHNlcnZlcjogaHR0cHM6Ly9jb3ZlcmFnZS5naXRlYS5pbwoKICBnaXR0ZXI6CiAgICBpbWFnZTogcGx1Z2lucy9naXR0ZXIK.HIbwP8NEFAdT6Nfjgw2OCVpvO3cE_YTxA-Xwxwevd2A

View File

@ -15,14 +15,10 @@ indent_size = 8
indent_style = tab indent_style = tab
indent_size = 4 indent_size = 4
[*.{less}] [*.{less,yml}]
indent_style = space indent_style = space
indent_size = 4 indent_size = 4
[*.{yml}]
indent_style = space
indent_size = 2
[*.js] [*.js]
indent_style = space indent_style = space
indent_size = 4 indent_size = 4

View File

@ -1,8 +1,6 @@
<!-- 1. Please speak English, this is the language everybody of us can speak and write.
1. Please speak English, this is the language all of us can speak and write. 2. Please ask questions or config/deploy problems on our Gitter channel: https://gitter.im/go-gitea/gitea
2. Please ask questions or configuration/deploy problems on our Discord 3. Please take a moment to search that an issue doesn't already exist.
server (https://discord.gg/NsatcWJ) or forum (https://discourse.gitea.io). 4. Please give all relevant information below for bug reports, incomplete details will be handled as an invalid report.
3. Please take a moment to check that your issue doesn't already exist.
4. Please give all relevant information below for bug reports, because **You MUST delete the content above including this line before posting, otherwise your issue will be invalid.**
incomplete details will be handled as an invalid report.
-->

3
.lgtm
View File

@ -1,3 +1,2 @@
pattern = "(?)LGTM" self_approval_off = false
self_approval_off = true
ignore_maintainers_file = true ignore_maintainers_file = true

View File

@ -7,7 +7,6 @@ Kim Carlbäcker <kim.carlbacker@gmail.com> (@bkcsoft)
LefsFlare <nobody@nobody.tld> (@LefsFlarey) LefsFlare <nobody@nobody.tld> (@LefsFlarey)
Lunny Xiao <xiaolunwen@gmail.com> (@lunny) Lunny Xiao <xiaolunwen@gmail.com> (@lunny)
Matthias Loibl <mail@matthiasloibl.com> (@metalmatze) Matthias Loibl <mail@matthiasloibl.com> (@metalmatze)
Morgan Bazalgette <the@howl.moe> (@thehowl)
Rachid Zarouali <nobody@nobody.tld> (@xinity) Rachid Zarouali <nobody@nobody.tld> (@xinity)
Rémy Boulanouar <admin@dblk.org> (@DblK) Rémy Boulanouar <admin@dblk.org> (@DblK)
Sandro Santilli <strk@kbt.io> (@strk) Sandro Santilli <strk@kbt.io> (@strk)
@ -15,10 +14,3 @@ Thibault Meyer <meyer.thibault@gmail.com> (@0xbaadf00d)
Thomas Boerger <thomas@webhippie.de> (@tboerger) Thomas Boerger <thomas@webhippie.de> (@tboerger)
Antoine Girard <sapk@sapk.fr> (@sapk) Antoine Girard <sapk@sapk.fr> (@sapk)
Lauris Bukšis-Haberkorns <lauris@nix.lv> (@lafriks) Lauris Bukšis-Haberkorns <lauris@nix.lv> (@lafriks)
Jonas Östanbäck <jonas.ostanback@gmail.com> (@cez81)
David Schneiderbauer <dschneiderbauer@gmail.com> (@daviian)
Peter Žeby <morlinest@gmail.com> (@morlinest)
Jonas Franz <info@jonasfranz.software> (@JonasFranzDEV)
Alexey Terentyev <axifnx@gmail.com> (@axifive)
Konrad Langenberg <k@knt.li> (@kolaente)
Andrew Thornton <art27@cantab.net> (@zeripath)

View File

@ -1,6 +1,6 @@
IMPORT := code.gitea.io/sdk IMPORT := code.gitea.io/sdk
PACKAGES ?= $(shell go list -e ./... | grep -v /vendor/ | grep -v /benchmark/) PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
GENERATE ?= code.gitea.io/sdk/gitea GENERATE ?= code.gitea.io/sdk/gitea
.PHONY: all .PHONY: all
@ -18,7 +18,7 @@ generate:
.PHONY: fmt .PHONY: fmt
fmt: fmt:
find . -name "*.go" -type f ! -path "./vendor/*" ! -path "./benchmark/*" | xargs gofmt -s -w find . -name "*.go" -type f -not -path "./vendor/*" | xargs gofmt -s -w
.PHONY: vet .PHONY: vet
vet: vet:
@ -27,7 +27,7 @@ vet:
.PHONY: lint .PHONY: lint
lint: lint:
@which golint > /dev/null; if [ $$? -ne 0 ]; then \ @which golint > /dev/null; if [ $$? -ne 0 ]; then \
go get -u golang.org/x/lint/golint; \ go get -u github.com/golang/lint/golint; \
fi fi
for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done; for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
@ -35,10 +35,6 @@ lint:
test: test:
for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done; for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done;
.PHONY: bench
bench:
go test -run=XXXXXX -benchtime=10s -bench=. || exit 1
.PHONY: build .PHONY: build
build: build:
go build ./gitea go build ./gitea

View File

@ -3,6 +3,7 @@
[![Build Status](http://drone.gitea.io/api/badges/go-gitea/go-sdk/status.svg)](http://drone.gitea.io/go-gitea/go-sdk) [![Build Status](http://drone.gitea.io/api/badges/go-gitea/go-sdk/status.svg)](http://drone.gitea.io/go-gitea/go-sdk)
[![Join the chat at https://img.shields.io/discord/322538954119184384.svg](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/NsatcWJ) [![Join the chat at https://img.shields.io/discord/322538954119184384.svg](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/NsatcWJ)
[![](https://images.microbadger.com/badges/image/gitea/gitea.svg)](http://microbadger.com/images/gitea/gitea "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/image/gitea/gitea.svg)](http://microbadger.com/images/gitea/gitea "Get your own image badge on microbadger.com")
[![Coverage Status](https://coverage.gitea.io/badges/go-gitea/go-sdk/coverage.svg)](https://coverage.gitea.io/go-gitea/go-sdk)
[![Go Report Card](https://goreportcard.com/badge/code.gitea.io/sdk)](https://goreportcard.com/report/code.gitea.io/sdk) [![Go Report Card](https://goreportcard.com/badge/code.gitea.io/sdk)](https://goreportcard.com/report/code.gitea.io/sdk)
[![GoDoc](https://godoc.org/code.gitea.io/sdk/gitea?status.svg)](https://godoc.org/code.gitea.io/sdk/gitea) [![GoDoc](https://godoc.org/code.gitea.io/sdk/gitea?status.svg)](https://godoc.org/code.gitea.io/sdk/gitea)

View File

@ -12,16 +12,12 @@ import (
// CreateUserOption create user options // CreateUserOption create user options
type CreateUserOption struct { type CreateUserOption struct {
SourceID int64 `json:"source_id"` SourceID int64 `json:"source_id"`
LoginName string `json:"login_name"` LoginName string `json:"login_name"`
// required: true Username string `json:"username" binding:"Required;AlphaDashDot;MaxSize(35)"`
Username string `json:"username" binding:"Required;AlphaDashDot;MaxSize(35)"` FullName string `json:"full_name" binding:"MaxSize(100)"`
FullName string `json:"full_name" binding:"MaxSize(100)"` Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
// required: true Password string `json:"password" binding:"MaxSize(255)"`
// swagger:strfmt email
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
// required: true
Password string `json:"password" binding:"Required;MaxSize(255)"`
SendNotify bool `json:"send_notify"` SendNotify bool `json:"send_notify"`
} }
@ -37,22 +33,18 @@ func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, error) {
// EditUserOption edit user options // EditUserOption edit user options
type EditUserOption struct { type EditUserOption struct {
SourceID int64 `json:"source_id"` SourceID int64 `json:"source_id"`
LoginName string `json:"login_name"` LoginName string `json:"login_name"`
FullName string `json:"full_name" binding:"MaxSize(100)"` FullName string `json:"full_name" binding:"MaxSize(100)"`
// required: true Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
// swagger:strfmt email Password string `json:"password" binding:"MaxSize(255)"`
Email string `json:"email" binding:"Required;Email;MaxSize(254)"` Website string `json:"website" binding:"MaxSize(50)"`
Password string `json:"password" binding:"MaxSize(255)"` Location string `json:"location" binding:"MaxSize(50)"`
Website string `json:"website" binding:"MaxSize(50)"` Active *bool `json:"active"`
Location string `json:"location" binding:"MaxSize(50)"` Admin *bool `json:"admin"`
Active *bool `json:"active"` AllowGitHook *bool `json:"allow_git_hook"`
Admin *bool `json:"admin"` AllowImportLocal *bool `json:"allow_import_local"`
AllowGitHook *bool `json:"allow_git_hook"` MaxRepoCreation *int `json:"max_repo_creation"`
AllowImportLocal *bool `json:"allow_import_local"`
MaxRepoCreation *int `json:"max_repo_creation"`
ProhibitLogin *bool `json:"prohibit_login"`
AllowCreateOrganization *bool `json:"allow_create_organization"`
} }
// AdminEditUser modify user informations // AdminEditUser modify user informations

View File

@ -1,92 +0,0 @@
// Copyright 2017 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package gitea // import "code.gitea.io/sdk/gitea"
import (
"bytes"
"encoding/json"
"fmt"
"io"
"mime/multipart"
"net/http"
"time"
)
// Attachment a generic attachment
// swagger:model
type Attachment struct {
ID int64 `json:"id"`
Name string `json:"name"`
Size int64 `json:"size"`
DownloadCount int64 `json:"download_count"`
// swagger:strfmt date-time
Created time.Time `json:"created_at"`
UUID string `json:"uuid"`
DownloadURL string `json:"browser_download_url"`
}
// ListReleaseAttachments list release's attachments
func (c *Client) ListReleaseAttachments(user, repo string, release int64) ([]*Attachment, error) {
attachments := make([]*Attachment, 0, 10)
err := c.getParsedResponse("GET",
fmt.Sprintf("/repos/%s/%s/releases/%d/assets", user, repo, release),
nil, nil, &attachments)
return attachments, err
}
// GetReleaseAttachment returns the requested attachment
func (c *Client) GetReleaseAttachment(user, repo string, release int64, id int64) (*Attachment, error) {
a := new(Attachment)
err := c.getParsedResponse("GET",
fmt.Sprintf("/repos/%s/%s/releases/%d/assets/%d", user, repo, release, id),
nil, nil, &a)
return a, err
}
// CreateReleaseAttachment creates an attachment for the given release
func (c *Client) CreateReleaseAttachment(user, repo string, release int64, file io.Reader, filename string) (*Attachment, error) {
// Write file to body
body := new(bytes.Buffer)
writer := multipart.NewWriter(body)
part, err := writer.CreateFormFile("attachment", filename)
if err != nil {
return nil, err
}
if _, err = io.Copy(part, file); err != nil {
return nil, err
}
if err = writer.Close(); err != nil {
return nil, err
}
// Send request
attachment := new(Attachment)
err = c.getParsedResponse("POST",
fmt.Sprintf("/repos/%s/%s/releases/%d/assets", user, repo, release),
http.Header{"Content-Type": {writer.FormDataContentType()}}, body, &attachment)
return attachment, err
}
// EditReleaseAttachment updates the given attachment with the given options
func (c *Client) EditReleaseAttachment(user, repo string, release int64, attachment int64, form EditAttachmentOptions) (*Attachment, error) {
body, err := json.Marshal(&form)
if err != nil {
return nil, err
}
attach := new(Attachment)
return attach, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/releases/%d/assets/%d", user, repo, release, attachment), jsonHeader, bytes.NewReader(body), attach)
}
// DeleteReleaseAttachment deletes the given attachment including the uploaded file
func (c *Client) DeleteReleaseAttachment(user, repo string, release int64, id int64) error {
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/releases/%d/assets/%d", user, repo, release, id), nil, nil)
return err
}
// EditAttachmentOptions options for editing attachments
// swagger:model
type EditAttachmentOptions struct {
Name string `json:"name"`
}

View File

@ -21,7 +21,6 @@ func (c *Client) ListForks(user, repo string) ([]*Repository, error) {
// CreateForkOption options for creating a fork // CreateForkOption options for creating a fork
type CreateForkOption struct { type CreateForkOption struct {
// organization name, if forking into an organization
Organization *string `json:"organization"` Organization *string `json:"organization"`
} }

View File

@ -7,7 +7,6 @@ package gitea
import ( import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -70,8 +69,6 @@ func (c *Client) getResponse(method, path string, header http.Header, body io.Re
return nil, errors.New("403 Forbidden") return nil, errors.New("403 Forbidden")
case 404: case 404:
return nil, errors.New("404 Not Found") return nil, errors.New("404 Not Found")
case 422:
return nil, fmt.Errorf("422 Unprocessable Entity: %s", string(data))
} }
if resp.StatusCode/100 != 2 { if resp.StatusCode/100 != 2 {

View File

@ -21,29 +21,24 @@ var (
// Hook a hook is a web hook when one repository changed // Hook a hook is a web hook when one repository changed
type Hook struct { type Hook struct {
ID int64 `json:"id"` ID int64 `json:"id"`
Type string `json:"type"` Type string `json:"type"`
URL string `json:"-"` URL string `json:"-"`
Config map[string]string `json:"config"` Config map[string]string `json:"config"`
Events []string `json:"events"` Events []string `json:"events"`
Active bool `json:"active"` Active bool `json:"active"`
// swagger:strfmt date-time Updated time.Time `json:"updated_at"`
Updated time.Time `json:"updated_at"` Created time.Time `json:"created_at"`
// swagger:strfmt date-time
Created time.Time `json:"created_at"`
} }
// HookList represents a list of API hook.
type HookList []*Hook
// ListOrgHooks list all the hooks of one organization // ListOrgHooks list all the hooks of one organization
func (c *Client) ListOrgHooks(org string) (HookList, error) { func (c *Client) ListOrgHooks(org string) ([]*Hook, error) {
hooks := make([]*Hook, 0, 10) hooks := make([]*Hook, 0, 10)
return hooks, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/hooks", org), nil, nil, &hooks) return hooks, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/hooks", org), nil, nil, &hooks)
} }
// ListRepoHooks list all the hooks of one repository // ListRepoHooks list all the hooks of one repository
func (c *Client) ListRepoHooks(user, repo string) (HookList, error) { func (c *Client) ListRepoHooks(user, repo string) ([]*Hook, error) {
hooks := make([]*Hook, 0, 10) hooks := make([]*Hook, 0, 10)
return hooks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks", user, repo), nil, nil, &hooks) return hooks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks", user, repo), nil, nil, &hooks)
} }
@ -62,14 +57,10 @@ func (c *Client) GetRepoHook(user, repo string, id int64) (*Hook, error) {
// CreateHookOption options when create a hook // CreateHookOption options when create a hook
type CreateHookOption struct { type CreateHookOption struct {
// required: true Type string `json:"type" binding:"Required"`
// enum: gitea,gogs,slack,discord
Type string `json:"type" binding:"Required"`
// required: true
Config map[string]string `json:"config" binding:"Required"` Config map[string]string `json:"config" binding:"Required"`
Events []string `json:"events"` Events []string `json:"events"`
// default: false Active bool `json:"active"`
Active bool `json:"active"`
} }
// CreateOrgHook create one hook for an organization, with options // CreateOrgHook create one hook for an organization, with options
@ -137,32 +128,25 @@ type Payloader interface {
JSONPayload() ([]byte, error) JSONPayload() ([]byte, error)
} }
// PayloadUser represents the author or committer of a commit // PayloadUser FIXME
type PayloadUser struct { type PayloadUser struct {
// Full name of the commit author Name string `json:"name"`
Name string `json:"name"`
// swagger:strfmt email
Email string `json:"email"` Email string `json:"email"`
UserName string `json:"username"` UserName string `json:"username"`
} }
// FIXME: consider using same format as API when commits API are added. // PayloadCommit FIXME: consider use same format as API when commits API are added.
// applies to PayloadCommit and PayloadCommitVerification
// PayloadCommit represents a commit
type PayloadCommit struct { type PayloadCommit struct {
// sha1 hash of the commit
ID string `json:"id"` ID string `json:"id"`
Message string `json:"message"` Message string `json:"message"`
URL string `json:"url"` URL string `json:"url"`
Author *PayloadUser `json:"author"` Author *PayloadUser `json:"author"`
Committer *PayloadUser `json:"committer"` Committer *PayloadUser `json:"committer"`
Verification *PayloadCommitVerification `json:"verification"` Verification *PayloadCommitVerification `json:"verification"`
// swagger:strfmt date-time Timestamp time.Time `json:"timestamp"`
Timestamp time.Time `json:"timestamp"`
} }
// PayloadCommitVerification represents the GPG verification of a commit // PayloadCommitVerification represent the GPG verification part of a commit. FIXME: like PayloadCommit consider use same format as API when commits API are added.
type PayloadCommitVerification struct { type PayloadCommitVerification struct {
Verified bool `json:"verified"` Verified bool `json:"verified"`
Reason string `json:"reason"` Reason string `json:"reason"`
@ -172,14 +156,9 @@ type PayloadCommitVerification struct {
var ( var (
_ Payloader = &CreatePayload{} _ Payloader = &CreatePayload{}
_ Payloader = &DeletePayload{}
_ Payloader = &ForkPayload{}
_ Payloader = &PushPayload{} _ Payloader = &PushPayload{}
_ Payloader = &IssuePayload{} _ Payloader = &IssuePayload{}
_ Payloader = &IssueCommentPayload{}
_ Payloader = &PullRequestPayload{} _ Payloader = &PullRequestPayload{}
_ Payloader = &RepositoryPayload{}
_ Payloader = &ReleasePayload{}
) )
// _________ __ // _________ __
@ -199,7 +178,7 @@ type CreatePayload struct {
Sender *User `json:"sender"` Sender *User `json:"sender"`
} }
// SetSecret modifies the secret of the CreatePayload // SetSecret FIXME
func (p *CreatePayload) SetSecret(secret string) { func (p *CreatePayload) SetSecret(secret string) {
p.Secret = secret p.Secret = secret
} }
@ -229,133 +208,6 @@ func ParseCreateHook(raw []byte) (*CreatePayload, error) {
return hook, nil return hook, nil
} }
// ________ .__ __
// \______ \ ____ | | _____/ |_ ____
// | | \_/ __ \| | _/ __ \ __\/ __ \
// | ` \ ___/| |_\ ___/| | \ ___/
// /_______ /\___ >____/\___ >__| \___ >
// \/ \/ \/ \/
// PusherType define the type to push
type PusherType string
// describe all the PusherTypes
const (
PusherTypeUser PusherType = "user"
)
// DeletePayload represents delete payload
type DeletePayload struct {
Secret string `json:"secret"`
Ref string `json:"ref"`
RefType string `json:"ref_type"`
PusherType PusherType `json:"pusher_type"`
Repo *Repository `json:"repository"`
Sender *User `json:"sender"`
}
// SetSecret modifies the secret of the DeletePayload
func (p *DeletePayload) SetSecret(secret string) {
p.Secret = secret
}
// JSONPayload implements Payload
func (p *DeletePayload) JSONPayload() ([]byte, error) {
return json.MarshalIndent(p, "", " ")
}
// ___________ __
// \_ _____/__________| | __
// | __)/ _ \_ __ \ |/ /
// | \( <_> ) | \/ <
// \___ / \____/|__| |__|_ \
// \/ \/
// ForkPayload represents fork payload
type ForkPayload struct {
Secret string `json:"secret"`
Forkee *Repository `json:"forkee"`
Repo *Repository `json:"repository"`
Sender *User `json:"sender"`
}
// SetSecret modifies the secret of the ForkPayload
func (p *ForkPayload) SetSecret(secret string) {
p.Secret = secret
}
// JSONPayload implements Payload
func (p *ForkPayload) JSONPayload() ([]byte, error) {
return json.MarshalIndent(p, "", " ")
}
// HookIssueCommentAction defines hook issue comment action
type HookIssueCommentAction string
// all issue comment actions
const (
HookIssueCommentCreated HookIssueCommentAction = "created"
HookIssueCommentEdited HookIssueCommentAction = "edited"
HookIssueCommentDeleted HookIssueCommentAction = "deleted"
)
// IssueCommentPayload represents a payload information of issue comment event.
type IssueCommentPayload struct {
Secret string `json:"secret"`
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"`
}
// SetSecret modifies the secret of the IssueCommentPayload
func (p *IssueCommentPayload) SetSecret(secret string) {
p.Secret = secret
}
// JSONPayload implements Payload
func (p *IssueCommentPayload) JSONPayload() ([]byte, error) {
return json.MarshalIndent(p, "", " ")
}
// __________ .__
// \______ \ ____ | | ____ _____ ______ ____
// | _// __ \| | _/ __ \\__ \ / ___// __ \
// | | \ ___/| |_\ ___/ / __ \_\___ \\ ___/
// |____|_ /\___ >____/\___ >____ /____ >\___ >
// \/ \/ \/ \/ \/ \/
// HookReleaseAction defines hook release action type
type HookReleaseAction string
// all release actions
const (
HookReleasePublished HookReleaseAction = "published"
HookReleaseUpdated HookReleaseAction = "updated"
HookReleaseDeleted HookReleaseAction = "deleted"
)
// ReleasePayload represents a payload information of release event.
type ReleasePayload struct {
Secret string `json:"secret"`
Action HookReleaseAction `json:"action"`
Release *Release `json:"release"`
Repository *Repository `json:"repository"`
Sender *User `json:"sender"`
}
// SetSecret modifies the secret of the ReleasePayload
func (p *ReleasePayload) SetSecret(secret string) {
p.Secret = secret
}
// JSONPayload implements Payload
func (p *ReleasePayload) JSONPayload() ([]byte, error) {
return json.MarshalIndent(p, "", " ")
}
// __________ .__ // __________ .__
// \______ \__ __ _____| |__ // \______ \__ __ _____| |__
// | ___/ | \/ ___/ | \ // | ___/ | \/ ___/ | \
@ -371,13 +223,12 @@ type PushPayload struct {
After string `json:"after"` After string `json:"after"`
CompareURL string `json:"compare_url"` CompareURL string `json:"compare_url"`
Commits []*PayloadCommit `json:"commits"` Commits []*PayloadCommit `json:"commits"`
HeadCommit *PayloadCommit `json:"head_commit"`
Repo *Repository `json:"repository"` Repo *Repository `json:"repository"`
Pusher *User `json:"pusher"` Pusher *User `json:"pusher"`
Sender *User `json:"sender"` Sender *User `json:"sender"`
} }
// SetSecret modifies the secret of the PushPayload // SetSecret FIXME
func (p *PushPayload) SetSecret(secret string) { func (p *PushPayload) SetSecret(secret string) {
p.Secret = secret p.Secret = secret
} }
@ -529,7 +380,7 @@ type RepositoryPayload struct {
Sender *User `json:"sender"` Sender *User `json:"sender"`
} }
// SetSecret modifies the secret of the RepositoryPayload // SetSecret set the payload's secret
func (p *RepositoryPayload) SetSecret(secret string) { func (p *RepositoryPayload) SetSecret(secret string) {
p.Secret = secret p.Secret = secret
} }

View File

@ -27,8 +27,7 @@ type PullRequestMeta struct {
Merged *time.Time `json:"merged_at"` Merged *time.Time `json:"merged_at"`
} }
// Issue represents an issue in a repository // Issue an issue to a repository
// swagger:model
type Issue struct { type Issue struct {
ID int64 `json:"id"` ID int64 `json:"id"`
URL string `json:"url"` URL string `json:"url"`
@ -39,21 +38,10 @@ type Issue struct {
Labels []*Label `json:"labels"` Labels []*Label `json:"labels"`
Milestone *Milestone `json:"milestone"` Milestone *Milestone `json:"milestone"`
Assignee *User `json:"assignee"` Assignee *User `json:"assignee"`
Assignees []*User `json:"assignees"` State StateType `json:"state"`
// Whether the issue is open or closed Comments int `json:"comments"`
// Created time.Time `json:"created_at"`
// type: string Updated time.Time `json:"updated_at"`
// enum: open,closed
State StateType `json:"state"`
Comments int `json:"comments"`
// swagger:strfmt date-time
Created time.Time `json:"created_at"`
// swagger:strfmt date-time
Updated time.Time `json:"updated_at"`
// swagger:strfmt date-time
Closed *time.Time `json:"closed_at"`
// swagger:strfmt date-time
Deadline *time.Time `json:"due_date"`
PullRequest *PullRequestMeta `json:"pull_request"` PullRequest *PullRequestMeta `json:"pull_request"`
} }
@ -90,19 +78,12 @@ func (c *Client) GetIssue(owner, repo string, index int64) (*Issue, error) {
// CreateIssueOption options to create one issue // CreateIssueOption options to create one issue
type CreateIssueOption struct { type CreateIssueOption struct {
// required:true Title string `json:"title" binding:"Required"`
Title string `json:"title" binding:"Required"` Body string `json:"body"`
Body string `json:"body"` Assignee string `json:"assignee"`
// username of assignee Milestone int64 `json:"milestone"`
Assignee string `json:"assignee"` Labels []int64 `json:"labels"`
Assignees []string `json:"assignees"` Closed bool `json:"closed"`
// swagger:strfmt date-time
Deadline *time.Time `json:"due_date"`
// milestone id
Milestone int64 `json:"milestone"`
// list of label ids
Labels []int64 `json:"labels"`
Closed bool `json:"closed"`
} }
// CreateIssue create a new issue for a given repository // CreateIssue create a new issue for a given repository
@ -116,16 +97,13 @@ func (c *Client) CreateIssue(owner, repo string, opt CreateIssueOption) (*Issue,
jsonHeader, bytes.NewReader(body), issue) jsonHeader, bytes.NewReader(body), issue)
} }
// EditIssueOption options for editing an issue // EditIssueOption edit issue options
type EditIssueOption struct { type EditIssueOption struct {
Title string `json:"title"` Title string `json:"title"`
Body *string `json:"body"` Body *string `json:"body"`
Assignee *string `json:"assignee"` Assignee *string `json:"assignee"`
Assignees []string `json:"assignees"` Milestone *int64 `json:"milestone"`
Milestone *int64 `json:"milestone"` State *string `json:"state"`
State *string `json:"state"`
// swagger:strfmt date-time
Deadline *time.Time `json:"due_date"`
} }
// EditIssue modify an existing issue for a given repository // EditIssue modify an existing issue for a given repository
@ -138,23 +116,3 @@ func (c *Client) EditIssue(owner, repo string, index int64, opt EditIssueOption)
return issue, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index), return issue, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index),
jsonHeader, bytes.NewReader(body), issue) jsonHeader, bytes.NewReader(body), issue)
} }
// EditDeadlineOption options for creating a deadline
type EditDeadlineOption struct {
// required:true
// swagger:strfmt date-time
Deadline *time.Time `json:"due_date"`
}
// IssueDeadline represents an issue deadline
// swagger:model
type IssueDeadline struct {
// swagger:strfmt date-time
Deadline *time.Time `json:"due_date"`
}
// EditPriorityOption options for updating priority
type EditPriorityOption struct {
// required:true
Priority int `json:"priority"`
}

View File

@ -11,18 +11,16 @@ import (
"time" "time"
) )
// Comment represents a comment on a commit or issue // Comment represents a comment in commit and issue page.
type Comment struct { type Comment struct {
ID int64 `json:"id"` ID int64 `json:"id"`
HTMLURL string `json:"html_url"` HTMLURL string `json:"html_url"`
PRURL string `json:"pull_request_url"` PRURL string `json:"pull_request_url"`
IssueURL string `json:"issue_url"` IssueURL string `json:"issue_url"`
Poster *User `json:"user"` Poster *User `json:"user"`
Body string `json:"body"` Body string `json:"body"`
// swagger:strfmt date-time Created time.Time `json:"created_at"`
Created time.Time `json:"created_at"` Updated time.Time `json:"updated_at"`
// swagger:strfmt date-time
Updated time.Time `json:"updated_at"`
} }
// ListIssueComments list comments on an issue. // ListIssueComments list comments on an issue.
@ -37,9 +35,8 @@ func (c *Client) ListRepoIssueComments(owner, repo string) ([]*Comment, error) {
return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/comments", owner, repo), nil, nil, &comments) return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/comments", owner, repo), nil, nil, &comments)
} }
// CreateIssueCommentOption options for creating a comment on an issue // CreateIssueCommentOption is option when creating an issue comment.
type CreateIssueCommentOption struct { type CreateIssueCommentOption struct {
// required:true
Body string `json:"body" binding:"Required"` Body string `json:"body" binding:"Required"`
} }
@ -53,9 +50,8 @@ func (c *Client) CreateIssueComment(owner, repo string, index int64, opt CreateI
return comment, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), jsonHeader, bytes.NewReader(body), comment) return comment, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), jsonHeader, bytes.NewReader(body), comment)
} }
// EditIssueCommentOption options for editing a comment // EditIssueCommentOption is option when editing an issue comment.
type EditIssueCommentOption struct { type EditIssueCommentOption struct {
// required: true
Body string `json:"body" binding:"Required"` Body string `json:"body" binding:"Required"`
} }

View File

@ -11,16 +11,14 @@ import (
) )
// Label a label to an issue or a pr // Label a label to an issue or a pr
// swagger:model
type Label struct { type Label struct {
ID int64 `json:"id"` ID int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
// example: 00aabb
Color string `json:"color"` Color string `json:"color"`
URL string `json:"url"` URL string `json:"url"`
} }
// ListRepoLabels list labels of one repository // ListRepoLabels list lables of one reppsitory
func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error) { func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error) {
labels := make([]*Label, 0, 10) labels := make([]*Label, 0, 10)
return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels", owner, repo), nil, nil, &labels) return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels", owner, repo), nil, nil, &labels)
@ -33,12 +31,9 @@ func (c *Client) GetRepoLabel(owner, repo string, id int64) (*Label, error) {
return label, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil, label) return label, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil, label)
} }
// CreateLabelOption options for creating a label // CreateLabelOption create options when one label of repository
type CreateLabelOption struct { type CreateLabelOption struct {
// required:true Name string `json:"name" binding:"Required"`
Name string `json:"name" binding:"Required"`
// required:true
// example: #00aabb
Color string `json:"color" binding:"Required;Size(7)"` Color string `json:"color" binding:"Required;Size(7)"`
} }
@ -53,7 +48,7 @@ func (c *Client) CreateLabel(owner, repo string, opt CreateLabelOption) (*Label,
jsonHeader, bytes.NewReader(body), label) jsonHeader, bytes.NewReader(body), label)
} }
// EditLabelOption options for editing a label // EditLabelOption edit label options
type EditLabelOption struct { type EditLabelOption struct {
Name *string `json:"name"` Name *string `json:"name"`
Color *string `json:"color"` Color *string `json:"color"`
@ -76,9 +71,8 @@ func (c *Client) DeleteLabel(owner, repo string, id int64) error {
return err return err
} }
// IssueLabelsOption a collection of labels // IssueLabelsOption list one issue's labels options
type IssueLabelsOption struct { type IssueLabelsOption struct {
// list of label IDs
Labels []int64 `json:"labels"` Labels []int64 `json:"labels"`
} }

View File

@ -13,16 +13,14 @@ import (
// Milestone milestone is a collection of issues on one repository // Milestone milestone is a collection of issues on one repository
type Milestone struct { type Milestone struct {
ID int64 `json:"id"` ID int64 `json:"id"`
Title string `json:"title"` Title string `json:"title"`
Description string `json:"description"` Description string `json:"description"`
State StateType `json:"state"` State StateType `json:"state"`
OpenIssues int `json:"open_issues"` OpenIssues int `json:"open_issues"`
ClosedIssues int `json:"closed_issues"` ClosedIssues int `json:"closed_issues"`
// swagger:strfmt date-time Closed *time.Time `json:"closed_at"`
Closed *time.Time `json:"closed_at"` Deadline *time.Time `json:"due_on"`
// swagger:strfmt date-time
Deadline *time.Time `json:"due_on"`
} }
// ListRepoMilestones list all the milestones of one repository // ListRepoMilestones list all the milestones of one repository
@ -37,12 +35,11 @@ func (c *Client) GetMilestone(owner, repo string, id int64) (*Milestone, error)
return milestone, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil, milestone) return milestone, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil, milestone)
} }
// CreateMilestoneOption options for creating a milestone // CreateMilestoneOption options when creating milestone
type CreateMilestoneOption struct { type CreateMilestoneOption struct {
Title string `json:"title"` Title string `json:"title"`
Description string `json:"description"` Description string `json:"description"`
// swagger:strfmt date-time Deadline *time.Time `json:"due_on"`
Deadline *time.Time `json:"due_on"`
} }
// CreateMilestone create one milestone with options // CreateMilestone create one milestone with options
@ -55,7 +52,7 @@ func (c *Client) CreateMilestone(owner, repo string, opt CreateMilestoneOption)
return milestone, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo), jsonHeader, bytes.NewReader(body), milestone) return milestone, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo), jsonHeader, bytes.NewReader(body), milestone)
} }
// EditMilestoneOption options for editing a milestone // EditMilestoneOption options when modify milestone
type EditMilestoneOption struct { type EditMilestoneOption struct {
Title string `json:"title"` Title string `json:"title"`
Description *string `json:"description"` Description *string `json:"description"`

View File

@ -1,68 +0,0 @@
// Copyright 2017 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package gitea
import (
"bytes"
"encoding/json"
"fmt"
"time"
)
// TrackedTime worked time for an issue / pr
type TrackedTime struct {
ID int64 `json:"id"`
// swagger:strfmt date-time
Created time.Time `json:"created"`
// Time in seconds
Time int64 `json:"time"`
UserID int64 `json:"user_id"`
IssueID int64 `json:"issue_id"`
}
// TrackedTimes represent a list of tracked times
type TrackedTimes []*TrackedTime
// GetUserTrackedTimes list tracked times of a user
func (c *Client) GetUserTrackedTimes(owner, repo, user string) (TrackedTimes, error) {
times := make(TrackedTimes, 0, 10)
return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times/%s", owner, repo, user), nil, nil, &times)
}
// GetRepoTrackedTimes list tracked times of a repository
func (c *Client) GetRepoTrackedTimes(owner, repo string) (TrackedTimes, error) {
times := make(TrackedTimes, 0, 10)
return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times", owner, repo), nil, nil, &times)
}
// GetMyTrackedTimes list tracked times of the current user
func (c *Client) GetMyTrackedTimes() (TrackedTimes, error) {
times := make(TrackedTimes, 0, 10)
return times, c.getParsedResponse("GET", "/user/times", nil, nil, &times)
}
// AddTimeOption options for adding time to an issue
type AddTimeOption struct {
// time in seconds
// required: true
Time int64 `json:"time" binding:"Required"`
}
// AddTime adds time to issue with the given index
func (c *Client) AddTime(owner, repo string, index int64, opt AddTimeOption) (*TrackedTime, error) {
body, err := json.Marshal(&opt)
if err != nil {
return nil, err
}
t := new(TrackedTime)
return t, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index),
jsonHeader, bytes.NewReader(body), t)
}
// ListTrackedTimes get tracked times of one issue via issue id
func (c *Client) ListTrackedTimes(owner, repo string, index int64) (TrackedTimes, error) {
times := make(TrackedTimes, 0, 5)
return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), nil, nil, &times)
}

View File

@ -1,65 +0,0 @@
// Copyright 2017 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package gitea
import (
"time"
)
// LFSLock represent a lock
// for use with the locks API.
type LFSLock struct {
ID string `json:"id"`
Path string `json:"path"`
LockedAt time.Time `json:"locked_at"`
Owner *LFSLockOwner `json:"owner"`
}
// LFSLockOwner represent a lock owner
// for use with the locks API.
type LFSLockOwner struct {
Name string `json:"name"`
}
// LFSLockRequest contains the path of the lock to create
// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#create-lock
type LFSLockRequest struct {
Path string `json:"path"`
}
// LFSLockResponse represent a lock created
// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#create-lock
type LFSLockResponse struct {
Lock *LFSLock `json:"lock"`
}
// LFSLockList represent a list of lock requested
// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#list-locks
type LFSLockList struct {
Locks []*LFSLock `json:"locks"`
Next string `json:"next_cursor,omitempty"`
}
// LFSLockListVerify represent a list of lock verification requested
// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#list-locks-for-verification
type LFSLockListVerify struct {
Ours []*LFSLock `json:"ours"`
Theirs []*LFSLock `json:"theirs"`
Next string `json:"next_cursor,omitempty"`
}
// LFSLockError contains information on the error that occurs
type LFSLockError struct {
Message string `json:"message"`
Lock *LFSLock `json:"lock,omitempty"`
Documentation string `json:"documentation_url,omitempty"`
RequestID string `json:"request_id,omitempty"`
}
// LFSLockDeleteRequest contains params of a delete request
// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#delete-lock
type LFSLockDeleteRequest struct {
Force bool `json:"force"`
}

View File

@ -4,19 +4,22 @@
package gitea package gitea
// SearchResults results of a successful search // SearchResults results of search
// swagger:response SearchResults
type SearchResults struct { type SearchResults struct {
OK bool `json:"ok"` OK bool `json:"ok"`
Data []*Repository `json:"data"` Data []*Repository `json:"data"`
} }
// SearchError error of a failed search // SearchError error of failing search
// swagger:response SearchError
type SearchError struct { type SearchError struct {
OK bool `json:"ok"` OK bool `json:"ok"`
Error string `json:"error"` Error string `json:"error"`
} }
// MarkdownOption markdown options // MarkdownOption markdown options
// swagger:parameters renderMarkdown
type MarkdownOption struct { type MarkdownOption struct {
// Text markdown to render // Text markdown to render
// //
@ -41,8 +44,9 @@ type MarkdownOption struct {
type MarkdownRender string type MarkdownRender string
// ServerVersion wraps the version of the server // ServerVersion wraps the version of the server
// swagger:response ServerVersion
type ServerVersion struct { type ServerVersion struct {
Version string `json:"version"` Version string
} }
// ServerVersion returns the version of the server // ServerVersion returns the version of the server

View File

@ -10,7 +10,7 @@ import (
"fmt" "fmt"
) )
// Organization represents an organization // Organization a group of some repositories, users and teams
type Organization struct { type Organization struct {
ID int64 `json:"id"` ID int64 `json:"id"`
UserName string `json:"username"` UserName string `json:"username"`
@ -39,9 +39,8 @@ func (c *Client) GetOrg(orgname string) (*Organization, error) {
return org, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s", orgname), nil, nil, org) return org, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s", orgname), nil, nil, org)
} }
// CreateOrgOption options for creating an organization // CreateOrgOption create one organization options
type CreateOrgOption struct { type CreateOrgOption struct {
// required: true
UserName string `json:"username" binding:"Required"` UserName string `json:"username" binding:"Required"`
FullName string `json:"full_name"` FullName string `json:"full_name"`
Description string `json:"description"` Description string `json:"description"`
@ -49,7 +48,7 @@ type CreateOrgOption struct {
Location string `json:"location"` Location string `json:"location"`
} }
// EditOrgOption options for editing an organization // EditOrgOption edit one organization options
type EditOrgOption struct { type EditOrgOption struct {
FullName string `json:"full_name"` FullName string `json:"full_name"`
Description string `json:"description"` Description string `json:"description"`

View File

@ -1,39 +1,27 @@
// Copyright 2016 The Gogs Authors. All rights reserved. // Copyright 2016 The Gogs Authors. All rights reserved.
// Copyright 2018 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package gitea package gitea
// Team represents a team in an organization // Team is a sub virtual organization of one Organization
type Team struct { type Team struct {
ID int64 `json:"id"` ID int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description"` Description string `json:"description"`
// enum: none,read,write,admin,owner Permission string `json:"permission"`
Permission string `json:"permission"`
// enum: repo.code,repo.issues,repo.ext_issues,repo.wiki,repo.pulls,repo.releases,repo.ext_wiki
Units []string `json:"units"`
} }
// CreateTeamOption options for creating a team // CreateTeamOption options when create team
type CreateTeamOption struct { type CreateTeamOption struct {
// required: true
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"` Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"`
Description string `json:"description" binding:"MaxSize(255)"` Description string `json:"description" binding:"MaxSize(255)"`
// enum: read,write,admin Permission string `json:"permission"`
Permission string `json:"permission"`
// enum: repo.code,repo.issues,repo.ext_issues,repo.wiki,repo.pulls,repo.releases,repo.ext_wiki
Units []string `json:"units"`
} }
// EditTeamOption options for editing a team // EditTeamOption options when edit team
type EditTeamOption struct { type EditTeamOption struct {
// required: true
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"` Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"`
Description string `json:"description" binding:"MaxSize(255)"` Description string `json:"description" binding:"MaxSize(255)"`
// enum: read,write,admin Permission string `json:"permission"`
Permission string `json:"permission"`
// enum: repo.code,repo.issues,repo.ext_issues,repo.wiki,repo.pulls,repo.releases,repo.ext_wiki
Units []string `json:"units"`
} }

View File

@ -11,7 +11,7 @@ import (
"time" "time"
) )
// PullRequest represents a pull request // PullRequest represents a pull request API object.
type PullRequest struct { type PullRequest struct {
ID int64 `json:"id"` ID int64 `json:"id"`
URL string `json:"url"` URL string `json:"url"`
@ -22,7 +22,6 @@ type PullRequest struct {
Labels []*Label `json:"labels"` Labels []*Label `json:"labels"`
Milestone *Milestone `json:"milestone"` Milestone *Milestone `json:"milestone"`
Assignee *User `json:"assignee"` Assignee *User `json:"assignee"`
Assignees []*User `json:"assignees"`
State StateType `json:"state"` State StateType `json:"state"`
Comments int `json:"comments"` Comments int `json:"comments"`
@ -30,9 +29,8 @@ type PullRequest struct {
DiffURL string `json:"diff_url"` DiffURL string `json:"diff_url"`
PatchURL string `json:"patch_url"` PatchURL string `json:"patch_url"`
Mergeable bool `json:"mergeable"` Mergeable bool `json:"mergeable"`
HasMerged bool `json:"merged"` HasMerged bool `json:"merged"`
// swagger:strfmt date-time
Merged *time.Time `json:"merged_at"` Merged *time.Time `json:"merged_at"`
MergedCommitID *string `json:"merge_commit_sha"` MergedCommitID *string `json:"merge_commit_sha"`
MergedBy *User `json:"merged_by"` MergedBy *User `json:"merged_by"`
@ -41,18 +39,11 @@ type PullRequest struct {
Head *PRBranchInfo `json:"head"` Head *PRBranchInfo `json:"head"`
MergeBase string `json:"merge_base"` MergeBase string `json:"merge_base"`
// swagger:strfmt date-time
Deadline *time.Time `json:"due_date"`
// swagger:strfmt date-time
Created *time.Time `json:"created_at"` Created *time.Time `json:"created_at"`
// swagger:strfmt date-time
Updated *time.Time `json:"updated_at"` Updated *time.Time `json:"updated_at"`
// swagger:strfmt date-time
Closed *time.Time `json:"closed_at"`
} }
// PRBranchInfo information about a branch // PRBranchInfo base branch info when send a PR
type PRBranchInfo struct { type PRBranchInfo struct {
Name string `json:"label"` Name string `json:"label"`
Ref string `json:"ref"` Ref string `json:"ref"`
@ -61,7 +52,7 @@ type PRBranchInfo struct {
Repository *Repository `json:"repo"` Repository *Repository `json:"repo"`
} }
// ListPullRequestsOptions options for listing pull requests // ListPullRequestsOptions options when list PRs
type ListPullRequestsOptions struct { type ListPullRequestsOptions struct {
Page int `json:"page"` Page int `json:"page"`
State string `json:"state"` State string `json:"state"`
@ -85,16 +76,13 @@ func (c *Client) GetPullRequest(owner, repo string, index int64) (*PullRequest,
// CreatePullRequestOption options when creating a pull request // CreatePullRequestOption options when creating a pull request
type CreatePullRequestOption struct { type CreatePullRequestOption struct {
Head string `json:"head" binding:"Required"` Head string `json:"head" binding:"Required"`
Base string `json:"base" binding:"Required"` Base string `json:"base" binding:"Required"`
Title string `json:"title" binding:"Required"` Title string `json:"title" binding:"Required"`
Body string `json:"body"` Body string `json:"body"`
Assignee string `json:"assignee"` Assignee string `json:"assignee"`
Assignees []string `json:"assignees"` Milestone int64 `json:"milestone"`
Milestone int64 `json:"milestone"` Labels []int64 `json:"labels"`
Labels []int64 `json:"labels"`
// swagger:strfmt date-time
Deadline *time.Time `json:"due_date"`
} }
// CreatePullRequest create pull request with options // CreatePullRequest create pull request with options
@ -110,15 +98,12 @@ func (c *Client) CreatePullRequest(owner, repo string, opt CreatePullRequestOpti
// EditPullRequestOption options when modify pull request // EditPullRequestOption options when modify pull request
type EditPullRequestOption struct { type EditPullRequestOption struct {
Title string `json:"title"` Title string `json:"title"`
Body string `json:"body"` Body string `json:"body"`
Assignee string `json:"assignee"` Assignee string `json:"assignee"`
Assignees []string `json:"assignees"` Milestone int64 `json:"milestone"`
Milestone int64 `json:"milestone"` Labels []int64 `json:"labels"`
Labels []int64 `json:"labels"` State *string `json:"state"`
State *string `json:"state"`
// swagger:strfmt date-time
Deadline *time.Time `json:"due_date"`
} }
// EditPullRequest modify pull request with PR id and options // EditPullRequest modify pull request with PR id and options

View File

@ -13,22 +13,19 @@ import (
// Release represents a repository release // Release represents a repository release
type Release struct { type Release struct {
ID int64 `json:"id"` ID int64 `json:"id"`
TagName string `json:"tag_name"` TagName string `json:"tag_name"`
Target string `json:"target_commitish"` Target string `json:"target_commitish"`
Title string `json:"name"` Title string `json:"name"`
Note string `json:"body"` Note string `json:"body"`
URL string `json:"url"` URL string `json:"url"`
TarURL string `json:"tarball_url"` TarURL string `json:"tarball_url"`
ZipURL string `json:"zipball_url"` ZipURL string `json:"zipball_url"`
IsDraft bool `json:"draft"` IsDraft bool `json:"draft"`
IsPrerelease bool `json:"prerelease"` IsPrerelease bool `json:"prerelease"`
// swagger:strfmt date-time CreatedAt time.Time `json:"created_at"`
CreatedAt time.Time `json:"created_at"` PublishedAt time.Time `json:"published_at"`
// swagger:strfmt date-time Publisher *User `json:"author"`
PublishedAt time.Time `json:"published_at"`
Publisher *User `json:"author"`
Attachments []*Attachment `json:"assets"`
} }
// ListReleases list releases of a repository // ListReleases list releases of a repository
@ -51,9 +48,8 @@ func (c *Client) GetRelease(user, repo string, id int64) (*Release, error) {
// CreateReleaseOption options when creating a release // CreateReleaseOption options when creating a release
type CreateReleaseOption struct { type CreateReleaseOption struct {
// required: true
TagName string `json:"tag_name" binding:"Required"` TagName string `json:"tag_name" binding:"Required"`
Target string `json:"target_commitish" binding:"Required"` Target string `json:"target_commitish"`
Title string `json:"name"` Title string `json:"name"`
Note string `json:"body"` Note string `json:"body"`
IsDraft bool `json:"draft"` IsDraft bool `json:"draft"`

View File

@ -11,14 +11,15 @@ import (
"time" "time"
) )
// Permission represents a set of permissions // Permission represents a API permission.
type Permission struct { type Permission struct {
Admin bool `json:"admin"` Admin bool `json:"admin"`
Push bool `json:"push"` Push bool `json:"push"`
Pull bool `json:"pull"` Pull bool `json:"pull"`
} }
// Repository represents a repository // Repository represents a API repository.
// swagger:response Repository
type Repository struct { type Repository struct {
ID int64 `json:"id"` ID int64 `json:"id"`
Owner *User `json:"owner"` Owner *User `json:"owner"`
@ -40,14 +41,15 @@ type Repository struct {
Watchers int `json:"watchers_count"` Watchers int `json:"watchers_count"`
OpenIssues int `json:"open_issues_count"` OpenIssues int `json:"open_issues_count"`
DefaultBranch string `json:"default_branch"` DefaultBranch string `json:"default_branch"`
Archived bool `json:"archived"` Created time.Time `json:"created_at"`
// swagger:strfmt date-time Updated time.Time `json:"updated_at"`
Created time.Time `json:"created_at"` Permissions *Permission `json:"permissions,omitempty"`
// swagger:strfmt date-time
Updated time.Time `json:"updated_at"`
Permissions *Permission `json:"permissions,omitempty"`
} }
// RepositoryList represents a list of API repository.
// swagger:response RepositoryList
type RepositoryList []*Repository
// ListMyRepos lists all repositories for the authenticated user that has access to. // ListMyRepos lists all repositories for the authenticated user that has access to.
func (c *Client) ListMyRepos() ([]*Repository, error) { func (c *Client) ListMyRepos() ([]*Repository, error) {
repos := make([]*Repository, 0, 10) repos := make([]*Repository, 0, 10)
@ -67,24 +69,36 @@ func (c *Client) ListOrgRepos(org string) ([]*Repository, error) {
} }
// CreateRepoOption options when creating repository // CreateRepoOption options when creating repository
// swagger:model //swagger:parameters createOrgRepo
type CreateRepoOption struct { type CreateRepoOption struct {
// Name of the repository to create // Name of the repository to create
// //
// required: true // in: body
// unique: true // unique: true
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"` Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
// Description of the repository to create // Description of the repository to create
//
// in: body
Description string `json:"description" binding:"MaxSize(255)"` Description string `json:"description" binding:"MaxSize(255)"`
// Whether the repository is private // Is the repository to create private ?
//
// in: body
Private bool `json:"private"` Private bool `json:"private"`
// Whether the repository should be auto-intialized? // Init the repository to create ?
//
// in: body
AutoInit bool `json:"auto_init"` AutoInit bool `json:"auto_init"`
// Gitignores to use // Gitignores to use
//
// in: body
Gitignores string `json:"gitignores"` Gitignores string `json:"gitignores"`
// License to use // License to use
//
// in: body
License string `json:"license"` License string `json:"license"`
// Readme of the repository to create // Readme of the repository to create
//
// in: body
Readme string `json:"readme"` Readme string `json:"readme"`
} }
@ -120,19 +134,16 @@ func (c *Client) DeleteRepo(owner, repo string) error {
return err return err
} }
// MigrateRepoOption options for migrating a repository from an external service // MigrateRepoOption options when migrate repository from an external place
type MigrateRepoOption struct { type MigrateRepoOption struct {
// required: true
CloneAddr string `json:"clone_addr" binding:"Required"` CloneAddr string `json:"clone_addr" binding:"Required"`
AuthUsername string `json:"auth_username"` AuthUsername string `json:"auth_username"`
AuthPassword string `json:"auth_password"` AuthPassword string `json:"auth_password"`
// required: true UID int `json:"uid" binding:"Required"`
UID int `json:"uid" binding:"Required"` RepoName string `json:"repo_name" binding:"Required"`
// required: true Mirror bool `json:"mirror"`
RepoName string `json:"repo_name" binding:"Required"` Private bool `json:"private"`
Mirror bool `json:"mirror"` Description string `json:"description"`
Private bool `json:"private"`
Description string `json:"description"`
} }
// MigrateRepo migrates a repository from other Git hosting sources for the // MigrateRepo migrates a repository from other Git hosting sources for the

View File

@ -8,7 +8,7 @@ import (
"fmt" "fmt"
) )
// Branch represents a repository branch // Branch represents a repository branch.
type Branch struct { type Branch struct {
Name string `json:"name"` Name string `json:"name"`
Commit *PayloadCommit `json:"commit"` Commit *PayloadCommit `json:"commit"`

View File

@ -33,7 +33,7 @@ func (c *Client) IsCollaborator(user, repo, collaborator string) (bool, error) {
return false, nil return false, nil
} }
// AddCollaboratorOption options when adding a user as a collaborator of a repository // AddCollaboratorOption options when add some user as a collaborator of a repository
type AddCollaboratorOption struct { type AddCollaboratorOption struct {
Permission *string `json:"permission"` Permission *string `json:"permission"`
} }

View File

@ -13,16 +13,12 @@ import (
// DeployKey a deploy key // DeployKey a deploy key
type DeployKey struct { type DeployKey struct {
ID int64 `json:"id"` ID int64 `json:"id"`
KeyID int64 `json:"key_id"` Key string `json:"key"`
Key string `json:"key"` URL string `json:"url"`
URL string `json:"url"` Title string `json:"title"`
Title string `json:"title"` Created time.Time `json:"created_at"`
Fingerprint string `json:"fingerprint"` ReadOnly bool `json:"read_only"`
// swagger:strfmt date-time
Created time.Time `json:"created_at"`
ReadOnly bool `json:"read_only"`
Repository *Repository `json:"repository,omitempty"`
} }
// ListDeployKeys list all the deploy keys of one repository // ListDeployKeys list all the deploy keys of one repository
@ -37,22 +33,21 @@ func (c *Client) GetDeployKey(user, repo string, keyID int64) (*DeployKey, error
return key, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/keys/%d", user, repo, keyID), nil, nil, &key) return key, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/keys/%d", user, repo, keyID), nil, nil, &key)
} }
// CreateKeyOption options when creating a key // CreateKeyOption options when create deploy key
// swagger:parameters userCurrentPostKey
type CreateKeyOption struct { type CreateKeyOption struct {
// Title of the key to add // Title of the key to add
// //
// in: body
// required: true // required: true
// unique: true // unique: true
Title string `json:"title" binding:"Required"` Title string `json:"title" binding:"Required"`
// An armored SSH key to add // An armored SSH key to add
// //
// in: body
// required: true // required: true
// unique: true // unique: true
Key string `json:"key" binding:"Required"` Key string `json:"key" binding:"Required"`
// Describe if the key has only read access or read/write
//
// required: false
ReadOnly bool `json:"read_only"`
} }
// CreateDeployKey options when create one deploy key // CreateDeployKey options when create one deploy key

View File

@ -1,69 +0,0 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package gitea
import (
"encoding/json"
"errors"
"fmt"
"strings"
)
// Reference represents a Git reference.
type Reference struct {
Ref string `json:"ref"`
URL string `json:"url"`
Object *GitObject `json:"object"`
}
// GitObject represents a Git object.
type GitObject struct {
Type string `json:"type"`
SHA string `json:"sha"`
URL string `json:"url"`
}
// GetRepoRef get one ref's information of one repository
func (c *Client) GetRepoRef(user, repo, ref string) (*Reference, error) {
ref = strings.TrimPrefix(ref, "refs/")
r := new(Reference)
err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/git/refs/%s", user, repo, ref), nil, nil, &r)
if _, ok := err.(*json.UnmarshalTypeError); ok {
// Multiple refs
return nil, errors.New("no exact match found for this ref")
} else if err != nil {
return nil, err
}
return r, nil
}
// GetRepoRefs get list of ref's information of one repository
func (c *Client) GetRepoRefs(user, repo, ref string) ([]*Reference, error) {
ref = strings.TrimPrefix(ref, "refs/")
resp, err := c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/git/refs/%s", user, repo, ref), nil, nil)
if err != nil {
return nil, err
}
// Attempt to unmarshal single returned ref.
r := new(Reference)
refErr := json.Unmarshal(resp, r)
if refErr == nil {
return []*Reference{r}, nil
}
// Attempt to unmarshal multiple refs.
var rs []*Reference
refsErr := json.Unmarshal(resp, &rs)
if refsErr == nil {
if len(rs) == 0 {
return nil, errors.New("unexpected response: an array of refs with length 0")
}
return rs, nil
}
return nil, fmt.Errorf("unmarshalling failed for both single and multiple refs: %s and %s", refErr, refsErr)
}

View File

@ -1,39 +0,0 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package gitea
import (
"fmt"
)
// GitEntry represents a git tree
type GitEntry struct {
Path string `json:"path"`
Mode string `json:"mode"`
Type string `json:"type"`
Size int64 `json:"size"`
SHA string `json:"sha"`
URL string `json:"url"`
}
// GitTreeResponse returns a git tree
type GitTreeResponse struct {
SHA string `json:"sha"`
URL string `json:"url"`
Entries []GitEntry `json:"tree"`
Truncated bool `json:"truncated"`
}
// GetTrees downloads a file of repository, ref can be branch/tag/commit.
// e.g.: ref -> master, tree -> macaron.go(no leading slash)
func (c *Client) GetTrees(user, repo, ref string, recursive bool) (*GitTreeResponse, error) {
var trees GitTreeResponse
var path = fmt.Sprintf("/repos/%s/%s/git/trees/%s", user, repo, ref)
if recursive {
path += "?recursive=1"
}
err := c.getParsedResponse("GET", path, nil, nil, &trees)
return &trees, err
}

View File

@ -10,7 +10,8 @@ import (
"time" "time"
) )
// WatchInfo represents an API watch status of one repository // WatchInfo represents a API watch status of one repository
// swagger:response WatchInfo
type WatchInfo struct { type WatchInfo struct {
Subscribed bool `json:"subscribed"` Subscribed bool `json:"subscribed"`
Ignored bool `json:"ignored"` Ignored bool `json:"ignored"`

View File

@ -21,7 +21,7 @@ const (
// StatusSuccess is for when the Status is Success // StatusSuccess is for when the Status is Success
StatusSuccess StatusState = "success" StatusSuccess StatusState = "success"
// StatusError is for when the Status is Error // StatusError is for when the Status is Error
StatusError StatusState = "error" StatusError StatusState = "error"
// StatusFailure is for when the Status is Failure // StatusFailure is for when the Status is Failure
StatusFailure StatusState = "failure" StatusFailure StatusState = "failure"
// StatusWarning is for when the Status is Warning // StatusWarning is for when the Status is Warning
@ -37,10 +37,8 @@ type Status struct {
URL string `json:"url"` URL string `json:"url"`
Context string `json:"context"` Context string `json:"context"`
Creator *User `json:"creator"` Creator *User `json:"creator"`
// swagger:strfmt date-time Created time.Time `json:"created_at"`
Created time.Time `json:"created_at"` Updated time.Time `json:"updated_at"`
// swagger:strfmt date-time
Updated time.Time `json:"updated_at"`
} }
// CombinedStatus holds the combined state of several statuses for a single commit // CombinedStatus holds the combined state of several statuses for a single commit

View File

@ -9,23 +9,20 @@ import (
"fmt" "fmt"
) )
// User represents a user // User represents a API user.
// swagger:model // swagger:response User
type User struct { type User struct {
// the user's id ID int64 `json:"id"`
ID int64 `json:"id"` UserName string `json:"login"`
// the user's username FullName string `json:"full_name"`
UserName string `json:"login"` Email string `json:"email"`
// the user's full name
FullName string `json:"full_name"`
// swagger:strfmt email
Email string `json:"email"`
// URL to the user's avatar
AvatarURL string `json:"avatar_url"` AvatarURL string `json:"avatar_url"`
// User locale
Language string `json:"language"`
} }
// UserList represents a list of API user.
// swagger:response UserList
type UserList []*User
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility // MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
func (u User) MarshalJSON() ([]byte, error) { func (u User) MarshalJSON() ([]byte, error) {
// Re-declaring User to avoid recursion // Re-declaring User to avoid recursion
@ -42,10 +39,3 @@ func (c *Client) GetUserInfo(user string) (*User, error) {
err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s", user), nil, nil, u) err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s", user), nil, nil, u)
return u, err return u, err
} }
// GetMyUserInfo get user info of current user
func (c *Client) GetMyUserInfo() (*User, error) {
u := new(User)
err := c.getParsedResponse("GET", "/user", nil, nil, u)
return u, err
}

View File

@ -20,14 +20,13 @@ func BasicAuthEncode(user, pass string) string {
// AccessToken represents a API access token. // AccessToken represents a API access token.
// swagger:response AccessToken // swagger:response AccessToken
type AccessToken struct { type AccessToken struct {
ID int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Sha1 string `json:"sha1"` Sha1 string `json:"sha1"`
} }
// AccessTokenList represents a list of API access token. // AccessTokenList represents a list of API access token.
// swagger:response AccessTokenList // swagger:response AccessTokenList
type AccessTokenList []*AccessToken type AccessTokenList []*AccessToken
// ListAccessTokens lista all the access tokens of user // ListAccessTokens lista all the access tokens of user
func (c *Client) ListAccessTokens(user, pass string) ([]*AccessToken, error) { func (c *Client) ListAccessTokens(user, pass string) ([]*AccessToken, error) {
@ -55,9 +54,3 @@ func (c *Client) CreateAccessToken(user, pass string, opt CreateAccessTokenOptio
"Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}}, "Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}},
bytes.NewReader(body), t) bytes.NewReader(body), t)
} }
// DeleteAccessToken delete token with key id
func (c *Client) DeleteAccessToken(user string, keyID int64) error {
_, err := c.getResponse("DELETE", fmt.Sprintf("/user/%s/tokens/%d", user, keyID), nil, nil)
return err
}

View File

@ -9,9 +9,8 @@ import (
"encoding/json" "encoding/json"
) )
// Email an email address belonging to a user // Email en email information of user
type Email struct { type Email struct {
// swagger:strfmt email
Email string `json:"email"` Email string `json:"email"`
Verified bool `json:"verified"` Verified bool `json:"verified"`
Primary bool `json:"primary"` Primary bool `json:"primary"`
@ -23,9 +22,8 @@ func (c *Client) ListEmails() ([]*Email, error) {
return emails, c.getParsedResponse("GET", "/user/emails", nil, nil, &emails) return emails, c.getParsedResponse("GET", "/user/emails", nil, nil, &emails)
} }
// CreateEmailOption options when creating email addresses // CreateEmailOption options when create an email
type CreateEmailOption struct { type CreateEmailOption struct {
// email addresses to add
Emails []string `json:"emails"` Emails []string `json:"emails"`
} }
@ -39,14 +37,8 @@ func (c *Client) AddEmail(opt CreateEmailOption) ([]*Email, error) {
return emails, c.getParsedResponse("POST", "/user/emails", jsonHeader, bytes.NewReader(body), emails) return emails, c.getParsedResponse("POST", "/user/emails", jsonHeader, bytes.NewReader(body), emails)
} }
// DeleteEmailOption options when deleting email addresses
type DeleteEmailOption struct {
// email addresses to delete
Emails []string `json:"emails"`
}
// DeleteEmail delete one email of current users' // DeleteEmail delete one email of current users'
func (c *Client) DeleteEmail(opt DeleteEmailOption) error { func (c *Client) DeleteEmail(opt CreateEmailOption) error {
body, err := json.Marshal(&opt) body, err := json.Marshal(&opt)
if err != nil { if err != nil {
return err return err

View File

@ -11,7 +11,12 @@ import (
"time" "time"
) )
// GPGKeyList represents a list of GPGKey
// swagger:response GPGKeyList
type GPGKeyList []*GPGKey
// GPGKey a user GPG key to sign commit and tag in repository // GPGKey a user GPG key to sign commit and tag in repository
// swagger:response GPGKey
type GPGKey struct { type GPGKey struct {
ID int64 `json:"id"` ID int64 `json:"id"`
PrimaryKeyID string `json:"primary_key_id"` PrimaryKeyID string `json:"primary_key_id"`
@ -23,13 +28,11 @@ type GPGKey struct {
CanEncryptComms bool `json:"can_encrypt_comms"` CanEncryptComms bool `json:"can_encrypt_comms"`
CanEncryptStorage bool `json:"can_encrypt_storage"` CanEncryptStorage bool `json:"can_encrypt_storage"`
CanCertify bool `json:"can_certify"` CanCertify bool `json:"can_certify"`
// swagger:strfmt date-time Created time.Time `json:"created_at,omitempty"`
Created time.Time `json:"created_at,omitempty"` Expires time.Time `json:"expires_at,omitempty"`
// swagger:strfmt date-time
Expires time.Time `json:"expires_at,omitempty"`
} }
// GPGKeyEmail an email attached to a GPGKey // GPGKeyEmail a email attache to a GPGKey
// swagger:model GPGKeyEmail // swagger:model GPGKeyEmail
type GPGKeyEmail struct { type GPGKeyEmail struct {
Email string `json:"email"` Email string `json:"email"`
@ -37,9 +40,11 @@ type GPGKeyEmail struct {
} }
// CreateGPGKeyOption options create user GPG key // CreateGPGKeyOption options create user GPG key
// swagger:parameters userCurrentPostGPGKey
type CreateGPGKeyOption struct { type CreateGPGKeyOption struct {
// An armored GPG key to add // An armored GPG key to add
// //
// in: body
// required: true // required: true
// unique: true // unique: true
ArmoredKey string `json:"armored_public_key" binding:"Required"` ArmoredKey string `json:"armored_public_key" binding:"Required"`

View File

@ -11,18 +11,18 @@ import (
"time" "time"
) )
// PublicKeyList represents a list of PublicKey
// swagger:response PublicKeyList
type PublicKeyList []*PublicKey
// PublicKey publickey is a user key to push code to repository // PublicKey publickey is a user key to push code to repository
// swagger:response PublicKey
type PublicKey struct { type PublicKey struct {
ID int64 `json:"id"` ID int64 `json:"id"`
Key string `json:"key"` Key string `json:"key"`
URL string `json:"url,omitempty"` URL string `json:"url,omitempty"`
Title string `json:"title,omitempty"` Title string `json:"title,omitempty"`
Fingerprint string `json:"fingerprint,omitempty"` Created time.Time `json:"created_at,omitempty"`
// swagger:strfmt date-time
Created time.Time `json:"created_at,omitempty"`
Owner *User `json:"user,omitempty"`
ReadOnly bool `json:"read_only,omitempty"`
KeyType string `json:"key_type,omitempty"`
} }
// ListPublicKeys list all the public keys of the user // ListPublicKeys list all the public keys of the user

View File

@ -1,14 +0,0 @@
package gitea
import "fmt"
type searchUsersResponse struct {
Users []*User `json:"data"`
}
// SearchUsers finds users by query
func (c *Client) SearchUsers(query string, limit int) ([]*User, error) {
resp := new(searchUsersResponse)
err := c.getParsedResponse("GET", fmt.Sprintf("/users/search?q=%s&limit=%d", query, limit), nil, nil, &resp)
return resp.Users, err
}