Documentation
¶
Overview ¶
Package ecosystems provides a client for the ecosyste.ms APIs.
This package wraps the generated OpenAPI clients for packages.ecosyste.ms and repos.ecosyste.ms, providing a higher-level API for common operations.
Index ¶
- Constants
- func PURLToName(purl packageurl.PackageURL) string
- func PURLToRegistry(purl packageurl.PackageURL) string
- func ParsePURL(s string) (packageurl.PackageURL, error)
- func SupportedPURLTypes() []string
- type Client
- func (c *Client) BulkLookup(ctx context.Context, purls []string) (map[string]*packages.PackageWithRegistry, error)
- func (c *Client) GetAdvisoriesByRepoURL(ctx context.Context, repositoryURL string, maxItems int) ([]advisories.Advisory, error)
- func (c *Client) GetAllVersions(ctx context.Context, registry, name string) ([]packages.Version, error)
- func (c *Client) GetAllVersionsPURL(ctx context.Context, purl packageurl.PackageURL) ([]packages.Version, error)
- func (c *Client) GetCommitsSummary(ctx context.Context, repositoryURL string) (*commits.Repository, error)
- func (c *Client) GetDependentPackages(ctx context.Context, registry, name string, maxItems int) ([]packages.Package, error)
- func (c *Client) GetIssuesSummary(ctx context.Context, repositoryURL string) (*issues.Repository, error)
- func (c *Client) GetRepository(ctx context.Context, url string) (*repos.Repository, error)
- func (c *Client) GetVersion(ctx context.Context, registry, name, version string) (*packages.VersionWithDependencies, error)
- func (c *Client) GetVersionPURL(ctx context.Context, purl packageurl.PackageURL) (*packages.VersionWithDependencies, error)
- func (c *Client) ListRegistries(ctx context.Context) ([]packages.Registry, error)
- func (c *Client) Lookup(ctx context.Context, purl string) (*packages.PackageWithRegistry, error)
- func (c *Client) LookupByRegistryAndName(ctx context.Context, registry, name string) (*packages.Package, error)
- func (c *Client) LookupPURL(ctx context.Context, purl packageurl.PackageURL) (*packages.Package, error)
- func (c *Client) LookupPackagesByPURL(ctx context.Context, purl string) ([]packages.PackageWithRegistry, error)
- func (c *Client) LookupPackagesByRepositoryURL(ctx context.Context, repositoryURL string, maxItems int) ([]packages.PackageWithRegistry, error)
- type Option
- func WithAPIKey(key string) Option
- func WithAdvisoriesServer(server string) Option
- func WithBatchSize(size int) Option
- func WithCommitsServer(server string) Option
- func WithFrom(email string) Option
- func WithHTTPClient(client *http.Client) Option
- func WithIssuesServer(server string) Option
- func WithPackagesServer(server string) Option
- func WithReposServer(server string) Option
Constants ¶
const ( DefaultPackagesServer = packages.ServerURLHTTPSPackagesEcosysteMsAPIV1 DefaultReposServer = repos.ServerURLHTTPSReposEcosysteMsAPIV1 DefaultAdvisoriesServer = advisories.ServerURLHTTPSAdvisoriesEcosysteMsAPIV1 DefaultCommitsServer = commits.ServerURLHTTPSCommitsEcosysteMsAPIV1 DefaultIssuesServer = issues.ServerURLHTTPSIssuesEcosysteMsAPIV1 DefaultTimeout = 30 * time.Second MaxBulkLookupSize = 100 )
Variables ¶
This section is empty.
Functions ¶
func PURLToName ¶
func PURLToName(purl packageurl.PackageURL) string
PURLToName converts a PURL to the ecosyste.ms package name format.
func PURLToRegistry ¶
func PURLToRegistry(purl packageurl.PackageURL) string
PURLToRegistry converts a PURL type to the ecosyste.ms registry name.
func ParsePURL ¶
func ParsePURL(s string) (packageurl.PackageURL, error)
ParsePURL parses a PURL string.
func SupportedPURLTypes ¶
func SupportedPURLTypes() []string
SupportedPURLTypes returns all PURL types that have registry mappings.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
NewClient creates a new ecosyste.ms API client. The userAgent parameter is required and should identify your application.
func (*Client) BulkLookup ¶
func (c *Client) BulkLookup(ctx context.Context, purls []string) (map[string]*packages.PackageWithRegistry, error)
BulkLookup looks up multiple packages by PURL. Returns a map keyed by PURL with package data. PURLs are processed in batches of the configured size (defaults to MaxBulkLookupSize). Use WithBatchSize to lower the batch size when the server rejects larger requests.
func (*Client) GetAdvisoriesByRepoURL ¶ added in v0.3.0
func (c *Client) GetAdvisoriesByRepoURL(ctx context.Context, repositoryURL string, maxItems int) ([]advisories.Advisory, error)
GetAdvisoriesByRepoURL returns advisories associated with a source repository.
func (*Client) GetAllVersions ¶
func (c *Client) GetAllVersions(ctx context.Context, registry, name string) ([]packages.Version, error)
GetAllVersions gets all versions of a package.
func (*Client) GetAllVersionsPURL ¶
func (c *Client) GetAllVersionsPURL(ctx context.Context, purl packageurl.PackageURL) ([]packages.Version, error)
GetAllVersionsPURL gets all versions for a package using a PURL.
func (*Client) GetCommitsSummary ¶ added in v0.3.0
func (c *Client) GetCommitsSummary(ctx context.Context, repositoryURL string) (*commits.Repository, error)
GetCommitsSummary looks up commit summary metadata for a source repository.
func (*Client) GetDependentPackages ¶ added in v0.3.0
func (c *Client) GetDependentPackages(ctx context.Context, registry, name string, maxItems int) ([]packages.Package, error)
GetDependentPackages returns packages that depend on registry/name.
func (*Client) GetIssuesSummary ¶ added in v0.3.0
func (c *Client) GetIssuesSummary(ctx context.Context, repositoryURL string) (*issues.Repository, error)
GetIssuesSummary looks up issue and pull-request summary metadata for a source repository.
func (*Client) GetRepository ¶
GetRepository looks up a repository by URL.
func (*Client) GetVersion ¶
func (c *Client) GetVersion(ctx context.Context, registry, name, version string) (*packages.VersionWithDependencies, error)
GetVersion gets a specific version of a package.
func (*Client) GetVersionPURL ¶
func (c *Client) GetVersionPURL(ctx context.Context, purl packageurl.PackageURL) (*packages.VersionWithDependencies, error)
GetVersionPURL gets a specific version using a PURL.
func (*Client) ListRegistries ¶
ListRegistries returns all available registries.
func (*Client) LookupByRegistryAndName ¶
func (c *Client) LookupByRegistryAndName(ctx context.Context, registry, name string) (*packages.Package, error)
LookupByRegistryAndName looks up a package by registry and name.
func (*Client) LookupPURL ¶
func (c *Client) LookupPURL(ctx context.Context, purl packageurl.PackageURL) (*packages.Package, error)
LookupPURL looks up a package by its PURL using the registry/name endpoint. This is useful when you need the full Package type rather than PackageWithRegistry.
func (*Client) LookupPackagesByPURL ¶ added in v0.3.0
func (c *Client) LookupPackagesByPURL(ctx context.Context, purl string) ([]packages.PackageWithRegistry, error)
LookupPackagesByPURL looks up package records matching a PURL.
func (*Client) LookupPackagesByRepositoryURL ¶ added in v0.3.0
func (c *Client) LookupPackagesByRepositoryURL(ctx context.Context, repositoryURL string, maxItems int) ([]packages.PackageWithRegistry, error)
LookupPackagesByRepositoryURL looks up package records published from a source repository.
type Option ¶
type Option func(*clientConfig)
func WithAPIKey ¶
WithAPIKey sets the API key for authenticated requests. This provides higher rate limits and access to additional features.
func WithAdvisoriesServer ¶ added in v0.3.0
func WithBatchSize ¶ added in v0.2.0
WithBatchSize sets the number of PURLs sent per BulkLookup request. Values <= 0 or greater than MaxBulkLookupSize fall back to MaxBulkLookupSize. Useful for clients that need to stay within stricter server-side limits.
func WithCommitsServer ¶ added in v0.3.0
func WithFrom ¶
WithFrom sets the From header (email address) for API requests. This helps ecosyste.ms identify who is making requests.
func WithHTTPClient ¶
func WithIssuesServer ¶ added in v0.3.0
func WithPackagesServer ¶
func WithReposServer ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package advisories provides primitives to interact with the openapi HTTP API.
|
Package advisories provides primitives to interact with the openapi HTTP API. |
|
Package commits provides primitives to interact with the openapi HTTP API.
|
Package commits provides primitives to interact with the openapi HTTP API. |
|
Package issues provides primitives to interact with the openapi HTTP API.
|
Package issues provides primitives to interact with the openapi HTTP API. |
|
Package packages provides primitives to interact with the openapi HTTP API.
|
Package packages provides primitives to interact with the openapi HTTP API. |
|
Package repos provides primitives to interact with the openapi HTTP API.
|
Package repos provides primitives to interact with the openapi HTTP API. |