diff --git a/cmd/forgegen/generator.go b/cmd/forgegen/generator.go index e339161..9bee666 100644 --- a/cmd/forgegen/generator.go +++ b/cmd/forgegen/generator.go @@ -5,6 +5,7 @@ import ( "cmp" "maps" "slices" + "strings" "text/template" core "dappco.re/go/core" @@ -175,6 +176,12 @@ import "time" {{- if .Description}} // {{.Name}} — {{sanitise .Description}} {{- end}} +{{- if .Usage}} +// +// Usage: +// +// opts := {{.Usage}} +{{- end}} {{- if .IsEnum}} type {{.Name}} string @@ -215,6 +222,8 @@ func Generate(types map[string]*GoType, pairs []CRUDPair, outDir string) error { return core.E("Generate", "create output directory", err) } + populateUsageExamples(types) + // Group types by output file. groups := make(map[string][]*GoType) for _, gt := range types { @@ -243,6 +252,127 @@ func Generate(types map[string]*GoType, pairs []CRUDPair, outDir string) error { return nil } +func populateUsageExamples(types map[string]*GoType) { + for _, gt := range types { + if !shouldHaveUsage(gt.Name) { + continue + } + gt.Usage = usageExample(gt) + } +} + +func shouldHaveUsage(name string) bool { + if core.HasSuffix(name, "Option") || core.HasSuffix(name, "Options") { + return true + } + for _, prefix := range []string{ + "Create", "Edit", "Update", "Delete", "Add", "Set", + "Dispatch", "Migrate", "Generate", "Replace", "Submit", "Transfer", + } { + if core.HasPrefix(name, prefix) { + return true + } + } + return false +} + +func usageExample(gt *GoType) string { + example := exampleTypeLiteral(gt) + if example == "" { + example = gt.Name + "{}" + } + return example +} + +func exampleTypeLiteral(gt *GoType) string { + if len(gt.Fields) == 0 { + return gt.Name + "{}" + } + + field := chooseUsageField(gt.Fields) + if field.GoName == "" { + return gt.Name + "{}" + } + + return gt.Name + "{" + field.GoName + ": " + exampleValue(field) + "}" +} + +func chooseUsageField(fields []GoField) GoField { + best := fields[0] + bestScore := usageFieldScore(best) + for _, field := range fields[1:] { + score := usageFieldScore(field) + if score < bestScore || (score == bestScore && field.GoName < best.GoName) { + best = field + bestScore = score + } + } + return best +} + +func usageFieldScore(field GoField) int { + score := 100 + if field.Required { + score -= 50 + } + switch { + case core.HasSuffix(field.GoType, "string"): + score -= 30 + case core.Contains(field.GoType, "time.Time"): + score -= 25 + case core.HasSuffix(field.GoType, "bool"): + score -= 20 + case core.Contains(field.GoType, "int"): + score -= 15 + case core.HasPrefix(field.GoType, "[]"): + score -= 10 + } + if core.Contains(field.GoName, "Name") || core.Contains(field.GoName, "Title") || core.Contains(field.GoName, "Body") || core.Contains(field.GoName, "Description") { + score -= 10 + } + return score +} + +func exampleValue(field GoField) string { + switch { + case core.HasPrefix(field.GoType, "*"): + return "&" + core.TrimPrefix(field.GoType, "*") + "{}" + case field.GoType == "string": + return exampleStringValue(field.GoName) + case field.GoType == "time.Time": + return "time.Now()" + case field.GoType == "bool": + return "true" + case core.HasSuffix(field.GoType, "int64"), core.HasSuffix(field.GoType, "int"), core.HasSuffix(field.GoType, "uint64"), core.HasSuffix(field.GoType, "uint"): + return "1" + case core.HasPrefix(field.GoType, "[]string"): + return "[]string{\"example\"}" + case core.HasPrefix(field.GoType, "[]int64"): + return "[]int64{1}" + case core.HasPrefix(field.GoType, "[]int"): + return "[]int{1}" + case core.HasPrefix(field.GoType, "map["): + return "map[string]string{\"key\": \"value\"}" + default: + return "{}" + } +} + +func exampleStringValue(fieldName string) string { + switch { + case core.Contains(fieldName, "URL"): + return "\"https://example.com\"" + case core.Contains(fieldName, "Email"): + return "\"alice@example.com\"" + case core.Contains(fieldName, "Tag"): + return "\"v1.0.0\"" + case core.Contains(fieldName, "Branch"), core.Contains(fieldName, "Ref"): + return "\"main\"" + default: + return "\"example\"" + } +} + // writeFile renders and writes a single Go source file for the given types. func writeFile(path string, types []*GoType) error { needTime := slices.ContainsFunc(types, func(gt *GoType) bool { @@ -264,7 +394,8 @@ func writeFile(path string, types []*GoType) error { return core.E("writeFile", "execute template", err) } - if err := coreio.Local.Write(path, buf.String()); err != nil { + content := strings.TrimRight(buf.String(), "\n") + "\n" + if err := coreio.Local.Write(path, content); err != nil { return core.E("writeFile", "write file", err) } diff --git a/cmd/forgegen/generator_test.go b/cmd/forgegen/generator_test.go index 9fd1b72..8e5910e 100644 --- a/cmd/forgegen/generator_test.go +++ b/cmd/forgegen/generator_test.go @@ -170,3 +170,37 @@ func TestGenerate_AdditionalProperties_Good(t *testing.T) { t.Fatal("typed units_map field not found in any generated file") } } + +func TestGenerate_UsageExamples_Good(t *testing.T) { + spec, err := LoadSpec("../../testdata/swagger.v1.json") + if err != nil { + t.Fatal(err) + } + + types := ExtractTypes(spec) + pairs := DetectCRUDPairs(spec) + + outDir := t.TempDir() + if err := Generate(types, pairs, outDir); err != nil { + t.Fatal(err) + } + + entries, _ := coreio.Local.List(outDir) + var content string + for _, e := range entries { + data, _ := coreio.Local.Read(core.JoinPath(outDir, e.Name())) + if core.Contains(data, "type CreateIssueOption struct") { + content = data + break + } + } + if content == "" { + t.Fatal("CreateIssueOption type not found in any generated file") + } + if !core.Contains(content, "// Usage:") { + t.Fatalf("generated option type is missing usage documentation:\n%s", content) + } + if !core.Contains(content, "opts :=") { + t.Fatalf("generated usage example is missing assignment syntax:\n%s", content) + } +} diff --git a/cmd/forgegen/parser.go b/cmd/forgegen/parser.go index 5c0acee..9a20fe2 100644 --- a/cmd/forgegen/parser.go +++ b/cmd/forgegen/parser.go @@ -71,6 +71,7 @@ type SchemaProperty struct { type GoType struct { Name string Description string + Usage string Fields []GoField IsEnum bool EnumValues []string diff --git a/types/action.go b/types/action.go index ebd7fec..b3eaa20 100644 --- a/types/action.go +++ b/types/action.go @@ -4,56 +4,69 @@ package types import "time" + // ActionTask — ActionTask represents a ActionTask type ActionTask struct { - CreatedAt time.Time `json:"created_at,omitempty"` - DisplayTitle string `json:"display_title,omitempty"` - Event string `json:"event,omitempty"` - HeadBranch string `json:"head_branch,omitempty"` - HeadSHA string `json:"head_sha,omitempty"` - ID int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - RunNumber int64 `json:"run_number,omitempty"` + CreatedAt time.Time `json:"created_at,omitempty"` + DisplayTitle string `json:"display_title,omitempty"` + Event string `json:"event,omitempty"` + HeadBranch string `json:"head_branch,omitempty"` + HeadSHA string `json:"head_sha,omitempty"` + ID int64 `json:"id,omitempty"` + Name string `json:"name,omitempty"` + RunNumber int64 `json:"run_number,omitempty"` RunStartedAt time.Time `json:"run_started_at,omitempty"` - Status string `json:"status,omitempty"` - URL string `json:"url,omitempty"` - UpdatedAt time.Time `json:"updated_at,omitempty"` - WorkflowID string `json:"workflow_id,omitempty"` + Status string `json:"status,omitempty"` + URL string `json:"url,omitempty"` + UpdatedAt time.Time `json:"updated_at,omitempty"` + WorkflowID string `json:"workflow_id,omitempty"` } // ActionTaskResponse — ActionTaskResponse returns a ActionTask type ActionTaskResponse struct { - Entries []*ActionTask `json:"workflow_runs,omitempty"` - TotalCount int64 `json:"total_count,omitempty"` + Entries []*ActionTask `json:"workflow_runs,omitempty"` + TotalCount int64 `json:"total_count,omitempty"` } // ActionVariable — ActionVariable return value of the query API type ActionVariable struct { - Data string `json:"data,omitempty"` // the value of the variable - Name string `json:"name,omitempty"` // the name of the variable - OwnerID int64 `json:"owner_id,omitempty"` // the owner to which the variable belongs - RepoID int64 `json:"repo_id,omitempty"` // the repository to which the variable belongs + Data string `json:"data,omitempty"` // the value of the variable + Name string `json:"name,omitempty"` // the name of the variable + OwnerID int64 `json:"owner_id,omitempty"` // the owner to which the variable belongs + RepoID int64 `json:"repo_id,omitempty"` // the repository to which the variable belongs } // CreateVariableOption — CreateVariableOption the option when creating variable +// +// Usage: +// +// opts := CreateVariableOption{Value: "example"} type CreateVariableOption struct { Value string `json:"value"` // Value of the variable to create } // DispatchWorkflowOption — DispatchWorkflowOption options when dispatching a workflow +// +// Usage: +// +// opts := DispatchWorkflowOption{Ref: "main"} type DispatchWorkflowOption struct { Inputs map[string]string `json:"inputs,omitempty"` // Input keys and values configured in the workflow file. - Ref string `json:"ref"` // Git reference for the workflow + Ref string `json:"ref"` // Git reference for the workflow } // Secret — Secret represents a secret type Secret struct { Created time.Time `json:"created_at,omitempty"` - Name string `json:"name,omitempty"` // the secret's name + Name string `json:"name,omitempty"` // the secret's name } // UpdateVariableOption — UpdateVariableOption the option when updating variable +// +// Usage: +// +// opts := UpdateVariableOption{Value: "example"} type UpdateVariableOption struct { - Name string `json:"name,omitempty"` // New name for the variable. If the field is empty, the variable name won't be updated. - Value string `json:"value"` // Value of the variable to update + Name string `json:"name,omitempty"` // New name for the variable. If the field is empty, the variable name won't be updated. + Value string `json:"value"` // Value of the variable to update } diff --git a/types/activity.go b/types/activity.go index d3793c8..63bf392 100644 --- a/types/activity.go +++ b/types/activity.go @@ -4,20 +4,21 @@ package types import "time" + type Activity struct { - ActUser *User `json:"act_user,omitempty"` - ActUserID int64 `json:"act_user_id,omitempty"` - Comment *Comment `json:"comment,omitempty"` - CommentID int64 `json:"comment_id,omitempty"` - Content string `json:"content,omitempty"` - Created time.Time `json:"created,omitempty"` - ID int64 `json:"id,omitempty"` - IsPrivate bool `json:"is_private,omitempty"` - OpType string `json:"op_type,omitempty"` // the type of action - RefName string `json:"ref_name,omitempty"` - Repo *Repository `json:"repo,omitempty"` - RepoID int64 `json:"repo_id,omitempty"` - UserID int64 `json:"user_id,omitempty"` + ActUser *User `json:"act_user,omitempty"` + ActUserID int64 `json:"act_user_id,omitempty"` + Comment *Comment `json:"comment,omitempty"` + CommentID int64 `json:"comment_id,omitempty"` + Content string `json:"content,omitempty"` + Created time.Time `json:"created,omitempty"` + ID int64 `json:"id,omitempty"` + IsPrivate bool `json:"is_private,omitempty"` + OpType string `json:"op_type,omitempty"` // the type of action + RefName string `json:"ref_name,omitempty"` + Repo *Repository `json:"repo,omitempty"` + RepoID int64 `json:"repo_id,omitempty"` + UserID int64 `json:"user_id,omitempty"` } // ActivityPub — ActivityPub type diff --git a/types/admin.go b/types/admin.go index f9418d2..7b89b65 100644 --- a/types/admin.go +++ b/types/admin.go @@ -4,16 +4,21 @@ package types import "time" + // Cron — Cron represents a Cron task type Cron struct { - ExecTimes int64 `json:"exec_times,omitempty"` - Name string `json:"name,omitempty"` - Next time.Time `json:"next,omitempty"` - Prev time.Time `json:"prev,omitempty"` - Schedule string `json:"schedule,omitempty"` + ExecTimes int64 `json:"exec_times,omitempty"` + Name string `json:"name,omitempty"` + Next time.Time `json:"next,omitempty"` + Prev time.Time `json:"prev,omitempty"` + Schedule string `json:"schedule,omitempty"` } // RenameUserOption — RenameUserOption options when renaming a user +// +// Usage: +// +// opts := RenameUserOption{NewName: "example"} type RenameUserOption struct { NewName string `json:"new_username"` // New username for this user. This name cannot be in use yet by any other user. } diff --git a/types/branch.go b/types/branch.go index fd46ab5..1503a73 100644 --- a/types/branch.go +++ b/types/branch.go @@ -4,114 +4,131 @@ package types import "time" + // Branch — Branch represents a repository branch type Branch struct { - Commit *PayloadCommit `json:"commit,omitempty"` - EffectiveBranchProtectionName string `json:"effective_branch_protection_name,omitempty"` - EnableStatusCheck bool `json:"enable_status_check,omitempty"` - Name string `json:"name,omitempty"` - Protected bool `json:"protected,omitempty"` - RequiredApprovals int64 `json:"required_approvals,omitempty"` - StatusCheckContexts []string `json:"status_check_contexts,omitempty"` - UserCanMerge bool `json:"user_can_merge,omitempty"` - UserCanPush bool `json:"user_can_push,omitempty"` + Commit *PayloadCommit `json:"commit,omitempty"` + EffectiveBranchProtectionName string `json:"effective_branch_protection_name,omitempty"` + EnableStatusCheck bool `json:"enable_status_check,omitempty"` + Name string `json:"name,omitempty"` + Protected bool `json:"protected,omitempty"` + RequiredApprovals int64 `json:"required_approvals,omitempty"` + StatusCheckContexts []string `json:"status_check_contexts,omitempty"` + UserCanMerge bool `json:"user_can_merge,omitempty"` + UserCanPush bool `json:"user_can_push,omitempty"` } // BranchProtection — BranchProtection represents a branch protection for a repository type BranchProtection struct { - ApplyToAdmins bool `json:"apply_to_admins,omitempty"` - ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams,omitempty"` - ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username,omitempty"` - BlockOnOfficialReviewRequests bool `json:"block_on_official_review_requests,omitempty"` - BlockOnOutdatedBranch bool `json:"block_on_outdated_branch,omitempty"` - BlockOnRejectedReviews bool `json:"block_on_rejected_reviews,omitempty"` - BranchName string `json:"branch_name,omitempty"` // Deprecated: true - Created time.Time `json:"created_at,omitempty"` - DismissStaleApprovals bool `json:"dismiss_stale_approvals,omitempty"` - EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist,omitempty"` - EnableMergeWhitelist bool `json:"enable_merge_whitelist,omitempty"` - EnablePush bool `json:"enable_push,omitempty"` - EnablePushWhitelist bool `json:"enable_push_whitelist,omitempty"` - EnableStatusCheck bool `json:"enable_status_check,omitempty"` - IgnoreStaleApprovals bool `json:"ignore_stale_approvals,omitempty"` - MergeWhitelistTeams []string `json:"merge_whitelist_teams,omitempty"` - MergeWhitelistUsernames []string `json:"merge_whitelist_usernames,omitempty"` - ProtectedFilePatterns string `json:"protected_file_patterns,omitempty"` - PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys,omitempty"` - PushWhitelistTeams []string `json:"push_whitelist_teams,omitempty"` - PushWhitelistUsernames []string `json:"push_whitelist_usernames,omitempty"` - RequireSignedCommits bool `json:"require_signed_commits,omitempty"` - RequiredApprovals int64 `json:"required_approvals,omitempty"` - RuleName string `json:"rule_name,omitempty"` - StatusCheckContexts []string `json:"status_check_contexts,omitempty"` - UnprotectedFilePatterns string `json:"unprotected_file_patterns,omitempty"` - Updated time.Time `json:"updated_at,omitempty"` + ApplyToAdmins bool `json:"apply_to_admins,omitempty"` + ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams,omitempty"` + ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username,omitempty"` + BlockOnOfficialReviewRequests bool `json:"block_on_official_review_requests,omitempty"` + BlockOnOutdatedBranch bool `json:"block_on_outdated_branch,omitempty"` + BlockOnRejectedReviews bool `json:"block_on_rejected_reviews,omitempty"` + BranchName string `json:"branch_name,omitempty"` // Deprecated: true + Created time.Time `json:"created_at,omitempty"` + DismissStaleApprovals bool `json:"dismiss_stale_approvals,omitempty"` + EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist,omitempty"` + EnableMergeWhitelist bool `json:"enable_merge_whitelist,omitempty"` + EnablePush bool `json:"enable_push,omitempty"` + EnablePushWhitelist bool `json:"enable_push_whitelist,omitempty"` + EnableStatusCheck bool `json:"enable_status_check,omitempty"` + IgnoreStaleApprovals bool `json:"ignore_stale_approvals,omitempty"` + MergeWhitelistTeams []string `json:"merge_whitelist_teams,omitempty"` + MergeWhitelistUsernames []string `json:"merge_whitelist_usernames,omitempty"` + ProtectedFilePatterns string `json:"protected_file_patterns,omitempty"` + PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys,omitempty"` + PushWhitelistTeams []string `json:"push_whitelist_teams,omitempty"` + PushWhitelistUsernames []string `json:"push_whitelist_usernames,omitempty"` + RequireSignedCommits bool `json:"require_signed_commits,omitempty"` + RequiredApprovals int64 `json:"required_approvals,omitempty"` + RuleName string `json:"rule_name,omitempty"` + StatusCheckContexts []string `json:"status_check_contexts,omitempty"` + UnprotectedFilePatterns string `json:"unprotected_file_patterns,omitempty"` + Updated time.Time `json:"updated_at,omitempty"` } // CreateBranchProtectionOption — CreateBranchProtectionOption options for creating a branch protection +// +// Usage: +// +// opts := CreateBranchProtectionOption{BranchName: "main"} type CreateBranchProtectionOption struct { - ApplyToAdmins bool `json:"apply_to_admins,omitempty"` - ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams,omitempty"` - ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username,omitempty"` - BlockOnOfficialReviewRequests bool `json:"block_on_official_review_requests,omitempty"` - BlockOnOutdatedBranch bool `json:"block_on_outdated_branch,omitempty"` - BlockOnRejectedReviews bool `json:"block_on_rejected_reviews,omitempty"` - BranchName string `json:"branch_name,omitempty"` // Deprecated: true - DismissStaleApprovals bool `json:"dismiss_stale_approvals,omitempty"` - EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist,omitempty"` - EnableMergeWhitelist bool `json:"enable_merge_whitelist,omitempty"` - EnablePush bool `json:"enable_push,omitempty"` - EnablePushWhitelist bool `json:"enable_push_whitelist,omitempty"` - EnableStatusCheck bool `json:"enable_status_check,omitempty"` - IgnoreStaleApprovals bool `json:"ignore_stale_approvals,omitempty"` - MergeWhitelistTeams []string `json:"merge_whitelist_teams,omitempty"` - MergeWhitelistUsernames []string `json:"merge_whitelist_usernames,omitempty"` - ProtectedFilePatterns string `json:"protected_file_patterns,omitempty"` - PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys,omitempty"` - PushWhitelistTeams []string `json:"push_whitelist_teams,omitempty"` - PushWhitelistUsernames []string `json:"push_whitelist_usernames,omitempty"` - RequireSignedCommits bool `json:"require_signed_commits,omitempty"` - RequiredApprovals int64 `json:"required_approvals,omitempty"` - RuleName string `json:"rule_name,omitempty"` - StatusCheckContexts []string `json:"status_check_contexts,omitempty"` - UnprotectedFilePatterns string `json:"unprotected_file_patterns,omitempty"` + ApplyToAdmins bool `json:"apply_to_admins,omitempty"` + ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams,omitempty"` + ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username,omitempty"` + BlockOnOfficialReviewRequests bool `json:"block_on_official_review_requests,omitempty"` + BlockOnOutdatedBranch bool `json:"block_on_outdated_branch,omitempty"` + BlockOnRejectedReviews bool `json:"block_on_rejected_reviews,omitempty"` + BranchName string `json:"branch_name,omitempty"` // Deprecated: true + DismissStaleApprovals bool `json:"dismiss_stale_approvals,omitempty"` + EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist,omitempty"` + EnableMergeWhitelist bool `json:"enable_merge_whitelist,omitempty"` + EnablePush bool `json:"enable_push,omitempty"` + EnablePushWhitelist bool `json:"enable_push_whitelist,omitempty"` + EnableStatusCheck bool `json:"enable_status_check,omitempty"` + IgnoreStaleApprovals bool `json:"ignore_stale_approvals,omitempty"` + MergeWhitelistTeams []string `json:"merge_whitelist_teams,omitempty"` + MergeWhitelistUsernames []string `json:"merge_whitelist_usernames,omitempty"` + ProtectedFilePatterns string `json:"protected_file_patterns,omitempty"` + PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys,omitempty"` + PushWhitelistTeams []string `json:"push_whitelist_teams,omitempty"` + PushWhitelistUsernames []string `json:"push_whitelist_usernames,omitempty"` + RequireSignedCommits bool `json:"require_signed_commits,omitempty"` + RequiredApprovals int64 `json:"required_approvals,omitempty"` + RuleName string `json:"rule_name,omitempty"` + StatusCheckContexts []string `json:"status_check_contexts,omitempty"` + UnprotectedFilePatterns string `json:"unprotected_file_patterns,omitempty"` } // CreateBranchRepoOption — CreateBranchRepoOption options when creating a branch in a repository +// +// Usage: +// +// opts := CreateBranchRepoOption{BranchName: "main"} type CreateBranchRepoOption struct { - BranchName string `json:"new_branch_name"` // Name of the branch to create + BranchName string `json:"new_branch_name"` // Name of the branch to create OldBranchName string `json:"old_branch_name,omitempty"` // Deprecated: true Name of the old branch to create from - OldRefName string `json:"old_ref_name,omitempty"` // Name of the old branch/tag/commit to create from + OldRefName string `json:"old_ref_name,omitempty"` // Name of the old branch/tag/commit to create from } // EditBranchProtectionOption — EditBranchProtectionOption options for editing a branch protection +// +// Usage: +// +// opts := EditBranchProtectionOption{ApprovalsWhitelistTeams: []string{"example"}} type EditBranchProtectionOption struct { - ApplyToAdmins bool `json:"apply_to_admins,omitempty"` - ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams,omitempty"` - ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username,omitempty"` - BlockOnOfficialReviewRequests bool `json:"block_on_official_review_requests,omitempty"` - BlockOnOutdatedBranch bool `json:"block_on_outdated_branch,omitempty"` - BlockOnRejectedReviews bool `json:"block_on_rejected_reviews,omitempty"` - DismissStaleApprovals bool `json:"dismiss_stale_approvals,omitempty"` - EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist,omitempty"` - EnableMergeWhitelist bool `json:"enable_merge_whitelist,omitempty"` - EnablePush bool `json:"enable_push,omitempty"` - EnablePushWhitelist bool `json:"enable_push_whitelist,omitempty"` - EnableStatusCheck bool `json:"enable_status_check,omitempty"` - IgnoreStaleApprovals bool `json:"ignore_stale_approvals,omitempty"` - MergeWhitelistTeams []string `json:"merge_whitelist_teams,omitempty"` - MergeWhitelistUsernames []string `json:"merge_whitelist_usernames,omitempty"` - ProtectedFilePatterns string `json:"protected_file_patterns,omitempty"` - PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys,omitempty"` - PushWhitelistTeams []string `json:"push_whitelist_teams,omitempty"` - PushWhitelistUsernames []string `json:"push_whitelist_usernames,omitempty"` - RequireSignedCommits bool `json:"require_signed_commits,omitempty"` - RequiredApprovals int64 `json:"required_approvals,omitempty"` - StatusCheckContexts []string `json:"status_check_contexts,omitempty"` - UnprotectedFilePatterns string `json:"unprotected_file_patterns,omitempty"` + ApplyToAdmins bool `json:"apply_to_admins,omitempty"` + ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams,omitempty"` + ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username,omitempty"` + BlockOnOfficialReviewRequests bool `json:"block_on_official_review_requests,omitempty"` + BlockOnOutdatedBranch bool `json:"block_on_outdated_branch,omitempty"` + BlockOnRejectedReviews bool `json:"block_on_rejected_reviews,omitempty"` + DismissStaleApprovals bool `json:"dismiss_stale_approvals,omitempty"` + EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist,omitempty"` + EnableMergeWhitelist bool `json:"enable_merge_whitelist,omitempty"` + EnablePush bool `json:"enable_push,omitempty"` + EnablePushWhitelist bool `json:"enable_push_whitelist,omitempty"` + EnableStatusCheck bool `json:"enable_status_check,omitempty"` + IgnoreStaleApprovals bool `json:"ignore_stale_approvals,omitempty"` + MergeWhitelistTeams []string `json:"merge_whitelist_teams,omitempty"` + MergeWhitelistUsernames []string `json:"merge_whitelist_usernames,omitempty"` + ProtectedFilePatterns string `json:"protected_file_patterns,omitempty"` + PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys,omitempty"` + PushWhitelistTeams []string `json:"push_whitelist_teams,omitempty"` + PushWhitelistUsernames []string `json:"push_whitelist_usernames,omitempty"` + RequireSignedCommits bool `json:"require_signed_commits,omitempty"` + RequiredApprovals int64 `json:"required_approvals,omitempty"` + StatusCheckContexts []string `json:"status_check_contexts,omitempty"` + UnprotectedFilePatterns string `json:"unprotected_file_patterns,omitempty"` } // UpdateBranchRepoOption — UpdateBranchRepoOption options when updating a branch in a repository +// +// Usage: +// +// opts := UpdateBranchRepoOption{Name: "example"} type UpdateBranchRepoOption struct { Name string `json:"name"` // New branch name } diff --git a/types/comment.go b/types/comment.go index 57867ca..06c703f 100644 --- a/types/comment.go +++ b/types/comment.go @@ -4,17 +4,18 @@ package types import "time" + // Comment — Comment represents a comment on a commit or issue type Comment struct { - Attachments []*Attachment `json:"assets,omitempty"` - Body string `json:"body,omitempty"` - Created time.Time `json:"created_at,omitempty"` - HTMLURL string `json:"html_url,omitempty"` - ID int64 `json:"id,omitempty"` - IssueURL string `json:"issue_url,omitempty"` - OriginalAuthor string `json:"original_author,omitempty"` - OriginalAuthorID int64 `json:"original_author_id,omitempty"` - PRURL string `json:"pull_request_url,omitempty"` - Updated time.Time `json:"updated_at,omitempty"` - User *User `json:"user,omitempty"` + Attachments []*Attachment `json:"assets,omitempty"` + Body string `json:"body,omitempty"` + Created time.Time `json:"created_at,omitempty"` + HTMLURL string `json:"html_url,omitempty"` + ID int64 `json:"id,omitempty"` + IssueURL string `json:"issue_url,omitempty"` + OriginalAuthor string `json:"original_author,omitempty"` + OriginalAuthorID int64 `json:"original_author_id,omitempty"` + PRURL string `json:"pull_request_url,omitempty"` + Updated time.Time `json:"updated_at,omitempty"` + User *User `json:"user,omitempty"` } diff --git a/types/commit.go b/types/commit.go index 5a654b6..c6ddbe0 100644 --- a/types/commit.go +++ b/types/commit.go @@ -4,55 +4,60 @@ package types import "time" + type Commit struct { - Author *User `json:"author,omitempty"` - Commit *RepoCommit `json:"commit,omitempty"` - Committer *User `json:"committer,omitempty"` - Created time.Time `json:"created,omitempty"` - Files []*CommitAffectedFiles `json:"files,omitempty"` - HTMLURL string `json:"html_url,omitempty"` - Parents []*CommitMeta `json:"parents,omitempty"` - SHA string `json:"sha,omitempty"` - Stats *CommitStats `json:"stats,omitempty"` - URL string `json:"url,omitempty"` + Author *User `json:"author,omitempty"` + Commit *RepoCommit `json:"commit,omitempty"` + Committer *User `json:"committer,omitempty"` + Created time.Time `json:"created,omitempty"` + Files []*CommitAffectedFiles `json:"files,omitempty"` + HTMLURL string `json:"html_url,omitempty"` + Parents []*CommitMeta `json:"parents,omitempty"` + SHA string `json:"sha,omitempty"` + Stats *CommitStats `json:"stats,omitempty"` + URL string `json:"url,omitempty"` } // CommitAffectedFiles — CommitAffectedFiles store information about files affected by the commit type CommitAffectedFiles struct { Filename string `json:"filename,omitempty"` - Status string `json:"status,omitempty"` + Status string `json:"status,omitempty"` } // CommitDateOptions — CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE +// +// Usage: +// +// opts := CommitDateOptions{Author: time.Now()} type CommitDateOptions struct { - Author time.Time `json:"author,omitempty"` + Author time.Time `json:"author,omitempty"` Committer time.Time `json:"committer,omitempty"` } type CommitMeta struct { Created time.Time `json:"created,omitempty"` - SHA string `json:"sha,omitempty"` - URL string `json:"url,omitempty"` + SHA string `json:"sha,omitempty"` + URL string `json:"url,omitempty"` } // CommitStats — CommitStats is statistics for a RepoCommit type CommitStats struct { Additions int64 `json:"additions,omitempty"` Deletions int64 `json:"deletions,omitempty"` - Total int64 `json:"total,omitempty"` + Total int64 `json:"total,omitempty"` } // CommitStatus — CommitStatus holds a single status of a single Commit type CommitStatus struct { - Context string `json:"context,omitempty"` - Created time.Time `json:"created_at,omitempty"` - Creator *User `json:"creator,omitempty"` - Description string `json:"description,omitempty"` - ID int64 `json:"id,omitempty"` - Status *CommitStatusState `json:"status,omitempty"` - TargetURL string `json:"target_url,omitempty"` - URL string `json:"url,omitempty"` - Updated time.Time `json:"updated_at,omitempty"` + Context string `json:"context,omitempty"` + Created time.Time `json:"created_at,omitempty"` + Creator *User `json:"creator,omitempty"` + Description string `json:"description,omitempty"` + ID int64 `json:"id,omitempty"` + Status *CommitStatusState `json:"status,omitempty"` + TargetURL string `json:"target_url,omitempty"` + URL string `json:"url,omitempty"` + Updated time.Time `json:"updated_at,omitempty"` } // CommitStatusState — CommitStatusState holds the state of a CommitStatus It can be "pending", "success", "error" and "failure" @@ -60,7 +65,7 @@ type CommitStatus struct { type CommitStatusState struct{} type CommitUser struct { - Date string `json:"date,omitempty"` + Date string `json:"date,omitempty"` Email string `json:"email,omitempty"` - Name string `json:"name,omitempty"` + Name string `json:"name,omitempty"` } diff --git a/types/common.go b/types/common.go index e5c2586..5e0d84a 100644 --- a/types/common.go +++ b/types/common.go @@ -4,33 +4,40 @@ package types import "time" + // Attachment — Attachment a generic attachment type Attachment struct { - Created time.Time `json:"created_at,omitempty"` - DownloadCount int64 `json:"download_count,omitempty"` - DownloadURL string `json:"browser_download_url,omitempty"` - ID int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Size int64 `json:"size,omitempty"` - Type string `json:"type,omitempty"` - UUID string `json:"uuid,omitempty"` + Created time.Time `json:"created_at,omitempty"` + DownloadCount int64 `json:"download_count,omitempty"` + DownloadURL string `json:"browser_download_url,omitempty"` + ID int64 `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Size int64 `json:"size,omitempty"` + Type string `json:"type,omitempty"` + UUID string `json:"uuid,omitempty"` } // EditAttachmentOptions — EditAttachmentOptions options for editing attachments +// +// Usage: +// +// opts := EditAttachmentOptions{Name: "example"} type EditAttachmentOptions struct { DownloadURL string `json:"browser_download_url,omitempty"` // (Can only be set if existing attachment is of external type) - Name string `json:"name,omitempty"` + Name string `json:"name,omitempty"` } // Permission — Permission represents a set of permissions type Permission struct { Admin bool `json:"admin,omitempty"` - Pull bool `json:"pull,omitempty"` - Push bool `json:"push,omitempty"` + Pull bool `json:"pull,omitempty"` + Push bool `json:"push,omitempty"` } -// StateType is the state of an issue or PR: "open", "closed". -type StateType string +// StateType — StateType issue state type +// StateType has no fields in the swagger spec. +type StateType struct{} -// TimeStamp is a Forgejo timestamp string. -type TimeStamp string +// TimeStamp — TimeStamp defines a timestamp +// TimeStamp has no fields in the swagger spec. +type TimeStamp struct{} diff --git a/types/content.go b/types/content.go index 057cf5f..b5908b3 100644 --- a/types/content.go +++ b/types/content.go @@ -4,99 +4,112 @@ package types import "time" + // ContentsResponse — ContentsResponse contains information about a repo's entry's (dir, file, symlink, submodule) metadata and content type ContentsResponse struct { - Content string `json:"content,omitempty"` // `content` is populated when `type` is `file`, otherwise null - DownloadURL string `json:"download_url,omitempty"` - Encoding string `json:"encoding,omitempty"` // `encoding` is populated when `type` is `file`, otherwise null - GitURL string `json:"git_url,omitempty"` - HTMLURL string `json:"html_url,omitempty"` - LastCommitSHA string `json:"last_commit_sha,omitempty"` - Links *FileLinksResponse `json:"_links,omitempty"` - Name string `json:"name,omitempty"` - Path string `json:"path,omitempty"` - SHA string `json:"sha,omitempty"` - Size int64 `json:"size,omitempty"` - SubmoduleGitURL string `json:"submodule_git_url,omitempty"` // `submodule_git_url` is populated when `type` is `submodule`, otherwise null - Target string `json:"target,omitempty"` // `target` is populated when `type` is `symlink`, otherwise null - Type string `json:"type,omitempty"` // `type` will be `file`, `dir`, `symlink`, or `submodule` - URL string `json:"url,omitempty"` + Content string `json:"content,omitempty"` // `content` is populated when `type` is `file`, otherwise null + DownloadURL string `json:"download_url,omitempty"` + Encoding string `json:"encoding,omitempty"` // `encoding` is populated when `type` is `file`, otherwise null + GitURL string `json:"git_url,omitempty"` + HTMLURL string `json:"html_url,omitempty"` + LastCommitSHA string `json:"last_commit_sha,omitempty"` + Links *FileLinksResponse `json:"_links,omitempty"` + Name string `json:"name,omitempty"` + Path string `json:"path,omitempty"` + SHA string `json:"sha,omitempty"` + Size int64 `json:"size,omitempty"` + SubmoduleGitURL string `json:"submodule_git_url,omitempty"` // `submodule_git_url` is populated when `type` is `submodule`, otherwise null + Target string `json:"target,omitempty"` // `target` is populated when `type` is `symlink`, otherwise null + Type string `json:"type,omitempty"` // `type` will be `file`, `dir`, `symlink`, or `submodule` + URL string `json:"url,omitempty"` } // CreateFileOptions — CreateFileOptions options for creating files Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) +// +// Usage: +// +// opts := CreateFileOptions{ContentBase64: "example"} type CreateFileOptions struct { - Author *Identity `json:"author,omitempty"` - BranchName string `json:"branch,omitempty"` // branch (optional) to base this file from. if not given, the default branch is used - Committer *Identity `json:"committer,omitempty"` - ContentBase64 string `json:"content"` // content must be base64 encoded - Dates *CommitDateOptions `json:"dates,omitempty"` - Message string `json:"message,omitempty"` // message (optional) for the commit of this file. if not supplied, a default message will be used - NewBranchName string `json:"new_branch,omitempty"` // new_branch (optional) will make a new branch from `branch` before creating the file - Signoff bool `json:"signoff,omitempty"` // Add a Signed-off-by trailer by the committer at the end of the commit log message. + Author *Identity `json:"author,omitempty"` + BranchName string `json:"branch,omitempty"` // branch (optional) to base this file from. if not given, the default branch is used + Committer *Identity `json:"committer,omitempty"` + ContentBase64 string `json:"content"` // content must be base64 encoded + Dates *CommitDateOptions `json:"dates,omitempty"` + Message string `json:"message,omitempty"` // message (optional) for the commit of this file. if not supplied, a default message will be used + NewBranchName string `json:"new_branch,omitempty"` // new_branch (optional) will make a new branch from `branch` before creating the file + Signoff bool `json:"signoff,omitempty"` // Add a Signed-off-by trailer by the committer at the end of the commit log message. } // DeleteFileOptions — DeleteFileOptions options for deleting files (used for other File structs below) Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) +// +// Usage: +// +// opts := DeleteFileOptions{SHA: "example"} type DeleteFileOptions struct { - Author *Identity `json:"author,omitempty"` - BranchName string `json:"branch,omitempty"` // branch (optional) to base this file from. if not given, the default branch is used - Committer *Identity `json:"committer,omitempty"` - Dates *CommitDateOptions `json:"dates,omitempty"` - Message string `json:"message,omitempty"` // message (optional) for the commit of this file. if not supplied, a default message will be used - NewBranchName string `json:"new_branch,omitempty"` // new_branch (optional) will make a new branch from `branch` before creating the file - SHA string `json:"sha"` // sha is the SHA for the file that already exists - Signoff bool `json:"signoff,omitempty"` // Add a Signed-off-by trailer by the committer at the end of the commit log message. + Author *Identity `json:"author,omitempty"` + BranchName string `json:"branch,omitempty"` // branch (optional) to base this file from. if not given, the default branch is used + Committer *Identity `json:"committer,omitempty"` + Dates *CommitDateOptions `json:"dates,omitempty"` + Message string `json:"message,omitempty"` // message (optional) for the commit of this file. if not supplied, a default message will be used + NewBranchName string `json:"new_branch,omitempty"` // new_branch (optional) will make a new branch from `branch` before creating the file + SHA string `json:"sha"` // sha is the SHA for the file that already exists + Signoff bool `json:"signoff,omitempty"` // Add a Signed-off-by trailer by the committer at the end of the commit log message. } type FileCommitResponse struct { - Author *CommitUser `json:"author,omitempty"` - Committer *CommitUser `json:"committer,omitempty"` - Created time.Time `json:"created,omitempty"` - HTMLURL string `json:"html_url,omitempty"` - Message string `json:"message,omitempty"` - Parents []*CommitMeta `json:"parents,omitempty"` - SHA string `json:"sha,omitempty"` - Tree *CommitMeta `json:"tree,omitempty"` - URL string `json:"url,omitempty"` + Author *CommitUser `json:"author,omitempty"` + Committer *CommitUser `json:"committer,omitempty"` + Created time.Time `json:"created,omitempty"` + HTMLURL string `json:"html_url,omitempty"` + Message string `json:"message,omitempty"` + Parents []*CommitMeta `json:"parents,omitempty"` + SHA string `json:"sha,omitempty"` + Tree *CommitMeta `json:"tree,omitempty"` + URL string `json:"url,omitempty"` } // FileDeleteResponse — FileDeleteResponse contains information about a repo's file that was deleted type FileDeleteResponse struct { - Commit *FileCommitResponse `json:"commit,omitempty"` - Content any `json:"content,omitempty"` + Commit *FileCommitResponse `json:"commit,omitempty"` + Content any `json:"content,omitempty"` Verification *PayloadCommitVerification `json:"verification,omitempty"` } // FileLinksResponse — FileLinksResponse contains the links for a repo's file type FileLinksResponse struct { - GitURL string `json:"git,omitempty"` + GitURL string `json:"git,omitempty"` HTMLURL string `json:"html,omitempty"` - Self string `json:"self,omitempty"` + Self string `json:"self,omitempty"` } // FileResponse — FileResponse contains information about a repo's file type FileResponse struct { - Commit *FileCommitResponse `json:"commit,omitempty"` - Content *ContentsResponse `json:"content,omitempty"` + Commit *FileCommitResponse `json:"commit,omitempty"` + Content *ContentsResponse `json:"content,omitempty"` Verification *PayloadCommitVerification `json:"verification,omitempty"` } // FilesResponse — FilesResponse contains information about multiple files from a repo type FilesResponse struct { - Commit *FileCommitResponse `json:"commit,omitempty"` - Files []*ContentsResponse `json:"files,omitempty"` + Commit *FileCommitResponse `json:"commit,omitempty"` + Files []*ContentsResponse `json:"files,omitempty"` Verification *PayloadCommitVerification `json:"verification,omitempty"` } // UpdateFileOptions — UpdateFileOptions options for updating files Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) +// +// Usage: +// +// opts := UpdateFileOptions{ContentBase64: "example"} type UpdateFileOptions struct { - Author *Identity `json:"author,omitempty"` - BranchName string `json:"branch,omitempty"` // branch (optional) to base this file from. if not given, the default branch is used - Committer *Identity `json:"committer,omitempty"` - ContentBase64 string `json:"content"` // content must be base64 encoded - Dates *CommitDateOptions `json:"dates,omitempty"` - FromPath string `json:"from_path,omitempty"` // from_path (optional) is the path of the original file which will be moved/renamed to the path in the URL - Message string `json:"message,omitempty"` // message (optional) for the commit of this file. if not supplied, a default message will be used - NewBranchName string `json:"new_branch,omitempty"` // new_branch (optional) will make a new branch from `branch` before creating the file - SHA string `json:"sha"` // sha is the SHA for the file that already exists - Signoff bool `json:"signoff,omitempty"` // Add a Signed-off-by trailer by the committer at the end of the commit log message. + Author *Identity `json:"author,omitempty"` + BranchName string `json:"branch,omitempty"` // branch (optional) to base this file from. if not given, the default branch is used + Committer *Identity `json:"committer,omitempty"` + ContentBase64 string `json:"content"` // content must be base64 encoded + Dates *CommitDateOptions `json:"dates,omitempty"` + FromPath string `json:"from_path,omitempty"` // from_path (optional) is the path of the original file which will be moved/renamed to the path in the URL + Message string `json:"message,omitempty"` // message (optional) for the commit of this file. if not supplied, a default message will be used + NewBranchName string `json:"new_branch,omitempty"` // new_branch (optional) will make a new branch from `branch` before creating the file + SHA string `json:"sha"` // sha is the SHA for the file that already exists + Signoff bool `json:"signoff,omitempty"` // Add a Signed-off-by trailer by the committer at the end of the commit log message. } diff --git a/types/error.go b/types/error.go index ba5c0b6..aa734e7 100644 --- a/types/error.go +++ b/types/error.go @@ -2,39 +2,40 @@ package types + // APIError — APIError is an api error with a message type APIError struct { Message string `json:"message,omitempty"` - URL string `json:"url,omitempty"` + URL string `json:"url,omitempty"` } type APIForbiddenError struct { Message string `json:"message,omitempty"` - URL string `json:"url,omitempty"` + URL string `json:"url,omitempty"` } type APIInvalidTopicsError struct { InvalidTopics []string `json:"invalidTopics,omitempty"` - Message string `json:"message,omitempty"` + Message string `json:"message,omitempty"` } type APINotFound struct { - Errors []string `json:"errors,omitempty"` - Message string `json:"message,omitempty"` - URL string `json:"url,omitempty"` + Errors []string `json:"errors,omitempty"` + Message string `json:"message,omitempty"` + URL string `json:"url,omitempty"` } type APIRepoArchivedError struct { Message string `json:"message,omitempty"` - URL string `json:"url,omitempty"` + URL string `json:"url,omitempty"` } type APIUnauthorizedError struct { Message string `json:"message,omitempty"` - URL string `json:"url,omitempty"` + URL string `json:"url,omitempty"` } type APIValidationError struct { Message string `json:"message,omitempty"` - URL string `json:"url,omitempty"` + URL string `json:"url,omitempty"` } diff --git a/types/federation.go b/types/federation.go index f798101..99d2bdb 100644 --- a/types/federation.go +++ b/types/federation.go @@ -2,41 +2,42 @@ package types + // NodeInfo — NodeInfo contains standardized way of exposing metadata about a server running one of the distributed social networks type NodeInfo struct { - Metadata map[string]any `json:"metadata,omitempty"` - OpenRegistrations bool `json:"openRegistrations,omitempty"` - Protocols []string `json:"protocols,omitempty"` - Services *NodeInfoServices `json:"services,omitempty"` - Software *NodeInfoSoftware `json:"software,omitempty"` - Usage *NodeInfoUsage `json:"usage,omitempty"` - Version string `json:"version,omitempty"` + Metadata map[string]any `json:"metadata,omitempty"` + OpenRegistrations bool `json:"openRegistrations,omitempty"` + Protocols []string `json:"protocols,omitempty"` + Services *NodeInfoServices `json:"services,omitempty"` + Software *NodeInfoSoftware `json:"software,omitempty"` + Usage *NodeInfoUsage `json:"usage,omitempty"` + Version string `json:"version,omitempty"` } // NodeInfoServices — NodeInfoServices contains the third party sites this server can connect to via their application API type NodeInfoServices struct { - Inbound []string `json:"inbound,omitempty"` + Inbound []string `json:"inbound,omitempty"` Outbound []string `json:"outbound,omitempty"` } // NodeInfoSoftware — NodeInfoSoftware contains Metadata about server software in use type NodeInfoSoftware struct { - Homepage string `json:"homepage,omitempty"` - Name string `json:"name,omitempty"` + Homepage string `json:"homepage,omitempty"` + Name string `json:"name,omitempty"` Repository string `json:"repository,omitempty"` - Version string `json:"version,omitempty"` + Version string `json:"version,omitempty"` } // NodeInfoUsage — NodeInfoUsage contains usage statistics for this server type NodeInfoUsage struct { - LocalComments int64 `json:"localComments,omitempty"` - LocalPosts int64 `json:"localPosts,omitempty"` - Users *NodeInfoUsageUsers `json:"users,omitempty"` + LocalComments int64 `json:"localComments,omitempty"` + LocalPosts int64 `json:"localPosts,omitempty"` + Users *NodeInfoUsageUsers `json:"users,omitempty"` } // NodeInfoUsageUsers — NodeInfoUsageUsers contains statistics about the users of this server type NodeInfoUsageUsers struct { ActiveHalfyear int64 `json:"activeHalfyear,omitempty"` - ActiveMonth int64 `json:"activeMonth,omitempty"` - Total int64 `json:"total,omitempty"` + ActiveMonth int64 `json:"activeMonth,omitempty"` + Total int64 `json:"total,omitempty"` } diff --git a/types/git.go b/types/git.go index ec723f5..332ef6d 100644 --- a/types/git.go +++ b/types/git.go @@ -2,91 +2,100 @@ package types + // AnnotatedTag — AnnotatedTag represents an annotated tag type AnnotatedTag struct { - ArchiveDownloadCount *TagArchiveDownloadCount `json:"archive_download_count,omitempty"` - Message string `json:"message,omitempty"` - Object *AnnotatedTagObject `json:"object,omitempty"` - SHA string `json:"sha,omitempty"` - Tag string `json:"tag,omitempty"` - Tagger *CommitUser `json:"tagger,omitempty"` - URL string `json:"url,omitempty"` - Verification *PayloadCommitVerification `json:"verification,omitempty"` + ArchiveDownloadCount *TagArchiveDownloadCount `json:"archive_download_count,omitempty"` + Message string `json:"message,omitempty"` + Object *AnnotatedTagObject `json:"object,omitempty"` + SHA string `json:"sha,omitempty"` + Tag string `json:"tag,omitempty"` + Tagger *CommitUser `json:"tagger,omitempty"` + URL string `json:"url,omitempty"` + Verification *PayloadCommitVerification `json:"verification,omitempty"` } // AnnotatedTagObject — AnnotatedTagObject contains meta information of the tag object type AnnotatedTagObject struct { - SHA string `json:"sha,omitempty"` + SHA string `json:"sha,omitempty"` Type string `json:"type,omitempty"` - URL string `json:"url,omitempty"` + URL string `json:"url,omitempty"` } // ChangedFile — ChangedFile store information about files affected by the pull request type ChangedFile struct { - Additions int64 `json:"additions,omitempty"` - Changes int64 `json:"changes,omitempty"` - ContentsURL string `json:"contents_url,omitempty"` - Deletions int64 `json:"deletions,omitempty"` - Filename string `json:"filename,omitempty"` - HTMLURL string `json:"html_url,omitempty"` + Additions int64 `json:"additions,omitempty"` + Changes int64 `json:"changes,omitempty"` + ContentsURL string `json:"contents_url,omitempty"` + Deletions int64 `json:"deletions,omitempty"` + Filename string `json:"filename,omitempty"` + HTMLURL string `json:"html_url,omitempty"` PreviousFilename string `json:"previous_filename,omitempty"` - RawURL string `json:"raw_url,omitempty"` - Status string `json:"status,omitempty"` + RawURL string `json:"raw_url,omitempty"` + Status string `json:"status,omitempty"` } // EditGitHookOption — EditGitHookOption options when modifying one Git hook +// +// Usage: +// +// opts := EditGitHookOption{Content: "example"} type EditGitHookOption struct { Content string `json:"content,omitempty"` } // GitBlobResponse — GitBlobResponse represents a git blob type GitBlobResponse struct { - Content string `json:"content,omitempty"` + Content string `json:"content,omitempty"` Encoding string `json:"encoding,omitempty"` - SHA string `json:"sha,omitempty"` - Size int64 `json:"size,omitempty"` - URL string `json:"url,omitempty"` + SHA string `json:"sha,omitempty"` + Size int64 `json:"size,omitempty"` + URL string `json:"url,omitempty"` } // GitEntry — GitEntry represents a git tree type GitEntry struct { Mode string `json:"mode,omitempty"` Path string `json:"path,omitempty"` - SHA string `json:"sha,omitempty"` - Size int64 `json:"size,omitempty"` + SHA string `json:"sha,omitempty"` + Size int64 `json:"size,omitempty"` Type string `json:"type,omitempty"` - URL string `json:"url,omitempty"` + URL string `json:"url,omitempty"` } // GitHook — GitHook represents a Git repository hook type GitHook struct { - Content string `json:"content,omitempty"` - IsActive bool `json:"is_active,omitempty"` - Name string `json:"name,omitempty"` + Content string `json:"content,omitempty"` + IsActive bool `json:"is_active,omitempty"` + Name string `json:"name,omitempty"` } type GitObject struct { - SHA string `json:"sha,omitempty"` + SHA string `json:"sha,omitempty"` Type string `json:"type,omitempty"` - URL string `json:"url,omitempty"` + URL string `json:"url,omitempty"` } // GitTreeResponse — GitTreeResponse returns a git tree type GitTreeResponse struct { - Entries []*GitEntry `json:"tree,omitempty"` - Page int64 `json:"page,omitempty"` - SHA string `json:"sha,omitempty"` - TotalCount int64 `json:"total_count,omitempty"` - Truncated bool `json:"truncated,omitempty"` - URL string `json:"url,omitempty"` + Entries []*GitEntry `json:"tree,omitempty"` + Page int64 `json:"page,omitempty"` + SHA string `json:"sha,omitempty"` + TotalCount int64 `json:"total_count,omitempty"` + Truncated bool `json:"truncated,omitempty"` + URL string `json:"url,omitempty"` } // Note — Note contains information related to a git note type Note struct { - Commit *Commit `json:"commit,omitempty"` - Message string `json:"message,omitempty"` + Commit *Commit `json:"commit,omitempty"` + Message string `json:"message,omitempty"` } +// +// Usage: +// +// opts := NoteOptions{Message: "example"} type NoteOptions struct { Message string `json:"message,omitempty"` } diff --git a/types/hook.go b/types/hook.go index 2ecc2fe..8a81c9f 100644 --- a/types/hook.go +++ b/types/hook.go @@ -4,63 +4,76 @@ package types import "time" + // CreateHookOption — CreateHookOption options when create a hook +// +// Usage: +// +// opts := CreateHookOption{Type: "example"} type CreateHookOption struct { - Active bool `json:"active,omitempty"` - AuthorizationHeader string `json:"authorization_header,omitempty"` - BranchFilter string `json:"branch_filter,omitempty"` - Config *CreateHookOptionConfig `json:"config"` - Events []string `json:"events,omitempty"` - Type string `json:"type"` + Active bool `json:"active,omitempty"` + AuthorizationHeader string `json:"authorization_header,omitempty"` + BranchFilter string `json:"branch_filter,omitempty"` + Config *CreateHookOptionConfig `json:"config"` + Events []string `json:"events,omitempty"` + Type string `json:"type"` } // CreateHookOptionConfig — CreateHookOptionConfig has all config options in it required are "content_type" and "url" Required +// +// Usage: +// +// opts := CreateHookOptionConfig{} type CreateHookOptionConfig map[string]any // EditHookOption — EditHookOption options when modify one hook +// +// Usage: +// +// opts := EditHookOption{AuthorizationHeader: "example"} type EditHookOption struct { - Active bool `json:"active,omitempty"` - AuthorizationHeader string `json:"authorization_header,omitempty"` - BranchFilter string `json:"branch_filter,omitempty"` - Config map[string]string `json:"config,omitempty"` - Events []string `json:"events,omitempty"` + Active bool `json:"active,omitempty"` + AuthorizationHeader string `json:"authorization_header,omitempty"` + BranchFilter string `json:"branch_filter,omitempty"` + Config map[string]string `json:"config,omitempty"` + Events []string `json:"events,omitempty"` } // Hook — Hook a hook is a web hook when one repository changed type Hook struct { - Active bool `json:"active,omitempty"` - AuthorizationHeader string `json:"authorization_header,omitempty"` - BranchFilter string `json:"branch_filter,omitempty"` - Config map[string]string `json:"config,omitempty"` // Deprecated: use Metadata instead - ContentType string `json:"content_type,omitempty"` - Created time.Time `json:"created_at,omitempty"` - Events []string `json:"events,omitempty"` - ID int64 `json:"id,omitempty"` - Metadata any `json:"metadata,omitempty"` - Type string `json:"type,omitempty"` - URL string `json:"url,omitempty"` - Updated time.Time `json:"updated_at,omitempty"` + Active bool `json:"active,omitempty"` + AuthorizationHeader string `json:"authorization_header,omitempty"` + BranchFilter string `json:"branch_filter,omitempty"` + Config map[string]string `json:"config,omitempty"` // Deprecated: use Metadata instead + ContentType string `json:"content_type,omitempty"` + Created time.Time `json:"created_at,omitempty"` + Events []string `json:"events,omitempty"` + ID int64 `json:"id,omitempty"` + Metadata any `json:"metadata,omitempty"` + Type string `json:"type,omitempty"` + URL string `json:"url,omitempty"` + Updated time.Time `json:"updated_at,omitempty"` } // PayloadCommit — PayloadCommit represents a commit type PayloadCommit struct { - Added []string `json:"added,omitempty"` - Author *PayloadUser `json:"author,omitempty"` - Committer *PayloadUser `json:"committer,omitempty"` - ID string `json:"id,omitempty"` // sha1 hash of the commit - Message string `json:"message,omitempty"` - Modified []string `json:"modified,omitempty"` - Removed []string `json:"removed,omitempty"` - Timestamp time.Time `json:"timestamp,omitempty"` - URL string `json:"url,omitempty"` + Added []string `json:"added,omitempty"` + Author *PayloadUser `json:"author,omitempty"` + Committer *PayloadUser `json:"committer,omitempty"` + ID string `json:"id,omitempty"` // sha1 hash of the commit + Message string `json:"message,omitempty"` + Modified []string `json:"modified,omitempty"` + Removed []string `json:"removed,omitempty"` + Timestamp time.Time `json:"timestamp,omitempty"` + URL string `json:"url,omitempty"` Verification *PayloadCommitVerification `json:"verification,omitempty"` } // PayloadCommitVerification — PayloadCommitVerification represents the GPG verification of a commit type PayloadCommitVerification struct { - Payload string `json:"payload,omitempty"` - Reason string `json:"reason,omitempty"` - Signature string `json:"signature,omitempty"` - Signer *PayloadUser `json:"signer,omitempty"` - Verified bool `json:"verified,omitempty"` + Payload string `json:"payload,omitempty"` + Reason string `json:"reason,omitempty"` + Signature string `json:"signature,omitempty"` + Signer *PayloadUser `json:"signer,omitempty"` + Verified bool `json:"verified,omitempty"` } diff --git a/types/issue.go b/types/issue.go index 6aa51b4..1249095 100644 --- a/types/issue.go +++ b/types/issue.go @@ -4,93 +4,114 @@ package types import "time" + // CreateIssueCommentOption — CreateIssueCommentOption options for creating a comment on an issue +// +// Usage: +// +// opts := CreateIssueCommentOption{Body: "example"} type CreateIssueCommentOption struct { - Body string `json:"body"` - Updated *time.Time `json:"updated_at,omitempty"` + Body string `json:"body"` + Updated time.Time `json:"updated_at,omitempty"` } // CreateIssueOption — CreateIssueOption options to create one issue +// +// Usage: +// +// opts := CreateIssueOption{Title: "example"} type CreateIssueOption struct { - Assignee string `json:"assignee,omitempty"` // deprecated - Assignees []string `json:"assignees,omitempty"` - Body string `json:"body,omitempty"` - Closed bool `json:"closed,omitempty"` - Deadline time.Time `json:"due_date,omitempty"` - Labels []int64 `json:"labels,omitempty"` // list of label ids - Milestone int64 `json:"milestone,omitempty"` // milestone id - Ref string `json:"ref,omitempty"` - Title string `json:"title"` + Assignee string `json:"assignee,omitempty"` // deprecated + Assignees []string `json:"assignees,omitempty"` + Body string `json:"body,omitempty"` + Closed bool `json:"closed,omitempty"` + Deadline time.Time `json:"due_date,omitempty"` + Labels []int64 `json:"labels,omitempty"` // list of label ids + Milestone int64 `json:"milestone,omitempty"` // milestone id + Ref string `json:"ref,omitempty"` + Title string `json:"title"` } // EditDeadlineOption — EditDeadlineOption options for creating a deadline +// +// Usage: +// +// opts := EditDeadlineOption{Deadline: time.Now()} type EditDeadlineOption struct { Deadline time.Time `json:"due_date"` } // EditIssueCommentOption — EditIssueCommentOption options for editing a comment +// +// Usage: +// +// opts := EditIssueCommentOption{Body: "example"} type EditIssueCommentOption struct { - Body string `json:"body"` + Body string `json:"body"` Updated time.Time `json:"updated_at,omitempty"` } // EditIssueOption — EditIssueOption options for editing an issue +// +// Usage: +// +// opts := EditIssueOption{Body: "example"} type EditIssueOption struct { - Assignee string `json:"assignee,omitempty"` // deprecated - Assignees []string `json:"assignees,omitempty"` - Body string `json:"body,omitempty"` - Deadline time.Time `json:"due_date,omitempty"` - Milestone int64 `json:"milestone,omitempty"` - Ref string `json:"ref,omitempty"` - RemoveDeadline bool `json:"unset_due_date,omitempty"` - State string `json:"state,omitempty"` - Title string `json:"title,omitempty"` - Updated time.Time `json:"updated_at,omitempty"` + Assignee string `json:"assignee,omitempty"` // deprecated + Assignees []string `json:"assignees,omitempty"` + Body string `json:"body,omitempty"` + Deadline time.Time `json:"due_date,omitempty"` + Milestone int64 `json:"milestone,omitempty"` + Ref string `json:"ref,omitempty"` + RemoveDeadline bool `json:"unset_due_date,omitempty"` + State string `json:"state,omitempty"` + Title string `json:"title,omitempty"` + Updated time.Time `json:"updated_at,omitempty"` } // Issue — Issue represents an issue in a repository type Issue struct { - Assignee *User `json:"assignee,omitempty"` - Assignees []*User `json:"assignees,omitempty"` - Attachments []*Attachment `json:"assets,omitempty"` - Body string `json:"body,omitempty"` - Closed time.Time `json:"closed_at,omitempty"` - Comments int64 `json:"comments,omitempty"` - Created time.Time `json:"created_at,omitempty"` - Deadline time.Time `json:"due_date,omitempty"` - HTMLURL string `json:"html_url,omitempty"` - ID int64 `json:"id,omitempty"` - Index int64 `json:"number,omitempty"` - IsLocked bool `json:"is_locked,omitempty"` - Labels []*Label `json:"labels,omitempty"` - Milestone *Milestone `json:"milestone,omitempty"` - OriginalAuthor string `json:"original_author,omitempty"` - OriginalAuthorID int64 `json:"original_author_id,omitempty"` - PinOrder int64 `json:"pin_order,omitempty"` - PullRequest *PullRequestMeta `json:"pull_request,omitempty"` - Ref string `json:"ref,omitempty"` - Repository *RepositoryMeta `json:"repository,omitempty"` - State StateType `json:"state,omitempty"` - Title string `json:"title,omitempty"` - URL string `json:"url,omitempty"` - Updated time.Time `json:"updated_at,omitempty"` - User *User `json:"user,omitempty"` + Assignee *User `json:"assignee,omitempty"` + Assignees []*User `json:"assignees,omitempty"` + Attachments []*Attachment `json:"assets,omitempty"` + Body string `json:"body,omitempty"` + Closed time.Time `json:"closed_at,omitempty"` + Comments int64 `json:"comments,omitempty"` + Created time.Time `json:"created_at,omitempty"` + Deadline time.Time `json:"due_date,omitempty"` + HTMLURL string `json:"html_url,omitempty"` + ID int64 `json:"id,omitempty"` + Index int64 `json:"number,omitempty"` + IsLocked bool `json:"is_locked,omitempty"` + Labels []*Label `json:"labels,omitempty"` + Milestone *Milestone `json:"milestone,omitempty"` + OriginalAuthor string `json:"original_author,omitempty"` + OriginalAuthorID int64 `json:"original_author_id,omitempty"` + PinOrder int64 `json:"pin_order,omitempty"` + PullRequest *PullRequestMeta `json:"pull_request,omitempty"` + Ref string `json:"ref,omitempty"` + Repository *RepositoryMeta `json:"repository,omitempty"` + State *StateType `json:"state,omitempty"` + Title string `json:"title,omitempty"` + URL string `json:"url,omitempty"` + Updated time.Time `json:"updated_at,omitempty"` + User *User `json:"user,omitempty"` } type IssueConfig struct { - BlankIssuesEnabled bool `json:"blank_issues_enabled,omitempty"` - ContactLinks []*IssueConfigContactLink `json:"contact_links,omitempty"` + BlankIssuesEnabled bool `json:"blank_issues_enabled,omitempty"` + ContactLinks []*IssueConfigContactLink `json:"contact_links,omitempty"` } type IssueConfigContactLink struct { About string `json:"about,omitempty"` - Name string `json:"name,omitempty"` - URL string `json:"url,omitempty"` + Name string `json:"name,omitempty"` + URL string `json:"url,omitempty"` } type IssueConfigValidation struct { Message string `json:"message,omitempty"` - Valid bool `json:"valid,omitempty"` + Valid bool `json:"valid,omitempty"` } // IssueDeadline — IssueDeadline represents an issue deadline @@ -100,11 +121,11 @@ type IssueDeadline struct { // IssueFormField — IssueFormField represents a form field type IssueFormField struct { - Attributes map[string]any `json:"attributes,omitempty"` - ID string `json:"id,omitempty"` - Type *IssueFormFieldType `json:"type,omitempty"` - Validations map[string]any `json:"validations,omitempty"` - Visible []*IssueFormFieldVisible `json:"visible,omitempty"` + Attributes map[string]any `json:"attributes,omitempty"` + ID string `json:"id,omitempty"` + Type *IssueFormFieldType `json:"type,omitempty"` + Validations map[string]any `json:"validations,omitempty"` + Visible []*IssueFormFieldVisible `json:"visible,omitempty"` } // IssueFormFieldType has no fields in the swagger spec. @@ -115,28 +136,32 @@ type IssueFormFieldType struct{} type IssueFormFieldVisible struct{} // IssueLabelsOption — IssueLabelsOption a collection of labels +// +// Usage: +// +// opts := IssueLabelsOption{Updated: time.Now()} type IssueLabelsOption struct { - Labels []any `json:"labels,omitempty"` // Labels can be a list of integers representing label IDs or a list of strings representing label names + Labels []any `json:"labels,omitempty"` // Labels can be a list of integers representing label IDs or a list of strings representing label names Updated time.Time `json:"updated_at,omitempty"` } // IssueMeta — IssueMeta basic issue information type IssueMeta struct { - Index int64 `json:"index,omitempty"` - Name string `json:"repo,omitempty"` + Index int64 `json:"index,omitempty"` + Name string `json:"repo,omitempty"` Owner string `json:"owner,omitempty"` } // IssueTemplate — IssueTemplate represents an issue template for a repository type IssueTemplate struct { - About string `json:"about,omitempty"` - Content string `json:"content,omitempty"` - Fields []*IssueFormField `json:"body,omitempty"` - FileName string `json:"file_name,omitempty"` - Labels *IssueTemplateLabels `json:"labels,omitempty"` - Name string `json:"name,omitempty"` - Ref string `json:"ref,omitempty"` - Title string `json:"title,omitempty"` + About string `json:"about,omitempty"` + Content string `json:"content,omitempty"` + Fields []*IssueFormField `json:"body,omitempty"` + FileName string `json:"file_name,omitempty"` + Labels *IssueTemplateLabels `json:"labels,omitempty"` + Name string `json:"name,omitempty"` + Ref string `json:"ref,omitempty"` + Title string `json:"title,omitempty"` } // IssueTemplateLabels has no fields in the swagger spec. diff --git a/types/key.go b/types/key.go index 7b472c9..3f57825 100644 --- a/types/key.go +++ b/types/key.go @@ -4,64 +4,73 @@ package types import "time" + // CreateGPGKeyOption — CreateGPGKeyOption options create user GPG key +// +// Usage: +// +// opts := CreateGPGKeyOption{ArmoredKey: "example"} type CreateGPGKeyOption struct { ArmoredKey string `json:"armored_public_key"` // An armored GPG key to add - Signature string `json:"armored_signature,omitempty"` + Signature string `json:"armored_signature,omitempty"` } // CreateKeyOption — CreateKeyOption options when creating a key +// +// Usage: +// +// opts := CreateKeyOption{Title: "example"} type CreateKeyOption struct { - Key string `json:"key"` // An armored SSH key to add - ReadOnly bool `json:"read_only,omitempty"` // Describe if the key has only read access or read/write - Title string `json:"title"` // Title of the key to add + Key string `json:"key"` // An armored SSH key to add + ReadOnly bool `json:"read_only,omitempty"` // Describe if the key has only read access or read/write + Title string `json:"title"` // Title of the key to add } // DeployKey — DeployKey a deploy key type DeployKey struct { - Created time.Time `json:"created_at,omitempty"` - Fingerprint string `json:"fingerprint,omitempty"` - ID int64 `json:"id,omitempty"` - Key string `json:"key,omitempty"` - KeyID int64 `json:"key_id,omitempty"` - ReadOnly bool `json:"read_only,omitempty"` - Repository *Repository `json:"repository,omitempty"` - Title string `json:"title,omitempty"` - URL string `json:"url,omitempty"` + Created time.Time `json:"created_at,omitempty"` + Fingerprint string `json:"fingerprint,omitempty"` + ID int64 `json:"id,omitempty"` + Key string `json:"key,omitempty"` + KeyID int64 `json:"key_id,omitempty"` + ReadOnly bool `json:"read_only,omitempty"` + Repository *Repository `json:"repository,omitempty"` + Title string `json:"title,omitempty"` + URL string `json:"url,omitempty"` } // GPGKey — GPGKey a user GPG key to sign commit and tag in repository type GPGKey struct { - CanCertify bool `json:"can_certify,omitempty"` - CanEncryptComms bool `json:"can_encrypt_comms,omitempty"` - CanEncryptStorage bool `json:"can_encrypt_storage,omitempty"` - CanSign bool `json:"can_sign,omitempty"` - Created time.Time `json:"created_at,omitempty"` - Emails []*GPGKeyEmail `json:"emails,omitempty"` - Expires time.Time `json:"expires_at,omitempty"` - ID int64 `json:"id,omitempty"` - KeyID string `json:"key_id,omitempty"` - PrimaryKeyID string `json:"primary_key_id,omitempty"` - PublicKey string `json:"public_key,omitempty"` - SubsKey []*GPGKey `json:"subkeys,omitempty"` - Verified bool `json:"verified,omitempty"` + CanCertify bool `json:"can_certify,omitempty"` + CanEncryptComms bool `json:"can_encrypt_comms,omitempty"` + CanEncryptStorage bool `json:"can_encrypt_storage,omitempty"` + CanSign bool `json:"can_sign,omitempty"` + Created time.Time `json:"created_at,omitempty"` + Emails []*GPGKeyEmail `json:"emails,omitempty"` + Expires time.Time `json:"expires_at,omitempty"` + ID int64 `json:"id,omitempty"` + KeyID string `json:"key_id,omitempty"` + PrimaryKeyID string `json:"primary_key_id,omitempty"` + PublicKey string `json:"public_key,omitempty"` + SubsKey []*GPGKey `json:"subkeys,omitempty"` + Verified bool `json:"verified,omitempty"` } // GPGKeyEmail — GPGKeyEmail an email attached to a GPGKey type GPGKeyEmail struct { - Email string `json:"email,omitempty"` - Verified bool `json:"verified,omitempty"` + Email string `json:"email,omitempty"` + Verified bool `json:"verified,omitempty"` } // PublicKey — PublicKey publickey is a user key to push code to repository type PublicKey struct { - Created time.Time `json:"created_at,omitempty"` - Fingerprint string `json:"fingerprint,omitempty"` - ID int64 `json:"id,omitempty"` - Key string `json:"key,omitempty"` - KeyType string `json:"key_type,omitempty"` - ReadOnly bool `json:"read_only,omitempty"` - Title string `json:"title,omitempty"` - URL string `json:"url,omitempty"` - User *User `json:"user,omitempty"` + Created time.Time `json:"created_at,omitempty"` + Fingerprint string `json:"fingerprint,omitempty"` + ID int64 `json:"id,omitempty"` + Key string `json:"key,omitempty"` + KeyType string `json:"key_type,omitempty"` + ReadOnly bool `json:"read_only,omitempty"` + Title string `json:"title,omitempty"` + URL string `json:"url,omitempty"` + User *User `json:"user,omitempty"` } diff --git a/types/label.go b/types/label.go index 117677c..b79c21f 100644 --- a/types/label.go +++ b/types/label.go @@ -4,44 +4,57 @@ package types import "time" + // CreateLabelOption — CreateLabelOption options for creating a label +// +// Usage: +// +// opts := CreateLabelOption{Name: "example"} type CreateLabelOption struct { - Color string `json:"color"` + Color string `json:"color"` Description string `json:"description,omitempty"` - Exclusive bool `json:"exclusive,omitempty"` - IsArchived bool `json:"is_archived,omitempty"` - Name string `json:"name"` + Exclusive bool `json:"exclusive,omitempty"` + IsArchived bool `json:"is_archived,omitempty"` + Name string `json:"name"` } // DeleteLabelsOption — DeleteLabelOption options for deleting a label +// +// Usage: +// +// opts := DeleteLabelsOption{Updated: time.Now()} type DeleteLabelsOption struct { Updated time.Time `json:"updated_at,omitempty"` } // EditLabelOption — EditLabelOption options for editing a label +// +// Usage: +// +// opts := EditLabelOption{Description: "example"} type EditLabelOption struct { - Color string `json:"color,omitempty"` + Color string `json:"color,omitempty"` Description string `json:"description,omitempty"` - Exclusive bool `json:"exclusive,omitempty"` - IsArchived bool `json:"is_archived,omitempty"` - Name string `json:"name,omitempty"` + Exclusive bool `json:"exclusive,omitempty"` + IsArchived bool `json:"is_archived,omitempty"` + Name string `json:"name,omitempty"` } // Label — Label a label to an issue or a pr type Label struct { - Color string `json:"color,omitempty"` + Color string `json:"color,omitempty"` Description string `json:"description,omitempty"` - Exclusive bool `json:"exclusive,omitempty"` - ID int64 `json:"id,omitempty"` - IsArchived bool `json:"is_archived,omitempty"` - Name string `json:"name,omitempty"` - URL string `json:"url,omitempty"` + Exclusive bool `json:"exclusive,omitempty"` + ID int64 `json:"id,omitempty"` + IsArchived bool `json:"is_archived,omitempty"` + Name string `json:"name,omitempty"` + URL string `json:"url,omitempty"` } // LabelTemplate — LabelTemplate info of a Label template type LabelTemplate struct { - Color string `json:"color,omitempty"` + Color string `json:"color,omitempty"` Description string `json:"description,omitempty"` - Exclusive bool `json:"exclusive,omitempty"` - Name string `json:"name,omitempty"` + Exclusive bool `json:"exclusive,omitempty"` + Name string `json:"name,omitempty"` } diff --git a/types/milestone.go b/types/milestone.go index 974d826..e22aa1a 100644 --- a/types/milestone.go +++ b/types/milestone.go @@ -4,32 +4,41 @@ package types import "time" + // CreateMilestoneOption — CreateMilestoneOption options for creating a milestone +// +// Usage: +// +// opts := CreateMilestoneOption{Description: "example"} type CreateMilestoneOption struct { - Deadline time.Time `json:"due_on,omitempty"` - Description string `json:"description,omitempty"` - State string `json:"state,omitempty"` - Title string `json:"title,omitempty"` + Deadline time.Time `json:"due_on,omitempty"` + Description string `json:"description,omitempty"` + State string `json:"state,omitempty"` + Title string `json:"title,omitempty"` } // EditMilestoneOption — EditMilestoneOption options for editing a milestone +// +// Usage: +// +// opts := EditMilestoneOption{Description: "example"} type EditMilestoneOption struct { - Deadline time.Time `json:"due_on,omitempty"` - Description string `json:"description,omitempty"` - State string `json:"state,omitempty"` - Title string `json:"title,omitempty"` + Deadline time.Time `json:"due_on,omitempty"` + Description string `json:"description,omitempty"` + State string `json:"state,omitempty"` + Title string `json:"title,omitempty"` } // Milestone — Milestone milestone is a collection of issues on one repository type Milestone struct { - Closed time.Time `json:"closed_at,omitempty"` - ClosedIssues int64 `json:"closed_issues,omitempty"` - Created time.Time `json:"created_at,omitempty"` - Deadline time.Time `json:"due_on,omitempty"` - Description string `json:"description,omitempty"` - ID int64 `json:"id,omitempty"` - OpenIssues int64 `json:"open_issues,omitempty"` - State *StateType `json:"state,omitempty"` - Title string `json:"title,omitempty"` - Updated time.Time `json:"updated_at,omitempty"` + Closed time.Time `json:"closed_at,omitempty"` + ClosedIssues int64 `json:"closed_issues,omitempty"` + Created time.Time `json:"created_at,omitempty"` + Deadline time.Time `json:"due_on,omitempty"` + Description string `json:"description,omitempty"` + ID int64 `json:"id,omitempty"` + OpenIssues int64 `json:"open_issues,omitempty"` + State *StateType `json:"state,omitempty"` + Title string `json:"title,omitempty"` + Updated time.Time `json:"updated_at,omitempty"` } diff --git a/types/misc.go b/types/misc.go index a1eada1..e7ab3d5 100644 --- a/types/misc.go +++ b/types/misc.go @@ -4,59 +4,84 @@ package types import "time" + // AddCollaboratorOption — AddCollaboratorOption options when adding a user as a collaborator of a repository +// +// Usage: +// +// opts := AddCollaboratorOption{Permission: "example"} type AddCollaboratorOption struct { Permission string `json:"permission,omitempty"` } // AddTimeOption — AddTimeOption options for adding time to an issue +// +// Usage: +// +// opts := AddTimeOption{Time: 1} type AddTimeOption struct { Created time.Time `json:"created,omitempty"` - Time int64 `json:"time"` // time in seconds - User string `json:"user_name,omitempty"` // User who spent the time (optional) + Time int64 `json:"time"` // time in seconds + User string `json:"user_name,omitempty"` // User who spent the time (optional) } // ChangeFileOperation — ChangeFileOperation for creating, updating or deleting a file type ChangeFileOperation struct { - ContentBase64 string `json:"content,omitempty"` // new or updated file content, must be base64 encoded - FromPath string `json:"from_path,omitempty"` // old path of the file to move - Operation string `json:"operation"` // indicates what to do with the file - Path string `json:"path"` // path to the existing or new file - SHA string `json:"sha,omitempty"` // sha is the SHA for the file that already exists, required for update or delete + ContentBase64 string `json:"content,omitempty"` // new or updated file content, must be base64 encoded + FromPath string `json:"from_path,omitempty"` // old path of the file to move + Operation string `json:"operation"` // indicates what to do with the file + Path string `json:"path"` // path to the existing or new file + SHA string `json:"sha,omitempty"` // sha is the SHA for the file that already exists, required for update or delete } // ChangeFilesOptions — ChangeFilesOptions options for creating, updating or deleting multiple files Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) +// +// Usage: +// +// opts := ChangeFilesOptions{Files: {}} type ChangeFilesOptions struct { - Author *Identity `json:"author,omitempty"` - BranchName string `json:"branch,omitempty"` // branch (optional) to base this file from. if not given, the default branch is used - Committer *Identity `json:"committer,omitempty"` - Dates *CommitDateOptions `json:"dates,omitempty"` - Files []*ChangeFileOperation `json:"files"` // list of file operations - Message string `json:"message,omitempty"` // message (optional) for the commit of this file. if not supplied, a default message will be used - NewBranchName string `json:"new_branch,omitempty"` // new_branch (optional) will make a new branch from `branch` before creating the file - Signoff bool `json:"signoff,omitempty"` // Add a Signed-off-by trailer by the committer at the end of the commit log message. + Author *Identity `json:"author,omitempty"` + BranchName string `json:"branch,omitempty"` // branch (optional) to base this file from. if not given, the default branch is used + Committer *Identity `json:"committer,omitempty"` + Dates *CommitDateOptions `json:"dates,omitempty"` + Files []*ChangeFileOperation `json:"files"` // list of file operations + Message string `json:"message,omitempty"` // message (optional) for the commit of this file. if not supplied, a default message will be used + NewBranchName string `json:"new_branch,omitempty"` // new_branch (optional) will make a new branch from `branch` before creating the file + Signoff bool `json:"signoff,omitempty"` // Add a Signed-off-by trailer by the committer at the end of the commit log message. } type Compare struct { - Commits []*Commit `json:"commits,omitempty"` - TotalCommits int64 `json:"total_commits,omitempty"` + Commits []*Commit `json:"commits,omitempty"` + TotalCommits int64 `json:"total_commits,omitempty"` } // CreateForkOption — CreateForkOption options for creating a fork +// +// Usage: +// +// opts := CreateForkOption{Name: "example"} type CreateForkOption struct { - Name string `json:"name,omitempty"` // name of the forked repository + Name string `json:"name,omitempty"` // name of the forked repository Organization string `json:"organization,omitempty"` // organization name, if forking into an organization } // CreateOrUpdateSecretOption — CreateOrUpdateSecretOption options when creating or updating secret +// +// Usage: +// +// opts := CreateOrUpdateSecretOption{Data: "example"} type CreateOrUpdateSecretOption struct { Data string `json:"data"` // Data of the secret to update } // DismissPullReviewOptions — DismissPullReviewOptions are options to dismiss a pull review +// +// Usage: +// +// opts := DismissPullReviewOptions{Message: "example"} type DismissPullReviewOptions struct { Message string `json:"message,omitempty"` - Priors bool `json:"priors,omitempty"` + Priors bool `json:"priors,omitempty"` } // ForgeLike — ForgeLike activity data type @@ -64,106 +89,126 @@ type DismissPullReviewOptions struct { type ForgeLike struct{} // GenerateRepoOption — GenerateRepoOption options when creating repository using a template +// +// Usage: +// +// opts := GenerateRepoOption{Name: "example"} type GenerateRepoOption struct { - Avatar bool `json:"avatar,omitempty"` // include avatar of the template repo - DefaultBranch string `json:"default_branch,omitempty"` // Default branch of the new repository - Description string `json:"description,omitempty"` // Description of the repository to create - GitContent bool `json:"git_content,omitempty"` // include git content of default branch in template repo - GitHooks bool `json:"git_hooks,omitempty"` // include git hooks in template repo - Labels bool `json:"labels,omitempty"` // include labels in template repo - Name string `json:"name"` // Name of the repository to create - Owner string `json:"owner"` // The organization or person who will own the new repository - Private bool `json:"private,omitempty"` // Whether the repository is private - ProtectedBranch bool `json:"protected_branch,omitempty"` // include protected branches in template repo - Topics bool `json:"topics,omitempty"` // include topics in template repo - Webhooks bool `json:"webhooks,omitempty"` // include webhooks in template repo + Avatar bool `json:"avatar,omitempty"` // include avatar of the template repo + DefaultBranch string `json:"default_branch,omitempty"` // Default branch of the new repository + Description string `json:"description,omitempty"` // Description of the repository to create + GitContent bool `json:"git_content,omitempty"` // include git content of default branch in template repo + GitHooks bool `json:"git_hooks,omitempty"` // include git hooks in template repo + Labels bool `json:"labels,omitempty"` // include labels in template repo + Name string `json:"name"` // Name of the repository to create + Owner string `json:"owner"` // The organization or person who will own the new repository + Private bool `json:"private,omitempty"` // Whether the repository is private + ProtectedBranch bool `json:"protected_branch,omitempty"` // include protected branches in template repo + Topics bool `json:"topics,omitempty"` // include topics in template repo + Webhooks bool `json:"webhooks,omitempty"` // include webhooks in template repo } // GitignoreTemplateInfo — GitignoreTemplateInfo name and text of a gitignore template type GitignoreTemplateInfo struct { - Name string `json:"name,omitempty"` + Name string `json:"name,omitempty"` Source string `json:"source,omitempty"` } // Identity — Identity for a person's identity like an author or committer type Identity struct { Email string `json:"email,omitempty"` - Name string `json:"name,omitempty"` + Name string `json:"name,omitempty"` } // LicenseTemplateInfo — LicensesInfo contains information about a License type LicenseTemplateInfo struct { - Body string `json:"body,omitempty"` + Body string `json:"body,omitempty"` Implementation string `json:"implementation,omitempty"` - Key string `json:"key,omitempty"` - Name string `json:"name,omitempty"` - URL string `json:"url,omitempty"` + Key string `json:"key,omitempty"` + Name string `json:"name,omitempty"` + URL string `json:"url,omitempty"` } // LicensesTemplateListEntry — LicensesListEntry is used for the API type LicensesTemplateListEntry struct { - Key string `json:"key,omitempty"` + Key string `json:"key,omitempty"` Name string `json:"name,omitempty"` - URL string `json:"url,omitempty"` + URL string `json:"url,omitempty"` } // MarkdownOption — MarkdownOption markdown options +// +// Usage: +// +// opts := MarkdownOption{Context: "example"} type MarkdownOption struct { Context string `json:"Context,omitempty"` // Context to render in: body - Mode string `json:"Mode,omitempty"` // Mode to render (comment, gfm, markdown) in: body - Text string `json:"Text,omitempty"` // Text markdown to render in: body - Wiki bool `json:"Wiki,omitempty"` // Is it a wiki page ? in: body + Mode string `json:"Mode,omitempty"` // Mode to render (comment, gfm, markdown) in: body + Text string `json:"Text,omitempty"` // Text markdown to render in: body + Wiki bool `json:"Wiki,omitempty"` // Is it a wiki page ? in: body } // MarkupOption — MarkupOption markup options +// +// Usage: +// +// opts := MarkupOption{BranchPath: "main"} type MarkupOption struct { BranchPath string `json:"BranchPath,omitempty"` // The current branch path where the form gets posted in: body - Context string `json:"Context,omitempty"` // Context to render in: body - FilePath string `json:"FilePath,omitempty"` // File path for detecting extension in file mode in: body - Mode string `json:"Mode,omitempty"` // Mode to render (comment, gfm, markdown, file) in: body - Text string `json:"Text,omitempty"` // Text markup to render in: body - Wiki bool `json:"Wiki,omitempty"` // Is it a wiki page ? in: body + Context string `json:"Context,omitempty"` // Context to render in: body + FilePath string `json:"FilePath,omitempty"` // File path for detecting extension in file mode in: body + Mode string `json:"Mode,omitempty"` // Mode to render (comment, gfm, markdown, file) in: body + Text string `json:"Text,omitempty"` // Text markup to render in: body + Wiki bool `json:"Wiki,omitempty"` // Is it a wiki page ? in: body } // MergePullRequestOption — MergePullRequestForm form for merging Pull Request +// +// Usage: +// +// opts := MergePullRequestOption{Do: "example"} type MergePullRequestOption struct { - DeleteBranchAfterMerge bool `json:"delete_branch_after_merge,omitempty"` - Do string `json:"Do"` - ForceMerge bool `json:"force_merge,omitempty"` - HeadCommitID string `json:"head_commit_id,omitempty"` - MergeCommitID string `json:"MergeCommitID,omitempty"` - MergeMessageField string `json:"MergeMessageField,omitempty"` - MergeTitleField string `json:"MergeTitleField,omitempty"` - MergeWhenChecksSucceed bool `json:"merge_when_checks_succeed,omitempty"` + DeleteBranchAfterMerge bool `json:"delete_branch_after_merge,omitempty"` + Do string `json:"Do"` + ForceMerge bool `json:"force_merge,omitempty"` + HeadCommitID string `json:"head_commit_id,omitempty"` + MergeCommitID string `json:"MergeCommitID,omitempty"` + MergeMessageField string `json:"MergeMessageField,omitempty"` + MergeTitleField string `json:"MergeTitleField,omitempty"` + MergeWhenChecksSucceed bool `json:"merge_when_checks_succeed,omitempty"` } // MigrateRepoOptions — MigrateRepoOptions options for migrating repository's this is used to interact with api v1 +// +// Usage: +// +// opts := MigrateRepoOptions{RepoName: "example"} type MigrateRepoOptions struct { - AuthPassword string `json:"auth_password,omitempty"` - AuthToken string `json:"auth_token,omitempty"` - AuthUsername string `json:"auth_username,omitempty"` - CloneAddr string `json:"clone_addr"` - Description string `json:"description,omitempty"` - Issues bool `json:"issues,omitempty"` - LFS bool `json:"lfs,omitempty"` - LFSEndpoint string `json:"lfs_endpoint,omitempty"` - Labels bool `json:"labels,omitempty"` - Milestones bool `json:"milestones,omitempty"` - Mirror bool `json:"mirror,omitempty"` + AuthPassword string `json:"auth_password,omitempty"` + AuthToken string `json:"auth_token,omitempty"` + AuthUsername string `json:"auth_username,omitempty"` + CloneAddr string `json:"clone_addr"` + Description string `json:"description,omitempty"` + Issues bool `json:"issues,omitempty"` + LFS bool `json:"lfs,omitempty"` + LFSEndpoint string `json:"lfs_endpoint,omitempty"` + Labels bool `json:"labels,omitempty"` + Milestones bool `json:"milestones,omitempty"` + Mirror bool `json:"mirror,omitempty"` MirrorInterval string `json:"mirror_interval,omitempty"` - Private bool `json:"private,omitempty"` - PullRequests bool `json:"pull_requests,omitempty"` - Releases bool `json:"releases,omitempty"` - RepoName string `json:"repo_name"` - RepoOwner string `json:"repo_owner,omitempty"` // Name of User or Organisation who will own Repo after migration - RepoOwnerID int64 `json:"uid,omitempty"` // deprecated (only for backwards compatibility) - Service string `json:"service,omitempty"` - Wiki bool `json:"wiki,omitempty"` + Private bool `json:"private,omitempty"` + PullRequests bool `json:"pull_requests,omitempty"` + Releases bool `json:"releases,omitempty"` + RepoName string `json:"repo_name"` + RepoOwner string `json:"repo_owner,omitempty"` // Name of User or Organisation who will own Repo after migration + RepoOwnerID int64 `json:"uid,omitempty"` // deprecated (only for backwards compatibility) + Service string `json:"service,omitempty"` + Wiki bool `json:"wiki,omitempty"` } // NewIssuePinsAllowed — NewIssuePinsAllowed represents an API response that says if new Issue Pins are allowed type NewIssuePinsAllowed struct { - Issues bool `json:"issues,omitempty"` + Issues bool `json:"issues,omitempty"` PullRequests bool `json:"pull_requests,omitempty"` } @@ -173,27 +218,31 @@ type NotifySubjectType struct{} // PRBranchInfo — PRBranchInfo information about a branch type PRBranchInfo struct { - Name string `json:"label,omitempty"` - Ref string `json:"ref,omitempty"` - Repo *Repository `json:"repo,omitempty"` - RepoID int64 `json:"repo_id,omitempty"` - Sha string `json:"sha,omitempty"` + Name string `json:"label,omitempty"` + Ref string `json:"ref,omitempty"` + Repo *Repository `json:"repo,omitempty"` + RepoID int64 `json:"repo_id,omitempty"` + Sha string `json:"sha,omitempty"` } // PayloadUser — PayloadUser represents the author or committer of a commit type PayloadUser struct { - Email string `json:"email,omitempty"` - Name string `json:"name,omitempty"` // Full name of the commit author + Email string `json:"email,omitempty"` + Name string `json:"name,omitempty"` // Full name of the commit author UserName string `json:"username,omitempty"` } type Reference struct { Object *GitObject `json:"object,omitempty"` - Ref string `json:"ref,omitempty"` - URL string `json:"url,omitempty"` + Ref string `json:"ref,omitempty"` + URL string `json:"url,omitempty"` } // ReplaceFlagsOption — ReplaceFlagsOption options when replacing the flags of a repository +// +// Usage: +// +// opts := ReplaceFlagsOption{Flags: []string{"example"}} type ReplaceFlagsOption struct { Flags []string `json:"flags,omitempty"` } @@ -201,7 +250,7 @@ type ReplaceFlagsOption struct { // SearchResults — SearchResults results of a successful search type SearchResults struct { Data []*Repository `json:"data,omitempty"` - OK bool `json:"ok,omitempty"` + OK bool `json:"ok,omitempty"` } // ServerVersion — ServerVersion wraps the version of the server @@ -211,43 +260,43 @@ type ServerVersion struct { // TimelineComment — TimelineComment represents a timeline comment (comment of any type) on a commit or issue type TimelineComment struct { - Assignee *User `json:"assignee,omitempty"` - AssigneeTeam *Team `json:"assignee_team,omitempty"` - Body string `json:"body,omitempty"` - Created time.Time `json:"created_at,omitempty"` - DependentIssue *Issue `json:"dependent_issue,omitempty"` - HTMLURL string `json:"html_url,omitempty"` - ID int64 `json:"id,omitempty"` - IssueURL string `json:"issue_url,omitempty"` - Label *Label `json:"label,omitempty"` - Milestone *Milestone `json:"milestone,omitempty"` - NewRef string `json:"new_ref,omitempty"` - NewTitle string `json:"new_title,omitempty"` - OldMilestone *Milestone `json:"old_milestone,omitempty"` - OldProjectID int64 `json:"old_project_id,omitempty"` - OldRef string `json:"old_ref,omitempty"` - OldTitle string `json:"old_title,omitempty"` - PRURL string `json:"pull_request_url,omitempty"` - ProjectID int64 `json:"project_id,omitempty"` - RefAction string `json:"ref_action,omitempty"` - RefComment *Comment `json:"ref_comment,omitempty"` - RefCommitSHA string `json:"ref_commit_sha,omitempty"` // commit SHA where issue/PR was referenced - RefIssue *Issue `json:"ref_issue,omitempty"` - RemovedAssignee bool `json:"removed_assignee,omitempty"` // whether the assignees were removed or added - ResolveDoer *User `json:"resolve_doer,omitempty"` - ReviewID int64 `json:"review_id,omitempty"` - TrackedTime *TrackedTime `json:"tracked_time,omitempty"` - Type string `json:"type,omitempty"` - Updated time.Time `json:"updated_at,omitempty"` - User *User `json:"user,omitempty"` + Assignee *User `json:"assignee,omitempty"` + AssigneeTeam *Team `json:"assignee_team,omitempty"` + Body string `json:"body,omitempty"` + Created time.Time `json:"created_at,omitempty"` + DependentIssue *Issue `json:"dependent_issue,omitempty"` + HTMLURL string `json:"html_url,omitempty"` + ID int64 `json:"id,omitempty"` + IssueURL string `json:"issue_url,omitempty"` + Label *Label `json:"label,omitempty"` + Milestone *Milestone `json:"milestone,omitempty"` + NewRef string `json:"new_ref,omitempty"` + NewTitle string `json:"new_title,omitempty"` + OldMilestone *Milestone `json:"old_milestone,omitempty"` + OldProjectID int64 `json:"old_project_id,omitempty"` + OldRef string `json:"old_ref,omitempty"` + OldTitle string `json:"old_title,omitempty"` + PRURL string `json:"pull_request_url,omitempty"` + ProjectID int64 `json:"project_id,omitempty"` + RefAction string `json:"ref_action,omitempty"` + RefComment *Comment `json:"ref_comment,omitempty"` + RefCommitSHA string `json:"ref_commit_sha,omitempty"` // commit SHA where issue/PR was referenced + RefIssue *Issue `json:"ref_issue,omitempty"` + RemovedAssignee bool `json:"removed_assignee,omitempty"` // whether the assignees were removed or added + ResolveDoer *User `json:"resolve_doer,omitempty"` + ReviewID int64 `json:"review_id,omitempty"` + TrackedTime *TrackedTime `json:"tracked_time,omitempty"` + Type string `json:"type,omitempty"` + Updated time.Time `json:"updated_at,omitempty"` + User *User `json:"user,omitempty"` } // WatchInfo — WatchInfo represents an API watch status of one repository type WatchInfo struct { - CreatedAt time.Time `json:"created_at,omitempty"` - Ignored bool `json:"ignored,omitempty"` - Reason any `json:"reason,omitempty"` - RepositoryURL string `json:"repository_url,omitempty"` - Subscribed bool `json:"subscribed,omitempty"` - URL string `json:"url,omitempty"` + CreatedAt time.Time `json:"created_at,omitempty"` + Ignored bool `json:"ignored,omitempty"` + Reason any `json:"reason,omitempty"` + RepositoryURL string `json:"repository_url,omitempty"` + Subscribed bool `json:"subscribed,omitempty"` + URL string `json:"url,omitempty"` } diff --git a/types/notification.go b/types/notification.go index 6e9fe0d..72e3381 100644 --- a/types/notification.go +++ b/types/notification.go @@ -4,6 +4,7 @@ package types import "time" + // NotificationCount — NotificationCount number of unread notifications type NotificationCount struct { New int64 `json:"new,omitempty"` @@ -11,22 +12,22 @@ type NotificationCount struct { // NotificationSubject — NotificationSubject contains the notification subject (Issue/Pull/Commit) type NotificationSubject struct { - HTMLURL string `json:"html_url,omitempty"` - LatestCommentHTMLURL string `json:"latest_comment_html_url,omitempty"` - LatestCommentURL string `json:"latest_comment_url,omitempty"` - State *StateType `json:"state,omitempty"` - Title string `json:"title,omitempty"` - Type *NotifySubjectType `json:"type,omitempty"` - URL string `json:"url,omitempty"` + HTMLURL string `json:"html_url,omitempty"` + LatestCommentHTMLURL string `json:"latest_comment_html_url,omitempty"` + LatestCommentURL string `json:"latest_comment_url,omitempty"` + State *StateType `json:"state,omitempty"` + Title string `json:"title,omitempty"` + Type *NotifySubjectType `json:"type,omitempty"` + URL string `json:"url,omitempty"` } // NotificationThread — NotificationThread expose Notification on API type NotificationThread struct { - ID int64 `json:"id,omitempty"` - Pinned bool `json:"pinned,omitempty"` - Repository *Repository `json:"repository,omitempty"` - Subject *NotificationSubject `json:"subject,omitempty"` - URL string `json:"url,omitempty"` - Unread bool `json:"unread,omitempty"` - UpdatedAt time.Time `json:"updated_at,omitempty"` + ID int64 `json:"id,omitempty"` + Pinned bool `json:"pinned,omitempty"` + Repository *Repository `json:"repository,omitempty"` + Subject *NotificationSubject `json:"subject,omitempty"` + URL string `json:"url,omitempty"` + Unread bool `json:"unread,omitempty"` + UpdatedAt time.Time `json:"updated_at,omitempty"` } diff --git a/types/oauth.go b/types/oauth.go index b6d27d8..acb1038 100644 --- a/types/oauth.go +++ b/types/oauth.go @@ -4,33 +4,42 @@ package types import "time" + type AccessToken struct { - ID int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Scopes []string `json:"scopes,omitempty"` - Token string `json:"sha1,omitempty"` - TokenLastEight string `json:"token_last_eight,omitempty"` + ID int64 `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Scopes []string `json:"scopes,omitempty"` + Token string `json:"sha1,omitempty"` + TokenLastEight string `json:"token_last_eight,omitempty"` } // CreateAccessTokenOption — CreateAccessTokenOption options when create access token +// +// Usage: +// +// opts := CreateAccessTokenOption{Name: "example"} type CreateAccessTokenOption struct { - Name string `json:"name"` + Name string `json:"name"` Scopes []string `json:"scopes,omitempty"` } // CreateOAuth2ApplicationOptions — CreateOAuth2ApplicationOptions holds options to create an oauth2 application +// +// Usage: +// +// opts := CreateOAuth2ApplicationOptions{Name: "example"} type CreateOAuth2ApplicationOptions struct { - ConfidentialClient bool `json:"confidential_client,omitempty"` - Name string `json:"name,omitempty"` - RedirectURIs []string `json:"redirect_uris,omitempty"` + ConfidentialClient bool `json:"confidential_client,omitempty"` + Name string `json:"name,omitempty"` + RedirectURIs []string `json:"redirect_uris,omitempty"` } type OAuth2Application struct { - ClientID string `json:"client_id,omitempty"` - ClientSecret string `json:"client_secret,omitempty"` - ConfidentialClient bool `json:"confidential_client,omitempty"` - Created time.Time `json:"created,omitempty"` - ID int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - RedirectURIs []string `json:"redirect_uris,omitempty"` + ClientID string `json:"client_id,omitempty"` + ClientSecret string `json:"client_secret,omitempty"` + ConfidentialClient bool `json:"confidential_client,omitempty"` + Created time.Time `json:"created,omitempty"` + ID int64 `json:"id,omitempty"` + Name string `json:"name,omitempty"` + RedirectURIs []string `json:"redirect_uris,omitempty"` } diff --git a/types/org.go b/types/org.go index bf084a0..d5611d2 100644 --- a/types/org.go +++ b/types/org.go @@ -2,49 +2,58 @@ package types + // CreateOrgOption — CreateOrgOption options for creating an organization +// +// Usage: +// +// opts := CreateOrgOption{UserName: "example"} type CreateOrgOption struct { - Description string `json:"description,omitempty"` - Email string `json:"email,omitempty"` - FullName string `json:"full_name,omitempty"` - Location string `json:"location,omitempty"` - RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access,omitempty"` - UserName string `json:"username"` - Visibility string `json:"visibility,omitempty"` // possible values are `public` (default), `limited` or `private` - Website string `json:"website,omitempty"` + Description string `json:"description,omitempty"` + Email string `json:"email,omitempty"` + FullName string `json:"full_name,omitempty"` + Location string `json:"location,omitempty"` + RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access,omitempty"` + UserName string `json:"username"` + Visibility string `json:"visibility,omitempty"` // possible values are `public` (default), `limited` or `private` + Website string `json:"website,omitempty"` } // EditOrgOption — EditOrgOption options for editing an organization +// +// Usage: +// +// opts := EditOrgOption{Description: "example"} type EditOrgOption struct { - Description string `json:"description,omitempty"` - Email string `json:"email,omitempty"` - FullName string `json:"full_name,omitempty"` - Location string `json:"location,omitempty"` - RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access,omitempty"` - Visibility string `json:"visibility,omitempty"` // possible values are `public`, `limited` or `private` - Website string `json:"website,omitempty"` + Description string `json:"description,omitempty"` + Email string `json:"email,omitempty"` + FullName string `json:"full_name,omitempty"` + Location string `json:"location,omitempty"` + RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access,omitempty"` + Visibility string `json:"visibility,omitempty"` // possible values are `public`, `limited` or `private` + Website string `json:"website,omitempty"` } // Organization — Organization represents an organization type Organization struct { - AvatarURL string `json:"avatar_url,omitempty"` - Description string `json:"description,omitempty"` - Email string `json:"email,omitempty"` - FullName string `json:"full_name,omitempty"` - ID int64 `json:"id,omitempty"` - Location string `json:"location,omitempty"` - Name string `json:"name,omitempty"` - RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access,omitempty"` - UserName string `json:"username,omitempty"` // deprecated - Visibility string `json:"visibility,omitempty"` - Website string `json:"website,omitempty"` + AvatarURL string `json:"avatar_url,omitempty"` + Description string `json:"description,omitempty"` + Email string `json:"email,omitempty"` + FullName string `json:"full_name,omitempty"` + ID int64 `json:"id,omitempty"` + Location string `json:"location,omitempty"` + Name string `json:"name,omitempty"` + RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access,omitempty"` + UserName string `json:"username,omitempty"` // deprecated + Visibility string `json:"visibility,omitempty"` + Website string `json:"website,omitempty"` } // OrganizationPermissions — OrganizationPermissions list different users permissions on an organization type OrganizationPermissions struct { CanCreateRepository bool `json:"can_create_repository,omitempty"` - CanRead bool `json:"can_read,omitempty"` - CanWrite bool `json:"can_write,omitempty"` - IsAdmin bool `json:"is_admin,omitempty"` - IsOwner bool `json:"is_owner,omitempty"` + CanRead bool `json:"can_read,omitempty"` + CanWrite bool `json:"can_write,omitempty"` + IsAdmin bool `json:"is_admin,omitempty"` + IsOwner bool `json:"is_owner,omitempty"` } diff --git a/types/package.go b/types/package.go index 491c5a7..02e639e 100644 --- a/types/package.go +++ b/types/package.go @@ -4,26 +4,27 @@ package types import "time" + // Package — Package represents a package type Package struct { - CreatedAt time.Time `json:"created_at,omitempty"` - Creator *User `json:"creator,omitempty"` - HTMLURL string `json:"html_url,omitempty"` - ID int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Owner *User `json:"owner,omitempty"` + CreatedAt time.Time `json:"created_at,omitempty"` + Creator *User `json:"creator,omitempty"` + HTMLURL string `json:"html_url,omitempty"` + ID int64 `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Owner *User `json:"owner,omitempty"` Repository *Repository `json:"repository,omitempty"` - Type string `json:"type,omitempty"` - Version string `json:"version,omitempty"` + Type string `json:"type,omitempty"` + Version string `json:"version,omitempty"` } // PackageFile — PackageFile represents a package file type PackageFile struct { - HashMD5 string `json:"md5,omitempty"` - HashSHA1 string `json:"sha1,omitempty"` + HashMD5 string `json:"md5,omitempty"` + HashSHA1 string `json:"sha1,omitempty"` HashSHA256 string `json:"sha256,omitempty"` HashSHA512 string `json:"sha512,omitempty"` - ID int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Size int64 `json:"Size,omitempty"` + ID int64 `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Size int64 `json:"Size,omitempty"` } diff --git a/types/pr.go b/types/pr.go index feb8bfd..9077c3b 100644 --- a/types/pr.go +++ b/types/pr.go @@ -4,148 +4,177 @@ package types import "time" + // CreatePullRequestOption — CreatePullRequestOption options when creating a pull request +// +// Usage: +// +// opts := CreatePullRequestOption{Body: "example"} type CreatePullRequestOption struct { - Assignee string `json:"assignee,omitempty"` - Assignees []string `json:"assignees,omitempty"` - Base string `json:"base,omitempty"` - Body string `json:"body,omitempty"` - Deadline time.Time `json:"due_date,omitempty"` - Head string `json:"head,omitempty"` - Labels []int64 `json:"labels,omitempty"` - Milestone int64 `json:"milestone,omitempty"` - Title string `json:"title,omitempty"` + Assignee string `json:"assignee,omitempty"` + Assignees []string `json:"assignees,omitempty"` + Base string `json:"base,omitempty"` + Body string `json:"body,omitempty"` + Deadline time.Time `json:"due_date,omitempty"` + Head string `json:"head,omitempty"` + Labels []int64 `json:"labels,omitempty"` + Milestone int64 `json:"milestone,omitempty"` + Title string `json:"title,omitempty"` } // CreatePullReviewComment — CreatePullReviewComment represent a review comment for creation api +// +// Usage: +// +// opts := CreatePullReviewComment{Body: "example"} type CreatePullReviewComment struct { - Body string `json:"body,omitempty"` - NewLineNum int64 `json:"new_position,omitempty"` // if comment to new file line or 0 - OldLineNum int64 `json:"old_position,omitempty"` // if comment to old file line or 0 - Path string `json:"path,omitempty"` // the tree path + Body string `json:"body,omitempty"` + NewLineNum int64 `json:"new_position,omitempty"` // if comment to new file line or 0 + OldLineNum int64 `json:"old_position,omitempty"` // if comment to old file line or 0 + Path string `json:"path,omitempty"` // the tree path } // CreatePullReviewCommentOptions — CreatePullReviewCommentOptions are options to create a pull review comment +// +// Usage: +// +// opts := CreatePullReviewCommentOptions{} // CreatePullReviewCommentOptions has no fields in the swagger spec. type CreatePullReviewCommentOptions struct{} // CreatePullReviewOptions — CreatePullReviewOptions are options to create a pull review +// +// Usage: +// +// opts := CreatePullReviewOptions{Body: "example"} type CreatePullReviewOptions struct { - Body string `json:"body,omitempty"` + Body string `json:"body,omitempty"` Comments []*CreatePullReviewComment `json:"comments,omitempty"` - CommitID string `json:"commit_id,omitempty"` - Event *ReviewStateType `json:"event,omitempty"` + CommitID string `json:"commit_id,omitempty"` + Event *ReviewStateType `json:"event,omitempty"` } // EditPullRequestOption — EditPullRequestOption options when modify pull request +// +// Usage: +// +// opts := EditPullRequestOption{Body: "example"} type EditPullRequestOption struct { - AllowMaintainerEdit bool `json:"allow_maintainer_edit,omitempty"` - Assignee string `json:"assignee,omitempty"` - Assignees []string `json:"assignees,omitempty"` - Base string `json:"base,omitempty"` - Body string `json:"body,omitempty"` - Deadline time.Time `json:"due_date,omitempty"` - Labels []int64 `json:"labels,omitempty"` - Milestone int64 `json:"milestone,omitempty"` - RemoveDeadline bool `json:"unset_due_date,omitempty"` - State string `json:"state,omitempty"` - Title string `json:"title,omitempty"` + AllowMaintainerEdit bool `json:"allow_maintainer_edit,omitempty"` + Assignee string `json:"assignee,omitempty"` + Assignees []string `json:"assignees,omitempty"` + Base string `json:"base,omitempty"` + Body string `json:"body,omitempty"` + Deadline time.Time `json:"due_date,omitempty"` + Labels []int64 `json:"labels,omitempty"` + Milestone int64 `json:"milestone,omitempty"` + RemoveDeadline bool `json:"unset_due_date,omitempty"` + State string `json:"state,omitempty"` + Title string `json:"title,omitempty"` } // PullRequest — PullRequest represents a pull request type PullRequest struct { - Additions int64 `json:"additions,omitempty"` - AllowMaintainerEdit bool `json:"allow_maintainer_edit,omitempty"` - Assignee *User `json:"assignee,omitempty"` - Assignees []*User `json:"assignees,omitempty"` - Base *PRBranchInfo `json:"base,omitempty"` - Body string `json:"body,omitempty"` - ChangedFiles int64 `json:"changed_files,omitempty"` - Closed time.Time `json:"closed_at,omitempty"` - Comments int64 `json:"comments,omitempty"` - Created time.Time `json:"created_at,omitempty"` - Deadline time.Time `json:"due_date,omitempty"` - Deletions int64 `json:"deletions,omitempty"` - DiffURL string `json:"diff_url,omitempty"` - Draft bool `json:"draft,omitempty"` - HTMLURL string `json:"html_url,omitempty"` - HasMerged bool `json:"merged,omitempty"` - Head *PRBranchInfo `json:"head,omitempty"` - ID int64 `json:"id,omitempty"` - Index int64 `json:"number,omitempty"` - IsLocked bool `json:"is_locked,omitempty"` - Labels []*Label `json:"labels,omitempty"` - MergeBase string `json:"merge_base,omitempty"` - Mergeable bool `json:"mergeable,omitempty"` - Merged time.Time `json:"merged_at,omitempty"` - MergedBy *User `json:"merged_by,omitempty"` - MergedCommitID string `json:"merge_commit_sha,omitempty"` - Milestone *Milestone `json:"milestone,omitempty"` - PatchURL string `json:"patch_url,omitempty"` - PinOrder int64 `json:"pin_order,omitempty"` - RequestedReviewers []*User `json:"requested_reviewers,omitempty"` - RequestedReviewersTeams []*Team `json:"requested_reviewers_teams,omitempty"` - ReviewComments int64 `json:"review_comments,omitempty"` // number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR) - State *StateType `json:"state,omitempty"` - Title string `json:"title,omitempty"` - URL string `json:"url,omitempty"` - Updated time.Time `json:"updated_at,omitempty"` - User *User `json:"user,omitempty"` + Additions int64 `json:"additions,omitempty"` + AllowMaintainerEdit bool `json:"allow_maintainer_edit,omitempty"` + Assignee *User `json:"assignee,omitempty"` + Assignees []*User `json:"assignees,omitempty"` + Base *PRBranchInfo `json:"base,omitempty"` + Body string `json:"body,omitempty"` + ChangedFiles int64 `json:"changed_files,omitempty"` + Closed time.Time `json:"closed_at,omitempty"` + Comments int64 `json:"comments,omitempty"` + Created time.Time `json:"created_at,omitempty"` + Deadline time.Time `json:"due_date,omitempty"` + Deletions int64 `json:"deletions,omitempty"` + DiffURL string `json:"diff_url,omitempty"` + Draft bool `json:"draft,omitempty"` + HTMLURL string `json:"html_url,omitempty"` + HasMerged bool `json:"merged,omitempty"` + Head *PRBranchInfo `json:"head,omitempty"` + ID int64 `json:"id,omitempty"` + Index int64 `json:"number,omitempty"` + IsLocked bool `json:"is_locked,omitempty"` + Labels []*Label `json:"labels,omitempty"` + MergeBase string `json:"merge_base,omitempty"` + Mergeable bool `json:"mergeable,omitempty"` + Merged time.Time `json:"merged_at,omitempty"` + MergedBy *User `json:"merged_by,omitempty"` + MergedCommitID string `json:"merge_commit_sha,omitempty"` + Milestone *Milestone `json:"milestone,omitempty"` + PatchURL string `json:"patch_url,omitempty"` + PinOrder int64 `json:"pin_order,omitempty"` + RequestedReviewers []*User `json:"requested_reviewers,omitempty"` + RequestedReviewersTeams []*Team `json:"requested_reviewers_teams,omitempty"` + ReviewComments int64 `json:"review_comments,omitempty"` // number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR) + State *StateType `json:"state,omitempty"` + Title string `json:"title,omitempty"` + URL string `json:"url,omitempty"` + Updated time.Time `json:"updated_at,omitempty"` + User *User `json:"user,omitempty"` } // PullRequestMeta — PullRequestMeta PR info if an issue is a PR type PullRequestMeta struct { - HTMLURL string `json:"html_url,omitempty"` - HasMerged bool `json:"merged,omitempty"` - IsWorkInProgress bool `json:"draft,omitempty"` - Merged time.Time `json:"merged_at,omitempty"` + HTMLURL string `json:"html_url,omitempty"` + HasMerged bool `json:"merged,omitempty"` + IsWorkInProgress bool `json:"draft,omitempty"` + Merged time.Time `json:"merged_at,omitempty"` } // PullReview — PullReview represents a pull request review type PullReview struct { - Body string `json:"body,omitempty"` - CodeCommentsCount int64 `json:"comments_count,omitempty"` - CommitID string `json:"commit_id,omitempty"` - Dismissed bool `json:"dismissed,omitempty"` - HTMLPullURL string `json:"pull_request_url,omitempty"` - HTMLURL string `json:"html_url,omitempty"` - ID int64 `json:"id,omitempty"` - Official bool `json:"official,omitempty"` - Stale bool `json:"stale,omitempty"` - State *ReviewStateType `json:"state,omitempty"` - Submitted time.Time `json:"submitted_at,omitempty"` - Team *Team `json:"team,omitempty"` - Updated time.Time `json:"updated_at,omitempty"` - User *User `json:"user,omitempty"` + Body string `json:"body,omitempty"` + CodeCommentsCount int64 `json:"comments_count,omitempty"` + CommitID string `json:"commit_id,omitempty"` + Dismissed bool `json:"dismissed,omitempty"` + HTMLPullURL string `json:"pull_request_url,omitempty"` + HTMLURL string `json:"html_url,omitempty"` + ID int64 `json:"id,omitempty"` + Official bool `json:"official,omitempty"` + Stale bool `json:"stale,omitempty"` + State *ReviewStateType `json:"state,omitempty"` + Submitted time.Time `json:"submitted_at,omitempty"` + Team *Team `json:"team,omitempty"` + Updated time.Time `json:"updated_at,omitempty"` + User *User `json:"user,omitempty"` } // PullReviewComment — PullReviewComment represents a comment on a pull request review type PullReviewComment struct { - Body string `json:"body,omitempty"` - CommitID string `json:"commit_id,omitempty"` - Created time.Time `json:"created_at,omitempty"` - DiffHunk string `json:"diff_hunk,omitempty"` - HTMLPullURL string `json:"pull_request_url,omitempty"` - HTMLURL string `json:"html_url,omitempty"` - ID int64 `json:"id,omitempty"` - LineNum int `json:"position,omitempty"` - OldLineNum int `json:"original_position,omitempty"` - OrigCommitID string `json:"original_commit_id,omitempty"` - Path string `json:"path,omitempty"` - Resolver *User `json:"resolver,omitempty"` - ReviewID int64 `json:"pull_request_review_id,omitempty"` - Updated time.Time `json:"updated_at,omitempty"` - User *User `json:"user,omitempty"` + Body string `json:"body,omitempty"` + CommitID string `json:"commit_id,omitempty"` + Created time.Time `json:"created_at,omitempty"` + DiffHunk string `json:"diff_hunk,omitempty"` + HTMLPullURL string `json:"pull_request_url,omitempty"` + HTMLURL string `json:"html_url,omitempty"` + ID int64 `json:"id,omitempty"` + LineNum int `json:"position,omitempty"` + OldLineNum int `json:"original_position,omitempty"` + OrigCommitID string `json:"original_commit_id,omitempty"` + Path string `json:"path,omitempty"` + Resolver *User `json:"resolver,omitempty"` + ReviewID int64 `json:"pull_request_review_id,omitempty"` + Updated time.Time `json:"updated_at,omitempty"` + User *User `json:"user,omitempty"` } // PullReviewRequestOptions — PullReviewRequestOptions are options to add or remove pull review requests +// +// Usage: +// +// opts := PullReviewRequestOptions{Reviewers: []string{"example"}} type PullReviewRequestOptions struct { - Reviewers []string `json:"reviewers,omitempty"` + Reviewers []string `json:"reviewers,omitempty"` TeamReviewers []string `json:"team_reviewers,omitempty"` } // SubmitPullReviewOptions — SubmitPullReviewOptions are options to submit a pending pull review +// +// Usage: +// +// opts := SubmitPullReviewOptions{Body: "example"} type SubmitPullReviewOptions struct { - Body string `json:"body,omitempty"` + Body string `json:"body,omitempty"` Event *ReviewStateType `json:"event,omitempty"` } diff --git a/types/quota.go b/types/quota.go index 62a0224..592af82 100644 --- a/types/quota.go +++ b/types/quota.go @@ -2,28 +2,41 @@ package types + // CreateQuotaGroupOptions — CreateQutaGroupOptions represents the options for creating a quota group +// +// Usage: +// +// opts := CreateQuotaGroupOptions{Name: "example"} type CreateQuotaGroupOptions struct { - Name string `json:"name,omitempty"` // Name of the quota group to create + Name string `json:"name,omitempty"` // Name of the quota group to create Rules []*CreateQuotaRuleOptions `json:"rules,omitempty"` // Rules to add to the newly created group. If a rule does not exist, it will be created. } // CreateQuotaRuleOptions — CreateQuotaRuleOptions represents the options for creating a quota rule +// +// Usage: +// +// opts := CreateQuotaRuleOptions{Name: "example"} type CreateQuotaRuleOptions struct { - Limit int64 `json:"limit,omitempty"` // The limit set by the rule - Name string `json:"name,omitempty"` // Name of the rule to create + Limit int64 `json:"limit,omitempty"` // The limit set by the rule + Name string `json:"name,omitempty"` // Name of the rule to create Subjects []string `json:"subjects,omitempty"` // The subjects affected by the rule } // EditQuotaRuleOptions — EditQuotaRuleOptions represents the options for editing a quota rule +// +// Usage: +// +// opts := EditQuotaRuleOptions{Subjects: []string{"example"}} type EditQuotaRuleOptions struct { - Limit int64 `json:"limit,omitempty"` // The limit set by the rule + Limit int64 `json:"limit,omitempty"` // The limit set by the rule Subjects []string `json:"subjects,omitempty"` // The subjects affected by the rule } // QuotaGroup — QuotaGroup represents a quota group type QuotaGroup struct { - Name string `json:"name,omitempty"` // Name of the group + Name string `json:"name,omitempty"` // Name of the group Rules []*QuotaRuleInfo `json:"rules,omitempty"` // Rules associated with the group } @@ -34,13 +47,13 @@ type QuotaGroupList struct{} // QuotaInfo — QuotaInfo represents information about a user's quota type QuotaInfo struct { Groups *QuotaGroupList `json:"groups,omitempty"` - Used *QuotaUsed `json:"used,omitempty"` + Used *QuotaUsed `json:"used,omitempty"` } // QuotaRuleInfo — QuotaRuleInfo contains information about a quota rule type QuotaRuleInfo struct { - Limit int64 `json:"limit,omitempty"` // The limit set by the rule - Name string `json:"name,omitempty"` // Name of the rule (only shown to admins) + Limit int64 `json:"limit,omitempty"` // The limit set by the rule + Name string `json:"name,omitempty"` // Name of the rule (only shown to admins) Subjects []string `json:"subjects,omitempty"` // Subjects the rule affects } @@ -52,8 +65,8 @@ type QuotaUsed struct { // QuotaUsedArtifact — QuotaUsedArtifact represents an artifact counting towards a user's quota type QuotaUsedArtifact struct { HTMLURL string `json:"html_url,omitempty"` // HTML URL to the action run containing the artifact - Name string `json:"name,omitempty"` // Name of the artifact - Size int64 `json:"size,omitempty"` // Size of the artifact (compressed) + Name string `json:"name,omitempty"` // Name of the artifact + Size int64 `json:"size,omitempty"` // Size of the artifact (compressed) } // QuotaUsedArtifactList — QuotaUsedArtifactList represents a list of artifacts counting towards a user's quota @@ -62,10 +75,10 @@ type QuotaUsedArtifactList struct{} // QuotaUsedAttachment — QuotaUsedAttachment represents an attachment counting towards a user's quota type QuotaUsedAttachment struct { - APIURL string `json:"api_url,omitempty"` // API URL for the attachment + APIURL string `json:"api_url,omitempty"` // API URL for the attachment ContainedIn map[string]any `json:"contained_in,omitempty"` // Context for the attachment: URLs to the containing object - Name string `json:"name,omitempty"` // Filename of the attachment - Size int64 `json:"size,omitempty"` // Size of the attachment (in bytes) + Name string `json:"name,omitempty"` // Filename of the attachment + Size int64 `json:"size,omitempty"` // Size of the attachment (in bytes) } // QuotaUsedAttachmentList — QuotaUsedAttachmentList represents a list of attachment counting towards a user's quota @@ -75,10 +88,10 @@ type QuotaUsedAttachmentList struct{} // QuotaUsedPackage — QuotaUsedPackage represents a package counting towards a user's quota type QuotaUsedPackage struct { HTMLURL string `json:"html_url,omitempty"` // HTML URL to the package version - Name string `json:"name,omitempty"` // Name of the package - Size int64 `json:"size,omitempty"` // Size of the package version - Type string `json:"type,omitempty"` // Type of the package - Version string `json:"version,omitempty"` // Version of the package + Name string `json:"name,omitempty"` // Name of the package + Size int64 `json:"size,omitempty"` // Size of the package version + Type string `json:"type,omitempty"` // Type of the package + Version string `json:"version,omitempty"` // Version of the package } // QuotaUsedPackageList — QuotaUsedPackageList represents a list of packages counting towards a user's quota @@ -88,20 +101,20 @@ type QuotaUsedPackageList struct{} // QuotaUsedSize — QuotaUsedSize represents the size-based quota usage of a user type QuotaUsedSize struct { Assets *QuotaUsedSizeAssets `json:"assets,omitempty"` - Git *QuotaUsedSizeGit `json:"git,omitempty"` - Repos *QuotaUsedSizeRepos `json:"repos,omitempty"` + Git *QuotaUsedSizeGit `json:"git,omitempty"` + Repos *QuotaUsedSizeRepos `json:"repos,omitempty"` } // QuotaUsedSizeAssets — QuotaUsedSizeAssets represents the size-based asset usage of a user type QuotaUsedSizeAssets struct { - Artifacts int64 `json:"artifacts,omitempty"` // Storage size used for the user's artifacts + Artifacts int64 `json:"artifacts,omitempty"` // Storage size used for the user's artifacts Attachments *QuotaUsedSizeAssetsAttachments `json:"attachments,omitempty"` - Packages *QuotaUsedSizeAssetsPackages `json:"packages,omitempty"` + Packages *QuotaUsedSizeAssetsPackages `json:"packages,omitempty"` } // QuotaUsedSizeAssetsAttachments — QuotaUsedSizeAssetsAttachments represents the size-based attachment quota usage of a user type QuotaUsedSizeAssetsAttachments struct { - Issues int64 `json:"issues,omitempty"` // Storage size used for the user's issue & comment attachments + Issues int64 `json:"issues,omitempty"` // Storage size used for the user's issue & comment attachments Releases int64 `json:"releases,omitempty"` // Storage size used for the user's release attachments } @@ -118,5 +131,5 @@ type QuotaUsedSizeGit struct { // QuotaUsedSizeRepos — QuotaUsedSizeRepos represents the size-based repository quota usage of a user type QuotaUsedSizeRepos struct { Private int64 `json:"private,omitempty"` // Storage size of the user's private repositories - Public int64 `json:"public,omitempty"` // Storage size of the user's public repositories + Public int64 `json:"public,omitempty"` // Storage size of the user's public repositories } diff --git a/types/reaction.go b/types/reaction.go index 77cefd2..415d52c 100644 --- a/types/reaction.go +++ b/types/reaction.go @@ -4,14 +4,19 @@ package types import "time" + // EditReactionOption — EditReactionOption contain the reaction type +// +// Usage: +// +// opts := EditReactionOption{Reaction: "example"} type EditReactionOption struct { Reaction string `json:"content,omitempty"` } // Reaction — Reaction contain one reaction type Reaction struct { - Created time.Time `json:"created_at,omitempty"` - Reaction string `json:"content,omitempty"` - User *User `json:"user,omitempty"` + Created time.Time `json:"created_at,omitempty"` + Reaction string `json:"content,omitempty"` + User *User `json:"user,omitempty"` } diff --git a/types/release.go b/types/release.go index 305eceb..b419a2e 100644 --- a/types/release.go +++ b/types/release.go @@ -4,46 +4,55 @@ package types import "time" + // CreateReleaseOption — CreateReleaseOption options when creating a release +// +// Usage: +// +// opts := CreateReleaseOption{TagName: "v1.0.0"} type CreateReleaseOption struct { - HideArchiveLinks bool `json:"hide_archive_links,omitempty"` - IsDraft bool `json:"draft,omitempty"` - IsPrerelease bool `json:"prerelease,omitempty"` - Note string `json:"body,omitempty"` - TagName string `json:"tag_name"` - Target string `json:"target_commitish,omitempty"` - Title string `json:"name,omitempty"` + HideArchiveLinks bool `json:"hide_archive_links,omitempty"` + IsDraft bool `json:"draft,omitempty"` + IsPrerelease bool `json:"prerelease,omitempty"` + Note string `json:"body,omitempty"` + TagName string `json:"tag_name"` + Target string `json:"target_commitish,omitempty"` + Title string `json:"name,omitempty"` } // EditReleaseOption — EditReleaseOption options when editing a release +// +// Usage: +// +// opts := EditReleaseOption{TagName: "v1.0.0"} type EditReleaseOption struct { - HideArchiveLinks bool `json:"hide_archive_links,omitempty"` - IsDraft bool `json:"draft,omitempty"` - IsPrerelease bool `json:"prerelease,omitempty"` - Note string `json:"body,omitempty"` - TagName string `json:"tag_name,omitempty"` - Target string `json:"target_commitish,omitempty"` - Title string `json:"name,omitempty"` + HideArchiveLinks bool `json:"hide_archive_links,omitempty"` + IsDraft bool `json:"draft,omitempty"` + IsPrerelease bool `json:"prerelease,omitempty"` + Note string `json:"body,omitempty"` + TagName string `json:"tag_name,omitempty"` + Target string `json:"target_commitish,omitempty"` + Title string `json:"name,omitempty"` } // Release — Release represents a repository release type Release struct { ArchiveDownloadCount *TagArchiveDownloadCount `json:"archive_download_count,omitempty"` - Attachments []*Attachment `json:"assets,omitempty"` - Author *User `json:"author,omitempty"` - CreatedAt time.Time `json:"created_at,omitempty"` - HTMLURL string `json:"html_url,omitempty"` - HideArchiveLinks bool `json:"hide_archive_links,omitempty"` - ID int64 `json:"id,omitempty"` - IsDraft bool `json:"draft,omitempty"` - IsPrerelease bool `json:"prerelease,omitempty"` - Note string `json:"body,omitempty"` - PublishedAt time.Time `json:"published_at,omitempty"` - TagName string `json:"tag_name,omitempty"` - TarURL string `json:"tarball_url,omitempty"` - Target string `json:"target_commitish,omitempty"` - Title string `json:"name,omitempty"` - URL string `json:"url,omitempty"` - UploadURL string `json:"upload_url,omitempty"` - ZipURL string `json:"zipball_url,omitempty"` + Attachments []*Attachment `json:"assets,omitempty"` + Author *User `json:"author,omitempty"` + CreatedAt time.Time `json:"created_at,omitempty"` + HTMLURL string `json:"html_url,omitempty"` + HideArchiveLinks bool `json:"hide_archive_links,omitempty"` + ID int64 `json:"id,omitempty"` + IsDraft bool `json:"draft,omitempty"` + IsPrerelease bool `json:"prerelease,omitempty"` + Note string `json:"body,omitempty"` + PublishedAt time.Time `json:"published_at,omitempty"` + TagName string `json:"tag_name,omitempty"` + TarURL string `json:"tarball_url,omitempty"` + Target string `json:"target_commitish,omitempty"` + Title string `json:"name,omitempty"` + URL string `json:"url,omitempty"` + UploadURL string `json:"upload_url,omitempty"` + ZipURL string `json:"zipball_url,omitempty"` } diff --git a/types/repo.go b/types/repo.go index b36f811..adca65d 100644 --- a/types/repo.go +++ b/types/repo.go @@ -4,75 +4,88 @@ package types import "time" + +// +// Usage: +// +// opts := CreatePushMirrorOption{Interval: "example"} type CreatePushMirrorOption struct { - Interval string `json:"interval,omitempty"` - RemoteAddress string `json:"remote_address,omitempty"` + Interval string `json:"interval,omitempty"` + RemoteAddress string `json:"remote_address,omitempty"` RemotePassword string `json:"remote_password,omitempty"` RemoteUsername string `json:"remote_username,omitempty"` - SyncOnCommit bool `json:"sync_on_commit,omitempty"` - UseSSH bool `json:"use_ssh,omitempty"` + SyncOnCommit bool `json:"sync_on_commit,omitempty"` + UseSSH bool `json:"use_ssh,omitempty"` } // CreateRepoOption — CreateRepoOption options when creating repository +// +// Usage: +// +// opts := CreateRepoOption{Name: "example"} type CreateRepoOption struct { - AutoInit bool `json:"auto_init,omitempty"` // Whether the repository should be auto-initialized? - DefaultBranch string `json:"default_branch,omitempty"` // DefaultBranch of the repository (used when initializes and in template) - Description string `json:"description,omitempty"` // Description of the repository to create - Gitignores string `json:"gitignores,omitempty"` // Gitignores to use - IssueLabels string `json:"issue_labels,omitempty"` // Label-Set to use - License string `json:"license,omitempty"` // License to use - Name string `json:"name"` // Name of the repository to create + AutoInit bool `json:"auto_init,omitempty"` // Whether the repository should be auto-initialized? + DefaultBranch string `json:"default_branch,omitempty"` // DefaultBranch of the repository (used when initializes and in template) + Description string `json:"description,omitempty"` // Description of the repository to create + Gitignores string `json:"gitignores,omitempty"` // Gitignores to use + IssueLabels string `json:"issue_labels,omitempty"` // Label-Set to use + License string `json:"license,omitempty"` // License to use + Name string `json:"name"` // Name of the repository to create ObjectFormatName string `json:"object_format_name,omitempty"` // ObjectFormatName of the underlying git repository - Private bool `json:"private,omitempty"` // Whether the repository is private - Readme string `json:"readme,omitempty"` // Readme of the repository to create - Template bool `json:"template,omitempty"` // Whether the repository is template - TrustModel string `json:"trust_model,omitempty"` // TrustModel of the repository + Private bool `json:"private,omitempty"` // Whether the repository is private + Readme string `json:"readme,omitempty"` // Readme of the repository to create + Template bool `json:"template,omitempty"` // Whether the repository is template + TrustModel string `json:"trust_model,omitempty"` // TrustModel of the repository } // EditRepoOption — EditRepoOption options when editing a repository's properties +// +// Usage: +// +// opts := EditRepoOption{Description: "example"} type EditRepoOption struct { - AllowFastForwardOnly bool `json:"allow_fast_forward_only_merge,omitempty"` // either `true` to allow fast-forward-only merging pull requests, or `false` to prevent fast-forward-only merging. - AllowManualMerge bool `json:"allow_manual_merge,omitempty"` // either `true` to allow mark pr as merged manually, or `false` to prevent it. - AllowMerge bool `json:"allow_merge_commits,omitempty"` // either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. - AllowRebase bool `json:"allow_rebase,omitempty"` // either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging. - AllowRebaseMerge bool `json:"allow_rebase_explicit,omitempty"` // either `true` to allow rebase with explicit merge commits (--no-ff), or `false` to prevent rebase with explicit merge commits. - AllowRebaseUpdate bool `json:"allow_rebase_update,omitempty"` // either `true` to allow updating pull request branch by rebase, or `false` to prevent it. - AllowSquash bool `json:"allow_squash_merge,omitempty"` // either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging. - Archived bool `json:"archived,omitempty"` // set to `true` to archive this repository. - AutodetectManualMerge bool `json:"autodetect_manual_merge,omitempty"` // either `true` to enable AutodetectManualMerge, or `false` to prevent it. Note: In some special cases, misjudgments can occur. - DefaultAllowMaintainerEdit bool `json:"default_allow_maintainer_edit,omitempty"` // set to `true` to allow edits from maintainers by default - DefaultBranch string `json:"default_branch,omitempty"` // sets the default branch for this repository. - DefaultDeleteBranchAfterMerge bool `json:"default_delete_branch_after_merge,omitempty"` // set to `true` to delete pr branch after merge by default - DefaultMergeStyle string `json:"default_merge_style,omitempty"` // set to a merge style to be used by this repository: "merge", "rebase", "rebase-merge", "squash", or "fast-forward-only". - DefaultUpdateStyle string `json:"default_update_style,omitempty"` // set to a update style to be used by this repository: "rebase" or "merge" - Description string `json:"description,omitempty"` // a short description of the repository. - EnablePrune bool `json:"enable_prune,omitempty"` // enable prune - remove obsolete remote-tracking references when mirroring - ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"` - ExternalWiki *ExternalWiki `json:"external_wiki,omitempty"` - GloballyEditableWiki bool `json:"globally_editable_wiki,omitempty"` // set the globally editable state of the wiki - HasActions bool `json:"has_actions,omitempty"` // either `true` to enable actions unit, or `false` to disable them. - HasIssues bool `json:"has_issues,omitempty"` // either `true` to enable issues for this repository or `false` to disable them. - HasPackages bool `json:"has_packages,omitempty"` // either `true` to enable packages unit, or `false` to disable them. - HasProjects bool `json:"has_projects,omitempty"` // either `true` to enable project unit, or `false` to disable them. - HasPullRequests bool `json:"has_pull_requests,omitempty"` // either `true` to allow pull requests, or `false` to prevent pull request. - HasReleases bool `json:"has_releases,omitempty"` // either `true` to enable releases unit, or `false` to disable them. - HasWiki bool `json:"has_wiki,omitempty"` // either `true` to enable the wiki for this repository or `false` to disable it. - IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts,omitempty"` // either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace. - InternalTracker *InternalTracker `json:"internal_tracker,omitempty"` - MirrorInterval string `json:"mirror_interval,omitempty"` // set to a string like `8h30m0s` to set the mirror interval time - Name string `json:"name,omitempty"` // name of the repository - Private bool `json:"private,omitempty"` // 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. - Template bool `json:"template,omitempty"` // either `true` to make this repository a template or `false` to make it a normal repository - Website string `json:"website,omitempty"` // a URL with more information about the repository. - WikiBranch string `json:"wiki_branch,omitempty"` // sets the branch used for this repository's wiki. + AllowFastForwardOnly bool `json:"allow_fast_forward_only_merge,omitempty"` // either `true` to allow fast-forward-only merging pull requests, or `false` to prevent fast-forward-only merging. + AllowManualMerge bool `json:"allow_manual_merge,omitempty"` // either `true` to allow mark pr as merged manually, or `false` to prevent it. + AllowMerge bool `json:"allow_merge_commits,omitempty"` // either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. + AllowRebase bool `json:"allow_rebase,omitempty"` // either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging. + AllowRebaseMerge bool `json:"allow_rebase_explicit,omitempty"` // either `true` to allow rebase with explicit merge commits (--no-ff), or `false` to prevent rebase with explicit merge commits. + AllowRebaseUpdate bool `json:"allow_rebase_update,omitempty"` // either `true` to allow updating pull request branch by rebase, or `false` to prevent it. + AllowSquash bool `json:"allow_squash_merge,omitempty"` // either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging. + Archived bool `json:"archived,omitempty"` // set to `true` to archive this repository. + AutodetectManualMerge bool `json:"autodetect_manual_merge,omitempty"` // either `true` to enable AutodetectManualMerge, or `false` to prevent it. Note: In some special cases, misjudgments can occur. + DefaultAllowMaintainerEdit bool `json:"default_allow_maintainer_edit,omitempty"` // set to `true` to allow edits from maintainers by default + DefaultBranch string `json:"default_branch,omitempty"` // sets the default branch for this repository. + DefaultDeleteBranchAfterMerge bool `json:"default_delete_branch_after_merge,omitempty"` // set to `true` to delete pr branch after merge by default + DefaultMergeStyle string `json:"default_merge_style,omitempty"` // set to a merge style to be used by this repository: "merge", "rebase", "rebase-merge", "squash", or "fast-forward-only". + DefaultUpdateStyle string `json:"default_update_style,omitempty"` // set to a update style to be used by this repository: "rebase" or "merge" + Description string `json:"description,omitempty"` // a short description of the repository. + EnablePrune bool `json:"enable_prune,omitempty"` // enable prune - remove obsolete remote-tracking references when mirroring + ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"` + ExternalWiki *ExternalWiki `json:"external_wiki,omitempty"` + GloballyEditableWiki bool `json:"globally_editable_wiki,omitempty"` // set the globally editable state of the wiki + HasActions bool `json:"has_actions,omitempty"` // either `true` to enable actions unit, or `false` to disable them. + HasIssues bool `json:"has_issues,omitempty"` // either `true` to enable issues for this repository or `false` to disable them. + HasPackages bool `json:"has_packages,omitempty"` // either `true` to enable packages unit, or `false` to disable them. + HasProjects bool `json:"has_projects,omitempty"` // either `true` to enable project unit, or `false` to disable them. + HasPullRequests bool `json:"has_pull_requests,omitempty"` // either `true` to allow pull requests, or `false` to prevent pull request. + HasReleases bool `json:"has_releases,omitempty"` // either `true` to enable releases unit, or `false` to disable them. + HasWiki bool `json:"has_wiki,omitempty"` // either `true` to enable the wiki for this repository or `false` to disable it. + IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts,omitempty"` // either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace. + InternalTracker *InternalTracker `json:"internal_tracker,omitempty"` + MirrorInterval string `json:"mirror_interval,omitempty"` // set to a string like `8h30m0s` to set the mirror interval time + Name string `json:"name,omitempty"` // name of the repository + Private bool `json:"private,omitempty"` // 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. + Template bool `json:"template,omitempty"` // either `true` to make this repository a template or `false` to make it a normal repository + Website string `json:"website,omitempty"` // a URL with more information about the repository. + WikiBranch string `json:"wiki_branch,omitempty"` // sets the branch used for this repository's wiki. } // ExternalTracker — ExternalTracker represents settings for external tracker type ExternalTracker struct { - ExternalTrackerFormat string `json:"external_tracker_format,omitempty"` // External Issue Tracker URL Format. Use the placeholders {user}, {repo} and {index} for the username, repository name and issue index. + ExternalTrackerFormat string `json:"external_tracker_format,omitempty"` // External Issue Tracker URL Format. Use the placeholders {user}, {repo} and {index} for the username, repository name and issue index. ExternalTrackerRegexpPattern string `json:"external_tracker_regexp_pattern,omitempty"` // External Issue Tracker issue regular expression - ExternalTrackerStyle string `json:"external_tracker_style,omitempty"` // External Issue Tracker Number Format, either `numeric`, `alphanumeric`, or `regexp` - ExternalTrackerURL string `json:"external_tracker_url,omitempty"` // URL of external issue tracker. + ExternalTrackerStyle string `json:"external_tracker_style,omitempty"` // External Issue Tracker Number Format, either `numeric`, `alphanumeric`, or `regexp` + ExternalTrackerURL string `json:"external_tracker_url,omitempty"` // URL of external issue tracker. } // ExternalWiki — ExternalWiki represents setting for external wiki @@ -83,133 +96,145 @@ type ExternalWiki struct { // InternalTracker — InternalTracker represents settings for internal tracker type InternalTracker struct { AllowOnlyContributorsToTrackTime bool `json:"allow_only_contributors_to_track_time,omitempty"` // Let only contributors track time (Built-in issue tracker) - EnableIssueDependencies bool `json:"enable_issue_dependencies,omitempty"` // Enable dependencies for issues and pull requests (Built-in issue tracker) - EnableTimeTracker bool `json:"enable_time_tracker,omitempty"` // Enable time tracking (Built-in issue tracker) + EnableIssueDependencies bool `json:"enable_issue_dependencies,omitempty"` // Enable dependencies for issues and pull requests (Built-in issue tracker) + EnableTimeTracker bool `json:"enable_time_tracker,omitempty"` // Enable time tracking (Built-in issue tracker) } // PushMirror — PushMirror represents information of a push mirror type PushMirror struct { - CreatedUnix time.Time `json:"created,omitempty"` - Interval string `json:"interval,omitempty"` - LastError string `json:"last_error,omitempty"` + CreatedUnix time.Time `json:"created,omitempty"` + Interval string `json:"interval,omitempty"` + LastError string `json:"last_error,omitempty"` LastUpdateUnix time.Time `json:"last_update,omitempty"` - PublicKey string `json:"public_key,omitempty"` - RemoteAddress string `json:"remote_address,omitempty"` - RemoteName string `json:"remote_name,omitempty"` - RepoName string `json:"repo_name,omitempty"` - SyncOnCommit bool `json:"sync_on_commit,omitempty"` + PublicKey string `json:"public_key,omitempty"` + RemoteAddress string `json:"remote_address,omitempty"` + RemoteName string `json:"remote_name,omitempty"` + RepoName string `json:"repo_name,omitempty"` + SyncOnCommit bool `json:"sync_on_commit,omitempty"` } // RepoCollaboratorPermission — RepoCollaboratorPermission to get repository permission for a collaborator type RepoCollaboratorPermission struct { Permission string `json:"permission,omitempty"` - RoleName string `json:"role_name,omitempty"` - User *User `json:"user,omitempty"` + RoleName string `json:"role_name,omitempty"` + User *User `json:"user,omitempty"` } type RepoCommit struct { - Author *CommitUser `json:"author,omitempty"` - Committer *CommitUser `json:"committer,omitempty"` - Message string `json:"message,omitempty"` - Tree *CommitMeta `json:"tree,omitempty"` - URL string `json:"url,omitempty"` + Author *CommitUser `json:"author,omitempty"` + Committer *CommitUser `json:"committer,omitempty"` + Message string `json:"message,omitempty"` + Tree *CommitMeta `json:"tree,omitempty"` + URL string `json:"url,omitempty"` Verification *PayloadCommitVerification `json:"verification,omitempty"` } // RepoTopicOptions — RepoTopicOptions a collection of repo topic names +// +// Usage: +// +// opts := RepoTopicOptions{Topics: []string{"example"}} type RepoTopicOptions struct { Topics []string `json:"topics,omitempty"` // list of topic names } // RepoTransfer — RepoTransfer represents a pending repo transfer type RepoTransfer struct { - Doer *User `json:"doer,omitempty"` - Recipient *User `json:"recipient,omitempty"` - Teams []*Team `json:"teams,omitempty"` + Doer *User `json:"doer,omitempty"` + Recipient *User `json:"recipient,omitempty"` + Teams []*Team `json:"teams,omitempty"` } // Repository — Repository represents a repository type Repository struct { - AllowFastForwardOnly bool `json:"allow_fast_forward_only_merge,omitempty"` - AllowMerge bool `json:"allow_merge_commits,omitempty"` - AllowRebase bool `json:"allow_rebase,omitempty"` - AllowRebaseMerge bool `json:"allow_rebase_explicit,omitempty"` - AllowRebaseUpdate bool `json:"allow_rebase_update,omitempty"` - AllowSquash bool `json:"allow_squash_merge,omitempty"` - Archived bool `json:"archived,omitempty"` - ArchivedAt time.Time `json:"archived_at,omitempty"` - AvatarURL string `json:"avatar_url,omitempty"` - CloneURL string `json:"clone_url,omitempty"` - Created time.Time `json:"created_at,omitempty"` - DefaultAllowMaintainerEdit bool `json:"default_allow_maintainer_edit,omitempty"` - DefaultBranch string `json:"default_branch,omitempty"` - DefaultDeleteBranchAfterMerge bool `json:"default_delete_branch_after_merge,omitempty"` - DefaultMergeStyle string `json:"default_merge_style,omitempty"` - DefaultUpdateStyle string `json:"default_update_style,omitempty"` - Description string `json:"description,omitempty"` - Empty bool `json:"empty,omitempty"` - ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"` - ExternalWiki *ExternalWiki `json:"external_wiki,omitempty"` - Fork bool `json:"fork,omitempty"` - Forks int64 `json:"forks_count,omitempty"` - FullName string `json:"full_name,omitempty"` - GloballyEditableWiki bool `json:"globally_editable_wiki,omitempty"` - HTMLURL string `json:"html_url,omitempty"` - HasActions bool `json:"has_actions,omitempty"` - HasIssues bool `json:"has_issues,omitempty"` - HasPackages bool `json:"has_packages,omitempty"` - HasProjects bool `json:"has_projects,omitempty"` - HasPullRequests bool `json:"has_pull_requests,omitempty"` - HasReleases bool `json:"has_releases,omitempty"` - HasWiki bool `json:"has_wiki,omitempty"` - ID int64 `json:"id,omitempty"` - IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts,omitempty"` - Internal bool `json:"internal,omitempty"` - InternalTracker *InternalTracker `json:"internal_tracker,omitempty"` - Language string `json:"language,omitempty"` - LanguagesURL string `json:"languages_url,omitempty"` - Link string `json:"link,omitempty"` - Mirror bool `json:"mirror,omitempty"` - MirrorInterval string `json:"mirror_interval,omitempty"` - MirrorUpdated time.Time `json:"mirror_updated,omitempty"` - Name string `json:"name,omitempty"` - ObjectFormatName string `json:"object_format_name,omitempty"` // ObjectFormatName of the underlying git repository - OpenIssues int64 `json:"open_issues_count,omitempty"` - OpenPulls int64 `json:"open_pr_counter,omitempty"` - OriginalURL string `json:"original_url,omitempty"` - Owner *User `json:"owner,omitempty"` - Parent *Repository `json:"parent,omitempty"` - Permissions *Permission `json:"permissions,omitempty"` - Private bool `json:"private,omitempty"` - Releases int64 `json:"release_counter,omitempty"` - RepoTransfer *RepoTransfer `json:"repo_transfer,omitempty"` - SSHURL string `json:"ssh_url,omitempty"` - Size int64 `json:"size,omitempty"` - Stars int64 `json:"stars_count,omitempty"` - Template bool `json:"template,omitempty"` - Topics []string `json:"topics,omitempty"` - URL string `json:"url,omitempty"` - Updated time.Time `json:"updated_at,omitempty"` - Watchers int64 `json:"watchers_count,omitempty"` - Website string `json:"website,omitempty"` - WikiBranch string `json:"wiki_branch,omitempty"` + AllowFastForwardOnly bool `json:"allow_fast_forward_only_merge,omitempty"` + AllowMerge bool `json:"allow_merge_commits,omitempty"` + AllowRebase bool `json:"allow_rebase,omitempty"` + AllowRebaseMerge bool `json:"allow_rebase_explicit,omitempty"` + AllowRebaseUpdate bool `json:"allow_rebase_update,omitempty"` + AllowSquash bool `json:"allow_squash_merge,omitempty"` + Archived bool `json:"archived,omitempty"` + ArchivedAt time.Time `json:"archived_at,omitempty"` + AvatarURL string `json:"avatar_url,omitempty"` + CloneURL string `json:"clone_url,omitempty"` + Created time.Time `json:"created_at,omitempty"` + DefaultAllowMaintainerEdit bool `json:"default_allow_maintainer_edit,omitempty"` + DefaultBranch string `json:"default_branch,omitempty"` + DefaultDeleteBranchAfterMerge bool `json:"default_delete_branch_after_merge,omitempty"` + DefaultMergeStyle string `json:"default_merge_style,omitempty"` + DefaultUpdateStyle string `json:"default_update_style,omitempty"` + Description string `json:"description,omitempty"` + Empty bool `json:"empty,omitempty"` + ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"` + ExternalWiki *ExternalWiki `json:"external_wiki,omitempty"` + Fork bool `json:"fork,omitempty"` + Forks int64 `json:"forks_count,omitempty"` + FullName string `json:"full_name,omitempty"` + GloballyEditableWiki bool `json:"globally_editable_wiki,omitempty"` + HTMLURL string `json:"html_url,omitempty"` + HasActions bool `json:"has_actions,omitempty"` + HasIssues bool `json:"has_issues,omitempty"` + HasPackages bool `json:"has_packages,omitempty"` + HasProjects bool `json:"has_projects,omitempty"` + HasPullRequests bool `json:"has_pull_requests,omitempty"` + HasReleases bool `json:"has_releases,omitempty"` + HasWiki bool `json:"has_wiki,omitempty"` + ID int64 `json:"id,omitempty"` + IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts,omitempty"` + Internal bool `json:"internal,omitempty"` + InternalTracker *InternalTracker `json:"internal_tracker,omitempty"` + Language string `json:"language,omitempty"` + LanguagesURL string `json:"languages_url,omitempty"` + Link string `json:"link,omitempty"` + Mirror bool `json:"mirror,omitempty"` + MirrorInterval string `json:"mirror_interval,omitempty"` + MirrorUpdated time.Time `json:"mirror_updated,omitempty"` + Name string `json:"name,omitempty"` + ObjectFormatName string `json:"object_format_name,omitempty"` // ObjectFormatName of the underlying git repository + OpenIssues int64 `json:"open_issues_count,omitempty"` + OpenPulls int64 `json:"open_pr_counter,omitempty"` + OriginalURL string `json:"original_url,omitempty"` + Owner *User `json:"owner,omitempty"` + Parent *Repository `json:"parent,omitempty"` + Permissions *Permission `json:"permissions,omitempty"` + Private bool `json:"private,omitempty"` + Releases int64 `json:"release_counter,omitempty"` + RepoTransfer *RepoTransfer `json:"repo_transfer,omitempty"` + SSHURL string `json:"ssh_url,omitempty"` + Size int64 `json:"size,omitempty"` + Stars int64 `json:"stars_count,omitempty"` + Template bool `json:"template,omitempty"` + Topics []string `json:"topics,omitempty"` + URL string `json:"url,omitempty"` + Updated time.Time `json:"updated_at,omitempty"` + Watchers int64 `json:"watchers_count,omitempty"` + Website string `json:"website,omitempty"` + WikiBranch string `json:"wiki_branch,omitempty"` } // RepositoryMeta — RepositoryMeta basic repository information type RepositoryMeta struct { FullName string `json:"full_name,omitempty"` - ID int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Owner string `json:"owner,omitempty"` + ID int64 `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Owner string `json:"owner,omitempty"` } // TransferRepoOption — TransferRepoOption options when transfer a repository's ownership +// +// Usage: +// +// opts := TransferRepoOption{NewOwner: "example"} type TransferRepoOption struct { - NewOwner string `json:"new_owner"` - TeamIDs []int64 `json:"team_ids,omitempty"` // ID of the team or teams to add to the repository. Teams can only be added to organization-owned repositories. + NewOwner string `json:"new_owner"` + TeamIDs []int64 `json:"team_ids,omitempty"` // ID of the team or teams to add to the repository. Teams can only be added to organization-owned repositories. } // UpdateRepoAvatarOption — UpdateRepoAvatarUserOption options when updating the repo avatar +// +// Usage: +// +// opts := UpdateRepoAvatarOption{Image: "example"} type UpdateRepoAvatarOption struct { Image string `json:"image,omitempty"` // image must be base64 encoded } diff --git a/types/review.go b/types/review.go index acdb918..3270e1b 100644 --- a/types/review.go +++ b/types/review.go @@ -2,6 +2,7 @@ package types + // ReviewStateType — ReviewStateType review state type // ReviewStateType has no fields in the swagger spec. type ReviewStateType struct{} diff --git a/types/settings.go b/types/settings.go index 0cc7bb6..e27581c 100644 --- a/types/settings.go +++ b/types/settings.go @@ -2,36 +2,37 @@ package types + // GeneralAPISettings — GeneralAPISettings contains global api settings exposed by it type GeneralAPISettings struct { DefaultGitTreesPerPage int64 `json:"default_git_trees_per_page,omitempty"` - DefaultMaxBlobSize int64 `json:"default_max_blob_size,omitempty"` - DefaultPagingNum int64 `json:"default_paging_num,omitempty"` - MaxResponseItems int64 `json:"max_response_items,omitempty"` + DefaultMaxBlobSize int64 `json:"default_max_blob_size,omitempty"` + DefaultPagingNum int64 `json:"default_paging_num,omitempty"` + MaxResponseItems int64 `json:"max_response_items,omitempty"` } // GeneralAttachmentSettings — GeneralAttachmentSettings contains global Attachment settings exposed by API type GeneralAttachmentSettings struct { AllowedTypes string `json:"allowed_types,omitempty"` - Enabled bool `json:"enabled,omitempty"` - MaxFiles int64 `json:"max_files,omitempty"` - MaxSize int64 `json:"max_size,omitempty"` + Enabled bool `json:"enabled,omitempty"` + MaxFiles int64 `json:"max_files,omitempty"` + MaxSize int64 `json:"max_size,omitempty"` } // GeneralRepoSettings — GeneralRepoSettings contains global repository settings exposed by API type GeneralRepoSettings struct { - ForksDisabled bool `json:"forks_disabled,omitempty"` - HTTPGitDisabled bool `json:"http_git_disabled,omitempty"` - LFSDisabled bool `json:"lfs_disabled,omitempty"` - MigrationsDisabled bool `json:"migrations_disabled,omitempty"` - MirrorsDisabled bool `json:"mirrors_disabled,omitempty"` - StarsDisabled bool `json:"stars_disabled,omitempty"` + ForksDisabled bool `json:"forks_disabled,omitempty"` + HTTPGitDisabled bool `json:"http_git_disabled,omitempty"` + LFSDisabled bool `json:"lfs_disabled,omitempty"` + MigrationsDisabled bool `json:"migrations_disabled,omitempty"` + MirrorsDisabled bool `json:"mirrors_disabled,omitempty"` + StarsDisabled bool `json:"stars_disabled,omitempty"` TimeTrackingDisabled bool `json:"time_tracking_disabled,omitempty"` } // GeneralUISettings — GeneralUISettings contains global ui settings exposed by API type GeneralUISettings struct { AllowedReactions []string `json:"allowed_reactions,omitempty"` - CustomEmojis []string `json:"custom_emojis,omitempty"` - DefaultTheme string `json:"default_theme,omitempty"` + CustomEmojis []string `json:"custom_emojis,omitempty"` + DefaultTheme string `json:"default_theme,omitempty"` } diff --git a/types/status.go b/types/status.go index 05f7c36..82cc42a 100644 --- a/types/status.go +++ b/types/status.go @@ -2,21 +2,26 @@ package types + // CombinedStatus — CombinedStatus holds the combined state of several statuses for a single commit type CombinedStatus struct { - CommitURL string `json:"commit_url,omitempty"` - Repository *Repository `json:"repository,omitempty"` - SHA string `json:"sha,omitempty"` - State *CommitStatusState `json:"state,omitempty"` - Statuses []*CommitStatus `json:"statuses,omitempty"` - TotalCount int64 `json:"total_count,omitempty"` - URL string `json:"url,omitempty"` + CommitURL string `json:"commit_url,omitempty"` + Repository *Repository `json:"repository,omitempty"` + SHA string `json:"sha,omitempty"` + State *CommitStatusState `json:"state,omitempty"` + Statuses []*CommitStatus `json:"statuses,omitempty"` + TotalCount int64 `json:"total_count,omitempty"` + URL string `json:"url,omitempty"` } // CreateStatusOption — CreateStatusOption holds the information needed to create a new CommitStatus for a Commit +// +// Usage: +// +// opts := CreateStatusOption{Description: "example"} type CreateStatusOption struct { - Context string `json:"context,omitempty"` - Description string `json:"description,omitempty"` - State *CommitStatusState `json:"state,omitempty"` - TargetURL string `json:"target_url,omitempty"` + Context string `json:"context,omitempty"` + Description string `json:"description,omitempty"` + State *CommitStatusState `json:"state,omitempty"` + TargetURL string `json:"target_url,omitempty"` } diff --git a/types/tag.go b/types/tag.go index a4529d8..5b2d5ee 100644 --- a/types/tag.go +++ b/types/tag.go @@ -4,50 +4,63 @@ package types import "time" + // CreateTagOption — CreateTagOption options when creating a tag +// +// Usage: +// +// opts := CreateTagOption{TagName: "v1.0.0"} type CreateTagOption struct { Message string `json:"message,omitempty"` TagName string `json:"tag_name"` - Target string `json:"target,omitempty"` + Target string `json:"target,omitempty"` } // CreateTagProtectionOption — CreateTagProtectionOption options for creating a tag protection +// +// Usage: +// +// opts := CreateTagProtectionOption{NamePattern: "example"} type CreateTagProtectionOption struct { - NamePattern string `json:"name_pattern,omitempty"` - WhitelistTeams []string `json:"whitelist_teams,omitempty"` + NamePattern string `json:"name_pattern,omitempty"` + WhitelistTeams []string `json:"whitelist_teams,omitempty"` WhitelistUsernames []string `json:"whitelist_usernames,omitempty"` } // EditTagProtectionOption — EditTagProtectionOption options for editing a tag protection +// +// Usage: +// +// opts := EditTagProtectionOption{NamePattern: "example"} type EditTagProtectionOption struct { - NamePattern string `json:"name_pattern,omitempty"` - WhitelistTeams []string `json:"whitelist_teams,omitempty"` + NamePattern string `json:"name_pattern,omitempty"` + WhitelistTeams []string `json:"whitelist_teams,omitempty"` WhitelistUsernames []string `json:"whitelist_usernames,omitempty"` } // Tag — Tag represents a repository tag type Tag struct { ArchiveDownloadCount *TagArchiveDownloadCount `json:"archive_download_count,omitempty"` - Commit *CommitMeta `json:"commit,omitempty"` - ID string `json:"id,omitempty"` - Message string `json:"message,omitempty"` - Name string `json:"name,omitempty"` - TarballURL string `json:"tarball_url,omitempty"` - ZipballURL string `json:"zipball_url,omitempty"` + Commit *CommitMeta `json:"commit,omitempty"` + ID string `json:"id,omitempty"` + Message string `json:"message,omitempty"` + Name string `json:"name,omitempty"` + TarballURL string `json:"tarball_url,omitempty"` + ZipballURL string `json:"zipball_url,omitempty"` } // TagArchiveDownloadCount — TagArchiveDownloadCount counts how many times a archive was downloaded type TagArchiveDownloadCount struct { TarGz int64 `json:"tar_gz,omitempty"` - Zip int64 `json:"zip,omitempty"` + Zip int64 `json:"zip,omitempty"` } // TagProtection — TagProtection represents a tag protection type TagProtection struct { - Created time.Time `json:"created_at,omitempty"` - ID int64 `json:"id,omitempty"` - NamePattern string `json:"name_pattern,omitempty"` - Updated time.Time `json:"updated_at,omitempty"` - WhitelistTeams []string `json:"whitelist_teams,omitempty"` - WhitelistUsernames []string `json:"whitelist_usernames,omitempty"` + Created time.Time `json:"created_at,omitempty"` + ID int64 `json:"id,omitempty"` + NamePattern string `json:"name_pattern,omitempty"` + Updated time.Time `json:"updated_at,omitempty"` + WhitelistTeams []string `json:"whitelist_teams,omitempty"` + WhitelistUsernames []string `json:"whitelist_usernames,omitempty"` } diff --git a/types/team.go b/types/team.go index c1aaf41..a8c7505 100644 --- a/types/team.go +++ b/types/team.go @@ -2,37 +2,46 @@ package types + // CreateTeamOption — CreateTeamOption options for creating a team +// +// Usage: +// +// opts := CreateTeamOption{Name: "example"} type CreateTeamOption struct { - CanCreateOrgRepo bool `json:"can_create_org_repo,omitempty"` - Description string `json:"description,omitempty"` - IncludesAllRepositories bool `json:"includes_all_repositories,omitempty"` - Name string `json:"name"` - Permission string `json:"permission,omitempty"` - Units []string `json:"units,omitempty"` - UnitsMap map[string]string `json:"units_map,omitempty"` + CanCreateOrgRepo bool `json:"can_create_org_repo,omitempty"` + Description string `json:"description,omitempty"` + IncludesAllRepositories bool `json:"includes_all_repositories,omitempty"` + Name string `json:"name"` + Permission string `json:"permission,omitempty"` + Units []string `json:"units,omitempty"` + UnitsMap map[string]string `json:"units_map,omitempty"` } // EditTeamOption — EditTeamOption options for editing a team +// +// Usage: +// +// opts := EditTeamOption{Name: "example"} type EditTeamOption struct { - CanCreateOrgRepo bool `json:"can_create_org_repo,omitempty"` - Description string `json:"description,omitempty"` - IncludesAllRepositories bool `json:"includes_all_repositories,omitempty"` - Name string `json:"name"` - Permission string `json:"permission,omitempty"` - Units []string `json:"units,omitempty"` - UnitsMap map[string]string `json:"units_map,omitempty"` + CanCreateOrgRepo bool `json:"can_create_org_repo,omitempty"` + Description string `json:"description,omitempty"` + IncludesAllRepositories bool `json:"includes_all_repositories,omitempty"` + Name string `json:"name"` + Permission string `json:"permission,omitempty"` + Units []string `json:"units,omitempty"` + UnitsMap map[string]string `json:"units_map,omitempty"` } // Team — Team represents a team in an organization type Team struct { - CanCreateOrgRepo bool `json:"can_create_org_repo,omitempty"` - Description string `json:"description,omitempty"` - ID int64 `json:"id,omitempty"` - IncludesAllRepositories bool `json:"includes_all_repositories,omitempty"` - Name string `json:"name,omitempty"` - Organization *Organization `json:"organization,omitempty"` - Permission string `json:"permission,omitempty"` - Units []string `json:"units,omitempty"` - UnitsMap map[string]string `json:"units_map,omitempty"` + CanCreateOrgRepo bool `json:"can_create_org_repo,omitempty"` + Description string `json:"description,omitempty"` + ID int64 `json:"id,omitempty"` + IncludesAllRepositories bool `json:"includes_all_repositories,omitempty"` + Name string `json:"name,omitempty"` + Organization *Organization `json:"organization,omitempty"` + Permission string `json:"permission,omitempty"` + Units []string `json:"units,omitempty"` + UnitsMap map[string]string `json:"units_map,omitempty"` } diff --git a/types/time_tracking.go b/types/time_tracking.go index fe5216b..bf3de14 100644 --- a/types/time_tracking.go +++ b/types/time_tracking.go @@ -4,24 +4,25 @@ package types import "time" + // StopWatch — StopWatch represent a running stopwatch type StopWatch struct { - Created time.Time `json:"created,omitempty"` - Duration string `json:"duration,omitempty"` - IssueIndex int64 `json:"issue_index,omitempty"` - IssueTitle string `json:"issue_title,omitempty"` - RepoName string `json:"repo_name,omitempty"` - RepoOwnerName string `json:"repo_owner_name,omitempty"` - Seconds int64 `json:"seconds,omitempty"` + Created time.Time `json:"created,omitempty"` + Duration string `json:"duration,omitempty"` + IssueIndex int64 `json:"issue_index,omitempty"` + IssueTitle string `json:"issue_title,omitempty"` + RepoName string `json:"repo_name,omitempty"` + RepoOwnerName string `json:"repo_owner_name,omitempty"` + Seconds int64 `json:"seconds,omitempty"` } // TrackedTime — TrackedTime worked time for an issue / pr type TrackedTime struct { - Created time.Time `json:"created,omitempty"` - ID int64 `json:"id,omitempty"` - Issue *Issue `json:"issue,omitempty"` - IssueID int64 `json:"issue_id,omitempty"` // deprecated (only for backwards compatibility) - Time int64 `json:"time,omitempty"` // Time in seconds - UserID int64 `json:"user_id,omitempty"` // deprecated (only for backwards compatibility) - UserName string `json:"user_name,omitempty"` + Created time.Time `json:"created,omitempty"` + ID int64 `json:"id,omitempty"` + Issue *Issue `json:"issue,omitempty"` + IssueID int64 `json:"issue_id,omitempty"` // deprecated (only for backwards compatibility) + Time int64 `json:"time,omitempty"` // Time in seconds + UserID int64 `json:"user_id,omitempty"` // deprecated (only for backwards compatibility) + UserName string `json:"user_name,omitempty"` } diff --git a/types/topic.go b/types/topic.go index 50dc3f7..4e95128 100644 --- a/types/topic.go +++ b/types/topic.go @@ -4,6 +4,7 @@ package types import "time" + // TopicName — TopicName a list of repo topic names type TopicName struct { TopicNames []string `json:"topics,omitempty"` @@ -11,9 +12,9 @@ type TopicName struct { // TopicResponse — TopicResponse for returning topics type TopicResponse struct { - Created time.Time `json:"created,omitempty"` - ID int64 `json:"id,omitempty"` - Name string `json:"topic_name,omitempty"` - RepoCount int64 `json:"repo_count,omitempty"` - Updated time.Time `json:"updated,omitempty"` + Created time.Time `json:"created,omitempty"` + ID int64 `json:"id,omitempty"` + Name string `json:"topic_name,omitempty"` + RepoCount int64 `json:"repo_count,omitempty"` + Updated time.Time `json:"updated,omitempty"` } diff --git a/types/user.go b/types/user.go index 7003c69..c02c1aa 100644 --- a/types/user.go +++ b/types/user.go @@ -4,137 +4,166 @@ package types import "time" + type BlockedUser struct { - BlockID int64 `json:"block_id,omitempty"` + BlockID int64 `json:"block_id,omitempty"` Created time.Time `json:"created_at,omitempty"` } // CreateEmailOption — CreateEmailOption options when creating email addresses +// +// Usage: +// +// opts := CreateEmailOption{Emails: []string{"example"}} type CreateEmailOption struct { Emails []string `json:"emails,omitempty"` // email addresses to add } // CreateUserOption — CreateUserOption create user options +// +// Usage: +// +// opts := CreateUserOption{Email: "alice@example.com"} type CreateUserOption struct { - Created time.Time `json:"created_at,omitempty"` // For explicitly setting the user creation timestamp. Useful when users are migrated from other systems. When omitted, the user's creation timestamp will be set to "now". - Email string `json:"email"` - FullName string `json:"full_name,omitempty"` - LoginName string `json:"login_name,omitempty"` - MustChangePassword bool `json:"must_change_password,omitempty"` - Password string `json:"password,omitempty"` - Restricted bool `json:"restricted,omitempty"` - SendNotify bool `json:"send_notify,omitempty"` - SourceID int64 `json:"source_id,omitempty"` - Username string `json:"username"` - Visibility string `json:"visibility,omitempty"` + Created time.Time `json:"created_at,omitempty"` // For explicitly setting the user creation timestamp. Useful when users are migrated from other systems. When omitted, the user's creation timestamp will be set to "now". + Email string `json:"email"` + FullName string `json:"full_name,omitempty"` + LoginName string `json:"login_name,omitempty"` + MustChangePassword bool `json:"must_change_password,omitempty"` + Password string `json:"password,omitempty"` + Restricted bool `json:"restricted,omitempty"` + SendNotify bool `json:"send_notify,omitempty"` + SourceID int64 `json:"source_id,omitempty"` + Username string `json:"username"` + Visibility string `json:"visibility,omitempty"` } // DeleteEmailOption — DeleteEmailOption options when deleting email addresses +// +// Usage: +// +// opts := DeleteEmailOption{Emails: []string{"example"}} type DeleteEmailOption struct { Emails []string `json:"emails,omitempty"` // email addresses to delete } // EditUserOption — EditUserOption edit user options +// +// Usage: +// +// opts := EditUserOption{Description: "example"} type EditUserOption struct { - Active bool `json:"active,omitempty"` - Admin bool `json:"admin,omitempty"` - AllowCreateOrganization bool `json:"allow_create_organization,omitempty"` - AllowGitHook bool `json:"allow_git_hook,omitempty"` - AllowImportLocal bool `json:"allow_import_local,omitempty"` - Description string `json:"description,omitempty"` - Email string `json:"email,omitempty"` - FullName string `json:"full_name,omitempty"` - Location string `json:"location,omitempty"` - LoginName string `json:"login_name,omitempty"` - MaxRepoCreation int64 `json:"max_repo_creation,omitempty"` - MustChangePassword bool `json:"must_change_password,omitempty"` - Password string `json:"password,omitempty"` - ProhibitLogin bool `json:"prohibit_login,omitempty"` - Pronouns string `json:"pronouns,omitempty"` - Restricted bool `json:"restricted,omitempty"` - SourceID int64 `json:"source_id,omitempty"` - Visibility string `json:"visibility,omitempty"` - Website string `json:"website,omitempty"` + Active bool `json:"active,omitempty"` + Admin bool `json:"admin,omitempty"` + AllowCreateOrganization bool `json:"allow_create_organization,omitempty"` + AllowGitHook bool `json:"allow_git_hook,omitempty"` + AllowImportLocal bool `json:"allow_import_local,omitempty"` + Description string `json:"description,omitempty"` + Email string `json:"email,omitempty"` + FullName string `json:"full_name,omitempty"` + Location string `json:"location,omitempty"` + LoginName string `json:"login_name,omitempty"` + MaxRepoCreation int64 `json:"max_repo_creation,omitempty"` + MustChangePassword bool `json:"must_change_password,omitempty"` + Password string `json:"password,omitempty"` + ProhibitLogin bool `json:"prohibit_login,omitempty"` + Pronouns string `json:"pronouns,omitempty"` + Restricted bool `json:"restricted,omitempty"` + SourceID int64 `json:"source_id,omitempty"` + Visibility string `json:"visibility,omitempty"` + Website string `json:"website,omitempty"` } // Email — Email an email address belonging to a user type Email struct { - Email string `json:"email,omitempty"` - Primary bool `json:"primary,omitempty"` - UserID int64 `json:"user_id,omitempty"` + Email string `json:"email,omitempty"` + Primary bool `json:"primary,omitempty"` + UserID int64 `json:"user_id,omitempty"` UserName string `json:"username,omitempty"` - Verified bool `json:"verified,omitempty"` + Verified bool `json:"verified,omitempty"` } // SetUserQuotaGroupsOptions — SetUserQuotaGroupsOptions represents the quota groups of a user +// +// Usage: +// +// opts := SetUserQuotaGroupsOptions{Groups: []string{"example"}} type SetUserQuotaGroupsOptions struct { Groups []string `json:"groups"` // Quota groups the user shall have } // UpdateUserAvatarOption — UpdateUserAvatarUserOption options when updating the user avatar +// +// Usage: +// +// opts := UpdateUserAvatarOption{Image: "example"} type UpdateUserAvatarOption struct { Image string `json:"image,omitempty"` // image must be base64 encoded } // User — User represents a user type User struct { - AvatarURL string `json:"avatar_url,omitempty"` // URL to the user's avatar - Created time.Time `json:"created,omitempty"` - Description string `json:"description,omitempty"` // the user's description - Email string `json:"email,omitempty"` - Followers int64 `json:"followers_count,omitempty"` // user counts - Following int64 `json:"following_count,omitempty"` - FullName string `json:"full_name,omitempty"` // the user's full name - HTMLURL string `json:"html_url,omitempty"` // URL to the user's gitea page - ID int64 `json:"id,omitempty"` // the user's id - IsActive bool `json:"active,omitempty"` // Is user active - IsAdmin bool `json:"is_admin,omitempty"` // Is the user an administrator - Language string `json:"language,omitempty"` // User locale - LastLogin time.Time `json:"last_login,omitempty"` - Location string `json:"location,omitempty"` // the user's location - LoginName string `json:"login_name,omitempty"` // the user's authentication sign-in name. - ProhibitLogin bool `json:"prohibit_login,omitempty"` // Is user login prohibited - Pronouns string `json:"pronouns,omitempty"` // the user's pronouns - Restricted bool `json:"restricted,omitempty"` // Is user restricted - SourceID int64 `json:"source_id,omitempty"` // The ID of the user's Authentication Source - StarredRepos int64 `json:"starred_repos_count,omitempty"` - UserName string `json:"login,omitempty"` // the user's username - Visibility string `json:"visibility,omitempty"` // User visibility level option: public, limited, private - Website string `json:"website,omitempty"` // the user's website + AvatarURL string `json:"avatar_url,omitempty"` // URL to the user's avatar + Created time.Time `json:"created,omitempty"` + Description string `json:"description,omitempty"` // the user's description + Email string `json:"email,omitempty"` + Followers int64 `json:"followers_count,omitempty"` // user counts + Following int64 `json:"following_count,omitempty"` + FullName string `json:"full_name,omitempty"` // the user's full name + HTMLURL string `json:"html_url,omitempty"` // URL to the user's gitea page + ID int64 `json:"id,omitempty"` // the user's id + IsActive bool `json:"active,omitempty"` // Is user active + IsAdmin bool `json:"is_admin,omitempty"` // Is the user an administrator + Language string `json:"language,omitempty"` // User locale + LastLogin time.Time `json:"last_login,omitempty"` + Location string `json:"location,omitempty"` // the user's location + LoginName string `json:"login_name,omitempty"` // the user's authentication sign-in name. + ProhibitLogin bool `json:"prohibit_login,omitempty"` // Is user login prohibited + Pronouns string `json:"pronouns,omitempty"` // the user's pronouns + Restricted bool `json:"restricted,omitempty"` // Is user restricted + SourceID int64 `json:"source_id,omitempty"` // The ID of the user's Authentication Source + StarredRepos int64 `json:"starred_repos_count,omitempty"` + UserName string `json:"login,omitempty"` // the user's username + Visibility string `json:"visibility,omitempty"` // User visibility level option: public, limited, private + Website string `json:"website,omitempty"` // the user's website } // UserHeatmapData — UserHeatmapData represents the data needed to create a heatmap type UserHeatmapData struct { - Contributions int64 `json:"contributions,omitempty"` - Timestamp *TimeStamp `json:"timestamp,omitempty"` + Contributions int64 `json:"contributions,omitempty"` + Timestamp *TimeStamp `json:"timestamp,omitempty"` } // UserSettings — UserSettings represents user settings type UserSettings struct { - Description string `json:"description,omitempty"` - DiffViewStyle string `json:"diff_view_style,omitempty"` - EnableRepoUnitHints bool `json:"enable_repo_unit_hints,omitempty"` - FullName string `json:"full_name,omitempty"` - HideActivity bool `json:"hide_activity,omitempty"` - HideEmail bool `json:"hide_email,omitempty"` // Privacy - Language string `json:"language,omitempty"` - Location string `json:"location,omitempty"` - Pronouns string `json:"pronouns,omitempty"` - Theme string `json:"theme,omitempty"` - Website string `json:"website,omitempty"` + Description string `json:"description,omitempty"` + DiffViewStyle string `json:"diff_view_style,omitempty"` + EnableRepoUnitHints bool `json:"enable_repo_unit_hints,omitempty"` + FullName string `json:"full_name,omitempty"` + HideActivity bool `json:"hide_activity,omitempty"` + HideEmail bool `json:"hide_email,omitempty"` // Privacy + Language string `json:"language,omitempty"` + Location string `json:"location,omitempty"` + Pronouns string `json:"pronouns,omitempty"` + Theme string `json:"theme,omitempty"` + Website string `json:"website,omitempty"` } // UserSettingsOptions — UserSettingsOptions represents options to change user settings +// +// Usage: +// +// opts := UserSettingsOptions{Description: "example"} type UserSettingsOptions struct { - Description string `json:"description,omitempty"` - DiffViewStyle string `json:"diff_view_style,omitempty"` - EnableRepoUnitHints bool `json:"enable_repo_unit_hints,omitempty"` - FullName string `json:"full_name,omitempty"` - HideActivity bool `json:"hide_activity,omitempty"` - HideEmail bool `json:"hide_email,omitempty"` // Privacy - Language string `json:"language,omitempty"` - Location string `json:"location,omitempty"` - Pronouns string `json:"pronouns,omitempty"` - Theme string `json:"theme,omitempty"` - Website string `json:"website,omitempty"` + Description string `json:"description,omitempty"` + DiffViewStyle string `json:"diff_view_style,omitempty"` + EnableRepoUnitHints bool `json:"enable_repo_unit_hints,omitempty"` + FullName string `json:"full_name,omitempty"` + HideActivity bool `json:"hide_activity,omitempty"` + HideEmail bool `json:"hide_email,omitempty"` // Privacy + Language string `json:"language,omitempty"` + Location string `json:"location,omitempty"` + Pronouns string `json:"pronouns,omitempty"` + Theme string `json:"theme,omitempty"` + Website string `json:"website,omitempty"` } diff --git a/types/wiki.go b/types/wiki.go index cba56b9..38c2af2 100644 --- a/types/wiki.go +++ b/types/wiki.go @@ -2,43 +2,48 @@ package types + // CreateWikiPageOptions — CreateWikiPageOptions form for creating wiki +// +// Usage: +// +// opts := CreateWikiPageOptions{Title: "example"} type CreateWikiPageOptions struct { ContentBase64 string `json:"content_base64,omitempty"` // content must be base64 encoded - Message string `json:"message,omitempty"` // optional commit message summarizing the change - Title string `json:"title,omitempty"` // page title. leave empty to keep unchanged + Message string `json:"message,omitempty"` // optional commit message summarizing the change + Title string `json:"title,omitempty"` // page title. leave empty to keep unchanged } // WikiCommit — WikiCommit page commit/revision type WikiCommit struct { - Author *CommitUser `json:"author,omitempty"` + Author *CommitUser `json:"author,omitempty"` Commiter *CommitUser `json:"commiter,omitempty"` - ID string `json:"sha,omitempty"` - Message string `json:"message,omitempty"` + ID string `json:"sha,omitempty"` + Message string `json:"message,omitempty"` } // WikiCommitList — WikiCommitList commit/revision list type WikiCommitList struct { - Count int64 `json:"count,omitempty"` + Count int64 `json:"count,omitempty"` WikiCommits []*WikiCommit `json:"commits,omitempty"` } // WikiPage — WikiPage a wiki page type WikiPage struct { - CommitCount int64 `json:"commit_count,omitempty"` - ContentBase64 string `json:"content_base64,omitempty"` // Page content, base64 encoded - Footer string `json:"footer,omitempty"` - HTMLURL string `json:"html_url,omitempty"` - LastCommit *WikiCommit `json:"last_commit,omitempty"` - Sidebar string `json:"sidebar,omitempty"` - SubURL string `json:"sub_url,omitempty"` - Title string `json:"title,omitempty"` + CommitCount int64 `json:"commit_count,omitempty"` + ContentBase64 string `json:"content_base64,omitempty"` // Page content, base64 encoded + Footer string `json:"footer,omitempty"` + HTMLURL string `json:"html_url,omitempty"` + LastCommit *WikiCommit `json:"last_commit,omitempty"` + Sidebar string `json:"sidebar,omitempty"` + SubURL string `json:"sub_url,omitempty"` + Title string `json:"title,omitempty"` } // WikiPageMetaData — WikiPageMetaData wiki page meta information type WikiPageMetaData struct { - HTMLURL string `json:"html_url,omitempty"` + HTMLURL string `json:"html_url,omitempty"` LastCommit *WikiCommit `json:"last_commit,omitempty"` - SubURL string `json:"sub_url,omitempty"` - Title string `json:"title,omitempty"` + SubURL string `json:"sub_url,omitempty"` + Title string `json:"title,omitempty"` }