Documentation
¶
Index ¶
- Constants
- type BuildResponse
- type BuildsResponse
- type Change
- type Client
- func (c *Client) DownloadBuild(ctx context.Context, projectID, version string, build int32, download string) (io.ReadCloser, error)
- func (c *Client) DownloadFile(ctx context.Context, projectID, version string, build int32, ...) (*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) FormatDownloadURL(projectID, version string, build int32, downloadName string) string
- func (c *Client) GetBuild(ctx context.Context, projectID, version string, build int32) (*BuildResponse, 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) (*BuildsResponse, 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) 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) (*ProjectResponse, error)
- func (c *Client) GetProjects(ctx context.Context) (*ProjectsResponse, 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) (*VersionResponse, error)
- func (c *Client) GetVersionGroup(ctx context.Context, projectID, family string) (*VersionFamilyResponse, error)
- func (c *Client) GetVersionGroupBuilds(ctx context.Context, projectID, family string) (*VersionFamilyBuildsResponse, error)
- func (c *Client) WithBaseURL(baseURL string) *Client
- func (c *Client) WithLimit(limit int) *Client
- func (c *Client) WithTimeout(timeout time.Duration) *Client
- type Download
- type DownloadResult
- type ProjectResponse
- type ProjectsResponse
- type VersionBuild
- type VersionFamilyBuild
- type VersionFamilyBuildsResponse
- type VersionFamilyResponse
- type VersionResponse
Constants ¶
const ( // DefaultBaseURL - base URL for PaperMC API DefaultBaseURL = "https://api.papermc.io" // DefaultTimeout - default timeout for HTTP requests DefaultTimeout = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildResponse ¶
type BuildResponse struct {
ProjectID string `json:"project_id"`
ProjectName string `json:"project_name"`
Version string `json:"version"`
Build int32 `json:"build"`
Time time.Time `json:"time"`
Channel string `json:"channel"`
Promoted bool `json:"promoted"`
Changes []Change `json:"changes"`
Downloads map[string]Download `json:"downloads"`
}
BuildResponse represents information about a specific build
type BuildsResponse ¶
type BuildsResponse struct {
ProjectID string `json:"project_id"`
ProjectName string `json:"project_name"`
Version string `json:"version"`
Builds []VersionBuild `json:"builds"`
}
BuildsResponse represents a list of available builds for a project version
type Change ¶
type Change struct {
Commit string `json:"commit"`
Summary string `json:"summary"`
Message string `json:"message"`
}
Change represents information about changes in a build
type Client ¶
type Client struct {
BaseURL string
HTTPClient *http.Client
Limit int // Limit the number of items to return (0 means no limit)
}
Client represents the PaperMC API client
func NewClient ¶
func NewClient() *Client
NewClient creates a new instance of the PaperMC API client
func (*Client) DownloadBuild ¶
func (c *Client) DownloadBuild(ctx context.Context, projectID, version string, build int32, download string) (io.ReadCloser, error)
DownloadBuild downloads the specified file from a build
func (*Client) DownloadFile ¶
func (c *Client) DownloadFile(ctx context.Context, projectID, version string, build int32, downloadName, 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
func (*Client) FormatDownloadURL ¶
func (c *Client) FormatDownloadURL(projectID, version string, build int32, downloadName string) string
FormatDownloadURL returns a URL for direct file download
func (*Client) GetBuild ¶
func (c *Client) GetBuild(ctx context.Context, projectID, version string, build int32) (*BuildResponse, 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) 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) 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) (*ProjectsResponse, 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) version
func (*Client) GetVersion ¶
func (c *Client) GetVersion(ctx context.Context, projectID, version string) (*VersionResponse, error)
GetVersion returns information about a project version
func (*Client) GetVersionGroup ¶
func (c *Client) GetVersionGroup(ctx context.Context, projectID, family string) (*VersionFamilyResponse, error)
GetVersionGroup returns information about a project's version group
func (*Client) GetVersionGroupBuilds ¶
func (c *Client) GetVersionGroupBuilds(ctx context.Context, projectID, family string) (*VersionFamilyBuildsResponse, error)
GetVersionGroupBuilds returns a list of available builds for a version group
func (*Client) WithBaseURL ¶
WithBaseURL sets a custom base URL for the API
type DownloadResult ¶
DownloadResult contains the result of downloading a file
type ProjectResponse ¶
type ProjectResponse struct {
ProjectID string `json:"project_id"`
ProjectName string `json:"project_name"`
VersionGroups []string `json:"version_groups"`
Versions []string `json:"versions"`
}
ProjectResponse represents information about a project
type ProjectsResponse ¶
type ProjectsResponse struct {
Projects []string `json:"projects"`
}
ProjectsResponse represents a list of all available projects
type VersionBuild ¶
type VersionBuild struct {
Build int32 `json:"build"`
Time time.Time `json:"time"`
Channel string `json:"channel"`
Promoted bool `json:"promoted"`
Changes []Change `json:"changes"`
Downloads map[string]Download `json:"downloads"`
}
VersionBuild represents information about a build in the version context
type VersionFamilyBuild ¶
type VersionFamilyBuild struct {
Version string `json:"version"`
Build int32 `json:"build"`
Time time.Time `json:"time"`
Channel string `json:"channel"`
Promoted bool `json:"promoted"`
Changes []Change `json:"changes"`
Downloads map[string]Download `json:"downloads"`
}
VersionFamilyBuild represents information about a build in the version group context
type VersionFamilyBuildsResponse ¶
type VersionFamilyBuildsResponse struct {
ProjectID string `json:"project_id"`
ProjectName string `json:"project_name"`
VersionGroup string `json:"version_group"`
Versions []string `json:"versions"`
Builds []VersionFamilyBuild `json:"builds"`
}
VersionFamilyBuildsResponse represents a list of available builds for a version group
type VersionFamilyResponse ¶
type VersionFamilyResponse struct {
ProjectID string `json:"project_id"`
ProjectName string `json:"project_name"`
VersionGroup string `json:"version_group"`
Versions []string `json:"versions"`
}
VersionFamilyResponse represents information about a project's version group