Documentation ¶
Overview ¶
peclapi package implements a HTTP-based client for the REST API initially used by pecl. It only supports the default pecl channel served at https://pecl.php.net/rest/. Note that this API is quite dated and might return some unexpected results (eg. redis extension is in the Database category but ListPackagesInCategory("Database") won't return redis).
Index ¶
- type Client
- func (c Client) DescribePackage(pkgName string) (Package, error)
- func (c Client) DescribeRelease(pkgName, pkgVersion string) (Release, error)
- func (c Client) DownloadRelease(release Release) (io.Reader, error)
- func (c Client) ListPackages() ([]string, error)
- func (c Client) ListPackagesInCategory(category string) ([]string, error)
- func (c Client) ListReleases(pkgName string) (PackageReleases, error)
- type ClientOpt
- type Package
- type PackageReleases
- type Release
- type Stability
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents the HTTP-based client for https://pecl.php.net/rest/.
func NewClient ¶
NewClient creates a new HTTP-based client for the API hosted at pecl.php.net/rest/. It takes ClientOpt as arguments. These could be used to set Client's internal properties (baseURI or httpClient).
func (Client) DescribePackage ¶
DescribePackage returns the details of a given package as served by the endpoint /p/{packageName}/info.xml. It returns an error if the request fails or if the endpoint returns a non-200 status code.
func (Client) DescribeRelease ¶
DescribeRelease returns the details about a given release of a given package, as served by the endpoint /r/{packageName}/{release}.xml. It returns an error if the request fails or if the endpoint returns a non-200 status code.
func (Client) DownloadRelease ¶
DownloadRelease downloads a given package release and returns an io.ReadCloser from which a tgz can be read. An error is returned if the HTTP request fails, if a bad status code is returned or if the downloaded file is not an application/x-gzip.
func (Client) ListPackages ¶
ListPackages returns the list of packages available at the endpoint /p/packages.xml. It returns an error if the HTTP request fails or if the endpoint returns a non-200 status code.
func (Client) ListPackagesInCategory ¶
ListPackagesInCategory returns the list of packages in the given category, as served by the endpoint /c/{category}/package.xml. It returns an error if the request fails or if th endpoint returns a non-200 status code.
func (Client) ListReleases ¶
func (c Client) ListReleases(pkgName string) (PackageReleases, error)
ListReleases returns the list of releases associated with their stability for a given package, as served by the endpoint /r/{packageName}/allreleases.xml. It returns an error if the request fails or if the endpoint returns a non-200 status code.
type ClientOpt ¶
type ClientOpt func(*Client)
ClientOpt are functions used by NewClient() to set Clients' internal properties.
func WithBaseURI ¶
WithBaseURI returns a ClientOpt that could be passed to NewClient to set the API base URI.
func WithHttpClient ¶
WithHttpClient returns a ClientOpt that could be passed to NewClient to set the HTTP client used to query the API.
type Package ¶
type Package struct { Name string `xml:"n"` Category string `xml:"ca"` License string `xml:"l"` Summary string `xml:"s"` Description string `xml:"d"` ReleasesLocation string `xml:"r"` ParentPackage string `xml:"pa"` DeprecatingPackage string `xml:"dp"` DeprecatingChannel string `xml:"dc"` }
Package represents a detailed package as returned by DescribePackage(). See https://pear.php.net/dtd/rest.package.xsd.
type PackageReleases ¶
PackageReleases is the list of releases associated to their stability for a given package. It supports sorting.
func (PackageReleases) Sort ¶
func (pr PackageReleases) Sort() []string
Sort returns a slice containing the releases of the package sorted in descending order.
type Release ¶
type Release struct { Package string `xml:"p"` Version string `xml:"v"` Stability string `xml:"st"` License string `xml:"l"` Maintainer string `xml:"m"` Summary string `xml:"s"` Description string `xml:"d"` ReleaseDate string `xml:"da"` ReleaseNotes string `xml:"n"` PartialURI string `xml:"g"` PackageXML string `xml:"x"` }
Release represents the details of a specific release of a package. See https://pear.php.net/dtd/rest.release.xsd.