go-forge/forge.go
Virgil 84d7c6a796
All checks were successful
Security Scan / security (push) Successful in 14s
Test / test (push) Successful in 1m49s
feat(forge): expose top-level client metadata
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 07:26:13 +00:00

87 lines
2.3 KiB
Go

package forge
// Forge is the top-level client for the Forgejo API.
//
// Usage:
//
// ctx := context.Background()
// f := forge.NewForge("https://forge.lthn.ai", "token")
// repo, err := f.Repos.Get(ctx, forge.Params{"owner": "core", "repo": "go-forge"})
type Forge struct {
client *Client
Repos *RepoService
Issues *IssueService
Pulls *PullService
Orgs *OrgService
Users *UserService
Teams *TeamService
Admin *AdminService
Branches *BranchService
Releases *ReleaseService
Labels *LabelService
Webhooks *WebhookService
Notifications *NotificationService
Packages *PackageService
Actions *ActionsService
Contents *ContentService
Wiki *WikiService
Misc *MiscService
Commits *CommitService
Milestones *MilestoneService
ActivityPub *ActivityPubService
}
// NewForge creates a new Forge client.
//
// Usage:
//
// ctx := context.Background()
// f := forge.NewForge("https://forge.lthn.ai", "token")
// repos, err := f.Repos.ListOrgRepos(ctx, "core")
func NewForge(url, token string, opts ...Option) *Forge {
c := NewClient(url, token, opts...)
f := &Forge{client: c}
f.Repos = newRepoService(c)
f.Issues = newIssueService(c)
f.Pulls = newPullService(c)
f.Orgs = newOrgService(c)
f.Users = newUserService(c)
f.Teams = newTeamService(c)
f.Admin = newAdminService(c)
f.Branches = newBranchService(c)
f.Releases = newReleaseService(c)
f.Labels = newLabelService(c)
f.Webhooks = newWebhookService(c)
f.Notifications = newNotificationService(c)
f.Packages = newPackageService(c)
f.Actions = newActionsService(c)
f.Contents = newContentService(c)
f.Wiki = newWikiService(c)
f.Misc = newMiscService(c)
f.Commits = newCommitService(c)
f.Milestones = newMilestoneService(c)
f.ActivityPub = newActivityPubService(c)
return f
}
// Client returns the underlying HTTP client.
//
// Usage:
//
// client := f.Client()
func (f *Forge) Client() *Client { return f.client }
// BaseURL returns the configured Forgejo base URL.
//
// Usage:
//
// baseURL := f.BaseURL()
func (f *Forge) BaseURL() string { return f.client.BaseURL() }
// RateLimit returns the last known rate limit information.
//
// Usage:
//
// rl := f.RateLimit()
func (f *Forge) RateLimit() RateLimit { return f.client.RateLimit() }