gen

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Group = endpoint.Define(
	"group",
	"The groups of the host",
	endpoint.Area(area.Security),
	endpoint.Prefix("node/{hostname}"),
	endpoint.Uses[dispatch.Deps](),
	endpoint.Tag("group_operations", "Group", "The groups of the host"),
	endpoint.CommandNotes("The [group behavior](../../../../../reference/behaviors/security/group/group.md) page tells where the behavior runs, what it is built on and its settings."),
	endpoint.Doc[types.RowStatus](dispatch.RowStatusDoc),
	endpoint.Get[ListRequest, GroupCollectionResponse]("list").
		Handle(HandleList).
		ID("GetNodeGroup").
		Describe("List the groups of the host").
		Permission("group:read").
		Returns("Each target host's result.").
		Explain("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.").
		Example("--target web-01", "A host with a group").
		Result("A host with a group, on one host:\n\n```ansi\n$ osapi client node group list --target web-01\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS  \x1b[0m\x1b[38;2;10;143;176mNAME        \x1b[0m\x1b[38;2;10;143;176mGID   \x1b[0m\x1b[38;2;10;143;176mMEMBERS\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mdevelopers\x1b[0m  1500  alice, bob\n  \x1b[38;2;138;138;138mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mroot\x1b[0m        0     none\n\n  1 host: \x1b[38;2;103;234;147m1 ok\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node group list --target _all\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS  \x1b[0m\x1b[38;2;10;143;176mNAME        \x1b[0m\x1b[38;2;10;143;176mGID   \x1b[0m\x1b[38;2;10;143;176mMEMBERS\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mdevelopers\x1b[0m  1500  alice, bob\n  \x1b[38;2;138;138;138mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mroot\x1b[0m        0     none\n  \x1b[1mweb-02\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mdevelopers\x1b[0m  1500  alice, bob\n  \x1b[38;2;138;138;138mweb-02\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mroot\x1b[0m        0     none\n\n  3 hosts: \x1b[38;2;103;234;147m2 ok\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n  \x1b[1mmac-01\x1b[0m  \x1b[38;5;222mskipped\x1b[0m  operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n  \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n  \"results\": [\n    {\n      \"gid\": 1500,\n      \"hostname\": \"web-01\",\n      \"members\": [\n        \"alice\",\n        \"bob\"\n      ],\n      \"name\": \"developers\",\n      \"status\": \"ok\"\n    },\n    {\n      \"gid\": 0,\n      \"hostname\": \"web-01\",\n      \"name\": \"root\",\n      \"status\": \"ok\"\n    }\n  ]\n}\n```").
		Errors(endpoint.NotFound(behavior.ErrNotFound, "The host does not have what the request names, such as the object of a deploy."), endpoint.Conflict(behavior.ErrNotManaged, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotManaged), endpoint.Conflict(behavior.ErrNotInstalled, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotInstalled), endpoint.Invalid(dispatch.ErrInvalid, "The request is not valid, or the host refuses the input, such as a path that is a directory.")),
	endpoint.Get[GetRequest, GroupGetResponse]("get").
		Handle(HandleGet).
		ID("GetNodeGroupByKey").
		Describe("Get one group").
		Permission("group:read").
		Returns("Each target host's result.").
		Explain("Reads one group from the same list. A group that the host does not have is not found.").
		Example("--target web-01 --name developers", "A group").
		Result("A group, on one host:\n\n```ansi\n$ osapi client node group get --target web-01 --name developers\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS  \x1b[0m\x1b[38;2;10;143;176mNAME        \x1b[0m\x1b[38;2;10;143;176mGID   \x1b[0m\x1b[38;2;10;143;176mMEMBERS\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mdevelopers\x1b[0m  1500  alice, bob\n\n  1 host: \x1b[38;2;103;234;147m1 ok\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node group get --target _all --name developers\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS  \x1b[0m\x1b[38;2;10;143;176mNAME        \x1b[0m\x1b[38;2;10;143;176mGID   \x1b[0m\x1b[38;2;10;143;176mMEMBERS\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mdevelopers\x1b[0m  1500  alice, bob\n  \x1b[1mweb-02\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mdevelopers\x1b[0m  1500  alice, bob\n\n  3 hosts: \x1b[38;2;103;234;147m2 ok\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n  \x1b[1mmac-01\x1b[0m  \x1b[38;5;222mskipped\x1b[0m  operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n  \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n  \"results\": [\n    {\n      \"gid\": 1500,\n      \"hostname\": \"web-01\",\n      \"members\": [\n        \"alice\",\n        \"bob\"\n      ],\n      \"name\": \"developers\",\n      \"status\": \"ok\"\n    }\n  ]\n}\n```\n\nThe command fails in these cases:\n\n| Call | Flags | Fails with |\n| --- | --- | --- |\n| A group that the host does not have | `--name nobody` | not found |\n| A name that is an option | `--name -r` | account_name |\n| A name longer than 32 characters | `--name aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` | max |").
		Errors(endpoint.NotFound(behavior.ErrNotFound, "The host has no group with that name."), endpoint.Conflict(behavior.ErrNotManaged, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotManaged), endpoint.Conflict(behavior.ErrNotInstalled, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotInstalled), endpoint.Invalid(dispatch.ErrInvalid, "The request is not valid, or the host refuses the input, such as a path that is a directory.")),
	endpoint.Post[CreateRequest, GroupCreateResponse]("create").
		Handle(HandleCreate).
		ID("PostNodeGroup").
		Describe("Add a group").
		Permission("group:write").
		Returns("Each target host's result, with whether it changed.").
		Explain("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.").
		Example("--target web-01 --name osapitest", "Add a group").
		Example("--target web-01 --name osapitest --gid 1999 --system", "Add a system group with its ID").
		Example("--target web-01 --name osapitest", "A group that the host has").
		Result("Add a group, on one host:\n\n```ansi\n$ osapi client node group create --target web-01 --name osapitest\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS   \x1b[0m\x1b[38;2;10;143;176mNAME\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mchanged\x1b[0m  \x1b[1mosapitest\x1b[0m\n\n  1 host: \x1b[38;2;103;234;147m1 changed\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node group create --target _all --name osapitest\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS   \x1b[0m\x1b[38;2;10;143;176mNAME\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mchanged\x1b[0m  \x1b[1mosapitest\x1b[0m\n  \x1b[1mweb-02\x1b[0m    \x1b[38;2;103;234;147mchanged\x1b[0m  \x1b[1mosapitest\x1b[0m\n\n  3 hosts: \x1b[38;2;103;234;147m2 changed\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n  \x1b[1mmac-01\x1b[0m  \x1b[38;5;222mskipped\x1b[0m  operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n  \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n  \"results\": [\n    {\n      \"changed\": true,\n      \"hostname\": \"web-01\",\n      \"name\": \"osapitest\",\n      \"status\": \"ok\"\n    }\n  ]\n}\n```\n\nAdd a system group with its ID, on one host:\n\n```ansi\n$ osapi client node group create --target web-01 --name osapitest --gid 1999 --system\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS   \x1b[0m\x1b[38;2;10;143;176mNAME\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mchanged\x1b[0m  \x1b[1mosapitest\x1b[0m\n\n  1 host: \x1b[38;2;103;234;147m1 changed\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node group create --target _all --name osapitest --gid 1999 --system\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS   \x1b[0m\x1b[38;2;10;143;176mNAME\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mchanged\x1b[0m  \x1b[1mosapitest\x1b[0m\n  \x1b[1mweb-02\x1b[0m    \x1b[38;2;103;234;147mchanged\x1b[0m  \x1b[1mosapitest\x1b[0m\n\n  3 hosts: \x1b[38;2;103;234;147m2 changed\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n  \x1b[1mmac-01\x1b[0m  \x1b[38;5;222mskipped\x1b[0m  operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n  \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n  \"results\": [\n    {\n      \"changed\": true,\n      \"hostname\": \"web-01\",\n      \"name\": \"osapitest\",\n      \"status\": \"ok\"\n    }\n  ]\n}\n```\n\nA group that the host has, on one host:\n\n```ansi\n$ osapi client node group create --target web-01 --name osapitest\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS  \x1b[0m\x1b[38;2;10;143;176mNAME\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m\n\n  1 host: \x1b[38;2;103;234;147m1 ok\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node group create --target _all --name osapitest\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS  \x1b[0m\x1b[38;2;10;143;176mNAME\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m\n  \x1b[1mweb-02\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m\n\n  3 hosts: \x1b[38;2;103;234;147m2 ok\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n  \x1b[1mmac-01\x1b[0m  \x1b[38;5;222mskipped\x1b[0m  operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n  \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n  \"results\": [\n    {\n      \"changed\": false,\n      \"hostname\": \"web-01\",\n      \"name\": \"osapitest\",\n      \"status\": \"ok\"\n    }\n  ]\n}\n```\n\nWith the default settings, each example does this on the host:\n\n| Example | On the host |\n| --- | --- |\n| Add a group | runs `groupadd -- osapitest` |\n| Add a system group with its ID | runs `groupadd -g 1999 -r -- osapitest` |\n\nThe command fails in these cases:\n\n| Call | Flags | Fails with |\n| --- | --- | --- |\n| A name that is an option | `--name -r` | account_name |\n| A name longer than 32 characters | `--name aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` | max |\n| A negative ID | `--name osapitest --gid -1` | min |").
		Errors(endpoint.NotFound(behavior.ErrNotFound, "The host does not have what the request names, such as the object of a deploy."), endpoint.Conflict(behavior.ErrNotManaged, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotManaged), endpoint.Conflict(behavior.ErrNotInstalled, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotInstalled), endpoint.Invalid(dispatch.ErrInvalid, "The request is not valid, or the host refuses the input, such as a path that is a directory.")),
	endpoint.Put[UpdateRequest, GroupUpdateResponse]("update").
		Handle(HandleUpdate).
		ID("PutNodeGroup").
		Describe("Set the members of a group").
		Permission("group:write").
		Returns("Each target host's result, with whether it changed.").
		Explain("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.").
		Example("--target web-01 --name osapitest --members root", "Set the members").
		Example("--target web-01 --name osapitest --members root", "The members it has").
		Result("Set the members, on one host:\n\n```ansi\n$ osapi client node group update --target web-01 --name osapitest --members root\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS   \x1b[0m\x1b[38;2;10;143;176mNAME\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mchanged\x1b[0m  \x1b[1mosapitest\x1b[0m\n\n  1 host: \x1b[38;2;103;234;147m1 changed\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node group update --target _all --name osapitest --members root\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS   \x1b[0m\x1b[38;2;10;143;176mNAME\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mchanged\x1b[0m  \x1b[1mosapitest\x1b[0m\n  \x1b[1mweb-02\x1b[0m    \x1b[38;2;103;234;147mchanged\x1b[0m  \x1b[1mosapitest\x1b[0m\n\n  3 hosts: \x1b[38;2;103;234;147m2 changed\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n  \x1b[1mmac-01\x1b[0m  \x1b[38;5;222mskipped\x1b[0m  operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n  \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n  \"results\": [\n    {\n      \"changed\": true,\n      \"hostname\": \"web-01\",\n      \"name\": \"osapitest\",\n      \"status\": \"ok\"\n    }\n  ]\n}\n```\n\nThe members it has, on one host:\n\n```ansi\n$ osapi client node group update --target web-01 --name osapitest --members root\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS  \x1b[0m\x1b[38;2;10;143;176mNAME\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m\n\n  1 host: \x1b[38;2;103;234;147m1 ok\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node group update --target _all --name osapitest --members root\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS  \x1b[0m\x1b[38;2;10;143;176mNAME\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m\n  \x1b[1mweb-02\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m\n\n  3 hosts: \x1b[38;2;103;234;147m2 ok\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n  \x1b[1mmac-01\x1b[0m  \x1b[38;5;222mskipped\x1b[0m  operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n  \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n  \"results\": [\n    {\n      \"changed\": false,\n      \"hostname\": \"web-01\",\n      \"name\": \"osapitest\",\n      \"status\": \"ok\"\n    }\n  ]\n}\n```\n\nWith the default settings, each example does this on the host:\n\n| Example | On the host |\n| --- | --- |\n| Set the members | runs `gpasswd -M root -- osapitest` |\n\nThe command fails in these cases:\n\n| Call | Flags | Fails with |\n| --- | --- | --- |\n| A group that the host does not have | `--name nobody` | not found |\n| A name that is an option | `--name -r` | account_name |\n| A name longer than 32 characters | `--name aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` | max |\n| A member that is an option | `--name developers --members -r` | account_name |\n| A member longer than 32 characters | `--name developers --members aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` | max |").
		Errors(endpoint.NotFound(behavior.ErrNotFound, "The host has no group with that name."), endpoint.Conflict(behavior.ErrNotManaged, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotManaged), endpoint.Conflict(behavior.ErrNotInstalled, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotInstalled), endpoint.Invalid(dispatch.ErrInvalid, "The request is not valid, or the host refuses the input, such as a path that is a directory.")),
	endpoint.Delete[DeleteRequest, GroupDeleteResponse]("delete").
		Handle(HandleDelete).
		ID("DeleteNodeGroup").
		Describe("Remove a group").
		Permission("group:write").
		Returns("Each target host's result, with whether it changed.").
		Explain("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.").
		Example("--target web-01 --name osapitest", "Remove a group").
		Example("--target web-01 --name osapitest", "A group that the host does not have").
		Result("Remove a group, on one host:\n\n```ansi\n$ osapi client node group delete --target web-01 --name osapitest\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS   \x1b[0m\x1b[38;2;10;143;176mNAME\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mchanged\x1b[0m  \x1b[1mosapitest\x1b[0m\n\n  1 host: \x1b[38;2;103;234;147m1 changed\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node group delete --target _all --name osapitest\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS   \x1b[0m\x1b[38;2;10;143;176mNAME\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mchanged\x1b[0m  \x1b[1mosapitest\x1b[0m\n  \x1b[1mweb-02\x1b[0m    \x1b[38;2;103;234;147mchanged\x1b[0m  \x1b[1mosapitest\x1b[0m\n\n  3 hosts: \x1b[38;2;103;234;147m2 changed\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n  \x1b[1mmac-01\x1b[0m  \x1b[38;5;222mskipped\x1b[0m  operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n  \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n  \"results\": [\n    {\n      \"changed\": true,\n      \"hostname\": \"web-01\",\n      \"name\": \"osapitest\",\n      \"status\": \"ok\"\n    }\n  ]\n}\n```\n\nA group that the host does not have, on one host:\n\n```ansi\n$ osapi client node group delete --target web-01 --name osapitest\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS  \x1b[0m\x1b[38;2;10;143;176mNAME\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m\n\n  1 host: \x1b[38;2;103;234;147m1 ok\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node group delete --target _all --name osapitest\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS  \x1b[0m\x1b[38;2;10;143;176mNAME\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m\n  \x1b[1mweb-02\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m\n\n  3 hosts: \x1b[38;2;103;234;147m2 ok\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n  \x1b[1mmac-01\x1b[0m  \x1b[38;5;222mskipped\x1b[0m  operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n  \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n  \"results\": [\n    {\n      \"changed\": false,\n      \"hostname\": \"web-01\",\n      \"name\": \"osapitest\",\n      \"status\": \"ok\"\n    }\n  ]\n}\n```\n\nWith the default settings, each example does this on the host:\n\n| Example | On the host |\n| --- | --- |\n| Remove a group | runs `groupdel -- osapitest` |\n\nThe command fails in these cases:\n\n| Call | Flags | Fails with |\n| --- | --- | --- |\n| A name that is an option | `--name -r` | account_name |\n| A name longer than 32 characters | `--name aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` | max |").
		Errors(endpoint.NotFound(behavior.ErrNotFound, "The host has no group with that name."), endpoint.Conflict(behavior.ErrNotManaged, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotManaged), endpoint.Conflict(behavior.ErrNotInstalled, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotInstalled), endpoint.Invalid(dispatch.ErrInvalid, "The request is not valid, or the host refuses the input, such as a path that is a directory.")),
)

