The groups of the host. osapi dsl behavior get --name group and
osapi dsl behavior method get show the same.
Behavior
| |
|---|
| Name | group |
| Description | The groups of the host |
| Placement | node |
| Area | security |
| 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 (5)
| NAME | VERB | HTTP | ROUTE | PERMISSION | DESCRIPTION |
|---|
| list | read | GET | /api/node/{hostname}/group | group:read | List the groups of the host |
| get | read | GET | /api/node/{hostname}/group/{name} | group:read | Get one group |
| create | write | POST | /api/node/{hostname}/group | group:write | Add a group |
| update | write | PUT | /api/node/{hostname}/group/{name} | group:write | Set the members of a group |
| delete | write | DELETE | /api/node/{hostname}/group/{name} | group:write | Remove a group |
Types (5)
| NAME | INPUT | OUTPUT |
|---|
| list | ListInput | []Account { name, gid, members } |
| get | GetInput { name* } | Account { name, gid, members } |
| create | CreateInput { name*, gid, system } | Result { name, changed } |
| update | UpdateInput { name*, members } | Result { name, changed } |
| delete | DeleteInput { name* } | Result { name, changed } |
Settings (0)
None. Declare them with behavior.Config.
Telemetry
| |
|---|
| Span | behavior.group.<method> |
| Child spans | exec groupadd, exec gpasswd, exec groupdel, exec id, exec dscl |
| 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, update, delete) |
Method list
| |
|---|
| Name | list |
| Verb | read |
| Description | List the groups of the host |
| Detail | Lists each group with its ID and its members, by name, from /etc/group through gohai, on every platform. The members are the users that /etc/group names; a user whose primary group it is is not listed again. |
| HTTP | GET |
| Route | /api/node/{hostname}/group |
| Permission | group:read |
| Command | osapi client node group list |
| Input type | ListInput |
| Output type | []Account |
None. The method takes no input; its command needs only --target.
Output (3)
| FIELD | TYPE | DESCRIPTION |
|---|
| name | string | The group |
| gid | integer | Its numeric group ID |
| members | array | The users it has as members, besides those whose primary group it is |
Examples (1)
| EXAMPLE | INPUT | OUTPUT |
|---|
| A host with a group | (none) | [gid=1500, members=[alice bob], name=developers] [gid=0, name=root] |
Method get
| |
|---|
| Name | get |
| Verb | read |
| Description | Get one group |
| Detail | Reads one group from the same list. A group that the host does not have is not found. |
| HTTP | GET |
| Route | /api/node/{hostname}/group/{name} |
| Permission | group:read |
| Command | osapi client node group get |
| Input type | GetInput |
| Output type | Account |
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|
| name | string | yes | pattern ^[a-z_][a-z0-9_-]*$?$, max length 32 | The group, such as developers |
Output (3)
| FIELD | TYPE | DESCRIPTION |
|---|
| name | string | The group |
| gid | integer | Its numeric group ID |
| members | array | The users it has as members, besides those whose primary group it is |
Examples (1)
| EXAMPLE | INPUT | OUTPUT |
|---|
| A group | name=developers | name=developers, gid=1500, members=[alice bob] |
Method create
| |
|---|
| Name | create |
| Verb | write |
| Description | Add a group |
| Detail | Adds the group with groupadd, with the ID when one is given. A group that the host has already does not change and reports changed: false, whatever its ID. It runs on the Debian family only, and elsewhere reports skipped. |
| HTTP | POST |
| Route | /api/node/{hostname}/group |
| Permission | group:write |
| Command | osapi client node group create |
| Input type | CreateInput |
| Output type | Result |
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|
| name | string | yes | pattern ^[a-z_][a-z0-9_-]*$?$, max length 32 | The group to add, such as developers |
| gid | integer | no | min 0 | Its numeric group ID; the system assigns one when it is 0 |
| system | boolean | no | | Add it as a system group, with an ID from the system range |
Output (2)
| FIELD | TYPE | DESCRIPTION |
|---|
| name | string | The group |
| changed | boolean | Whether the host changed |
Examples (3)
| EXAMPLE | INPUT | OUTPUT |
|---|
| Add a group | name=osapitest | name=osapitest, changed=true |
| Add a system group with its ID | name=osapitest, gid=1999, system=true | name=osapitest, changed=true |
| A group that the host has | name=osapitest | name=osapitest, changed=false |
Method update
| |
|---|
| Name | update |
| Verb | write |
| Description | Set the members of a group |
| Detail | Sets the members with gpasswd -M, in place of the members that the group has. The same members, in any order, do not change it and report changed: false. A group that the host does not have is not found. It runs on the Debian family only, and elsewhere reports skipped. |
| HTTP | PUT |
| Route | /api/node/{hostname}/group/{name} |
| Permission | group:write |
| Command | osapi client node group update |
| Input type | UpdateInput |
| Output type | Result |
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|
| name | string | yes | pattern ^[a-z_][a-z0-9_-]*$?$, max length 32 | The group, such as developers |
| members | array | no | | Its members, which replace the members it has; none when empty |
Output (2)
| FIELD | TYPE | DESCRIPTION |
|---|
| name | string | The group |
| changed | boolean | Whether the host changed |
Examples (2)
| EXAMPLE | INPUT | OUTPUT |
|---|
| Set the members | name=osapitest, members=[root] | name=osapitest, changed=true |
| The members it has | name=osapitest, members=[root] | name=osapitest, changed=false |
Method delete
| |
|---|
| Name | delete |
| Verb | write |
| Description | Remove a group |
| Detail | Removes the group with groupdel. A group that the host does not have does not change and reports changed: false. It runs on the Debian family only, and elsewhere reports skipped. |
| HTTP | DELETE |
| Route | /api/node/{hostname}/group/{name} |
| Permission | group:write |
| Command | osapi client node group delete |
| Input type | DeleteInput |
| Output type | Result |
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|
| name | string | yes | pattern ^[a-z_][a-z0-9_-]*$?$, max length 32 | The group to remove, such as developers |
Output (2)
| FIELD | TYPE | DESCRIPTION |
|---|
| name | string | The group |
| changed | boolean | Whether the host changed |
Examples (2)
| EXAMPLE | INPUT | OUTPUT |
|---|
| Remove a group | name=osapitest | name=osapitest, changed=true |
| A group that the host does not have | name=osapitest | name=osapitest, changed=false |