Documentation
¶
Overview ¶
Package v3 implements the NuGet v3 protocol.
It provides service index discovery, package search, metadata access, and package download functionality for NuGet v3 feeds.
Index ¶
- Constants
- type AutocompleteClient
- func (c *AutocompleteClient) AutocompletePackageIDs(ctx context.Context, sourceURL, query string, skip, take int, prerelease bool) (*AutocompleteResponse, error)
- func (c *AutocompleteClient) AutocompletePackageVersions(ctx context.Context, sourceURL, packageID string, prerelease bool) (*AutocompleteResponse, error)
- type AutocompleteResponse
- type Dependency
- type DependencyGroup
- type DownloadClient
- func (c *DownloadClient) DownloadNuspec(ctx context.Context, sourceURL, packageID, version string) (io.ReadCloser, error)
- func (c *DownloadClient) DownloadPackage(ctx context.Context, sourceURL, packageID, version string) (io.ReadCloser, error)
- func (c *DownloadClient) GetPackageVersions(ctx context.Context, sourceURL, packageID string) ([]string, error)
- type MetadataClient
- func (c *MetadataClient) GetPackageMetadata(ctx context.Context, sourceURL, packageID string) (*RegistrationIndex, error)
- func (c *MetadataClient) GetVersionMetadata(ctx context.Context, sourceURL, packageID, version string) (*RegistrationCatalog, error)
- func (c *MetadataClient) ListVersions(ctx context.Context, sourceURL, packageID string) ([]string, error)
- func (c *MetadataClient) SetHTTPCache(httpCache *cache.DiskCache)
- type PackageType
- type RegistrationCatalog
- type RegistrationIndex
- type RegistrationLeaf
- type RegistrationPage
- type Resource
- type SearchClient
- type SearchOptions
- type SearchResponse
- type SearchResult
- type SearchVersion
- type ServiceIndex
- type ServiceIndexClient
- func (c *ServiceIndexClient) ClearCache()
- func (c *ServiceIndexClient) GetAllResourceURLs(ctx context.Context, sourceURL, resourceType string) ([]string, error)
- func (c *ServiceIndexClient) GetResourceURL(ctx context.Context, sourceURL, resourceType string) (string, error)
- func (c *ServiceIndexClient) GetServiceIndex(ctx context.Context, sourceURL string) (*ServiceIndex, error)
Constants ¶
const ( // Search ResourceTypeSearchQueryService = "SearchQueryService" ResourceTypeSearchAutocompleteService = "SearchAutocompleteService" // Registration (metadata) ResourceTypeRegistrationsBaseURL = "RegistrationsBaseUrl" // Package download ResourceTypePackageBaseAddress = "PackageBaseAddress" // Package publish ResourceTypePackagePublish = "PackagePublish" // Catalog ResourceTypeCatalog = "Catalog/3.0.0" )
Well-known resource types
const ServiceIndexCacheTTL = 40 * time.Minute
ServiceIndexCacheTTL is the default service index cache TTL (40 minutes as per NuGet spec).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutocompleteClient ¶
type AutocompleteClient struct {
// contains filtered or unexported fields
}
AutocompleteClient provides package ID and version autocomplete functionality.
func NewAutocompleteClient ¶
func NewAutocompleteClient(httpClient *nugethttp.Client, serviceIndexClient *ServiceIndexClient) *AutocompleteClient
NewAutocompleteClient creates a new autocomplete client.
func (*AutocompleteClient) AutocompletePackageIDs ¶
func (c *AutocompleteClient) AutocompletePackageIDs(ctx context.Context, sourceURL, query string, skip, take int, prerelease bool) (*AutocompleteResponse, error)
AutocompletePackageIDs returns package ID suggestions for a given query.
func (*AutocompleteClient) AutocompletePackageVersions ¶
func (c *AutocompleteClient) AutocompletePackageVersions(ctx context.Context, sourceURL, packageID string, prerelease bool) (*AutocompleteResponse, error)
AutocompletePackageVersions returns version suggestions for a given package ID.
type AutocompleteResponse ¶
type AutocompleteResponse struct {
TotalHits int `json:"totalHits"`
Data []string `json:"data"`
Context any `json:"@context,omitempty"`
}
AutocompleteResponse represents the response from autocomplete API.
type Dependency ¶
Dependency represents a single package dependency.
type DependencyGroup ¶
type DependencyGroup struct {
TargetFramework string `json:"targetFramework,omitempty"`
Dependencies []Dependency `json:"dependencies,omitempty"`
}
DependencyGroup represents dependencies for a specific target framework.
type DownloadClient ¶
type DownloadClient struct {
// contains filtered or unexported fields
}
DownloadClient provides package download functionality.
func NewDownloadClient ¶
func NewDownloadClient(httpClient *nugethttp.Client, serviceIndexClient *ServiceIndexClient) *DownloadClient
NewDownloadClient creates a new download client.
func (*DownloadClient) DownloadNuspec ¶
func (c *DownloadClient) DownloadNuspec(ctx context.Context, sourceURL, packageID, version string) (io.ReadCloser, error)
DownloadNuspec downloads the .nuspec manifest file for a package. Caller is responsible for closing the response body.
func (*DownloadClient) DownloadPackage ¶
func (c *DownloadClient) DownloadPackage(ctx context.Context, sourceURL, packageID, version string) (io.ReadCloser, error)
DownloadPackage downloads a .nupkg file and returns the response body. Caller is responsible for closing the response body.
func (*DownloadClient) GetPackageVersions ¶
func (c *DownloadClient) GetPackageVersions(ctx context.Context, sourceURL, packageID string) ([]string, error)
GetPackageVersions lists all available versions for a package. Uses the package base address versions endpoint.
type MetadataClient ¶
type MetadataClient struct {
// contains filtered or unexported fields
}
MetadataClient provides package metadata functionality.
func NewMetadataClient ¶
func NewMetadataClient(httpClient *nugethttp.Client, serviceIndexClient *ServiceIndexClient) *MetadataClient
NewMetadataClient creates a new metadata client.
func (*MetadataClient) GetPackageMetadata ¶
func (c *MetadataClient) GetPackageMetadata(ctx context.Context, sourceURL, packageID string) (*RegistrationIndex, error)
GetPackageMetadata retrieves metadata for a specific package ID. Returns all versions and their metadata.
func (*MetadataClient) GetVersionMetadata ¶
func (c *MetadataClient) GetVersionMetadata(ctx context.Context, sourceURL, packageID, version string) (*RegistrationCatalog, error)
GetVersionMetadata retrieves metadata for a specific package version.
func (*MetadataClient) ListVersions ¶
func (c *MetadataClient) ListVersions(ctx context.Context, sourceURL, packageID string) ([]string, error)
ListVersions returns all available versions for a package.
func (*MetadataClient) SetHTTPCache ¶
func (c *MetadataClient) SetHTTPCache(httpCache *cache.DiskCache)
SetHTTPCache configures the HTTP disk cache for registration API responses. Cache key format matches NuGet.Client: list_{packageid}_index, list_{packageid}_range_{lower}-{upper}
type PackageType ¶
PackageType represents the type of package.
type RegistrationCatalog ¶
type RegistrationCatalog struct {
ID string `json:"@id"`
PackageID string `json:"id"`
Version string `json:"version"`
Authors string `json:"authors,omitempty"`
Description string `json:"description,omitempty"`
IconURL string `json:"iconUrl,omitempty"`
LicenseURL string `json:"licenseUrl,omitempty"`
LicenseExpression string `json:"licenseExpression,omitempty"`
ProjectURL string `json:"projectUrl,omitempty"`
Published string `json:"published,omitempty"`
RequireLicenseAcceptance bool `json:"requireLicenseAcceptance"`
Summary string `json:"summary,omitempty"`
Tags []string `json:"tags,omitempty"`
Title string `json:"title,omitempty"`
DependencyGroups []DependencyGroup `json:"dependencyGroups,omitempty"`
PackageTypes []PackageType `json:"packageTypes,omitempty"`
}
RegistrationCatalog contains detailed package metadata.
type RegistrationIndex ¶
type RegistrationIndex struct {
Count int `json:"count"`
Items []RegistrationPage `json:"items"`
}
RegistrationIndex represents the top-level registration index.
type RegistrationLeaf ¶
type RegistrationLeaf struct {
ID string `json:"@id"`
CatalogEntry *RegistrationCatalog `json:"catalogEntry"`
PackageContent string `json:"packageContent"`
}
RegistrationLeaf represents a single package version registration.
type RegistrationPage ¶
type RegistrationPage struct {
ID string `json:"@id"`
Count int `json:"count"`
Items []RegistrationLeaf `json:"items,omitempty"`
Lower string `json:"lower"`
Upper string `json:"upper"`
}
RegistrationPage represents a page of registration entries.
type Resource ¶
type Resource struct {
ID string `json:"@id"`
Type string `json:"@type"`
Comment string `json:"comment,omitempty"`
}
Resource represents a service resource in the service index.
type SearchClient ¶
type SearchClient struct {
// contains filtered or unexported fields
}
SearchClient provides package search functionality.
func NewSearchClient ¶
func NewSearchClient(httpClient *nugethttp.Client, serviceIndexClient *ServiceIndexClient) *SearchClient
NewSearchClient creates a new search client.
func (*SearchClient) Search ¶
func (c *SearchClient) Search(ctx context.Context, sourceURL string, opts SearchOptions) (*SearchResponse, error)
Search searches for packages matching the query.
func (*SearchClient) SearchSimple ¶
func (c *SearchClient) SearchSimple(ctx context.Context, sourceURL, query string) (*SearchResponse, error)
SearchSimple performs a simple search with default options.
type SearchOptions ¶
type SearchOptions struct {
Query string
Skip int
Take int
Prerelease bool
SemVerLevel string // "2.0.0" for SemVer 2.0 support
}
SearchOptions holds search parameters.
type SearchResponse ¶
type SearchResponse struct {
TotalHits int `json:"totalHits"`
Data []SearchResult `json:"data"`
Context any `json:"@context,omitempty"`
}
SearchResponse represents the response from the search API.
type SearchResult ¶
type SearchResult struct {
ID string `json:"@id"`
Type string `json:"@type"`
Registration string `json:"registration,omitempty"`
PackageID string `json:"id"`
Version string `json:"version"`
Description string `json:"description"`
Summary string `json:"summary,omitempty"`
Title string `json:"title,omitempty"`
IconURL string `json:"iconUrl,omitempty"`
LicenseURL string `json:"licenseUrl,omitempty"`
ProjectURL string `json:"projectUrl,omitempty"`
Tags []string `json:"tags,omitempty"`
Authors []string `json:"authors,omitempty"`
TotalDownloads int64 `json:"totalDownloads"`
Verified bool `json:"verified"`
Versions []SearchVersion `json:"versions,omitempty"`
}
SearchResult represents a single search result.
type SearchVersion ¶
type SearchVersion struct {
Version string `json:"version"`
Downloads int64 `json:"downloads"`
ID string `json:"@id"`
}
SearchVersion represents a version in search results.
type ServiceIndex ¶
type ServiceIndex struct {
Version string `json:"version"`
Resources []Resource `json:"resources"`
Context any `json:"@context,omitempty"`
}
ServiceIndex represents the NuGet v3 service index. See: https://docs.microsoft.com/en-us/nuget/api/service-index
type ServiceIndexClient ¶
type ServiceIndexClient struct {
// contains filtered or unexported fields
}
ServiceIndexClient provides access to NuGet v3 service index.
func NewServiceIndexClient ¶
func NewServiceIndexClient(httpClient *nugethttp.Client) *ServiceIndexClient
NewServiceIndexClient creates a new service index client.
func NewServiceIndexClientWithCache ¶
func NewServiceIndexClientWithCache(httpClient *nugethttp.Client, mtCache *cache.MultiTierCache) *ServiceIndexClient
NewServiceIndexClientWithCache creates a new service index client with optional disk cache.
func (*ServiceIndexClient) ClearCache ¶
func (c *ServiceIndexClient) ClearCache()
ClearCache removes all cached service indexes.
func (*ServiceIndexClient) GetAllResourceURLs ¶
func (c *ServiceIndexClient) GetAllResourceURLs(ctx context.Context, sourceURL, resourceType string) ([]string, error)
GetAllResourceURLs finds all resources of the given type. Matches resource types with or without version suffixes (e.g., "PackageBaseAddress" matches "PackageBaseAddress/3.0.0").
func (*ServiceIndexClient) GetResourceURL ¶
func (c *ServiceIndexClient) GetResourceURL(ctx context.Context, sourceURL, resourceType string) (string, error)
GetResourceURL finds the first resource of the given type. Matches resource types with or without version suffixes (e.g., "PackageBaseAddress" matches "PackageBaseAddress/3.0.0").
func (*ServiceIndexClient) GetServiceIndex ¶
func (c *ServiceIndexClient) GetServiceIndex(ctx context.Context, sourceURL string) (*ServiceIndex, error)
GetServiceIndex retrieves the service index for a given source URL. Caches the result for ServiceIndexCacheTTL.