Update Structs (#524)
Update gitea structs to [365c4e9316bbcc8bdf9cf68ef237bf18ae8db315](365c4e9316
) state.
use:
`git log --name-only --pretty=oneline --full-index v1.14.0..HEAD | grep -vE '^[0-9a-f]{40} ' | sort | uniq | grep ^modules/structs`
and
`git diff --full-index v1.13.0..HEAD -- modules/structs`
if you like to check yourselve
Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/524
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
cc08994d13
commit
13d2d23dfc
12 changed files with 144 additions and 59 deletions
|
@ -13,6 +13,7 @@ Just follow this guid and if you still encounter problems, ask for help on disco
|
||||||
|
|
||||||
- The `State` field at **NotificationSubject** changed from **StateType** to **NotifySubjectState**, it also contains `"open"`, `"closed"` and add `"merged"`.
|
- The `State` field at **NotificationSubject** changed from **StateType** to **NotifySubjectState**, it also contains `"open"`, `"closed"` and add `"merged"`.
|
||||||
- In **Issue**, **CreateIssueOption** and **EditIssueOption** structs, `Assignee` got removed. Use `Assignees`.
|
- In **Issue**, **CreateIssueOption** and **EditIssueOption** structs, `Assignee` got removed. Use `Assignees`.
|
||||||
|
- `Type` field at **CreateHookOption** now use **HookType** instead of pure string.
|
||||||
|
|
||||||
Pulls:
|
Pulls:
|
||||||
- [#503 Drop deprecations](https://gitea.com/gitea/go-sdk/pulls/503)
|
- [#503 Drop deprecations](https://gitea.com/gitea/go-sdk/pulls/503)
|
||||||
|
|
|
@ -26,14 +26,15 @@ func (c *Client) AdminListUsers(opt AdminListUsersOptions) ([]*User, *Response,
|
||||||
|
|
||||||
// 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"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
FullName string `json:"full_name"`
|
FullName string `json:"full_name"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
MustChangePassword *bool `json:"must_change_password"`
|
MustChangePassword *bool `json:"must_change_password"`
|
||||||
SendNotify bool `json:"send_notify"`
|
SendNotify bool `json:"send_notify"`
|
||||||
|
Visibility *VisibleType `json:"visibility"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the CreateUserOption struct
|
// Validate the CreateUserOption struct
|
||||||
|
@ -63,21 +64,24 @@ func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, *Response, 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"`
|
||||||
Email *string `json:"email"`
|
Email *string `json:"email"`
|
||||||
FullName *string `json:"full_name"`
|
FullName *string `json:"full_name"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
MustChangePassword *bool `json:"must_change_password"`
|
Description *string `json:"description"`
|
||||||
Website *string `json:"website"`
|
MustChangePassword *bool `json:"must_change_password"`
|
||||||
Location *string `json:"location"`
|
Website *string `json:"website"`
|
||||||
Active *bool `json:"active"`
|
Location *string `json:"location"`
|
||||||
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"`
|
||||||
ProhibitLogin *bool `json:"prohibit_login"`
|
MaxRepoCreation *int `json:"max_repo_creation"`
|
||||||
AllowCreateOrganization *bool `json:"allow_create_organization"`
|
ProhibitLogin *bool `json:"prohibit_login"`
|
||||||
|
AllowCreateOrganization *bool `json:"allow_create_organization"`
|
||||||
|
Restricted *bool `json:"restricted"`
|
||||||
|
Visibility *VisibleType `json:"visibility"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdminEditUser modify user informations
|
// AdminEditUser modify user informations
|
||||||
|
|
|
@ -24,6 +24,28 @@ type Hook struct {
|
||||||
Created time.Time `json:"created_at"`
|
Created time.Time `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HookType represent all webhook types gitea currently offer
|
||||||
|
type HookType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// HookTypeDingtalk webhook that dingtalk understand
|
||||||
|
HookTypeDingtalk HookType = "dingtalk"
|
||||||
|
// HookTypeDiscord webhook that discord understand
|
||||||
|
HookTypeDiscord HookType = "discord"
|
||||||
|
// HookTypeGitea webhook that gitea understand
|
||||||
|
HookTypeGitea HookType = "gitea"
|
||||||
|
// HookTypeGogs webhook that gogs understand
|
||||||
|
HookTypeGogs HookType = "gogs"
|
||||||
|
// HookTypeMsteams webhook that msteams understand
|
||||||
|
HookTypeMsteams HookType = "msteams"
|
||||||
|
// HookTypeSlack webhook that slack understand
|
||||||
|
HookTypeSlack HookType = "slack"
|
||||||
|
// HookTypeTelegram webhook that telegram understand
|
||||||
|
HookTypeTelegram HookType = "telegram"
|
||||||
|
// HookTypeFeishu webhook that feishu understand
|
||||||
|
HookTypeFeishu HookType = "feishu"
|
||||||
|
)
|
||||||
|
|
||||||
// ListHooksOptions options for listing hooks
|
// ListHooksOptions options for listing hooks
|
||||||
type ListHooksOptions struct {
|
type ListHooksOptions struct {
|
||||||
ListOptions
|
ListOptions
|
||||||
|
@ -73,7 +95,7 @@ func (c *Client) GetRepoHook(user, repo string, id int64) (*Hook, *Response, err
|
||||||
|
|
||||||
// CreateHookOption options when create a hook
|
// CreateHookOption options when create a hook
|
||||||
type CreateHookOption struct {
|
type CreateHookOption struct {
|
||||||
Type string `json:"type"`
|
Type HookType `json:"type"`
|
||||||
Config map[string]string `json:"config"`
|
Config map[string]string `json:"config"`
|
||||||
Events []string `json:"events"`
|
Events []string `json:"events"`
|
||||||
BranchFilter string `json:"branch_filter"`
|
BranchFilter string `json:"branch_filter"`
|
||||||
|
|
13
gitea/org.go
13
gitea/org.go
|
@ -73,12 +73,13 @@ func (c *Client) GetOrg(orgname string) (*Organization, *Response, error) {
|
||||||
|
|
||||||
// CreateOrgOption options for creating an organization
|
// CreateOrgOption options for creating an organization
|
||||||
type CreateOrgOption struct {
|
type CreateOrgOption struct {
|
||||||
Name string `json:"username"`
|
Name string `json:"username"`
|
||||||
FullName string `json:"full_name"`
|
FullName string `json:"full_name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Website string `json:"website"`
|
Website string `json:"website"`
|
||||||
Location string `json:"location"`
|
Location string `json:"location"`
|
||||||
Visibility VisibleType `json:"visibility"`
|
Visibility VisibleType `json:"visibility"`
|
||||||
|
RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkVisibilityOpt check if mode exist
|
// checkVisibilityOpt check if mode exist
|
||||||
|
|
|
@ -12,17 +12,38 @@ import (
|
||||||
|
|
||||||
// Team represents a team in an organization
|
// Team represents a team in an 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"`
|
||||||
Organization *Organization `json:"organization"`
|
Organization *Organization `json:"organization"`
|
||||||
Permission AccessMode `json:"permission"`
|
Permission AccessMode `json:"permission"`
|
||||||
CanCreateOrgRepo bool `json:"can_create_org_repo"`
|
CanCreateOrgRepo bool `json:"can_create_org_repo"`
|
||||||
IncludesAllRepositories bool `json:"includes_all_repositories"`
|
IncludesAllRepositories bool `json:"includes_all_repositories"`
|
||||||
// example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"]
|
Units []RepoUnitType `json:"units"`
|
||||||
Units []string `json:"units"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RepoUnitType represent all unit types of a repo gitea currently offer
|
||||||
|
type RepoUnitType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// RepoUnitCode represent file view of a repository
|
||||||
|
RepoUnitCode RepoUnitType = "repo.code"
|
||||||
|
// RepoUnitIssues represent issues of a repository
|
||||||
|
RepoUnitIssues RepoUnitType = "repo.issues"
|
||||||
|
// RepoUnitPulls represent pulls of a repository
|
||||||
|
RepoUnitPulls RepoUnitType = "repo.pulls"
|
||||||
|
// RepoUnitExtIssues represent external issues of a repository
|
||||||
|
RepoUnitExtIssues RepoUnitType = "repo.ext_issues"
|
||||||
|
// RepoUnitWiki represent wiki of a repository
|
||||||
|
RepoUnitWiki RepoUnitType = "repo.wiki"
|
||||||
|
// RepoUnitExtWiki represent external wiki of a repository
|
||||||
|
RepoUnitExtWiki RepoUnitType = "repo.ext_wiki"
|
||||||
|
// RepoUnitReleases represent releases of a repository
|
||||||
|
RepoUnitReleases RepoUnitType = "repo.releases"
|
||||||
|
// RepoUnitProjects represent projects of a repository
|
||||||
|
RepoUnitProjects RepoUnitType = "repo.projects"
|
||||||
|
)
|
||||||
|
|
||||||
// ListTeamsOptions options for listing teams
|
// ListTeamsOptions options for listing teams
|
||||||
type ListTeamsOptions struct {
|
type ListTeamsOptions struct {
|
||||||
ListOptions
|
ListOptions
|
||||||
|
@ -56,13 +77,12 @@ func (c *Client) GetTeam(id int64) (*Team, *Response, error) {
|
||||||
|
|
||||||
// CreateTeamOption options for creating a team
|
// CreateTeamOption options for creating a team
|
||||||
type CreateTeamOption struct {
|
type CreateTeamOption struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Permission AccessMode `json:"permission"`
|
Permission AccessMode `json:"permission"`
|
||||||
CanCreateOrgRepo bool `json:"can_create_org_repo"`
|
CanCreateOrgRepo bool `json:"can_create_org_repo"`
|
||||||
IncludesAllRepositories bool `json:"includes_all_repositories"`
|
IncludesAllRepositories bool `json:"includes_all_repositories"`
|
||||||
// example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"]
|
Units []RepoUnitType `json:"units"`
|
||||||
Units []string `json:"units"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the CreateTeamOption struct
|
// Validate the CreateTeamOption struct
|
||||||
|
@ -103,13 +123,12 @@ func (c *Client) CreateTeam(org string, opt CreateTeamOption) (*Team, *Response,
|
||||||
|
|
||||||
// EditTeamOption options for editing a team
|
// EditTeamOption options for editing a team
|
||||||
type EditTeamOption struct {
|
type EditTeamOption struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description *string `json:"description"`
|
Description *string `json:"description"`
|
||||||
Permission AccessMode `json:"permission"`
|
Permission AccessMode `json:"permission"`
|
||||||
CanCreateOrgRepo *bool `json:"can_create_org_repo"`
|
CanCreateOrgRepo *bool `json:"can_create_org_repo"`
|
||||||
IncludesAllRepositories *bool `json:"includes_all_repositories"`
|
IncludesAllRepositories *bool `json:"includes_all_repositories"`
|
||||||
// example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"]
|
Units []RepoUnitType `json:"units"`
|
||||||
Units []string `json:"units"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the EditTeamOption struct
|
// Validate the EditTeamOption struct
|
||||||
|
|
|
@ -57,6 +57,7 @@ type PullReviewComment struct {
|
||||||
Body string `json:"body"`
|
Body string `json:"body"`
|
||||||
Reviewer *User `json:"user"`
|
Reviewer *User `json:"user"`
|
||||||
ReviewID int64 `json:"pull_request_review_id"`
|
ReviewID int64 `json:"pull_request_review_id"`
|
||||||
|
Resolver *User `json:"resolver"`
|
||||||
|
|
||||||
Created time.Time `json:"created_at"`
|
Created time.Time `json:"created_at"`
|
||||||
Updated time.Time `json:"updated_at"`
|
Updated time.Time `json:"updated_at"`
|
||||||
|
|
|
@ -93,6 +93,7 @@ type Repository struct {
|
||||||
AvatarURL string `json:"avatar_url"`
|
AvatarURL string `json:"avatar_url"`
|
||||||
Internal bool `json:"internal"`
|
Internal bool `json:"internal"`
|
||||||
MirrorInterval string `json:"mirror_interval"`
|
MirrorInterval string `json:"mirror_interval"`
|
||||||
|
DefaultMergeStyle MergeStyle `json:"default_merge_style"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RepoType represent repo type
|
// RepoType represent repo type
|
||||||
|
@ -433,6 +434,13 @@ type EditRepoOption struct {
|
||||||
Archived *bool `json:"archived,omitempty"`
|
Archived *bool `json:"archived,omitempty"`
|
||||||
// set to a string like `8h30m0s` to set the mirror interval time
|
// set to a string like `8h30m0s` to set the mirror interval time
|
||||||
MirrorInterval *string `json:"mirror_interval,omitempty"`
|
MirrorInterval *string `json:"mirror_interval,omitempty"`
|
||||||
|
// either `true` to allow mark pr as merged manually, or `false` to prevent it. `has_pull_requests` must be `true`.
|
||||||
|
AllowManualMerge *bool `json:"allow_manual_merge,omitempty"`
|
||||||
|
// either `true` to enable AutodetectManualMerge, or `false` to prevent it. `has_pull_requests` must be `true`, Note: In some special cases, misjudgments can occur.
|
||||||
|
AutodetectManualMerge *bool `json:"autodetect_manual_merge,omitempty"`
|
||||||
|
// set to a merge style to be used by this repository: "merge", "rebase", "rebase-merge", or "squash". `has_pull_requests` must be `true`.
|
||||||
|
DefaultMergeStyle *MergeStyle `json:"default_merge_style,omitempty"`
|
||||||
|
// set to `true` to archive this repository.
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditRepo edit the properties of a repository
|
// EditRepo edit the properties of a repository
|
||||||
|
|
|
@ -47,6 +47,8 @@ type MigrateRepoOption struct {
|
||||||
PullRequests bool `json:"pull_requests"`
|
PullRequests bool `json:"pull_requests"`
|
||||||
Releases bool `json:"releases"`
|
Releases bool `json:"releases"`
|
||||||
MirrorInterval string `json:"mirror_interval"`
|
MirrorInterval string `json:"mirror_interval"`
|
||||||
|
LFS bool `json:"lfs"`
|
||||||
|
LFSEndpoint string `json:"lfs_endpoint"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the MigrateRepoOption struct
|
// Validate the MigrateRepoOption struct
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
// Tag represents a repository tag
|
// Tag represents a repository tag
|
||||||
type Tag struct {
|
type Tag struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
Message string `json:"message"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Commit *CommitMeta `json:"commit"`
|
Commit *CommitMeta `json:"commit"`
|
||||||
ZipballURL string `json:"zipball_url"`
|
ZipballURL string `json:"zipball_url"`
|
||||||
|
|
|
@ -8,13 +8,17 @@ package gitea
|
||||||
type GlobalUISettings struct {
|
type GlobalUISettings struct {
|
||||||
DefaultTheme string `json:"default_theme"`
|
DefaultTheme string `json:"default_theme"`
|
||||||
AllowedReactions []string `json:"allowed_reactions"`
|
AllowedReactions []string `json:"allowed_reactions"`
|
||||||
|
CustomEmojis []string `json:"custom_emojis"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GlobalRepoSettings represent the global repository settings of a gitea instance witch is exposed by API
|
// GlobalRepoSettings represent the global repository settings of a gitea instance witch is exposed by API
|
||||||
type GlobalRepoSettings struct {
|
type GlobalRepoSettings struct {
|
||||||
MirrorsDisabled bool `json:"mirrors_disabled"`
|
MirrorsDisabled bool `json:"mirrors_disabled"`
|
||||||
HTTPGitDisabled bool `json:"http_git_disabled"`
|
HTTPGitDisabled bool `json:"http_git_disabled"`
|
||||||
MigrationsDisabled bool `json:"migrations_disabled"`
|
MigrationsDisabled bool `json:"migrations_disabled"`
|
||||||
|
StarsDisabled bool `json:"stars_disabled"`
|
||||||
|
TimeTrackingDisabled bool `json:"time_tracking_disabled"`
|
||||||
|
LFSDisabled bool `json:"lfs_disabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GlobalAPISettings contains global api settings exposed by it
|
// GlobalAPISettings contains global api settings exposed by it
|
||||||
|
|
|
@ -25,6 +25,7 @@ func TestGetGlobalSettings(t *testing.T) {
|
||||||
assert.EqualValues(t, &GlobalRepoSettings{
|
assert.EqualValues(t, &GlobalRepoSettings{
|
||||||
HTTPGitDisabled: false,
|
HTTPGitDisabled: false,
|
||||||
MirrorsDisabled: false,
|
MirrorsDisabled: false,
|
||||||
|
LFSDisabled: true,
|
||||||
}, repoSettings)
|
}, repoSettings)
|
||||||
|
|
||||||
apiSettings, _, err := c.GetGlobalAPISettings()
|
apiSettings, _, err := c.GetGlobalAPISettings()
|
||||||
|
|
|
@ -25,9 +25,30 @@ type User struct {
|
||||||
// User locale
|
// User locale
|
||||||
Language string `json:"language"`
|
Language string `json:"language"`
|
||||||
// Is the user an administrator
|
// Is the user an administrator
|
||||||
IsAdmin bool `json:"is_admin"`
|
IsAdmin bool `json:"is_admin"`
|
||||||
LastLogin time.Time `json:"last_login,omitempty"`
|
// Date and Time of last login
|
||||||
Created time.Time `json:"created,omitempty"`
|
LastLogin time.Time `json:"last_login"`
|
||||||
|
// Date and Time of user creation
|
||||||
|
Created time.Time `json:"created"`
|
||||||
|
// Is user restricted
|
||||||
|
Restricted bool `json:"restricted"`
|
||||||
|
// Is user active
|
||||||
|
IsActive bool `json:"active"`
|
||||||
|
// Is user login prohibited
|
||||||
|
ProhibitLogin bool `json:"prohibit_login"`
|
||||||
|
// the user's location
|
||||||
|
Location string `json:"location"`
|
||||||
|
// the user's website
|
||||||
|
Website string `json:"website"`
|
||||||
|
// the user's description
|
||||||
|
Description string `json:"description"`
|
||||||
|
// User visibility level option
|
||||||
|
Visibility VisibleType `json:"visibility"`
|
||||||
|
|
||||||
|
// user counts
|
||||||
|
FollowerCount int `json:"followers_count"`
|
||||||
|
FollowingCount int `json:"following_count"`
|
||||||
|
StarredRepoCount int `json:"starred_repos_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserInfo get user info by user's name
|
// GetUserInfo get user info by user's name
|
||||||
|
|
Loading…
Reference in a new issue