Skip to main content

Package

The packages installed on the host. osapi behavior get --name package and osapi behavior method get show the same.

Behavior​

Namepackage
DescriptionThe packages installed on the host
Placementnode
Internalno
APIyes
CLIyes
Nextno
Platformsdebian, linux, darwin
Sudonone
Runsnone
Writesnone
Keeps stateno
Usesnone
Used bynone

Methods (4)​

NAMEVERBHTTPROUTEPERMISSIONDESCRIPTION
listreadGET/api/node/{hostname}/packagepackage:readList the packages installed on the host
getreadGET/api/node/{hostname}/package/{name}package:readGet one installed package
createwritePOST/api/node/{hostname}/packagepackage:writeInstall a package
deletewriteDELETE/api/node/{hostname}/package/{name}package:writeRemove a package

Types (4)​

NAMEINPUTOUTPUT
listListInput[]Installed { name, version, architecture, manager, description, size }
getGetInput { name* }Installed { name, version, architecture, manager, description, size }
createCreateInput { name*, version }Result { name, changed }
deleteDeleteInput { name* }Result { name, changed }

Settings (0)​

None. Declare them with behavior.Config.

Telemetry​

Spanbehavior.package.<method>
Child spansexec apt-get, exec dpkg-query, exec brew, exec rpm
Metricsosapi_behavior_calls_total, osapi_behavior_duration_seconds, osapi_behavior_changes_total
Attributesosapi.behavior.name, osapi.behavior.method, osapi.behavior.verb, osapi.behavior.outcome, osapi.behavior.changed
Recorded inputsname (get, create, delete)

Method list​

Namelist
Verbread
DescriptionList the packages installed on the host
DetailLists each installed package with its version: dpkg on the Debian family, rpm on the other Linux families, and Homebrew on macOS.
HTTPGET
Route/api/node/{hostname}/package
Permissionpackage:read
Commandosapi client node package list
Input typeListInput
Output type[]Installed

Input (0)​

None. The method takes no input; its command needs only --target.

Output (6)​

FIELDTYPEDESCRIPTION
namestringThe package
versionstringThe installed version
architecturestringThe architecture it is built for, such as amd64
managerstringThe package database that has it: dpkg, rpm or brew
descriptionstringIts one-line summary
sizeintegerIts installed size in bytes

Examples (3)​

EXAMPLEINPUTOUTPUT
A Debian host(none)[architecture=amd64, description=command line tool for transferring data with URL syntax, manager=dpkg, name=curl, size=512000, version=8.5.0-2ubuntu10]
A Fedora host(none)[architecture=x86_64, description=A utility for getting files from remote servers, manager=rpm, name=curl, size=790000, version=8.6.0-7.fc40]
A Mac(none)[manager=brew, name=jq, version=1.7.1]

Method get​

Nameget
Verbread
DescriptionGet one installed package
DetailReads one package from the same list. A package that is not installed is not found.
HTTPGET
Route/api/node/{hostname}/package/{name}
Permissionpackage:read
Commandosapi client node package get
Input typeGetInput
Output typeInstalled

Input (1)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[a-zA-Z0-9][a-zA-Z0-9.+_:~=-]*$, max length 255The package, such as curl

Output (6)​

FIELDTYPEDESCRIPTION
namestringThe package
versionstringThe installed version
architecturestringThe architecture it is built for, such as amd64
managerstringThe package database that has it: dpkg, rpm or brew
descriptionstringIts one-line summary
sizeintegerIts installed size in bytes

Examples (3)​

EXAMPLEINPUTOUTPUT
An installed packagename=curlname=curl, version=8.5.0-2ubuntu10, architecture=amd64, manager=dpkg, description=command line tool for transferring data with URL syntax, size=512000
An installed formulaname=jqname=jq, version=1.7.1, manager=brew
An installed RPMname=curlname=curl, version=8.6.0-7.fc40, architecture=x86_64, manager=rpm

Method create​

Namecreate
Verbwrite
DescriptionInstall a package
DetailInstalls the package with apt-get install, at the version when one is given. A package that is installed, at that version when one is given, does not change and reports changed: false. It runs on the Debian family only, and elsewhere reports skipped.
HTTPPOST
Route/api/node/{hostname}/package
Permissionpackage:write
Commandosapi client node package create
Input typeCreateInput
Output typeResult

Input (2)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[a-zA-Z0-9][a-zA-Z0-9.+_:~=-]*$, max length 255The package to install, such as curl
versionstringnopattern ^[0-9][A-Za-z0-9.+~:-]*$, max length 255The version to install, such as 8.5.0-2ubuntu10; the newest when empty

Output (2)​

FIELDTYPEDESCRIPTION
namestringThe package
changedbooleanWhether the host changed

Examples (1)​

EXAMPLEINPUTOUTPUT
Install a packagename=treename=tree, changed=true

Method delete​

Namedelete
Verbwrite
DescriptionRemove a package
DetailRemoves the package with apt-get remove. A package that is not installed does not change and reports changed: false. It runs on the Debian family only, and elsewhere reports skipped.
HTTPDELETE
Route/api/node/{hostname}/package/{name}
Permissionpackage:write
Commandosapi client node package delete
Input typeDeleteInput
Output typeResult

Input (1)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[a-zA-Z0-9][a-zA-Z0-9.+_:~=-]*$, max length 255The package to remove, such as curl

Output (2)​

FIELDTYPEDESCRIPTION
namestringThe package
changedbooleanWhether the host changed

Examples (2)​

EXAMPLEINPUTOUTPUT
Remove a packagename=treename=tree, changed=true
A package that is not installedname=treename=tree, changed=false