Documentation
¶
Index ¶
- Constants
- type BuildV3Response
- type BuildsV3Response
- type Channel
- type ChecksumsV3
- type Client
- func (c *Client) DownloadBuild(ctx context.Context, downloadURL string) (io.ReadCloser, error)
- func (c *Client) DownloadFile(ctx context.Context, projectID, version string, build int32, destPath string) (*DownloadResult, error)
- func (c *Client) DownloadLatestBuild(ctx context.Context, projectID, version, destDir string) (*DownloadResult, error)
- func (c *Client) DownloadLatestStableVersion(ctx context.Context, projectID, destDir string) (*DownloadResult, error)
- func (c *Client) DownloadPromotedBuild(ctx context.Context, projectID, version, destDir string) (*DownloadResult, error)
- func (c *Client) FindPromotedBuild(ctx context.Context, projectID, version string) (int32, error)
- func (c *Client) GetBuild(ctx context.Context, projectID, version string, build int32) (*BuildV3Response, error)
- func (c *Client) GetBuildURL(ctx context.Context, projectID, version string, build int32) (string, error)
- func (c *Client) GetBuilds(ctx context.Context, projectID, version string, channels ...Channel) ([]BuildV3Response, error)
- func (c *Client) GetDefaultDownloadName(ctx context.Context, projectID, version string, build int32) (string, error)
- func (c *Client) GetLatestBuild(ctx context.Context, projectID, version string) (int32, error)
- func (c *Client) GetLatestBuildURL(ctx context.Context, projectID, version string) (string, error)
- func (c *Client) GetLatestBuildV3(ctx context.Context, projectID, version string) (*BuildV3Response, error)
- func (c *Client) GetLatestVersion(ctx context.Context, projectID string) (string, error)
- func (c *Client) GetLatestVersionURL(ctx context.Context, projectID string) (string, error)
- func (c *Client) GetProject(ctx context.Context, projectID string) (*ProjectV3Response, error)
- func (c *Client) GetProjects(ctx context.Context) (*ProjectsV3Response, error)
- func (c *Client) GetPromotedBuildURL(ctx context.Context, projectID, version string) (string, error)
- func (c *Client) GetRecommendedVersion(ctx context.Context, projectID string) (string, error)
- func (c *Client) GetVersion(ctx context.Context, projectID, version string) (*VersionV3Response, error)
- func (c *Client) GetVersions(ctx context.Context, projectID string) ([]VersionV3Response, error)
- func (c *Client) WithBaseURL(baseURL string) *Client
- func (c *Client) WithChannel(channel Channel) *Client
- func (c *Client) WithLimit(limit int) *Client
- func (c *Client) WithTimeout(timeout time.Duration) *Client
- type CommitV3
- type DownloadResult
- type DownloadV3
- type JavaFlags
- type JavaInfo
- type JavaVersion
- type ProjectMeta
- type ProjectV3Info
- type ProjectV3Response
- type ProjectsV3Response
- type SupportInfo
- type SupportStatus
- type VersionMeta
- type VersionV3Response
Constants ¶
const ( // DefaultBaseURL is the base URL for PaperMC API v3. DefaultBaseURL = "https://fill.papermc.io" // DefaultTimeout is the default timeout for HTTP requests. DefaultTimeout = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildV3Response ¶ added in v0.0.3
type BuildV3Response struct {
ID int32 `json:"id"`
Time time.Time `json:"time"`
Channel string `json:"channel"`
Commits []CommitV3 `json:"commits"`
Downloads map[string]DownloadV3 `json:"downloads"`
}
BuildV3Response represents the v3 API response for a build.
func (*BuildV3Response) GetDownloadName ¶ added in v0.0.3
func (b *BuildV3Response) GetDownloadName() string
GetDownloadName returns the filename of the default server application.
func (*BuildV3Response) GetDownloadSHA256 ¶ added in v0.0.3
func (b *BuildV3Response) GetDownloadSHA256() string
GetDownloadSHA256 returns the SHA256 checksum of the default server application.
func (*BuildV3Response) GetDownloadURL ¶ added in v0.0.3
func (b *BuildV3Response) GetDownloadURL() string
GetDownloadURL returns the download URL for the default server application.
type BuildsV3Response ¶ added in v0.0.3
type BuildsV3Response struct {
Builds []BuildV3Response `json:"builds"`
}
BuildsV3Response represents the v3 API response for builds list.
type Channel ¶ added in v0.0.3
type Channel string
Channel represents build stability channels in v3 API.
type ChecksumsV3 ¶ added in v0.0.3
type ChecksumsV3 struct {
SHA256 string `json:"sha256"`
}
ChecksumsV3 represents file checksums in v3 API.
type Client ¶
type Client struct {
BaseURL string
HTTPClient *http.Client
Limit int // Limit the number of items to return (0 means no limit)
Channel Channel // Filter builds by channel (empty means no filter)
}
Client represents the PaperMC API client.
func NewClient ¶
func NewClient() *Client
NewClient creates a new instance of the PaperMC API client.
func (*Client) DownloadBuild ¶
DownloadBuild downloads the specified file from a build.
func (*Client) DownloadFile ¶
func (c *Client) DownloadFile(ctx context.Context, projectID, version string, build int32, destPath string) (*DownloadResult, error)
DownloadFile downloads a file from a build and verifies its hash.
func (*Client) DownloadLatestBuild ¶
func (c *Client) DownloadLatestBuild(ctx context.Context, projectID, version, destDir string) (*DownloadResult, error)
DownloadLatestBuild downloads the latest build of the specified project version.
func (*Client) DownloadLatestStableVersion ¶
func (c *Client) DownloadLatestStableVersion(ctx context.Context, projectID, destDir string) (*DownloadResult, error)
DownloadLatestStableVersion downloads the latest stable version of the project.
func (*Client) DownloadPromotedBuild ¶
func (c *Client) DownloadPromotedBuild(ctx context.Context, projectID, version, destDir string) (*DownloadResult, error)
DownloadPromotedBuild downloads the recommended build of the specified version.
func (*Client) FindPromotedBuild ¶
FindPromotedBuild finds a recommended (promoted) build for the specified version. In v3 API, looks for builds with RECOMMENDED channel first, then STABLE.
func (*Client) GetBuild ¶
func (c *Client) GetBuild(ctx context.Context, projectID, version string, build int32) (*BuildV3Response, error)
GetBuild returns information about a specific build.
func (*Client) GetBuildURL ¶
func (c *Client) GetBuildURL(ctx context.Context, projectID, version string, build int32) (string, error)
GetBuildURL returns the download URL for a specific build.
func (*Client) GetBuilds ¶
func (c *Client) GetBuilds(ctx context.Context, projectID, version string, channels ...Channel) ([]BuildV3Response, error)
GetBuilds returns a list of available builds for a project version. Optionally filter by channels (ALPHA, BETA, STABLE, RECOMMENDED).
func (*Client) GetDefaultDownloadName ¶
func (c *Client) GetDefaultDownloadName(ctx context.Context, projectID, version string, build int32) (string, error)
GetDefaultDownloadName returns the name of the main downloadable file for a build.
func (*Client) GetLatestBuild ¶
GetLatestBuild returns the number of the latest build for the specified version.
func (*Client) GetLatestBuildURL ¶
GetLatestBuildURL returns the download URL for the latest build of a version.
func (*Client) GetLatestBuildV3 ¶ added in v0.0.3
func (c *Client) GetLatestBuildV3(ctx context.Context, projectID, version string) (*BuildV3Response, error)
GetLatestBuildV3 returns the latest build for the specified version using v3 API. If channel filter is set, uses /builds endpoint with filter and returns the last one.
func (*Client) GetLatestVersion ¶
GetLatestVersion returns the latest available version for a project.
func (*Client) GetLatestVersionURL ¶
GetLatestVersionURL returns the download URL for the latest version of a project.
func (*Client) GetProject ¶
GetProject returns information about a specific project.
func (*Client) GetProjects ¶
func (c *Client) GetProjects(ctx context.Context) (*ProjectsV3Response, error)
GetProjects returns a list of all available projects.
func (*Client) GetPromotedBuildURL ¶
func (c *Client) GetPromotedBuildURL(ctx context.Context, projectID, version string) (string, error)
GetPromotedBuildURL returns the download URL for the promoted build of a version.
func (*Client) GetRecommendedVersion ¶
GetRecommendedVersion returns the recommended version for the project. Usually it's the latest stable (not SNAPSHOT and not pre/rc) version.
func (*Client) GetVersion ¶
func (c *Client) GetVersion(ctx context.Context, projectID, version string) (*VersionV3Response, error)
GetVersion returns information about a project version.
func (*Client) GetVersions ¶ added in v0.0.3
GetVersions returns a list of all versions for a project with full metadata.
func (*Client) WithBaseURL ¶
WithBaseURL sets a custom base URL for the API.
func (*Client) WithChannel ¶ added in v0.0.3
WithChannel sets a channel filter for builds.
type CommitV3 ¶ added in v0.0.3
type CommitV3 struct {
SHA string `json:"sha"`
Time time.Time `json:"time"`
Message string `json:"message"`
}
CommitV3 represents a commit in v3 API.
type DownloadResult ¶
DownloadResult contains the result of downloading a file.
type DownloadV3 ¶ added in v0.0.3
type DownloadV3 struct {
Name string `json:"name"`
URL string `json:"url"`
Checksums ChecksumsV3 `json:"checksums"`
Size int64 `json:"size"`
}
DownloadV3 represents a downloadable file in v3 API.
type JavaFlags ¶ added in v0.0.3
type JavaFlags struct {
Recommended []string `json:"recommended"`
}
JavaFlags represents recommended JVM flags in v3 API.
type JavaInfo ¶ added in v0.0.3
type JavaInfo struct {
Version JavaVersion `json:"version"`
Flags JavaFlags `json:"flags"`
}
JavaInfo represents Java configuration in v3 API.
type JavaVersion ¶ added in v0.0.3
type JavaVersion struct {
Minimum int `json:"minimum"`
}
JavaVersion represents Java version requirements in v3 API.
type ProjectMeta ¶ added in v0.0.3
ProjectMeta represents basic project information in v3 API.
type ProjectV3Info ¶ added in v0.0.3
type ProjectV3Info struct {
Project ProjectMeta `json:"project"`
Versions map[string][]string `json:"versions"` // e.g., {"1.21": ["1.21.11", "1.21.10"]}
}
ProjectV3Info represents a project with its versions in v3 projects list.
type ProjectV3Response ¶ added in v0.0.3
type ProjectV3Response struct {
Project ProjectMeta `json:"project"`
Versions map[string][]string `json:"versions"`
}
ProjectV3Response represents the v3 API response for a single project.
func (*ProjectV3Response) FlattenVersions ¶ added in v0.0.3
func (p *ProjectV3Response) FlattenVersions() []string
FlattenVersions returns all versions as a flat slice, sorted from oldest to newest using semver.
type ProjectsV3Response ¶ added in v0.0.3
type ProjectsV3Response struct {
Projects []ProjectV3Info `json:"projects"`
}
ProjectsV3Response represents the v3 API response for projects list.
type SupportInfo ¶ added in v0.0.3
type SupportInfo struct {
Status string `json:"status"` // SUPPORTED, DEPRECATED, UNSUPPORTED
End *time.Time `json:"end,omitempty"`
}
SupportInfo represents version support status in v3 API.
type SupportStatus ¶ added in v0.0.3
type SupportStatus string
SupportStatus represents version support status in v3 API.
const ( SupportStatusSupported SupportStatus = "SUPPORTED" SupportStatusDeprecated SupportStatus = "DEPRECATED" SupportStatusUnsupported SupportStatus = "UNSUPPORTED" )
type VersionMeta ¶ added in v0.0.3
type VersionMeta struct {
ID string `json:"id"`
Support SupportInfo `json:"support"`
Java JavaInfo `json:"java"`
}
VersionMeta represents version metadata in v3 API.
type VersionV3Response ¶ added in v0.0.3
type VersionV3Response struct {
Version VersionMeta `json:"version"`
Builds []int32 `json:"builds"`
}
VersionV3Response represents the v3 API response for a version.