This commit is contained in:
2025-08-13 10:12:57 +02:00
parent 50f33e9303
commit 15aeb136b2
3 changed files with 306 additions and 298 deletions

19
examples/clients/gitea.vsh Executable file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
import freeflowuniverse.herolib.core
import freeflowuniverse.herolib.clients.gitea_client
// Configure PostgreSQL client
heroscript := "
!!gitea_client.configure
url: 'https://gitea.example.com'
user: 'despiegk'
token: '0597b7c143953bc66b47268bfcdc324340b3f47d'
"
// Process the heroscript configuration
gitea_client.play(heroscript: heroscript)!
// Get the configured client
mut db_client := gitea_client.get()!

View File

@@ -12,6 +12,7 @@ pub const version = '0.0.0'
pub struct GiteaClient { pub struct GiteaClient {
pub mut: pub mut:
name string = 'default' name string = 'default'
user string
url string = 'https://git.ourworld.tf' url string = 'https://git.ourworld.tf'
secret string secret string
} }
@@ -35,10 +36,6 @@ fn obj_init(mycfg_ GiteaClient) !GiteaClient {
if mycfg.url == '' { if mycfg.url == '' {
return error('url needs to be filled in for ${mycfg.name}') return error('url needs to be filled in for ${mycfg.name}')
} }
// The secret is optional for public gitea instances
// if mycfg.secret == '' {
// return error('secret needs to be filled in for ${mycfg.name}')
// }
return mycfg return mycfg
} }

View File

