Documentation
¶
Overview ¶
Package gitea provides a Go SDK for the Gitea API.
Index ¶
- type APIError
- type Attachment
- type ChunkedUpload
- type ChunkedUploadOptions
- type Client
- func (c *Client) CreateChunkedUpload(ctx context.Context, owner, repo string, releaseID int64, ...) (*ChunkedUpload, error)
- func (c *Client) GetCurrentUser(ctx context.Context) (*User, error)
- func (c *Client) GetRelease(ctx context.Context, owner, repo, tag string) (*Release, error)
- func (c *Client) GetRepository(ctx context.Context, owner, repo string) (*Repository, error)
- func (c *Client) GetVersion(ctx context.Context) (string, error)
- func (c *Client) ListReleases(ctx context.Context, owner, repo string) ([]*Release, error)
- func (c *Client) UploadReleaseAsset(ctx context.Context, owner, repo string, releaseID int64, fileName string, ...) (*UploadResult, error)
- type ClientOption
- type Progress
- type ProgressFunc
- type Release
- type Repository
- type UploadOption
- type UploadResult
- type UploadSession
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
Code string `json:"code"`
Message string `json:"message"`
Status int `json:"status"`
Details map[string]any `json:"details,omitempty"`
}
APIError represents an API error response
type Attachment ¶
type Attachment struct {
ID int64 `json:"id"`
Name string `json:"name"`
Size int64 `json:"size"`
DownloadCount int64 `json:"download_count"`
DownloadURL string `json:"browser_download_url"`
CreatedAt time.Time `json:"created_at"`
}
Attachment represents a release asset
type ChunkedUpload ¶
type ChunkedUpload struct {
// contains filtered or unexported fields
}
ChunkedUpload handles large file uploads
func (*ChunkedUpload) Cancel ¶
func (cu *ChunkedUpload) Cancel(ctx context.Context) error
Cancel cancels the upload
func (*ChunkedUpload) GetSession ¶
func (cu *ChunkedUpload) GetSession() *UploadSession
GetSession returns the current session
func (*ChunkedUpload) Upload ¶
func (cu *ChunkedUpload) Upload(ctx context.Context, reader io.Reader, size int64) (*UploadResult, error)
Upload uploads the file from the reader
type ChunkedUploadOptions ¶
type ChunkedUploadOptions struct {
FileName string
ChunkSize int64
Parallel int
VerifyChecksum bool
OnProgress ProgressFunc
}
ChunkedUploadOptions configures a chunked upload
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Gitea API client
func NewClient ¶
func NewClient(baseURL string, opts ...ClientOption) (*Client, error)
NewClient creates a new Gitea API client
func (*Client) CreateChunkedUpload ¶
func (c *Client) CreateChunkedUpload(ctx context.Context, owner, repo string, releaseID int64, opts ChunkedUploadOptions) (*ChunkedUpload, error)
CreateChunkedUpload starts a new chunked upload session
func (*Client) GetCurrentUser ¶
GetCurrentUser returns the authenticated user
func (*Client) GetRelease ¶
GetRelease returns a release by tag name
func (*Client) GetRepository ¶
GetRepository returns a repository by owner and name
func (*Client) GetVersion ¶
GetVersion returns the Gitea server version
func (*Client) ListReleases ¶
ListReleases returns all releases for a repository
type ClientOption ¶
type ClientOption func(*Client)
ClientOption is a function that configures the client
func SetHTTPClient ¶
func SetHTTPClient(client *http.Client) ClientOption
SetHTTPClient sets a custom HTTP client
type Progress ¶
type Progress struct {
BytesDone int64
BytesTotal int64
ChunksDone int64
ChunksTotal int64
Percent float64
Speed float64 // bytes per second
ETA time.Duration
}
Progress represents upload progress
type Release ¶
type Release struct {
ID int64 `json:"id"`
TagName string `json:"tag_name"`
Name string `json:"name"`
Body string `json:"body"`
Draft bool `json:"draft"`
Prerelease bool `json:"prerelease"`
PublishedAt time.Time `json:"published_at"`
Assets []Attachment `json:"assets"`
}
Release represents a Gitea release
type Repository ¶
type Repository struct {
ID int64 `json:"id"`
Owner *User `json:"owner"`
Name string `json:"name"`
FullName string `json:"full_name"`
Description string `json:"description"`
Private bool `json:"private"`
Fork bool `json:"fork"`
DefaultBranch string `json:"default_branch"`
Stars int `json:"stars_count"`
Forks int `json:"forks_count"`
CloneURL string `json:"clone_url"`
HTMLURL string `json:"html_url"`
}
Repository represents a Gitea repository
type UploadOption ¶
type UploadOption func(*ChunkedUploadOptions)
UploadOption configures an upload
func WithChecksum ¶
func WithChecksum(verify bool) UploadOption
WithChecksum enables checksum verification
func WithParallel ¶
func WithParallel(n int) UploadOption
WithParallel sets the number of parallel uploads
func WithProgress ¶
func WithProgress(fn ProgressFunc) UploadOption
WithProgress sets the progress callback
type UploadResult ¶
type UploadResult struct {
ID int64 `json:"id"`
Name string `json:"name"`
Size int64 `json:"size"`
DownloadURL string `json:"browser_download_url"`
ChecksumVerified bool `json:"checksum_verified"`
}
UploadResult represents the result of a completed upload
type UploadSession ¶
type UploadSession struct {
ID string `json:"id"`
FileName string `json:"file_name"`
FileSize int64 `json:"file_size"`
ChunkSize int64 `json:"chunk_size"`
TotalChunks int64 `json:"total_chunks"`
ChunksReceived int64 `json:"chunks_received"`
Status string `json:"status"`
ExpiresAt time.Time `json:"expires_at"`
Checksum string `json:"checksum,omitempty"`
}
UploadSession represents a chunked upload session
Source Files
¶
- client.go
- upload.go