PackageUpdates
c.PackageUpdates calls the API's PackageUpdates group. The updates the package
index has for the host.
Methods
| Method | Returns | Permission | Description |
|---|---|---|---|
List(ctx, hostname) | *Response[Collection[PackageUpdatesAvailable]] | package:read | List the packages the index has newer versions of. |
Update(ctx, hostname) | *Response[Collection[PackageUpdatesResult]] | package:write | Refresh 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
| Field | Type | Description |
|---|---|---|
CurrentVersion | string | The installed version. |
Error | string | Error message if the agent failed. |
Hostname | string | Hostname of the agent that produced this result. |
Name | string | The package. |
NewVersion | string | The version the index has. |
Status | 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. |
PackageUpdatesResult
| Field | Type | Description |
|---|---|---|
Changed | bool | Whether the refresh got new index data. |
Error | string | Error message if the agent failed. |
Hostname | string | Hostname of the agent that produced this result. |
Status | 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. |
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.