@@ -1,431 +1,423 @@
// File: lib/clients/gitea_client/models.v
module gitea_client module gitea_client
import time import time
// NOTE: This file is auto-generated from a Swagger specification.
// All data models required for the Gitea API are defined here.
//
// Data Models from Swagger Definitions
//
pub struct APIError { pub struct APIError {
pub: pub:
message string @[json: 'message'] message string
url string @[json: 'url'] url string
} }
pub struct AccessToken { pub struct AccessToken {
pub: pub:
id i64 @[json: 'id'] id i64
name string @[json: 'name'] name string
scopes []string @[json: 'scopes'] scopes []string
sha1 string @[json: 'sha1'] sha1 string
token_last_eight string @[json: 'token_last_eight'] token_last_eight string
} }
pub struct ActionVariable { pub struct ActionVariable {
pub: pub:
owner_id i64 @[json: 'owner_id'] owner_id i64
repo_id i64 @[json: 'repo_id'] repo_id i64
name string @[json: 'name'] name string
data string @[json: 'data'] data string
} }
pub struct Activity { pub struct Activity {
pub: pub:
act_user &User @[json: 'act_user'] act_user &User
act_user_id i64 @[json: 'act_user_id'] act_user_id i64
comment &Comment @[json: 'comment'] comment &Comment
comment_id i64 @[json: 'comment_id'] comment_id i64
content string @[json: 'content'] content string
created time.Time @[json: 'created'] created time.Time
id i64 @[json: 'id'] id i64
is_private bool @[json: 'is_private'] is_private bool
op_type string @[json: 'op_type'] op_type string
ref_name string @[json: 'ref_name'] ref_name string
repo &Repository @[json: 'repo'] repo &Repository
repo_id i64 @[json: 'repo_id'] repo_id i64
user_id i64 @[json: 'user_id'] user_id i64
} }
pub struct AddCollaboratorOption { pub struct AddCollaboratorOption {
pub: pub:
permission string @[json: 'permission'] permission string
} }
pub struct AddTimeOption { pub struct AddTimeOption {
pub: pub:
time i64 @[json: 'time'] time i64
created time.Time @[json: 'created'] created time.Time
user_name string @[json: 'user_name'] user_name string
} }
pub struct AnnotatedTagObject { pub struct AnnotatedTagObject {
pub: pub:
sha string @[json: 'sha'] sha string
typ string @[json: 'type'] // `type` is a keyword in V typ string @[json: 'type'] // `type` is a keyword in V
url string @[json: 'url'] url string
} }
pub struct AnnotatedTag { pub struct AnnotatedTag {
pub: pub:
message string @[json: 'message'] message string
object &AnnotatedTagObject @[json: 'object'] object &AnnotatedTagObject
sha string @[json: 'sha'] sha string
tag string @[json: 'tag'] tag string
tagger &CommitUser @[json: 'tagger'] tagger &CommitUser
url string @[json: 'url'] url string
verification &PayloadCommitVerification @[json: 'verification'] verification &PayloadCommitVerification
} }
pub struct Attachment { pub struct Attachment {
pub: pub:
browser_download_url string @[json: 'browser_download_url'] browser_download_url string
created_at time.Time @[json: 'created_at'] created_at time.Time
download_count i64 @[json: 'download_count'] download_count i64
id i64 @[json: 'id'] id i64
name string @[json: 'name'] name string
size i64 @[json: 'size'] size i64
uuid string @[json: 'uuid'] uuid string
} }
pub struct Badge { pub struct Badge {
pub: pub:
id i64 @[json: 'id'] id i64
slug string @[json: 'slug'] slug string
description string @[json: 'description'] description string
image_url string @[json: 'image_url'] image_url string
} }
pub struct Branch { pub struct Branch {
pub: pub:
commit &PayloadCommit @[json: 'commit'] commit &PayloadCommit
effective_branch_protection_name string @[json: 'effective_branch_protection_name'] effective_branch_protection_name string
enable_status_check bool @[json: 'enable_status_check'] enable_status_check bool
name string @[json: 'name'] name string
protected bool @[json: 'protected'] protected bool
required_approvals i64 @[json: 'required_approvals'] required_approvals i64
status_check_contexts []string @[json: 'status_check_contexts'] status_check_contexts []string
user_can_merge bool @[json: 'user_can_merge'] user_can_merge bool
user_can_push bool @[json: 'user_can_push'] user_can_push bool
} }
pub struct BranchProtection { pub struct BranchProtection {
pub: pub:
branch_name string branch_name string
rule_name string @[json: 'rule_name'] rule_name string
enable_push bool @[json: 'enable_push'] enable_push bool
enable_push_whitelist bool @[json: 'enable_push_whitelist'] enable_push_whitelist bool
push_whitelist_usernames []string @[json: 'push_whitelist_usernames'] push_whitelist_usernames []string
push_whitelist_teams []string @[json: 'push_whitelist_teams'] push_whitelist_teams []string
push_whitelist_deploy_keys bool @[json: 'push_whitelist_deploy_keys'] push_whitelist_deploy_keys bool
enable_merge_whitelist bool @[json: 'enable_merge_whitelist'] enable_merge_whitelist bool
merge_whitelist_usernames []string @[json: 'merge_whitelist_usernames'] merge_whitelist_usernames []string
merge_whitelist_teams []string @[json: 'merge_whitelist_teams'] merge_whitelist_teams []string
enable_status_check bool @[json: 'enable_status_check'] enable_status_check bool
status_check_contexts []string @[json: 'status_check_contexts'] status_check_contexts []string
required_approvals i64 @[json: 'required_approvals'] required_approvals i64
enable_approvals_whitelist bool @[json: 'enable_approvals_whitelist'] enable_approvals_whitelist bool
approvals_whitelist_username []string @[json: 'approvals_whitelist_username'] approvals_whitelist_username []string
approvals_whitelist_teams []string @[json: 'approvals_whitelist_teams'] approvals_whitelist_teams []string
block_on_rejected_reviews bool @[json: 'block_on_rejected_reviews'] block_on_rejected_reviews bool
block_on_official_review_requests bool @[json: 'block_on_official_review_requests'] block_on_official_review_requests bool
block_on_outdated_branch bool @[json: 'block: 'block_on_outdated_branch'] block_on_outdated_branch bool
dismiss_stale_approvals bool @[json: 'dismiss_stale_approvals'] dismiss_stale_approvals bool
ignore_stale_approvals bool @[json: 'ignore_stale_approvals'] ignore_stale_approvals bool
require_signed_commits bool @[json: 'require_signed_commits'] require_signed_commits bool
protected_file_patterns string @[json: 'protected_file_patterns'] protected_file_patterns string
unprotected_file_patterns string @[json: 'unprotected_file_patterns'] unprotected_file_patterns string
created_at time.Time @[json: 'created_at'] created_at time.Time
updated_at time.Time @[json: 'updated_at'] updated_at time.Time
} }
pub struct ChangeFileOperation { pub struct ChangeFileOperation {
pub: pub:
operation string @[json: 'operation'] // "create", "update", "delete" operation string // "create", "update", "delete"
path string @[json: 'path'] path string
content string @[json: 'content'] // base64 encoded content string // base64 encoded
from_path string @[json: 'from_path'] from_path string
sha string @[json: 'sha'] sha string
} }
pub struct ChangeFilesOptions { pub struct ChangeFilesOptions {
pub: pub:
author &Identity @[json: 'author'] author &Identity
branch string @[json: 'branch'] branch string
committer &Identity @[json: 'committer'] committer &Identity
dates &CommitDateOptions @[json: 'dates'] dates &CommitDateOptions
files []ChangeFileOperation @[json: 'files'] files []ChangeFileOperation
message string @[json: 'message'] message string
new_branch string @[json: 'new_branch'] new_branch string
signoff bool @[json: 'signoff'] signoff bool
} }
pub struct ChangedFile { pub struct ChangedFile {
pub: pub:
additions i64 @[json: 'additions'] additions i64
changes i64 @[json: 'changes'] changes i64
contents_url string @[json: 'contents_url'] contents_url string
deletions i64 @[json: 'deletions'] deletions i64
filename string @[json: 'filename'] filename string
html_url string @[json: 'html_url'] html_url string
previous_filename string @[json: 'previous_filename'] previous_filename string
raw_url string @[json: 'raw_url'] raw_url string
status string @[json: 'status'] status string
} }
pub struct Commit { pub struct Commit {
pub: pub:
author &User @[json: 'author'] author &User
commit &RepoCommit @[json: 'commit'] commit &RepoCommit
committer &User @[json: 'committer'] committer &User
created time.Time @[json: 'created'] created time.Time
files []CommitAffectedFiles @[json: 'files'] files []CommitAffectedFiles
html_url string @[json: 'html_url'] html_url string
parents []CommitMeta @[json: 'parents'] parents []CommitMeta
sha string @[json: 'sha'] sha string
stats &CommitStats @[json: 'stats'] stats &CommitStats
url string @[json: 'url'] url string
} }
pub struct CommitAffectedFiles { pub struct CommitAffectedFiles {
pub: pub:
filename string @[json: 'filename'] filename string
status string @[json: 'status'] status string
} }
pub struct CommitDateOptions { pub struct CommitDateOptions {
pub: pub:
author time.Time @[json: 'author'] author time.Time
committer time.Time @[json: 'committer'] committer time.Time
} }
pub struct CommitMeta { pub struct CommitMeta {
pub: pub:
created time.Time @[json: 'created'] created time.Time
sha string @[json: 'sha'] sha string
url string @[json: 'url'] url string
} }
pub struct CommitStats { pub struct CommitStats {
pub: pub:
additions i64 @[json: 'additions'] additions i64
deletions i64 @[json: 'deletions'] deletions i64
total i64 @[json: 'total'] total i64
} }
pub struct CommitUser { pub struct CommitUser {
pub: pub:
date string @[json: 'date'] date string
email string @[json: 'email'] email string
name string @[json: 'name'] name string
} }
pub struct CreateIssueOption { pub struct CreateIssueOption {
pub: pub:
title string @[json: 'title'] title string
assignee string @[json: 'assignee'] assignee string
assignees []string @[json: 'assignees'] assignees []string
body string @[json: 'body'] body string
closed bool @[json: 'closed'] closed bool
due_date time.Time @[json: 'due_date'] due_date time.Time
labels []i64 @[json: 'labels'] labels []i64
milestone i64 @[json: 'milestone'] milestone i64
ref string @[json: 'ref'] ref string
} }
pub struct CreateRepoOption { pub struct CreateRepoOption {
pub: pub:
name string @[json: 'name'] name string
auto_init bool @[json: 'auto_init'] auto_init bool
default_branch string @[json: 'default_branch'] default_branch string
description string @[json: 'description'] description string
gitignores string @[json: 'gitignores'] gitignores string
issue_labels string @[json: 'issue_labels'] issue_labels string
license string @[json: 'license'] license string
object_format_name string @[json: 'object_format_name'] // "sha1" or "sha256" object_format_name string // "sha1" or "sha256"
private bool @[json: 'private'] private bool
readme string @[json: 'readme'] readme string
template bool @[json: 'template'] template bool
trust_model string @[json: 'trust_model'] // "default", "collaborator", "committer", "collaboratorcommitter" trust_model string // "default", "collaborator", "committer", "collaboratorcommitter"
} }
pub struct Identity { pub struct Identity {
pub: pub:
email string @[json: 'email'] email string
name string @[json: 'name'] name string
} }
pub struct Issue { pub struct Issue {
pub: pub:
id i64 @[json: 'id'] id i64
url string @[json: 'url'] url string
html_url string @[json: 'html_url'] html_url string
number i64 @[json: 'number'] number i64
user &User @[json: 'user'] user &User
original_author string @[json: 'original_author'] original_author string
original_author_id i64 @[json: 'original_author_id'] original_author_id i64
title string @[json: 'title'] title string
body string @[json: 'body'] body string
ref string @[json: 'ref'] ref string
labels []Label @[json: 'labels'] labels []Label
milestone &Milestone @[json: 'milestone'] milestone &Milestone
assignee &User @[json: 'assignee'] assignee &User
assignees []User @[json: 'assignees'] assignees []User
state string @[json: 'state'] // StateType state string // StateType
is_locked bool @[json: 'is_locked'] is_locked bool
comments i64 @[json: 'comments'] comments i64
created_at time.Time @[json: 'created_at'] created_at time.Time
updated_at time.Time @[json: 'updated_at'] updated_at time.Time
closed_at time.Time @[json: 'closed_at'] closed_at time.Time
due_date time.Time @[json: 'due_date'] due_date time.Time
pull_request &PullRequestMeta @[json: 'pull_request'] pull_request &PullRequestMeta
repository &RepositoryMeta @[json: 'repository'] repository &RepositoryMeta
assets []Attachment @[json: 'assets'] assets []Attachment
pin_order i64 @[json: 'pin_order'] pin_order i64
} }
pub struct Label { pub struct Label {
pub: pub:
id i64 @[json: 'id'] id i64
name string @[json: 'name'] name string
exclusive bool @[json: 'exclusive'] exclusive bool
is_archived bool @[json: 'is_archived'] is_archived bool
color string @[json: 'color'] color string
description string @[json: 'description'] description string
url string @[json: 'url'] url string
} }
pub struct Milestone { pub struct Milestone {
pub: pub:
id i64 @[json: 'id'] id i64
title string @[json: 'title'] title string
description string @[json: 'description'] description string
state string @[json: 'state'] // StateType state string // StateType
open_issues i64 @[json: 'open_issues'] open_issues i64
closed_issues i64 @[json: "closed_issues"] closed_issues i64
created_at time.Time @[json: 'created_at'] created_at time.Time
updated_at time.Time @[json: 'updated_at'] updated_at time.Time
closed_at time.Time @[json: 'closed_at'] closed_at time.Time
due_on time.Time @[json: 'due_on'] due_on time.Time
} }
pub struct PayloadCommitVerification { pub struct PayloadCommitVerification {
pub: pub:
payload string @[json: 'payload'] payload string
reason string @[json: 'reason'] reason string
signature string @[json: 'signature'] signature string
signer &PayloadUser @[json: 'signer'] signer &PayloadUser
verified bool @[json: 'verified'] verified bool
} }
pub struct PullRequestMeta { pub struct PullRequestMeta {
pub: pub:
merged bool @[json: 'merged'] merged bool
merged_at time.Time @[json: 'merged_at'] merged_at time.Time
draft bool @[json: 'draft'] draft bool
html_url string @[json: 'html_url'] html_url string
} }
pub struct RepoCommit { pub struct RepoCommit {
pub: pub:
author &CommitUser @[json: 'author'] author &CommitUser
committer &CommitUser @[json: 'committer'] committer &CommitUser
message string @[json: 'message'] message string
tree &CommitMeta @[json: 'tree'] tree &CommitMeta
url string @[json: 'url'] url string
verification &PayloadCommitVerification @[json: 'verification'] verification &PayloadCommitVerification
} }
pub struct Repository { pub struct Repository {
pub: pub:
id i64 @[json: 'id'] id i64
owner &User @[json: 'owner'] owner &User
name string @[json: 'name'] name string
full_name string @[json: 'full_name'] full_name string
description string @[json: 'description'] description string
empty bool @[json: 'empty'] empty bool
private bool @[json: 'private'] private bool
fork bool @[json: 'fork'] fork bool
template bool @[json: 'template'] template bool
parent &Repository @[json: 'parent'] parent &Repository
mirror bool @[json: 'mirror'] mirror bool
size i64 @[json: 'size'] size i64
language string @[json: 'language'] language string
languages_url string @[json: 'languages_url'] languages_url string
html_url string @[json: 'html_url'] html_url string
url string @[json: 'url'] url string
link string @[json: 'link'] link string
ssh_url string @[json: 'ssh_url'] ssh_url string
clone_url string @[json: 'clone_url'] clone_url string
website string @[json: 'website'] website string
stars_count i64 @[json: 'stars_count'] stars_count i64
forks_count i64 @[json: 'forks_count'] forks_count i64
watchers_count i64 @[json: 'watchers_count'] watchers_count i64
open_issues_count i64 @[json: 'open_issues_count'] open_issues_count i64
open_pr_counter i64 @[json: 'open_pr_counter'] open_pr_counter i64
release_counter i64 @[json: 'release_counter'] release_counter i64
default_branch string @[json: 'default_branch'] default_branch string
archived bool @[json: 'archived'] archived bool
created_at time.Time @[json: 'created_at'] created_at time.Time
updated_at time.Time @[json: 'updated_at'] updated_at time.Time
archived_at time.Time @[json: 'archived_at'] archived_at time.Time
permissions &Permission @[json: 'permissions'] permissions &Permission
has_issues bool @[json: 'has_issues'] has_issues bool
internal_tracker &InternalTracker @[json: 'internal_tracker'] internal_tracker &InternalTracker
has_wiki bool @[json: 'has_wiki'] has_wiki bool
has_pull_requests bool @[json: 'has_pull_requests'] has_pull_requests bool
has_projects bool @[json: 'has_projects'] has_projects bool
has_releases bool @[json: 'has_releases'] has_releases bool
has_packages bool @[json: 'has_packages'] has_packages bool
has_actions bool @[json: 'has_actions'] has_actions bool
ignore_whitespace_conflicts bool @[json: 'ignore_whitespace_conflicts'] ignore_whitespace_conflicts bool
allow_merge_commits bool @[json: 'allow_merge_commits'] allow_merge_commits bool
allow_rebase bool @[json: 'allow_rebase'] allow_rebase bool
allow_rebase_explicit bool @[json: 'allow_rebase_explicit'] allow_rebase_explicit bool
allow_squash_merge bool @[json: 'allow_squash_merge'] allow_squash_merge bool
allow_fast_forward_only_merge bool @[json: 'allow_fast_forward_only_merge'] allow_fast_forward_only_merge bool
allow_rebase_update bool @[json: 'allow_rebase_update'] allow_rebase_update bool
default_delete_branch_after_merge bool @[json: 'default_delete_branch_after_merge'] default_delete_branch_after_merge bool
default_merge_style string @[json: 'default_merge_style'] default_merge_style string
default_allow_maintainer_edit bool @[json: 'default_allow_maintainer_edit'] default_allow_maintainer_edit bool
avatar_url string @[json: 'avatar_url'] avatar_url string
internal bool @[json: 'internal'] internal bool
mirror_interval string @[json: 'mirror_interval'] mirror_interval string
mirror_updated time.Time @[json: 'mirror_updated'] mirror_updated time.Time
repo_transfer &RepoTransfer @[json: 'repo_transfer'] repo_transfer &RepoTransfer
} }
pub struct RepositoryMeta { pub struct RepositoryMeta {
pub: pub:
id i64 @[json: 'id'] id i64
name string @[json: 'name'] name string
owner string @[json: 'owner'] owner string
full_name string @[json: 'full_name'] full_name string
} }
pub struct User { pub struct User {
pub: pub:
id i64 @[json: 'id'] id i64
login string @[json: 'login'] login string
full_name string @[json: 'full_name'] full_name string
email string @[json: 'email'] email string
avatar_url string @[json: 'avatar_url'] avatar_url string
language string @[json: 'language'] language string
is_admin bool @[json: 'is_admin'] is_admin bool
last_login time.Time @[json: 'last_login'] last_login time.Time
created time.Time @[json: 'created'] created time.Time
restricted bool @[json: 'restricted'] restricted bool
active bool @[json: 'active'] active bool
prohibit_login bool @[json: 'prohibit_login'] prohibit_login bool
location string @[json: 'location'] location string
website string @[json: 'website'] website string
description string @[json: 'description'] description string
visibility string @[json: 'visibility'] visibility string
followers_count i64 @[json: 'followers_count'] followers_count i64
following_count i64 @[json: 'following_count'] following_count i64
starred_repos_count i64 @[json: 'starred_repos_count'] starred_repos_count i64
username string @[json: 'username'] username string
} }