The packages installed on the host. osapi behavior get --name package and
osapi behavior method get show the same.
Behavior
| |
|---|
| Name | package |
| Description | The packages installed on the host |
| Placement | node |
| Internal | no |
| API | yes |
| CLI | yes |
| Next | no |
| Platforms | debian, linux, darwin |
| Sudo | none |
| Runs | none |
| Writes | none |
| Keeps state | no |
| Uses | none |
| Used by | none |
Methods (4)
| NAME | VERB | HTTP | ROUTE | PERMISSION | DESCRIPTION |
|---|
| list | read | GET | /api/node/{hostname}/package | package:read | List the packages installed on the host |
| get | read | GET | /api/node/{hostname}/package/{name} | package:read | Get one installed package |
| create | write | POST | /api/node/{hostname}/package | package:write | Install a package |
| delete | write | DELETE | /api/node/{hostname}/package/{name} | package:write | Remove a package |
Types (4)
| NAME | INPUT | OUTPUT |
|---|
| list | ListInput | []Installed { name, version, architecture, manager, description, size } |
| get | GetInput { name* } | Installed { name, version, architecture, manager, description, size } |
| create | CreateInput { name*, version } | Result { name, changed } |
| delete | DeleteInput { name* } | Result { name, changed } |
Settings (0)
None. Declare them with behavior.Config.
Telemetry
| |
|---|
| Span | behavior.package.<method> |
| Child spans | exec apt-get, exec dpkg-query, exec brew, exec rpm |
| Metrics | osapi_behavior_calls_total, osapi_behavior_duration_seconds, osapi_behavior_changes_total |
| Attributes | osapi.behavior.name, osapi.behavior.method, osapi.behavior.verb, osapi.behavior.outcome, osapi.behavior.changed |
| Recorded inputs | name (get, create, delete) |
Method list
| |
|---|
| Name | list |
| Verb | read |
| Description | List the packages installed on the host |
| Detail | Lists each installed package with its version: dpkg on the Debian family, rpm on the other Linux families, and Homebrew on macOS. |
| HTTP | GET |
| Route | /api/node/{hostname}/package |
| Permission | package:read |
| Command | osapi client node package list |
| Input type | ListInput |
| Output type | []Installed |
None. The method takes no input; its command needs only --target.
Output (6)
| FIELD | TYPE | DESCRIPTION |
|---|
| name | string | The package |
| version | string | The installed version |
| architecture | string | The architecture it is built for, such as amd64 |
| manager | string | The package database that has it: dpkg, rpm or brew |
| description | string | Its one-line summary |
| size | integer | Its installed size in bytes |
Examples (3)
| EXAMPLE | INPUT | OUTPUT |
|---|
| 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
| |
|---|
| Name | get |
| Verb | read |
| Description | Get one installed package |
| Detail | Reads one package from the same list. A package that is not installed is not found. |
| HTTP | GET |
| Route | /api/node/{hostname}/package/{name} |
| Permission | package:read |
| Command | osapi client node package get |
| Input type | GetInput |
| Output type | Installed |
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|
| name | string | yes | pattern ^[a-zA-Z0-9][a-zA-Z0-9.+_:~=-]*$, max length 255 | The package, such as curl |
Output (6)
| FIELD | TYPE | DESCRIPTION |
|---|
| name | string | The package |
| version | string | The installed version |
| architecture | string | The architecture it is built for, such as amd64 |
| manager | string | The package database that has it: dpkg, rpm or brew |
| description | string | Its one-line summary |
| size | integer | Its installed size in bytes |
Examples (3)
| EXAMPLE | INPUT | OUTPUT |
|---|
| An installed package | name=curl | name=curl, version=8.5.0-2ubuntu10, architecture=amd64, manager=dpkg, description=command line tool for transferring data with URL syntax, size=512000 |
| An installed formula | name=jq | name=jq, version=1.7.1, manager=brew |
| An installed RPM | name=curl | name=curl, version=8.6.0-7.fc40, architecture=x86_64, manager=rpm |
Method create
| |
|---|
| Name | create |
| Verb | write |
| Description | Install a package |
| Detail | Installs 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. |
| HTTP | POST |
| Route | /api/node/{hostname}/package |
| Permission | package:write |
| Command | osapi client node package create |
| Input type | CreateInput |
| Output type | Result |
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|
| name | string | yes | pattern ^[a-zA-Z0-9][a-zA-Z0-9.+_:~=-]*$, max length 255 | The package to install, such as curl |
| version | string | no | pattern ^[0-9][A-Za-z0-9.+~:-]*$, max length 255 | The version to install, such as 8.5.0-2ubuntu10; the newest when empty |
Output (2)
| FIELD | TYPE | DESCRIPTION |
|---|
| name | string | The package |
| changed | boolean | Whether the host changed |
Examples (1)
| EXAMPLE | INPUT | OUTPUT |
|---|
| Install a package | name=tree | name=tree, changed=true |
Method delete
| |
|---|
| Name | delete |
| Verb | write |
| Description | Remove a package |
| Detail | Removes 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. |
| HTTP | DELETE |
| Route | /api/node/{hostname}/package/{name} |
| Permission | package:write |
| Command | osapi client node package delete |
| Input type | DeleteInput |
| Output type | Result |
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|
| name | string | yes | pattern ^[a-zA-Z0-9][a-zA-Z0-9.+_:~=-]*$, max length 255 | The package to remove, such as curl |
Output (2)
| FIELD | TYPE | DESCRIPTION |
|---|
| name | string | The package |
| changed | boolean | Whether the host changed |
Examples (2)
| EXAMPLE | INPUT | OUTPUT |
|---|
| Remove a package | name=tree | name=tree, changed=true |
| A package that is not installed | name=tree | name=tree, changed=false |