Group is group as an endpoint group, which its spec comes from.

Functions

func Routes

func Routes(
	s *server.Server,
) []server.Route

Routes are the group group's endpoints, as its definition declares them.

Types

type CreateRequest

type CreateRequest struct {
	Hostname string             `` /* 182-byte string literal not displayed */
	Body     GroupCreateRequest `in:"body" validate:"required"`
}

CreateRequest is the request of group create: its target and its input.

type DeleteRequest

type DeleteRequest struct {
	Hostname string `` /* 182-byte string literal not displayed */
	Name     string `doc:"The group to remove, such as developers" in:"path" json:"name" param:"GroupName" validate:"required,max=32,account_name"`
}

DeleteRequest is the request of group delete: its target and its input.

type GetRequest

type GetRequest struct {
	Hostname string `` /* 182-byte string literal not displayed */
	Name     string `doc:"The group, such as developers" in:"path" json:"name" param:"GroupName" validate:"required,max=32,account_name"`
}

GetRequest is the request of group get: its target and its input.

type GroupAccount

type GroupAccount struct {
	Hostname string          `doc:"Hostname of the agent that produced this result." json:"hostname"`
	Status   types.RowStatus `doc:"The status of the operation for this host." json:"status"`
	Name     *string         `doc:"The group" json:"name,omitempty"`
	GID      *int            `doc:"Its numeric group ID" json:"gid,omitempty"`
	Members  *[]string       `doc:"The users it has as members, besides those whose primary group it is" json:"members,omitempty"`
	Error    *string         `doc:"Error message if the agent failed." json:"error,omitempty"`
}

