Documentation ¶
Overview ¶
Package api is a client for the minepkg API https://api.minepkg/docs
Index ¶
- Constants
- Variables
- type CrashReport
- type CrashReportFabricDetail
- type CrashReportForgeDetail
- type CrashReportPackage
- type Dependency
- type ErrNoMatchingRelease
- type ErrNoQueryResult
- type ForgeVersion
- type GetProjectsQuery
- type MinepkgAPI
- func (m *MinepkgAPI) CreateProject(p *Project) (*Project, error)
- func (m *MinepkgAPI) DecorateRequest(req *http.Request)
- func (m *MinepkgAPI) DeleteRelease(ctx context.Context, platform string, identifier string) (*Release, error)
- func (m *MinepkgAPI) FindRelease(ctx context.Context, project string, reqs *RequirementQuery) (*Release, error)
- func (m *MinepkgAPI) GetAccount(ctx context.Context) (*User, error)
- func (m *MinepkgAPI) GetProject(ctx context.Context, name string) (*Project, error)
- func (m *MinepkgAPI) GetProjects(ctx context.Context, opts *GetProjectsQuery) ([]Project, error)
- func (m *MinepkgAPI) GetRelease(ctx context.Context, platform string, identifier string) (*Release, error)
- func (m *MinepkgAPI) GetReleaseList(ctx context.Context, project string) ([]*Release, error)
- func (m *MinepkgAPI) HasCredentials() bool
- func (a *MinepkgAPI) NewRelease(m *manifest.Manifest) *Release
- func (a *MinepkgAPI) NewUnpublishedRelease(m *manifest.Manifest) *Release
- func (m *MinepkgAPI) OAuthLogin(c *OAuthLoginConfig) *oauth2.Token
- func (m *MinepkgAPI) PostCrashReport(ctx context.Context, report *CrashReport) error
- func (m *MinepkgAPI) PostProjectMedia(ctx context.Context, project string, content io.Reader) error
- func (m *MinepkgAPI) Project(name string) *Project
- func (m *MinepkgAPI) PutRelease(project string, version string, reader io.Reader) (*Release, error)
- func (m *MinepkgAPI) ReleasesQuery(ctx context.Context, query *ReleasesQuery) (*Release, error)
- type MinepkgError
- type OAuthLoginConfig
- type Project
- type ProjectStats
- type Release
- func (r *Release) DownloadURL() string
- func (r *Release) Filename() string
- func (r *Release) Identifier() string
- func (r *Release) LatestTestedMinecraftVersion() string
- func (r *Release) SemverVersion() *semver.Version
- func (r *Release) Upload(reader io.Reader, size int64) (*Release, error)
- func (r *Release) WorksWithManifest(man *manifest.Manifest) bool
- type ReleaseList
- type ReleaseMeta
- type ReleaseTest
- type ReleasesQuery
- type RequirementQuery
- type Requirements
- type User
Constants ¶
const ( // TypeMod indicates a mod TypeMod = "mod" // TypeModpack indicates a modpack TypeModpack = "modpack" )
Variables ¶
var ( // ErrNotFound gets returned when a 404 occurred ErrNotFound = errors.New("resource not found") // ErrBadRequest gets returned when a 400 occurred ErrBadRequest = errors.New("bad Request") // DefaultURL is "https://api.preview.minepkg.io/v1" DefaultURL = "https://api.preview.minepkg.io/v1" )
var ( ErrNoReleasesForPlatform = errors.New("project has no releases for this platform") ErrProjectDoesNotExist = errors.New("project does not exist") ErrNoReleaseForMinecraftVersion = errors.New("no release exists for the wanted Minecraft version") ErrNoReleaseForVersion = errors.New("no release exists for the wanted Version") ErrNoReleaseWithConstrains = errors.New("no release exists for the given version/minecraft requirement") )
var ErrInvalidMinecraftRequirement = errors.New("minecraft requirement is invalid. Only * or a version number is allowed. No semver")
ErrInvalidMinecraftRequirement is returned if an invalid minecraft requirement was passed
Functions ¶
This section is empty.
Types ¶
type CrashReport ¶
type CrashReport struct { Package CrashReportPackage `json:"package"` Fabric *CrashReportFabricDetail `json:"fabric,omitempty"` Forge *CrashReportForgeDetail `json:"forge,omitempty"` MinecraftVersion string `json:"minecraftVersion"` Server bool `json:"server"` Mods map[string]string `json:"mods"` Logs string `json:"logs,omitempty"` OS string `json:"os,omitempty"` Arch string `json:"arch,omitempty"` JavaVersion string `json:"javaVersion,omitempty"` ExitCode int `json:"exitCode,omitempty"` }
CrashReport is a crash report
type CrashReportFabricDetail ¶
type CrashReportFabricDetail struct { Loader string `json:"loader"` Mapping string `json:"mapping"` }
CrashReportFabricDetail is a the fabric part of the crash report
type CrashReportForgeDetail ¶
type CrashReportForgeDetail struct {
Loader string `json:"loader"`
}
CrashReportForgeDetail is a the forge part of the crash report
type CrashReportPackage ¶
type CrashReportPackage struct { Name string `json:"name"` Platform string `json:"platform"` Version string `json:"version"` }
CrashReportPackage is a package in a crash report
type Dependency ¶
type Dependency struct { // Provider is only minepkg for now. Kept for future extensions Provider string `json:"provider"` // Name is the name of the package (eg. storage-drawers) Name string `json:"name"` // VersionRequirement is a semver version Constraint // Example: `^2.9.22` or `5.x.x` VersionRequirement string `json:"versionRequirement"` // contains filtered or unexported fields }
Dependency in verbose form
type ErrNoMatchingRelease ¶
type ErrNoMatchingRelease struct { // Package is the name of the package that can not be resolved Package string // Requirements are the requirements for this package to resolve (eg. minecraft version) Requirements *RequirementQuery // Err is the underlying error that describes why there is no matching release Err error }
ErrNoMatchingRelease is returned if a wanted package (release) could not be resolved given the requirements
func (*ErrNoMatchingRelease) Error ¶
func (e *ErrNoMatchingRelease) Error() string
type ErrNoQueryResult ¶ added in v0.0.64
type ErrNoQueryResult struct { // Query is the query that did not resolve Query *ReleasesQuery // Err is the underlying error that describes why there was no package found Err error }
ErrNoMatchingRelease is returned if a wanted package query could not be resolved
func (*ErrNoQueryResult) Error ¶ added in v0.0.64
func (e *ErrNoQueryResult) Error() string
type ForgeVersion ¶
type ForgeVersion struct { Branch string `json:"branch"` Build int `json:"build"` Files [][]string `json:"files"` McVersion string `json:"mcversion"` Modified int `json:"modified"` Version string `json:"version"` Recommended bool `json:"recommended"` }
ForgeVersion is a release of forge
type GetProjectsQuery ¶
type GetProjectsQuery struct { Type string `json:"type"` Platform string `json:"platform"` Simple bool `json:"simple"` }
GetProjectsQuery are the query parameters for the GetProjects function
type MinepkgAPI ¶
type MinepkgAPI struct { // HTTP is the internal http client HTTP *http.Client // BaseAPI is the API url used. defaults to `https://api.preview.minepkg.io/v1` APIUrl string APIKey string JWT string User *User }
MinepkgAPI contains credentials and methods to talk to the minepkg api
func NewWithClient ¶
func NewWithClient(client *http.Client) *MinepkgAPI
NewWithClient returns a new MinepkgAPI instance using a custom http client supplied as a first parameter
func (*MinepkgAPI) CreateProject ¶
func (m *MinepkgAPI) CreateProject(p *Project) (*Project, error)
CreateProject creates a new project
func (*MinepkgAPI) DecorateRequest ¶
func (m *MinepkgAPI) DecorateRequest(req *http.Request)
DecorateRequest decorates a provided http request with the User-Agent header and a auth header if set
func (*MinepkgAPI) DeleteRelease ¶ added in v0.0.67
func (m *MinepkgAPI) DeleteRelease(ctx context.Context, platform string, identifier string) (*Release, error)
DeleteRelease gets a single release from a project `identifier` is a project@version string
func (*MinepkgAPI) FindRelease ¶
func (m *MinepkgAPI) FindRelease(ctx context.Context, project string, reqs *RequirementQuery) (*Release, error)
FindRelease gets the latest release matching the passed requirements via `RequirementQuery`
func (*MinepkgAPI) GetAccount ¶
func (m *MinepkgAPI) GetAccount(ctx context.Context) (*User, error)
GetAccount gets the account information
func (*MinepkgAPI) GetProject ¶
GetProject gets a single project
func (*MinepkgAPI) GetProjects ¶
func (m *MinepkgAPI) GetProjects(ctx context.Context, opts *GetProjectsQuery) ([]Project, error)
GetProjects gets all projects matching a query
func (*MinepkgAPI) GetRelease ¶
func (m *MinepkgAPI) GetRelease(ctx context.Context, platform string, identifier string) (*Release, error)
GetRelease gets a single release from a project `identifier` is a project@version string
func (*MinepkgAPI) GetReleaseList ¶
GetReleaseList gets a all available releases for a project
func (*MinepkgAPI) HasCredentials ¶
func (m *MinepkgAPI) HasCredentials() bool
HasCredentials returns true if a jwt or api is set
func (*MinepkgAPI) NewRelease ¶
func (a *MinepkgAPI) NewRelease(m *manifest.Manifest) *Release
NewRelease returns a `Release` object. Only exists locally. Can be used to POST a new release to the API
func (*MinepkgAPI) NewUnpublishedRelease ¶
func (a *MinepkgAPI) NewUnpublishedRelease(m *manifest.Manifest) *Release
NewUnpublishedRelease returns a `Release` object that has `Meta.published` set to false. should be used if you want to upload an artifact after publishing this release Only exists locally. Can be used to POST a new release to the API
func (*MinepkgAPI) OAuthLogin ¶
func (m *MinepkgAPI) OAuthLogin(c *OAuthLoginConfig) *oauth2.Token
OAuthLogin opens a browser that prompts the user to authorize this app and returns oauth credentials
func (*MinepkgAPI) PostCrashReport ¶
func (m *MinepkgAPI) PostCrashReport(ctx context.Context, report *CrashReport) error
PostCrashReport posts a new crash report
func (*MinepkgAPI) PostProjectMedia ¶
PostProjectMedia uploads a new image to a project
func (*MinepkgAPI) Project ¶
func (m *MinepkgAPI) Project(name string) *Project
Project returns a Project object without fetching it from the API
func (*MinepkgAPI) PutRelease ¶
PutRelease uploads a new release
func (*MinepkgAPI) ReleasesQuery ¶ added in v0.0.63
func (m *MinepkgAPI) ReleasesQuery(ctx context.Context, query *ReleasesQuery) (*Release, error)
FindRelease gets the latest release matching the passed requirements via `RequirementQuery`
type MinepkgError ¶
type MinepkgError struct { StatusCode uint16 `json:"statusCode"` Status string `json:"error"` Message string `json:"message"` // ResolveError is only present for release queries ResolveError string `json:"resolveError"` }
MinepkgError is the json response if the response was not successful
func (MinepkgError) Error ¶
func (m MinepkgError) Error() string
type OAuthLoginConfig ¶
OAuthLoginConfig describes your oauth app
type Project ¶
type Project struct { Name string `json:"name"` Type string `json:"type"` Description string `json:"description,omitempty"` Readme string `json:"readme,omitempty"` Links struct { Source string `json:"source,omitempty"` Homepage string `json:"homepage,omitempty"` } `json:"links,omitempty"` Stats *ProjectStats `json:"stats,omitempty"` Unofficial bool `json:"unofficial,omitempty"` // contains filtered or unexported fields }
Project is a project
func (*Project) CreateRelease ¶
CreateRelease will create a new release
func (*Project) GetReleases ¶
GetReleases gets a all available releases for this project
type ProjectStats ¶
type ProjectStats struct {
TotalDownloads uint32 `json:"totalDownloads"`
}
ProjectStats contains statistics for a project
type Release ¶
type Release struct { *manifest.Manifest Meta *ReleaseMeta `json:"meta,omitempty"` Tests map[string]ReleaseTest `json:"tests,omitempty"` // contains filtered or unexported fields }
Release is a released version of a project
func (*Release) DownloadURL ¶
DownloadURL returns the download url for this release
func (*Release) Filename ¶
Filename returns this release in a "project@version.jar" format. eg: `fabric@0.2.0.jar`
func (*Release) Identifier ¶
Identifier returns this release in a "project@version" format. eg: `fabric@0.2.0`
func (*Release) LatestTestedMinecraftVersion ¶
LatestTestedMinecraftVersion returns the last (highest) tested Minecraft version for this release
func (*Release) SemverVersion ¶
func (r *Release) SemverVersion() *semver.Version
SemverVersion returns the Version as a `semver.Version` struct
type ReleaseList ¶
type ReleaseList []*Release
ReleaseList is a slice of releases with a helper function
func (*ReleaseList) Latest ¶
func (r *ReleaseList) Latest() *Release
Latest returns the latest release from the release list based on the semver version number
type ReleaseMeta ¶
type ReleaseMeta struct { IPFSHash string `json:"ipfsHash,omitempty"` Sha256 string `json:"sha256,omitempty"` Published bool `json:"published"` Unofficial *bool `json:"unofficial,omitempty"` CreatedAt *time.Time `json:"createdAt,omitempty"` }
ReleaseMeta is metadata for a release. found in the `meta` field
type ReleaseTest ¶
type ReleaseTest struct { ID string `json:"_id"` Minecraft string `json:"minecraft"` Works bool `json:"works"` }
ReleaseTest is a test of the package
type ReleasesQuery ¶ added in v0.0.63
type ReleasesQuery struct { // Platform can bei either fabric or forge Platform string // Name should be the name of the wanted package Name string // Minecraft version for the project. This has to be either ” or a valid version number. // a semver string is NOT allowed here Minecraft string // VersionRange can be any semver string specifying the desired package version VersionRange string }
ReleasesQuery is a query to find a release
type RequirementQuery ¶
type RequirementQuery struct { // Version to return. this can be any semver string Version string // Minecraft version for the project. This has to be either '*' or a valid version number. // any semver string is NOT allowed here Minecraft string // Platform can bei either fabric or forge Platform string }
RequirementQuery is a query for a release describing contained requirements
type Requirements ¶
type Requirements struct { Minecraft string `json:"minecraft"` Forge string `json:"forge,omitempty"` Fabric string `json:"fabric,omitempty"` }
Requirements contains the wanted Minecraft version and either the required Forge or Fabric version