summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/lfs/locks.go2
-rw-r--r--modules/repofiles/blob.go2
-rw-r--r--modules/repofiles/blob_test.go2
-rw-r--r--modules/repofiles/content.go2
-rw-r--r--modules/repofiles/content_test.go6
-rw-r--r--modules/repofiles/delete.go2
-rw-r--r--modules/repofiles/delete_test.go2
-rw-r--r--modules/repofiles/file.go2
-rw-r--r--modules/repofiles/file_test.go2
-rw-r--r--modules/repofiles/tree.go2
-rw-r--r--modules/repofiles/tree_test.go2
-rw-r--r--modules/repofiles/update.go4
-rw-r--r--modules/repofiles/update_test.go2
-rw-r--r--modules/repofiles/verification.go6
-rw-r--r--modules/structs/admin_user.go43
-rw-r--r--modules/structs/attachment.go27
-rw-r--r--modules/structs/doc.go5
-rw-r--r--modules/structs/fork.go11
-rw-r--r--modules/structs/git_blob.go14
-rw-r--r--modules/structs/git_hook.go20
-rw-r--r--modules/structs/hook.go465
-rw-r--r--modules/structs/issue.go111
-rw-r--r--modules/structs/issue_comment.go35
-rw-r--r--modules/structs/issue_label.go36
-rw-r--r--modules/structs/issue_milestone.go39
-rw-r--r--modules/structs/issue_tracked_time.go30
-rw-r--r--modules/structs/lfs_lock.go65
-rw-r--r--modules/structs/miscellaneous.go46
-rw-r--r--modules/structs/org.go36
-rw-r--r--modules/structs/org_member.go10
-rw-r--r--modules/structs/org_team.go40
-rw-r--r--modules/structs/pull.go92
-rw-r--r--modules/structs/release.go50
-rw-r--r--modules/structs/repo.go121
-rw-r--r--modules/structs/repo_branch.go11
-rw-r--r--modules/structs/repo_collaborator.go10
-rw-r--r--modules/structs/repo_commit.go44
-rw-r--r--modules/structs/repo_file.go80
-rw-r--r--modules/structs/repo_key.go41
-rw-r--r--modules/structs/repo_refs.go19
-rw-r--r--modules/structs/repo_tag.go16
-rw-r--r--modules/structs/repo_tree.go25
-rw-r--r--modules/structs/repo_watch.go19
-rw-r--r--modules/structs/status.go65
-rw-r--r--modules/structs/user.go38
-rw-r--r--modules/structs/user_app.go34
-rw-r--r--modules/structs/user_email.go25
-rw-r--r--modules/structs/user_gpgkey.go43
-rw-r--r--modules/structs/user_key.go23
-rw-r--r--modules/structs/user_search.go5
-rw-r--r--modules/structs/utils.go26
51 files changed, 1839 insertions, 19 deletions
diff --git a/modules/lfs/locks.go b/modules/lfs/locks.go
index 7a7d3ad42a..525a93645f 100644
--- a/modules/lfs/locks.go
+++ b/modules/lfs/locks.go
@@ -12,7 +12,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/setting"
- api "code.gitea.io/sdk/gitea"
+ api "code.gitea.io/gitea/modules/structs"
)
//checkIsValidRequest check if it a valid request in case of bad request it write the response to ctx.
diff --git a/modules/repofiles/blob.go b/modules/repofiles/blob.go
index 2f9ca72bd4..e9d85a0dcf 100644
--- a/modules/repofiles/blob.go
+++ b/modules/repofiles/blob.go
@@ -8,7 +8,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/setting"
- api "code.gitea.io/sdk/gitea"
+ api "code.gitea.io/gitea/modules/structs"
)
// GetBlobBySHA get the GitBlobResponse of a repository using a sha hash.
diff --git a/modules/repofiles/blob_test.go b/modules/repofiles/blob_test.go
index 55320345f9..1dc183a8af 100644
--- a/modules/repofiles/blob_test.go
+++ b/modules/repofiles/blob_test.go
@@ -8,8 +8,8 @@ import (
"testing"
"code.gitea.io/gitea/models"
+ api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/test"
- api "code.gitea.io/sdk/gitea"
"github.com/stretchr/testify/assert"
)
diff --git a/modules/repofiles/content.go b/modules/repofiles/content.go
index d35c5a6a67..3098087dc6 100644
--- a/modules/repofiles/content.go
+++ b/modules/repofiles/content.go
@@ -9,7 +9,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
- api "code.gitea.io/sdk/gitea"
+ api "code.gitea.io/gitea/modules/structs"
)
// GetFileContents gets the meta data on a file's contents
diff --git a/modules/repofiles/content_test.go b/modules/repofiles/content_test.go
index 0257284a53..ce3f5f3678 100644
--- a/modules/repofiles/content_test.go
+++ b/modules/repofiles/content_test.go
@@ -9,8 +9,8 @@ import (
"testing"
"code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/test"
- "code.gitea.io/sdk/gitea"
"github.com/stretchr/testify/assert"
)
@@ -30,7 +30,7 @@ func TestGetFileContents(t *testing.T) {
treePath := "README.md"
ref := ctx.Repo.Repository.DefaultBranch
- expectedFileContentResponse := &gitea.FileContentResponse{
+ expectedFileContentResponse := &structs.FileContentResponse{
Name: treePath,
Path: treePath,
SHA: "4b4851ad51df6a7d9f25c979345979eaeb5b349f",
@@ -40,7 +40,7 @@ func TestGetFileContents(t *testing.T) {
GitURL: "https://try.gitea.io/api/v1/repos/user2/repo1/git/blobs/4b4851ad51df6a7d9f25c979345979eaeb5b349f",
DownloadURL: "https://try.gitea.io/user2/repo1/raw/branch/master/README.md",
Type: "blob",
- Links: &gitea.FileLinksResponse{
+ Links: &structs.FileLinksResponse{
Self: "https://try.gitea.io/api/v1/repos/user2/repo1/contents/README.md",
GitURL: "https://try.gitea.io/api/v1/repos/user2/repo1/git/blobs/4b4851ad51df6a7d9f25c979345979eaeb5b349f",
HTMLURL: "https://try.gitea.io/user2/repo1/blob/master/README.md",
diff --git a/modules/repofiles/delete.go b/modules/repofiles/delete.go
index ce7993dc54..ccf90f43b3 100644
--- a/modules/repofiles/delete.go
+++ b/modules/repofiles/delete.go
@@ -10,7 +10,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
- api "code.gitea.io/sdk/gitea"
+ api "code.gitea.io/gitea/modules/structs"
)
// DeleteRepoFileOptions holds the repository delete file options
diff --git a/modules/repofiles/delete_test.go b/modules/repofiles/delete_test.go
index 0b0558e766..9d034066f5 100644
--- a/modules/repofiles/delete_test.go
+++ b/modules/repofiles/delete_test.go
@@ -8,8 +8,8 @@ import (
"testing"
"code.gitea.io/gitea/models"
+ api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/test"
- api "code.gitea.io/sdk/gitea"
"github.com/stretchr/testify/assert"
)
diff --git a/modules/repofiles/file.go b/modules/repofiles/file.go
index 913a9ed535..de3ee71dba 100644
--- a/modules/repofiles/file.go
+++ b/modules/repofiles/file.go
@@ -12,7 +12,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
- api "code.gitea.io/sdk/gitea"
+ api "code.gitea.io/gitea/modules/structs"
)
// GetFileResponseFromCommit Constructs a FileResponse from a Commit object
diff --git a/modules/repofiles/file_test.go b/modules/repofiles/file_test.go
index c9ee7f21e2..5f6320a938 100644
--- a/modules/repofiles/file_test.go
+++ b/modules/repofiles/file_test.go
@@ -9,8 +9,8 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
+ api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/test"
- api "code.gitea.io/sdk/gitea"
"github.com/stretchr/testify/assert"
)
diff --git a/modules/repofiles/tree.go b/modules/repofiles/tree.go
index e189fe1229..4eb54a2598 100644
--- a/modules/repofiles/tree.go
+++ b/modules/repofiles/tree.go
@@ -10,7 +10,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/setting"
- api "code.gitea.io/sdk/gitea"
+ api "code.gitea.io/gitea/modules/structs"
)
// GetTreeBySHA get the GitTreeResponse of a repository using a sha hash.
diff --git a/modules/repofiles/tree_test.go b/modules/repofiles/tree_test.go
index c211cfcfd2..ecff8b9071 100644
--- a/modules/repofiles/tree_test.go
+++ b/modules/repofiles/tree_test.go
@@ -8,8 +8,8 @@ import (
"testing"
"code.gitea.io/gitea/models"
+ api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/test"
- api "code.gitea.io/sdk/gitea"
"github.com/stretchr/testify/assert"
)
diff --git a/modules/repofiles/update.go b/modules/repofiles/update.go
index 8bc3b50ae0..66e3f2babc 100644
--- a/modules/repofiles/update.go
+++ b/modules/repofiles/update.go
@@ -19,7 +19,7 @@ import (
"code.gitea.io/gitea/modules/lfs"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
- "code.gitea.io/sdk/gitea"
+ "code.gitea.io/gitea/modules/structs"
)
// IdentityOptions for a person's identity like an author or committer
@@ -108,7 +108,7 @@ func detectEncodingAndBOM(entry *git.TreeEntry, repo *models.Repository) (string
}
// CreateOrUpdateRepoFile adds or updates a file in the given repository
-func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *UpdateRepoFileOptions) (*gitea.FileResponse, error) {
+func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *UpdateRepoFileOptions) (*structs.FileResponse, error) {
// If no branch name is set, assume master
if opts.OldBranch == "" {
opts.OldBranch = repo.DefaultBranch
diff --git a/modules/repofiles/update_test.go b/modules/repofiles/update_test.go
index bf28021793..a3a0b0a420 100644
--- a/modules/repofiles/update_test.go
+++ b/modules/repofiles/update_test.go
@@ -10,8 +10,8 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
+ api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/test"
- api "code.gitea.io/sdk/gitea"
"github.com/stretchr/testify/assert"
)
diff --git a/modules/repofiles/verification.go b/modules/repofiles/verification.go
index 75ead92d0f..be56f9b8b8 100644
--- a/modules/repofiles/verification.go
+++ b/modules/repofiles/verification.go
@@ -7,12 +7,12 @@ package repofiles
import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
- "code.gitea.io/sdk/gitea"
+ "code.gitea.io/gitea/modules/structs"
)
// GetPayloadCommitVerification returns the verification information of a commit
-func GetPayloadCommitVerification(commit *git.Commit) *gitea.PayloadCommitVerification {
- verification := &gitea.PayloadCommitVerification{}
+func GetPayloadCommitVerification(commit *git.Commit) *structs.PayloadCommitVerification {
+ verification := &structs.PayloadCommitVerification{}
commitVerification := models.ParseCommitWithSignature(commit)
if commit.Signature != nil {
verification.Signature = commit.Signature.Signature
diff --git a/modules/structs/admin_user.go b/modules/structs/admin_user.go
new file mode 100644
index 0000000000..7a447e44f5
--- /dev/null
+++ b/modules/structs/admin_user.go
@@ -0,0 +1,43 @@
+// Copyright 2015 The Gogs Authors. All rights reserved.
+// Copyright 2019 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 structs
+
+// CreateUserOption create user options
+type CreateUserOption struct {
+ SourceID int64 `json:"source_id"`
+ LoginName string `json:"login_name"`
+ // required: true
+ Username string `json:"username" binding:"Required;AlphaDashDot;MaxSize(40)"`
+ FullName string `json:"full_name" binding:"MaxSize(100)"`
+ // required: true
+ // swagger:strfmt email
+ Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
+ // required: true
+ Password string `json:"password" binding:"Required;MaxSize(255)"`
+ MustChangePassword *bool `json:"must_change_password"`
+ SendNotify bool `json:"send_notify"`
+}
+
+// EditUserOption edit user options
+type EditUserOption struct {
+ SourceID int64 `json:"source_id"`
+ LoginName string `json:"login_name"`
+ FullName string `json:"full_name" binding:"MaxSize(100)"`
+ // required: true
+ // swagger:strfmt email
+ Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
+ Password string `json:"password" binding:"MaxSize(255)"`
+ MustChangePassword *bool `json:"must_change_password"`
+ Website string `json:"website" binding:"MaxSize(50)"`
+ Location string `json:"location" binding:"MaxSize(50)"`
+ Active *bool `json:"active"`
+ Admin *bool `json:"admin"`
+ AllowGitHook *bool `json:"allow_git_hook"`
+ AllowImportLocal *bool `json:"allow_import_local"`
+ MaxRepoCreation *int `json:"max_repo_creation"`
+ ProhibitLogin *bool `json:"prohibit_login"`
+ AllowCreateOrganization *bool `json:"allow_create_organization"`
+}
diff --git a/modules/structs/attachment.go b/modules/structs/attachment.go
new file mode 100644
index 0000000000..954956f328
--- /dev/null
+++ b/modules/structs/attachment.go
@@ -0,0 +1,27 @@
+// 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 structs // import "code.gitea.io/gitea/modules/structs"
+import (
+ "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"`
+}
+
+// EditAttachmentOptions options for editing attachments
+// swagger:model
+type EditAttachmentOptions struct {
+ Name string `json:"name"`
+}
diff --git a/modules/structs/doc.go b/modules/structs/doc.go
new file mode 100644
index 0000000000..4c2fdbf73d
--- /dev/null
+++ b/modules/structs/doc.go
@@ -0,0 +1,5 @@
+// Copyright 2016 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 structs
diff --git a/modules/structs/fork.go b/modules/structs/fork.go
new file mode 100644
index 0000000000..dd6e24e8b7
--- /dev/null
+++ b/modules/structs/fork.go
@@ -0,0 +1,11 @@
+// Copyright 2016 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 structs
+
+// CreateForkOption options for creating a fork
+type CreateForkOption struct {
+ // organization name, if forking into an organization
+ Organization *string `json:"organization"`
+}
diff --git a/modules/structs/git_blob.go b/modules/structs/git_blob.go
new file mode 100644
index 0000000000..5715f2585b
--- /dev/null
+++ b/modules/structs/git_blob.go
@@ -0,0 +1,14 @@
+// Copyright 2019 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 structs
+
+// GitBlobResponse represents a git blob
+type GitBlobResponse struct {
+ Content string `json:"content"`
+ Encoding string `json:"encoding"`
+ URL string `json:"url"`
+ SHA string `json:"sha"`
+ Size int64 `json:"size"`
+}
diff --git a/modules/structs/git_hook.go b/modules/structs/git_hook.go
new file mode 100644
index 0000000000..8a36b0b266
--- /dev/null
+++ b/modules/structs/git_hook.go
@@ -0,0 +1,20 @@
+// Copyright 2019 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 structs
+
+// GitHook represents a Git repository hook
+type GitHook struct {
+ Name string `json:"name"`
+ IsActive bool `json:"is_active"`
+ Content string `json:"content,omitempty"`
+}
+
+// GitHookList represents a list of Git hooks
+type GitHookList []*GitHook
+
+// EditGitHookOption options when modifying one Git hook
+type EditGitHookOption struct {
+ Content string `json:"content"`
+}
diff --git a/modules/structs/hook.go b/modules/structs/hook.go
new file mode 100644
index 0000000000..8dae578ec6
--- /dev/null
+++ b/modules/structs/hook.go
@@ -0,0 +1,465 @@
+// Copyright 2014 The Gogs Authors. All rights reserved.
+// 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 structs
+
+import (
+ "encoding/json"
+ "errors"
+ "strings"
+ "time"
+)
+
+var (
+ // ErrInvalidReceiveHook FIXME
+ ErrInvalidReceiveHook = errors.New("Invalid JSON payload received over webhook")
+)
+
+// Hook a hook is a web hook when one repository changed
+type Hook struct {
+ ID int64 `json:"id"`
+ Type string `json:"type"`
+ URL string `json:"-"`
+ Config map[string]string `json:"config"`
+ Events []string `json:"events"`
+ Active bool `json:"active"`
+ // swagger:strfmt date-time
+ Updated time.Time `json:"updated_at"`
+ // swagger:strfmt date-time
+ Created time.Time `json:"created_at"`
+}
+
+// HookList represents a list of API hook.
+type HookList []*Hook
+
+// CreateHookOption options when create a hook
+type CreateHookOption struct {
+ // required: true
+ // enum: gitea,gogs,slack,discord
+ Type string `json:"type" binding:"Required"`
+ // required: true
+ Config map[string]string `json:"config" binding:"Required"`
+ Events []string `json:"events"`
+ // default: false
+ Active bool `json:"active"`
+}
+
+// EditHookOption options when modify one hook
+type EditHookOption struct {
+ Config map[string]string `json:"config"`
+ Events []string `json:"events"`
+ Active *bool `json:"active"`
+}
+
+// Payloader payload is some part of one hook
+type Payloader interface {
+ SetSecret(string)
+ JSONPayload() ([]byte, error)
+}
+
+// PayloadUser represents the author or committer of a commit
+type PayloadUser struct {
+ // Full name of the commit author
+ Name string `json:"name"`
+ // swagger:strfmt email
+ Email string `json:"email"`
+ UserName string `json:"username"`
+}
+
+// FIXME: consider using same format as API when commits API are added.
+// applies to PayloadCommit and PayloadCommitVerification
+
+// PayloadCommit represents a commit
+type PayloadCommit struct {
+ // sha1 hash of the commit
+ ID string `json:"id"`
+ Message string `json:"message"`
+ URL string `json:"url"`
+ Author *PayloadUser `json:"author"`
+ Committer *PayloadUser `json:"committer"`
+ Verification *PayloadCommitVerification `json:"verification"`
+ // swagger:strfmt date-time
+ Timestamp time.Time `json:"timestamp"`
+ Added []string `json:"added"`
+ Removed []string `json:"removed"`
+ Modified []string `json:"modified"`
+}
+
+// PayloadCommitVerification represents the GPG verification of a commit
+type PayloadCommitVerification struct {
+ Verified bool `json:"verified"`
+ Reason string `json:"reason"`
+ Signature string `json:"signature"`
+ Payload string `json:"payload"`
+}
+
+var (
+ _ Payloader = &CreatePayload{}
+ _ Payloader = &DeletePayload{}
+ _ Payloader = &ForkPayload{}
+ _ Payloader = &PushPayload{}
+ _ Payloader = &IssuePayload{}
+ _ Payloader = &IssueCommentPayload{}
+ _ Payloader = &PullRequestPayload{}
+ _ Payloader = &RepositoryPayload{}
+ _ Payloader = &ReleasePayload{}
+)
+
+// _________ __
+// \_ ___ \_______ ____ _____ _/ |_ ____
+// / \ \/\_ __ \_/ __ \\__ \\ __\/ __ \
+// \ \____| | \/\ ___/ / __ \| | \ ___/
+// \______ /|__| \___ >____ /__| \___ >
+// \/ \/ \/ \/
+
+// CreatePayload FIXME
+type CreatePayload struct {
+ Secret string `json:"secret"`
+ Sha string `json:"sha"`
+ Ref string `json:"ref"`
+ RefType string `json:"ref_type"`
+ Repo *Repository `json:"repository"`
+ Sender *User `json:"sender"`
+}
+
+// SetSecret modifies the secret of the CreatePayload
+func (p *CreatePayload) SetSecret(secret string) {
+ p.Secret = secret
+}
+
+// JSONPayload return payload information
+func (p *CreatePayload) JSONPayload() ([]byte, error) {
+ return json.MarshalIndent(p, "", " ")
+}
+
+// ParseCreateHook parses create event hook content.
+func ParseCreateHook(raw []byte) (*CreatePayload, error) {
+ hook := new(CreatePayload)
+ if err := json.Unmarshal(raw, hook); err != nil {
+ return nil, err
+ }
+
+ // it is possible the JSON was parsed, however,
+ // was not from Gogs (maybe was from Bitbucket)
+ // So we'll check to be sure certain key fields
+ // were populated
+ switch {
+ case hook.Repo == nil:
+ return nil, ErrInvalidReceiveHook
+ case len(hook.Ref) == 0:
+ return nil, ErrInvalidReceiveHook
+ }
+ 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, "", " ")
+}
+
+// __________ .__
+// \______ \__ __ _____| |__
+// | ___/ | \/ ___/ | \
+// | | | | /\___ \| Y \
+// |____| |____//____ >___| /
+// \/ \/
+
+// PushPayload represents a payload information of push event.
+type PushPayload struct {
+ Secret string `json:"secret"`
+ Ref string `json:"ref"`
+ Before string `json:"before"`
+ After string `json:"after"`
+ CompareURL string `json:"compare_url"`
+ Commits []*PayloadCommit `json:"commits"`
+ HeadCommit *PayloadCommit `json:"head_commit"`
+ Repo *Repository `json:"repository"`
+ Pusher *User `json:"pusher"`
+ Sender *User `json:"sender"`
+}
+
+// SetSecret modifies the secret of the PushPayload
+func (p *PushPayload) SetSecret(secret string) {
+ p.Secret = secret
+}
+
+// JSONPayload FIXME
+func (p *PushPayload) JSONPayload() ([]byte, error) {
+ return json.MarshalIndent(p, "", " ")
+}
+
+// ParsePushHook parses push event hook content.
+func ParsePushHook(raw []byte) (*PushPayload, error) {
+ hook := new(PushPayload)
+ if err := json.Unmarshal(raw, hook); err != nil {
+ return nil, err
+ }
+
+ switch {
+ case hook.Repo == nil:
+ return nil, ErrInvalidReceiveHook
+ case len(hook.Ref) == 0:
+ return nil, ErrInvalidReceiveHook
+ }
+ return hook, nil
+}
+
+// Branch returns branch name from a payload
+func (p *PushPayload) Branch() string {
+ return strings.Replace(p.Ref, "refs/heads/", "", -1)
+}
+
+// .___
+// | | ______ ________ __ ____
+// | |/ ___// ___/ | \_/ __ \
+// | |\___ \ \___ \| | /\ ___/
+// |___/____ >____ >____/ \___ >
+// \/ \/ \/
+
+// HookIssueAction FIXME
+type HookIssueAction string
+
+const (
+ // HookIssueOpened opened
+ HookIssueOpened HookIssueAction = "opened"
+ // HookIssueClosed closed
+ HookIssueClosed HookIssueAction = "closed"
+ // HookIssueReOpened reopened
+ HookIssueReOpened HookIssueAction = "reopened"
+ // HookIssueEdited edited
+ HookIssueEdited HookIssueAction = "edited"
+ // HookIssueAssigned assigned
+ HookIssueAssigned HookIssueAction = "assigned"
+ // HookIssueUnassigned unassigned
+ HookIssueUnassigned HookIssueAction = "unassigned"
+ // HookIssueLabelUpdated label_updated
+ HookIssueLabelUpdated HookIssueAction = "label_updated"
+ // HookIssueLabelCleared label_cleared
+ HookIssueLabelCleared HookIssueAction = "label_cleared"
+ // HookIssueSynchronized synchronized
+ HookIssueSynchronized HookIssueAction = "synchronized"
+ // HookIssueMilestoned is an issue action for when a milestone is set on an issue.
+ HookIssueMilestoned HookIssueAction = "milestoned"
+ // HookIssueDemilestoned is an issue action for when a milestone is cleared on an issue.
+ HookIssueDemilestoned HookIssueAction = "demilestoned"
+)
+
+// IssuePayload represents the payload information that is sent along with an issue event.
+type IssuePayload struct {
+ Secret string `json:"secret"`
+ Action HookIssueAction `json:"action"`
+ Index int64 `json:"number"`
+ Changes *ChangesPayload `json:"changes,omitempty"`
+ Issue *Issue `json:"issue"`
+ Repository *Repository `json:"repository"`
+ Sender *User `json:"sender"`
+}
+
+// SetSecret modifies the secret of the IssuePayload.
+func (p *IssuePayload) SetSecret(secret string) {
+ p.Secret = secret
+}
+
+// JSONPayload encodes the IssuePayload to JSON, with an indentation of two spaces.
+func (p *IssuePayload) JSONPayload() ([]byte, error) {
+ return json.MarshalIndent(p, "", " ")
+}
+
+// ChangesFromPayload FIXME
+type ChangesFromPayload struct {
+ From string `json:"from"`
+}
+
+// ChangesPayload FIXME
+type ChangesPayload struct {
+ Title *ChangesFromPayload `json:"title,omitempty"`
+ Body *ChangesFromPayload `json:"body,omitempty"`
+}
+
+// __________ .__ .__ __________ __
+// \______ \__ __| | | | \______ \ ____ ________ __ ____ _______/ |_
+// | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\
+// | | | | / |_| |__ | | \ ___< <_| | | /\ ___/ \___ \ | |
+// |____| |____/|____/____/ |____|_ /\___ >__ |____/ \___ >____ > |__|
+// \/ \/ |__| \/ \/
+
+// PullRequestPayload represents a payload information of pull request event.
+type PullRequestPayload struct {
+ Secret string `json:"secret"`
+ Action HookIssueAction `json:"action"`
+ Index int64 `json:"number"`
+ Changes *ChangesPayload `json:"changes,omitempty"`
+ PullRequest *PullRequest `json:"pull_request"`
+ Repository *Repository `json:"repository"`
+ Sender *User `json:"sender"`
+}
+
+// SetSecret modifies the secret of the PullRequestPayload.
+func (p *PullRequestPayload) SetSecret(secret string) {
+ p.Secret = secret
+}
+
+// JSONPayload FIXME
+func (p *PullRequestPayload) JSONPayload() ([]byte, error) {
+ return json.MarshalIndent(p, "", " ")
+}
+
+//__________ .__ __
+//\______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__.
+// | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | |
+// | | \ ___/| |_> > <_> )___ \| || | ( <_> ) | \/\___ |
+// |____|_ /\___ > __/ \____/____ >__||__| \____/|__| / ____|
+// \/ \/|__| \/ \/
+
+// HookRepoAction an action that happens to a repo
+type HookRepoAction string
+
+const (
+ // HookRepoCreated created
+ HookRepoCreated HookRepoAction = "created"
+ // HookRepoDeleted deleted
+ HookRepoDeleted HookRepoAction = "deleted"
+)
+
+// RepositoryPayload payload for repository webhooks
+type RepositoryPayload struct {
+ Secret string `json:"secret"`
+ Action HookRepoAction `json:"action"`
+ Repository *Repository `json:"repository"`
+ Organization *User `json:"organization"`
+ Sender *User `json:"sender"`
+}
+
+// SetSecret modifies the secret of the RepositoryPayload
+func (p *RepositoryPayload) SetSecret(secret string) {
+ p.Secret = secret
+}
+
+// JSONPayload JSON representation of the payload
+func (p *RepositoryPayload) JSONPayload() ([]byte, error) {
+ return json.MarshalIndent(p, "", " ")
+}
diff --git a/modules/structs/issue.go b/modules/structs/issue.go
new file mode 100644
index 0000000000..af6aa6e541
--- /dev/null
+++ b/modules/structs/issue.go
@@ -0,0 +1,111 @@
+// Copyright 2016 The Gogs 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 structs
+
+import (
+ "time"
+)
+
+// StateType issue state type
+type StateType string
+
+const (
+ // StateOpen pr is opend
+ StateOpen StateType = "open"
+ // StateClosed pr is closed
+ StateClosed StateType = "closed"
+)
+
+// PullRequestMeta PR info if an issue is a PR
+type PullRequestMeta struct {
+ HasMerged bool `json:"merged"`
+ Merged *time.Time `json:"merged_at"`
+}
+
+// Issue represents an issue in a repository
+// swagger:model
+type Issue struct {
+ ID int64 `json:"id"`
+ URL string `json:"url"`
+ Index int64 `json:"number"`
+ Poster *User `json:"user"`
+ Title string `json:"title"`
+ Body string `json:"body"`
+ Labels []*Label `json:"labels"`
+ Milestone *Milestone `json:"milestone"`
+ Assignee *User `json:"assignee"`
+ Assignees []*User `json:"assignees"`
+ // Whether the issue is open or closed
+ //
+ // type: string
+ // 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"`
+}
+
+// ListIssueOption list issue options
+type ListIssueOption struct {
+ Page int
+ State string
+}
+
+// CreateIssueOption options to create one issue
+type CreateIssueOption struct {
+ // required:true
+ Title string `json:"title" binding:"Required"`
+ Body string `json:"body"`
+ // username of assignee
+ Assignee string `json:"assignee"`
+ Assignees []string `json:"assignees"`
+ // 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"`
+}
+
+// EditIssueOption options for editing an issue
+type EditIssueOption struct {
+ Title string `json:"title"`
+ Body *string `json:"body"`
+ Assignee *string `json:"assignee"`
+ Assignees []string `json:"assignees"`
+ Milestone *int64 `json:"milestone"`
+ State *string `json:"state"`
+ // swagger:strfmt date-time
+ Deadline *time.Time `json:"due_date"`
+}
+
+// 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"`
+}
diff --git a/modules/structs/issue_comment.go b/modules/structs/issue_comment.go
new file mode 100644
index 0000000000..185f3910ed
--- /dev/null
+++ b/modules/structs/issue_comment.go
@@ -0,0 +1,35 @@
+// Copyright 2016 The Gogs 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 structs
+
+import (
+ "time"
+)
+
+// Comment represents a comment on a commit or issue
+type Comment struct {
+ ID int64 `json:"id"`
+ HTMLURL string `json:"html_url"`
+ PRURL string `json:"pull_request_url"`
+ IssueURL string `json:"issue_url"`
+ Poster *User `json:"user"`
+ Body string `json:"body"`
+ // swagger:strfmt date-time
+ Created time.Time `json:"created_at"`
+ // swagger:strfmt date-time
+ Updated time.Time `json:"updated_at"`
+}
+
+// CreateIssueCommentOption options for creating a comment on an issue
+type CreateIssueCommentOption struct {
+ // required:true
+ Body string `json:"body" binding:"Required"`
+}
+
+// EditIssueCommentOption options for editing a comment
+type EditIssueCommentOption struct {
+ // required: true
+ Body string `json:"body" binding:"Required"`
+}
diff --git a/modules/structs/issue_label.go b/modules/structs/issue_label.go
new file mode 100644
index 0000000000..f0821fbaf5
--- /dev/null
+++ b/modules/structs/issue_label.go
@@ -0,0 +1,36 @@
+// Copyright 2016 The Gogs 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 structs
+
+// Label a label to an issue or a pr
+// swagger:model
+type Label struct {
+ ID int64 `json:"id"`
+ Name string `json:"name"`
+ // example: 00aabb
+ Color string `json:"color"`
+ URL string `json:"url"`
+}
+
+// CreateLabelOption options for creating a label
+type CreateLabelOption struct {
+ // required:true
+ Name string `json:"name" binding:"Required"`
+ // required:true
+ // example: #00aabb
+ Color string `json:"color" binding:"Required;Size(7)"`
+}
+
+// EditLabelOption options for editing a label
+type EditLabelOption struct {
+ Name *string `json:"name"`
+ Color *string `json:"color"`
+}
+
+// IssueLabelsOption a collection of labels
+type IssueLabelsOption struct {
+ // list of label IDs
+ Labels []int64 `json:"labels"`
+}
diff --git a/modules/structs/issue_milestone.go b/modules/structs/issue_milestone.go
new file mode 100644
index 0000000000..2bfdcd6bff
--- /dev/null
+++ b/modules/structs/issue_milestone.go
@@ -0,0 +1,39 @@
+// Copyright 2016 The Gogs 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 structs
+
+import (
+ "time"
+)
+
+// Milestone milestone is a collection of issues on one repository
+type Milestone struct {
+ ID int64 `json:"id"`
+ Title string `json:"title"`
+ Description string `json:"description"`
+ State StateType `json:"state"`
+ OpenIssues int `json:"open_issues"`
+ ClosedIssues int `json:"closed_issues"`
+ // swagger:strfmt date-time
+ Closed *time.Time `json:"closed_at"`
+ // swagger:strfmt date-time
+ Deadline *time.Time `json:"due_on"`
+}
+
+// CreateMilestoneOption options for creating a milestone
+type CreateMilestoneOption struct {
+ Title string `json:"title"`
+ Description string `json:"description"`
+ // swagger:strfmt date-time
+ Deadline *time.Time `json:"due_on"`
+}
+
+// EditMilestoneOption options for editing a milestone
+type EditMilestoneOption struct {
+ Title string `json:"title"`
+ Description *string `json:"description"`
+ State *string `json:"state"`
+ Deadline *time.Time `json:"due_on"`
+}
diff --git a/modules/structs/issue_tracked_time.go b/modules/structs/issue_tracked_time.go
new file mode 100644
index 0000000000..be90b36267
--- /dev/null
+++ b/modules/structs/issue_tracked_time.go
@@ -0,0 +1,30 @@
+// 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 structs
+
+import (
+ "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
+
+// AddTimeOption options for adding time to an issue
+type AddTimeOption struct {
+ // time in seconds
+ // required: true
+ Time int64 `json:"time" binding:"Required"`
+}
diff --git a/modules/structs/lfs_lock.go b/modules/structs/lfs_lock.go
new file mode 100644
index 0000000000..3709106315
--- /dev/null
+++ b/modules/structs/lfs_lock.go
@@ -0,0 +1,65 @@
+// 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 structs
+
+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"`
+}
diff --git a/modules/structs/miscellaneous.go b/modules/structs/miscellaneous.go
new file mode 100644
index 0000000000..8eca90330e
--- /dev/null
+++ b/modules/structs/miscellaneous.go
@@ -0,0 +1,46 @@
+// Copyright 2015 The Gogs 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 structs
+
+// SearchResults results of a successful search
+type SearchResults struct {
+ OK bool `json:"ok"`
+ Data []*Repository `json:"data"`
+}
+
+// SearchError error of a failed search
+type SearchError struct {
+ OK bool `json:"ok"`
+ Error string `json:"error"`
+}
+
+// MarkdownOption markdown options
+type MarkdownOption struct {
+ // Text markdown to render
+ //
+ // in: body
+ Text string
+ // Mode to render
+ //
+ // in: body
+ Mode string
+ // Context to render
+ //
+ // in: body
+ Context string
+ // Is it a wiki page ?
+ //
+ // in: body
+ Wiki bool
+}
+
+// MarkdownRender is a rendered markdown document
+// swagger:response MarkdownRender
+type MarkdownRender string
+
+// ServerVersion wraps the version of the server
+type ServerVersion struct {
+ Version string `json:"version"`
+}
diff --git a/modules/structs/org.go b/modules/structs/org.go
new file mode 100644
index 0000000000..fd15da1ce9
--- /dev/null
+++ b/modules/structs/org.go
@@ -0,0 +1,36 @@
+// Copyright 2015 The Gogs 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 structs
+
+// Organization represents an organization
+type Organization struct {
+ ID int64 `json:"id"`
+ UserName string `json:"username"`
+ FullName string `json:"full_name"`
+ AvatarURL string `json:"avatar_url"`
+ Description string `json:"description"`
+ Website string `json:"website"`
+ Location string `json:"location"`
+ Visibility VisibleType `json:"visibility"`
+}
+
+// CreateOrgOption options for creating an organization
+type CreateOrgOption struct {
+ // required: true
+ UserName string `json:"username" binding:"Required"`
+ FullName string `json:"full_name"`
+ Description string `json:"description"`
+ Website string `json:"website"`
+ Location string `json:"location"`
+ Visibility VisibleType `json:"visibility"`
+}
+
+// EditOrgOption options for editing an organization
+type EditOrgOption struct {
+ FullName string `json:"full_name"`
+ Description string `json:"description"`
+ Website string `json:"website"`
+ Location string `json:"location"`
+}
diff --git a/modules/structs/org_member.go b/modules/structs/org_member.go
new file mode 100644
index 0000000000..3b2a8b599a
--- /dev/null
+++ b/modules/structs/org_member.go
@@ -0,0 +1,10 @@
+// Copyright 2016 The Gogs 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 structs
+
+// AddOrgMembershipOption add user to organization options
+type AddOrgMembershipOption struct {
+ Role string `json:"role" binding:"Required"`
+}
diff --git a/modules/structs/org_team.go b/modules/structs/org_team.go
new file mode 100644
index 0000000000..b8b5090225
--- /dev/null
+++ b/modules/structs/org_team.go
@@ -0,0 +1,40 @@
+// 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
+// license that can be found in the LICENSE file.
+
+package structs
+
+// Team represents a team in an organization
+type Team struct {
+ ID int64 `json:"id"`
+ Name string `json:"name"`
+ Description string `json:"description"`
+ Organization *Organization `json:"organization"`
+ // enum: none,read,write,admin,owner
+ 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
+type CreateTeamOption struct {
+ // required: true
+ Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"`
+ Description string `json:"description" binding:"MaxSize(255)"`
+ // enum: read,write,admin
+ 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
+type EditTeamOption struct {
+ // required: true
+ Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"`
+ Description string `json:"description" binding:"MaxSize(255)"`
+ // enum: read,write,admin
+ 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"`
+}
diff --git a/modules/structs/pull.go b/modules/structs/pull.go
new file mode 100644
index 0000000000..722d245afc
--- /dev/null
+++ b/modules/structs/pull.go
@@ -0,0 +1,92 @@
+// Copyright 2016 The Gogs 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 structs
+
+import (
+ "time"
+)
+
+// PullRequest represents a pull request
+type PullRequest struct {
+ ID int64 `json:"id"`
+ URL string `json:"url"`
+ Index int64 `json:"number"`
+ Poster *User `json:"user"`
+ Title string `json:"title"`
+ Body string `json:"body"`
+ Labels []*Label `json:"labels"`
+ Milestone *Milestone `json:"milestone"`
+ Assignee *User `json:"assignee"`
+ Assignees []*User `json:"assignees"`
+ State StateType `json:"state"`
+ Comments int `json:"comments"`
+
+ HTMLURL string `json:"html_url"`
+ DiffURL string `json:"diff_url"`
+ PatchURL string `json:"patch_url"`
+
+ Mergeable bool `json:"mergeable"`
+ HasMerged bool `json:"merged"`
+ // swagger:strfmt date-time
+ Merged *time.Time `json:"merged_at"`
+ MergedCommitID *string `json:"merge_commit_sha"`
+ MergedBy *User `json:"merged_by"`
+
+ Base *PRBranchInfo `json:"base"`
+ Head *PRBranchInfo `json:"head"`
+ 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"`
+ // swagger:strfmt date-time
+ Updated *time.Time `json:"updated_at"`
+ // swagger:strfmt date-time
+ Closed *time.Time `json:"closed_at"`
+}
+
+// PRBranchInfo information about a branch
+type PRBranchInfo struct {
+ Name string `json:"label"`
+ Ref string `json:"ref"`
+ Sha string `json:"sha"`
+ RepoID int64 `json:"repo_id"`
+ Repository *Repository `json:"repo"`
+}
+
+// ListPullRequestsOptions options for listing pull requests
+type ListPullRequestsOptions struct {
+ Page int `json:"page"`
+ State string `json:"state"`
+}
+
+// CreatePullRequestOption options when creating a pull request
+type CreatePullRequestOption struct {
+ Head string `json:"head" binding:"Required"`
+ Base string `json:"base" binding:"Required"`
+ Title string `json:"title" binding:"Required"`
+ Body string `json:"body"`
+ Assignee string `json:"assignee"`
+ Assignees []string `json:"assignees"`
+ Milestone int64 `json:"milestone"`
+ Labels []int64 `json:"labels"`
+ // swagger:strfmt date-time
+ Deadline *time.Time `json:"due_date"`
+}
+
+// EditPullRequestOption options when modify pull request
+type EditPullRequestOption struct {
+ Title string `json:"title"`
+ Body string `json:"body"`
+ Assignee string `json:"assignee"`
+ Assignees []string `json:"assignees"`
+ Milestone int64 `json:"milestone"`
+ Labels []int64 `json:"labels"`
+ State *string `json:"state"`
+ // swagger:strfmt date-time
+ Deadline *time.Time `json:"due_date"`
+}
diff --git a/modules/structs/release.go b/modules/structs/release.go
new file mode 100644
index 0000000000..b7575af39a
--- /dev/null
+++ b/modules/structs/release.go
@@ -0,0 +1,50 @@
+// Copyright 2016 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 structs
+
+import (
+ "time"
+)
+
+// Release represents a repository release
+type Release struct {
+ ID int64 `json:"id"`
+ TagName string `json:"tag_name"`
+ Target string `json:"target_commitish"`
+ Title string `json:"name"`
+ Note string `json:"body"`
+ URL string `json:"url"`
+ TarURL string `json:"tarball_url"`
+ ZipURL string `json:"zipball_url"`
+ IsDraft bool `json:"draft"`
+ IsPrerelease bool `json:"prerelease"`
+ // swagger:strfmt date-time
+ CreatedAt time.Time `json:"created_at"`
+ // swagger:strfmt date-time
+ PublishedAt time.Time `json:"published_at"`
+ Publisher *User `json:"author"`
+ Attachments []*Attachment `json:"assets"`
+}
+
+// CreateReleaseOption options when creating a release
+type CreateReleaseOption struct {
+ // required: true
+ TagName string `json:"tag_name" binding:"Required"`
+ Target string `json:"target_commitish"`
+ Title string `json:"name"`
+ Note string `json:"body"`
+ IsDraft bool `json:"draft"`
+ IsPrerelease bool `json:"prerelease"`
+}
+
+// EditReleaseOption options when editing a release
+type EditReleaseOption struct {
+ TagName string `json:"tag_name"`
+ Target string `json:"target_commitish"`
+ Title string `json:"name"`
+ Note string `json:"body"`
+ IsDraft *bool `json:"draft"`
+ IsPrerelease *bool `json:"prerelease"`
+}
diff --git a/modules/structs/repo.go b/modules/structs/repo.go
new file mode 100644
index 0000000000..b5283beeaa
--- /dev/null
+++ b/modules/structs/repo.go
@@ -0,0 +1,121 @@
+// Copyright 2014 The Gogs 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 structs
+
+import (
+ "time"
+)
+
+// Permission represents a set of permissions
+type Permission struct {
+ Admin bool `json:"admin"`
+ Push bool `json:"push"`
+ Pull bool `json:"pull"`
+}
+
+// Repository represents a repository
+type Repository struct {
+ ID int64 `json:"id"`
+ Owner *User `json:"owner"`
+ Name string `json:"name"`
+ FullName string `json:"full_name"`
+ Description string `json:"description"`
+ Empty bool `json:"empty"`
+ Private bool `json:"private"`
+ Fork bool `json:"fork"`
+ Parent *Repository `json:"parent"`
+ Mirror bool `json:"mirror"`
+ Size int `json:"size"`
+ HTMLURL string `json:"html_url"`
+ SSHURL string `json:"ssh_url"`
+ CloneURL string `json:"clone_url"`
+ Website string `json:"website"`
+ Stars int `json:"stars_count"`
+ Forks int `json:"forks_count"`
+ Watchers int `json:"watchers_count"`
+ OpenIssues int `json:"open_issues_count"`
+ DefaultBranch string `json:"default_branch"`
+ Archived bool `json:"archived"`
+ // swagger:strfmt date-time
+ Created time.Time `json:"created_at"`
+ // swagger:strfmt date-time
+ Updated time.Time `json:"updated_at"`
+ Permissions *Permission `json:"permissions,omitempty"`
+}
+
+// CreateRepoOption options when creating repository
+// swagger:model
+type CreateRepoOption struct {
+ // Name of the repository to create
+ //
+ // required: true
+ // unique: true
+ Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
+ // Description of the repository to create
+ Description string `json:"description" binding:"MaxSize(255)"`
+ // Whether the repository is private
+ Private bool `json:"private"`
+ // Whether the repository should be auto-intialized?
+ AutoInit bool `json:"auto_init"`
+ // Gitignores to use
+ Gitignores string `json:"gitignores"`
+ // License to use
+ License string `json:"license"`
+ // Readme of the repository to create
+ Readme string `json:"readme"`
+}
+
+// EditRepoOption options when editing a repository's properties
+// swagger:model
+type EditRepoOption struct {
+ // Name of the repository
+ //
+ // required: true
+ // unique: true
+ Name *string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
+ // A short description of the repository.
+ Description *string `json:"description,omitempty" binding:"MaxSize(255)"`
+ // A URL with more information about the repository.
+ Website *string `json:"website,omitempty" binding:"MaxSize(255)"`
+ // Either `true` to make the repository private or `false` to make it public.
+ // Note: You will get a 422 error if the organization restricts changing repository visibility to organization
+ // owners and a non-owner tries to change the value of private.
+ Private *bool `json:"private,omitempty"`
+ // Either `true` to enable issues for this repository or `false` to disable them.
+ EnableIssues *bool `json:"enable_issues,omitempty"`
+ // Either `true` to enable the wiki for this repository or `false` to disable it.
+ EnableWiki *bool `json:"enable_wiki,omitempty"`
+ // Updates the default branch for this repository.
+ DefaultBranch *string `json:"default_branch,omitempty"`
+ // Either `true` to allow pull requests, or `false` to prevent pull request.
+ EnablePullRequests *bool `json:"enable_pull_requests,omitempty"`
+ // Either `true` to ignore whitepace for conflicts, or `false` to not ignore whitespace. `enabled_pull_requests` must be `true`.
+ IgnoreWhitespaceConflicts *bool `json:"ignore_whitespace,omitempty"`
+ // Either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. `enabled_pull_requests` must be `true`.
+ AllowMerge *bool `json:"allow_merge_commits,omitempty"`
+ // Either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging. `enabled_pull_requests` must be `true`.
+ AllowRebase *bool `json:"allow_rebase,omitempty"`
+ // Either `true` to allow rebase with explicit merge commits (--no-ff), or `false` to prevent rebase with explicit merge commits. `enabled_pull_requests` must be `true`.
+ AllowRebaseMerge *bool `json:"allow_rebase_explicit,omitempty"`
+ // Either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging. `enabled_pull_requests` must be `true`.
+ AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"`
+ // `true` to archive this repository. Note: You cannot unarchive repositories through the API.
+ Archived *bool `json:"archived,omitempty"`
+}
+
+// MigrateRepoOption options for migrating a repository from an external service
+type MigrateRepoOption struct {
+ // required: true
+ CloneAddr string `json:"clone_addr" binding:"Required"`
+ AuthUsername string `json:"auth_username"`
+ AuthPassword string `json:"auth_password"`
+ // required: true
+ UID int `json:"uid" binding:"Required"`
+ // required: true
+ RepoName string `json:"repo_name" binding:"Required"`
+ Mirror bool `json:"mirror"`
+ Private bool `json:"private"`
+ Description string `json:"description"`
+}
diff --git a/modules/structs/repo_branch.go b/modules/structs/repo_branch.go
new file mode 100644
index 0000000000..a6ae6c1663
--- /dev/null
+++ b/modules/structs/repo_branch.go
@@ -0,0 +1,11 @@
+// Copyright 2016 The Gogs 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 structs
+
+// Branch represents a repository branch
+type Branch struct {
+ Name string `json:"name"`
+ Commit *PayloadCommit `json:"commit"`
+}
diff --git a/modules/structs/repo_collaborator.go b/modules/structs/repo_collaborator.go
new file mode 100644
index 0000000000..2b4fa390d2
--- /dev/null
+++ b/modules/structs/repo_collaborator.go
@@ -0,0 +1,10 @@
+// Copyright 2016 The Gogs 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 structs
+
+// AddCollaboratorOption options when adding a user as a collaborator of a repository
+type AddCollaboratorOption struct {
+ Permission *string `json:"permission"`
+}
diff --git a/modules/structs/repo_commit.go b/modules/structs/repo_commit.go
new file mode 100644
index 0000000000..9cde2873d4
--- /dev/null
+++ b/modules/structs/repo_commit.go
@@ -0,0 +1,44 @@
+// Copyright 2018 The Gogs Authors. All rights reserved.
+// Copyright 2019 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 structs
+
+// Identity for a person's identity like an author or committer
+type Identity struct {
+ Name string `json:"name" binding:"MaxSize(100)"`
+ // swagger:strfmt email
+ Email string `json:"email" binding:"MaxSize(254)"`
+}
+
+// CommitMeta contains meta information of a commit in terms of API.
+type CommitMeta struct {
+ URL string `json:"url"`
+ SHA string `json:"sha"`
+}
+
+// CommitUser contains information of a user in the context of a commit.
+type CommitUser struct {
+ Identity
+ Date string `json:"date"`
+}
+
+// RepoCommit contains information of a commit in the context of a repository.
+type RepoCommit struct {
+ URL string `json:"url"`
+ Author *CommitUser `json:"author"`
+ Committer *CommitUser `json:"committer"`
+ Message string `json:"message"`
+ Tree *CommitMeta `json:"tree"`
+}
+
+// Commit contains information generated from a Git commit.
+type Commit struct {
+ *CommitMeta
+ HTMLURL string `json:"html_url"`
+ RepoCommit *RepoCommit `json:"commit"`
+ Author *User `json:"author"`
+ Committer *User `json:"committer"`
+ Parents []*CommitMeta `json:"parents"`
+}
diff --git a/modules/structs/repo_file.go b/modules/structs/repo_file.go
new file mode 100644
index 0000000000..ac8b9333fe
--- /dev/null
+++ b/modules/structs/repo_file.go
@@ -0,0 +1,80 @@
+// Copyright 2014 The Gogs Authors. All rights reserved.
+// Copyright 2019 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 structs
+
+// FileOptions options for all file APIs
+type FileOptions struct {
+ Message string `json:"message" binding:"Required"`
+ BranchName string `json:"branch"`
+ NewBranchName string `json:"new_branch"`
+ Author Identity `json:"author"`
+ Committer Identity `json:"committer"`
+}
+
+// CreateFileOptions options for creating files
+type CreateFileOptions struct {
+ FileOptions
+ Content string `json:"content"`
+}
+
+// DeleteFileOptions options for deleting files (used for other File structs below)
+type DeleteFileOptions struct {
+ FileOptions
+ SHA string `json:"sha" binding:"Required"`
+}
+
+// UpdateFileOptions options for updating files
+type UpdateFileOptions struct {
+ DeleteFileOptions
+ Content string `json:"content"`
+ FromPath string `json:"from_path" binding:"MaxSize(500)"`
+}
+
+// FileLinksResponse contains the links for a repo's file
+type FileLinksResponse struct {
+ Self string `json:"url"`
+ GitURL string `json:"git_url"`
+ HTMLURL string `json:"html_url"`
+}
+
+// FileContentResponse contains information about a repo's file stats and content
+type FileContentResponse struct {
+ Name string `json:"name"`
+ Path string `json:"path"`
+ SHA string `json:"sha"`
+ Size int64 `json:"size"`
+ URL string `json:"url"`
+ HTMLURL string `json:"html_url"`
+ GitURL string `json:"git_url"`
+ DownloadURL string `json:"download_url"`
+ Type string `json:"type"`
+ Links *FileLinksResponse `json:"_links"`
+}
+
+// FileCommitResponse contains information generated from a Git commit for a repo's file.
+type FileCommitResponse struct {
+ CommitMeta
+ HTMLURL string `json:"html_url"`
+ Author *CommitUser `json:"author"`
+ Committer *CommitUser `json:"committer"`
+ Parents []*CommitMeta `json:"parents"`
+ Message string `json:"message"`
+ Tree *CommitMeta `json:"tree"`
+}
+
+// FileResponse contains information about a repo's file
+type FileResponse struct {
+ Content *FileContentResponse `json:"content"`
+ Commit *FileCommitResponse `json:"commit"`
+ Verification *PayloadCommitVerification `json:"verification"`
+}
+
+// FileDeleteResponse contains information about a repo's file that was deleted
+type FileDeleteResponse struct {
+ Content interface{} `json:"content"` // to be set to nil
+ Commit *FileCommitResponse `json:"commit"`
+ Verification *PayloadCommitVerification `json:"verification"`
+}
diff --git a/modules/structs/repo_key.go b/modules/structs/repo_key.go
new file mode 100644
index 0000000000..29928bd97e
--- /dev/null
+++ b/modules/structs/repo_key.go
@@ -0,0 +1,41 @@
+// Copyright 2015 The Gogs 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 structs
+
+import (
+ "time"
+)
+
+// DeployKey a deploy key
+type DeployKey struct {
+ ID int64 `json:"id"`
+ KeyID int64 `json:"key_id"`
+ Key string `json:"key"`
+ URL string `json:"url"`
+ Title string `json:"title"`
+ Fingerprint string `json:"fingerprint"`
+ // swagger:strfmt date-time
+ Created time.Time `json:"created_at"`
+ ReadOnly bool `json:"read_only"`
+ Repository *Repository `json:"repository,omitempty"`
+}
+
+// CreateKeyOption options when creating a key
+type CreateKeyOption struct {
+ // Title of the key to add
+ //
+ // required: true
+ // unique: true
+ Title string `json:"title" binding:"Required"`
+ // An armored SSH key to add
+ //
+ // required: true
+ // unique: true
+ Key string `json:"key" binding:"Required"`
+ // Describe if the key has only read access or read/write
+ //
+ // required: false
+ ReadOnly bool `json:"read_only"`
+}
diff --git a/modules/structs/repo_refs.go b/modules/structs/repo_refs.go
new file mode 100644
index 0000000000..0bf4b94ae1
--- /dev/null
+++ b/modules/structs/repo_refs.go
@@ -0,0 +1,19 @@
+// 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 structs
+
+// 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"`
+}
diff --git a/modules/structs/repo_tag.go b/modules/structs/repo_tag.go
new file mode 100644
index 0000000000..6294a8099d
--- /dev/null
+++ b/modules/structs/repo_tag.go
@@ -0,0 +1,16 @@
+// Copyright 2019 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 structs
+
+// Tag represents a repository tag
+type Tag struct {
+ Name string `json:"name"`
+ Commit struct {
+ SHA string `json:"sha"`
+ URL string `json:"url"`
+ } `json:"commit"`
+ ZipballURL string `json:"zipball_url"`
+ TarballURL string `json:"tarball_url"`
+}
diff --git a/modules/structs/repo_tree.go b/modules/structs/repo_tree.go
new file mode 100644
index 0000000000..58aa3b8339
--- /dev/null
+++ b/modules/structs/repo_tree.go
@@ -0,0 +1,25 @@
+// 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 structs
+
+// 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"`
+ Page int `json:"page"`
+ TotalCount int `json:"total_count"`
+}
diff --git a/modules/structs/repo_watch.go b/modules/structs/repo_watch.go
new file mode 100644
index 0000000000..606785a4fd
--- /dev/null
+++ b/modules/structs/repo_watch.go
@@ -0,0 +1,19 @@
+// 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 structs
+
+import (
+ "time"
+)
+
+// WatchInfo represents an API watch status of one repository
+type WatchInfo struct {
+ Subscribed bool `json:"subscribed"`
+ Ignored bool `json:"ignored"`
+ Reason interface{} `json:"reason"`
+ CreatedAt time.Time `json:"created_at"`
+ URL string `json:"url"`
+ RepositoryURL string `json:"repository_url"`
+}
diff --git a/modules/structs/status.go b/modules/structs/status.go
new file mode 100644
index 0000000000..e833bd69e5
--- /dev/null
+++ b/modules/structs/status.go
@@ -0,0 +1,65 @@
+// 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 structs
+
+import (
+ "time"
+)
+
+// StatusState holds the state of a Status
+// It can be "pending", "success", "error", "failure", and "warning"
+type StatusState string
+
+const (
+ // StatusPending is for when the Status is Pending
+ StatusPending StatusState = "pending"
+ // StatusSuccess is for when the Status is Success
+ StatusSuccess StatusState = "success"
+ // StatusError is for when the Status is Error
+ StatusError StatusState = "error"
+ // StatusFailure is for when the Status is Failure
+ StatusFailure StatusState = "failure"
+ // StatusWarning is for when the Status is Warning
+ StatusWarning StatusState = "warning"
+)
+
+// Status holds a single Status of a single Commit
+type Status struct {
+ ID int64 `json:"id"`
+ State StatusState `json:"status"`
+ TargetURL string `json:"target_url"`
+ Description string `json:"description"`
+ URL string `json:"url"`
+ Context string `json:"context"`
+ Creator *User `json:"creator"`
+ // swagger:strfmt date-time
+ Created time.Time `json:"created_at"`
+ // swagger:strfmt date-time
+ Updated time.Time `json:"updated_at"`
+}
+
+// CombinedStatus holds the combined state of several statuses for a single commit
+type CombinedStatus struct {
+ State StatusState `json:"state"`
+ SHA string `json:"sha"`
+ TotalCount int `json:"total_count"`
+ Statuses []*Status `json:"statuses"`
+ Repository *Repository `json:"repository"`
+ CommitURL string `json:"commit_url"`
+ URL string `json:"url"`
+}
+
+// CreateStatusOption holds the information needed to create a new Status for a Commit
+type CreateStatusOption struct {
+ State StatusState `json:"state"`
+ TargetURL string `json:"target_url"`
+ Description string `json:"description"`
+ Context string `json:"context"`
+}
+
+// ListStatusesOption holds pagination information
+type ListStatusesOption struct {
+ Page int
+}
diff --git a/modules/structs/user.go b/modules/structs/user.go
new file mode 100644
index 0000000000..251c803129
--- /dev/null
+++ b/modules/structs/user.go
@@ -0,0 +1,38 @@
+// Copyright 2014 The Gogs 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 structs
+
+import (
+ "encoding/json"
+)
+
+// User represents a user
+// swagger:model
+type User struct {
+ // the user's id
+ ID int64 `json:"id"`
+ // the user's username
+ UserName string `json:"login"`
+ // 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"`
+ // User locale
+ Language string `json:"language"`
+ // Is the user an administrator
+ IsAdmin bool `json:"is_admin"`
+}
+
+// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
+func (u User) MarshalJSON() ([]byte, error) {
+ // Re-declaring User to avoid recursion
+ type shadow User
+ return json.Marshal(struct {
+ shadow
+ CompatUserName string `json:"username"`
+ }{shadow(u), u.UserName})
+}
diff --git a/modules/structs/user_app.go b/modules/structs/user_app.go
new file mode 100644
index 0000000000..9340486685
--- /dev/null
+++ b/modules/structs/user_app.go
@@ -0,0 +1,34 @@
+// Copyright 2014 The Gogs Authors. All rights reserved.
+// Copyright 2019 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 structs
+
+import (
+ "encoding/base64"
+)
+
+// BasicAuthEncode generate base64 of basic auth head
+func BasicAuthEncode(user, pass string) string {
+ return base64.StdEncoding.EncodeToString([]byte(user + ":" + pass))
+}
+
+// AccessToken represents an API access token.
+// swagger:response AccessToken
+type AccessToken struct {
+ ID int64 `json:"id"`
+ Name string `json:"name"`
+ Token string `json:"sha1"`
+ TokenLastEight string `json:"token_last_eight"`
+}
+
+// AccessTokenList represents a list of API access token.
+// swagger:response AccessTokenList
+type AccessTokenList []*AccessToken
+
+// CreateAccessTokenOption options when create access token
+// swagger:parameters userCreateToken
+type CreateAccessTokenOption struct {
+ Name string `json:"name" binding:"Required"`
+}
diff --git a/modules/structs/user_email.go b/modules/structs/user_email.go
new file mode 100644
index 0000000000..a72b04119a
--- /dev/null
+++ b/modules/structs/user_email.go
@@ -0,0 +1,25 @@
+// Copyright 2015 The Gogs 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 structs
+
+// Email an email address belonging to a user
+type Email struct {
+ // swagger:strfmt email
+ Email string `json:"email"`
+ Verified bool `json:"verified"`
+ Primary bool `json:"primary"`
+}
+
+// CreateEmailOption options when creating email addresses
+type CreateEmailOption struct {
+ // email addresses to add
+ Emails []string `json:"emails"`
+}
+
+// DeleteEmailOption options when deleting email addresses
+type DeleteEmailOption struct {
+ // email addresses to delete
+ Emails []string `json:"emails"`
+}
diff --git a/modules/structs/user_gpgkey.go b/modules/structs/user_gpgkey.go
new file mode 100644
index 0000000000..f501a09cb9
--- /dev/null
+++ b/modules/structs/user_gpgkey.go
@@ -0,0 +1,43 @@
+// Copyright 2017 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 structs
+
+import (
+ "time"
+)
+
+// GPGKey a user GPG key to sign commit and tag in repository
+type GPGKey struct {
+ ID int64 `json:"id"`
+ PrimaryKeyID string `json:"primary_key_id"`
+ KeyID string `json:"key_id"`
+ PublicKey string `json:"public_key"`
+ Emails []*GPGKeyEmail `json:"emails"`
+ SubsKey []*GPGKey `json:"subkeys"`
+ CanSign bool `json:"can_sign"`
+ CanEncryptComms bool `json:"can_encrypt_comms"`
+ CanEncryptStorage bool `json:"can_encrypt_storage"`
+ CanCertify bool `json:"can_certify"`
+ // swagger:strfmt date-time
+ Created time.Time `json:"created_at,omitempty"`
+ // swagger:strfmt date-time
+ Expires time.Time `json:"expires_at,omitempty"`
+}
+
+// GPGKeyEmail an email attached to a GPGKey
+// swagger:model GPGKeyEmail
+type GPGKeyEmail struct {
+ Email string `json:"email"`
+ Verified bool `json:"verified"`
+}
+
+// CreateGPGKeyOption options create user GPG key
+type CreateGPGKeyOption struct {
+ // An armored GPG key to add
+ //
+ // required: true
+ // unique: true
+ ArmoredKey string `json:"armored_public_key" binding:"Required"`
+}
diff --git a/modules/structs/user_key.go b/modules/structs/user_key.go
new file mode 100644
index 0000000000..ee487607c3
--- /dev/null
+++ b/modules/structs/user_key.go
@@ -0,0 +1,23 @@
+// Copyright 2015 The Gogs 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 structs
+
+import (
+ "time"
+)
+
+// PublicKey publickey is a user key to push code to repository
+type PublicKey struct {
+ ID int64 `json:"id"`
+ Key string `json:"key"`
+ URL string `json:"url,omitempty"`
+ Title string `json:"title,omitempty"`
+ Fingerprint string `json:"fingerprint,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"`
+}
diff --git a/modules/structs/user_search.go b/modules/structs/user_search.go
new file mode 100644
index 0000000000..1650cf736a
--- /dev/null
+++ b/modules/structs/user_search.go
@@ -0,0 +1,5 @@
+package structs
+
+type searchUsersResponse struct {
+ Users []*User `json:"data"`
+}
diff --git a/modules/structs/utils.go b/modules/structs/utils.go
new file mode 100644
index 0000000000..1b9d689562
--- /dev/null
+++ b/modules/structs/utils.go
@@ -0,0 +1,26 @@
+// Copyright 2015 The Gogs 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 structs
+
+import (
+ "net/http"
+)
+
+var jsonHeader = http.Header{"content-type": []string{"application/json"}}
+
+// Bool return address of bool value
+func Bool(v bool) *bool {
+ return &v
+}
+
+// String return address of string value
+func String(v string) *string {
+ return &v
+}
+
+// Int64 return address of int64 value
+func Int64(v int64) *int64 {
+ return &v
+}