Skip to main content

PackageUpdates

c.PackageUpdates calls the API's PackageUpdates group. The updates the package index has for the host.

Methods​

MethodReturnsPermissionDescription
List(ctx, hostname)*Response[Collection[PackageUpdatesAvailable]]package:readList the packages the index has newer versions of.
Update(ctx, hostname)*Response[Collection[PackageUpdatesResult]]package:writeRefresh the package index.

List​

func (s *PackageUpdatesService) List(
ctx context.Context,
hostname string,
) (*Response[Collection[PackageUpdatesAvailable]], error)

List the packages the index has newer versions of.

Runs apt list --upgradable: each package with its installed version and the version the index has. Refresh the index first for what the repositories have now.

It sends GET /api/node/{hostname}/package/updates, and needs the permission package:read.

The examples of the method's definition:

Two updates, go run package_updates.go list:

resp, err := c.PackageUpdates.List(ctx, target)

Update​

func (s *PackageUpdatesService) Update(
ctx context.Context,
hostname string,
) (*Response[Collection[PackageUpdatesResult]], error)

Refresh the package index.

Runs apt-get update. It reports changed: true when the Release file of a repository under /var/lib/apt/lists changed, and changed: false when each repository was unchanged.

It sends PUT /api/node/{hostname}/package/updates, and needs the permission package:write.

The examples of the method's definition:

The repositories are unchanged since the last refresh, go run package_updates.go update:

resp, err := c.PackageUpdates.Update(ctx, target)

Types​

The fields of each type are the properties of its schema in the API's spec.

PackageUpdatesAvailable​

FieldTypeDescription
CurrentVersionstringThe installed version.
ErrorstringError message if the agent failed.
HostnamestringHostname of the agent that produced this result.
NamestringThe package.
NewVersionstringThe version the index has.
StatusRowStatusWhat happened on the host: ok, the operation ran and succeeded; failed, it ran and did not succeed; skipped, the host's OS family does not support it; timeout, the host did not answer, so nobody knows whether it ran.

PackageUpdatesResult​

FieldTypeDescription
ChangedboolWhether the refresh got new index data.
ErrorstringError message if the agent failed.
HostnamestringHostname of the agent that produced this result.
StatusRowStatusWhat happened on the host: ok, the operation ran and succeeded; failed, it ran and did not succeed; skipped, the host's OS family does not support it; timeout, the host did not answer, so nobody knows whether it ran.

RowStatus​

What happened on the host: ok, the operation ran and succeeded; failed, it ran and did not succeed; skipped, the host's OS family does not support it; timeout, the host did not answer, so nobody knows whether it ran.

A string, one of ok, failed, skipped, timeout.

Example​

examples/sdk/client/package_updates.go runs each example of this page. With no argument, it lists them.