GroupAccount is the result of group on one host.

type GroupCollectionResponse

type GroupCollectionResponse struct {
	JobID   string         `` /* 133-byte string literal not displayed */
	Results []GroupAccount `json:"results"`
}

GroupCollectionResponse is each target host's result.

func HandleList

HandleList runs group list on the target, for the endpoint server.

type GroupCreateRequest

type GroupCreateRequest struct {
	Name   string `doc:"The group to add, such as developers" json:"name" validate:"required,max=32,account_name"`
	GID    int    `doc:"Its numeric group ID; the system assigns one when it is 0" json:"gid,omitempty" validate:"omitempty,min=0"`
	System bool   `doc:"Add it as a system group, with an ID from the system range" json:"system,omitempty" validate:"omitempty"`
}

GroupCreateRequest is the body of group create.

type GroupCreateResponse

type GroupCreateResponse struct {
	JobID   string        `` /* 133-byte string literal not displayed */
	Results []GroupResult `json:"results"`
}

GroupCreateResponse is each target host's result.

func HandleCreate

func HandleCreate(
	ctx context.Context,
	d dispatch.Deps,
	in CreateRequest,
) (GroupCreateResponse, error)

HandleCreate runs group create on the target, for the endpoint server.

type GroupDeleteResponse

type GroupDeleteResponse struct {
	JobID   string        `` /* 133-byte string literal not displayed */
	Results []GroupResult `json:"results"`
}

GroupDeleteResponse is each target host's result.

func HandleDelete

func HandleDelete(
	ctx context.Context,
	d dispatch.Deps,
	in DeleteRequest,
) (GroupDeleteResponse, error)

HandleDelete runs group delete on the target, for the endpoint server.

type GroupGetResponse

type GroupGetResponse struct {
	JobID   string         `` /* 133-byte string literal not displayed */
	Results []GroupAccount `json:"results"`
}

GroupGetResponse is each target host's result.

func HandleGet

func HandleGet(
	ctx context.Context,
	d dispatch.Deps,
	in GetRequest,
) (GroupGetResponse, error)

HandleGet runs group get on the target, for the endpoint server.

type GroupResult

type GroupResult struct {
	Hostname string          `doc:"Hostname of the agent that produced this result." json:"hostname"`
	Status   types.RowStatus `doc:"The status of the operation for this host." json:"status"`
	Name     *string         `doc:"The group" json:"name,omitempty"`
	Changed  *bool           `doc:"Whether the host changed" json:"changed,omitempty"`
	Error    *string         `doc:"Error message if the agent failed." json:"error,omitempty"`
}

GroupResult is the result of group on one host.

type GroupUpdateRequest

type GroupUpdateRequest struct {
	Members []string `` /* 139-byte string literal not displayed */
}

GroupUpdateRequest is the body of group update.

type GroupUpdateResponse

type GroupUpdateResponse struct {
	JobID   string        `` /* 133-byte string literal not displayed */
	Results []GroupResult `json:"results"`
}

GroupUpdateResponse is each target host's result.

func HandleUpdate

func HandleUpdate(
	ctx context.Context,
	d dispatch.Deps,
	in UpdateRequest,
) (GroupUpdateResponse, error)

HandleUpdate runs group update on the target, for the endpoint server.

type ListRequest

type ListRequest struct {
	Hostname string `` /* 182-byte string literal not displayed */
}

ListRequest is the request of group list: its target and its input.

type UpdateRequest

type UpdateRequest struct {
	Hostname string             `` /* 182-byte string literal not displayed */
	Name     string             `doc:"The group, such as developers" in:"path" json:"name" param:"GroupName" validate:"required,max=32,account_name"`
	Body     GroupUpdateRequest `in:"body" validate:"required"`
}

UpdateRequest is the request of group update: its target and its input.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL